@apps-in-toss/native-modules 0.0.0-dev.1752049503789 → 1.0.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/bridges-meta.json +36 -13
- package/dist/index.cjs +256 -120
- package/dist/index.d.cts +697 -229
- package/dist/index.d.ts +697 -229
- package/dist/index.js +233 -103
- package/package.json +7 -8
- package/src/AppsInTossModule/constants.ts +6 -0
- package/src/AppsInTossModule/native-event-emitter/appsInTossEvent.ts +13 -0
- package/src/AppsInTossModule/native-event-emitter/contactsViral.ts +140 -0
- package/src/AppsInTossModule/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts +10 -0
- package/src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts +60 -0
- package/src/AppsInTossModule/native-event-emitter/index.ts +5 -0
- package/src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts +45 -0
- package/src/AppsInTossModule/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts +50 -0
- package/src/AppsInTossModule/native-event-emitter/internal/appBridge.spec.ts +135 -0
- package/src/AppsInTossModule/native-event-emitter/internal/appBridge.ts +79 -0
- package/src/AppsInTossModule/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts +20 -0
- package/src/AppsInTossModule/native-event-emitter/nativeEventEmitter.ts +35 -0
- package/src/AppsInTossModule/native-event-emitter/startUpdateLocation.ts +98 -0
- package/src/AppsInTossModule/native-event-emitter/types.ts +4 -0
- package/src/AppsInTossModule/native-modules/AppsInTossModule.ts +89 -0
- package/src/AppsInTossModule/native-modules/ads/googleAdMob.ts +690 -0
- package/src/AppsInTossModule/native-modules/ads/types.ts +106 -0
- package/src/AppsInTossModule/native-modules/appLogin.ts +29 -0
- package/src/AppsInTossModule/native-modules/checkoutPayment.ts +80 -0
- package/src/AppsInTossModule/native-modules/eventLog.spec.ts +300 -0
- package/src/AppsInTossModule/native-modules/eventLog.ts +77 -0
- package/src/AppsInTossModule/native-modules/fetchAlbumPhotos.ts +88 -0
- package/src/AppsInTossModule/native-modules/fetchContacts.ts +121 -0
- package/src/AppsInTossModule/native-modules/getClipboardText.ts +47 -0
- package/src/AppsInTossModule/native-modules/getCurrentLocation.ts +65 -0
- package/src/AppsInTossModule/native-modules/getDeviceId.ts +33 -0
- package/src/AppsInTossModule/native-modules/getGameCenterGameProfile.ts +68 -0
- package/src/AppsInTossModule/native-modules/getOperationalEnvironment.ts +37 -0
- package/src/AppsInTossModule/native-modules/getPermission.ts +58 -0
- package/src/AppsInTossModule/native-modules/getTossAppVersion.ts +33 -0
- package/src/AppsInTossModule/native-modules/getTossShareLink.ts +39 -0
- package/src/AppsInTossModule/native-modules/iap.ts +213 -0
- package/src/AppsInTossModule/native-modules/index.ts +86 -0
- package/src/AppsInTossModule/native-modules/isMinVersionSupported.spec.ts +190 -0
- package/src/AppsInTossModule/native-modules/isMinVersionSupported.ts +68 -0
- package/src/AppsInTossModule/native-modules/openCamera.ts +81 -0
- package/src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts +44 -0
- package/src/AppsInTossModule/native-modules/openPermissionDialog.ts +54 -0
- package/src/AppsInTossModule/native-modules/requestPermission.ts +63 -0
- package/src/AppsInTossModule/native-modules/saveBase64Data.ts +57 -0
- package/src/AppsInTossModule/native-modules/setClipboardText.ts +39 -0
- package/src/AppsInTossModule/native-modules/setDeviceOrientation.ts +74 -0
- package/src/AppsInTossModule/native-modules/storage.ts +100 -0
- package/src/AppsInTossModule/native-modules/submitGameCenterLeaderBoardScore.ts +74 -0
- package/src/AppsInTossModule/native-modules/tossCore.ts +29 -0
- package/src/BedrockModule/native-modules/core/BedrockCoreModule.ts +8 -0
- package/src/BedrockModule/native-modules/index.ts +4 -0
- package/src/BedrockModule/native-modules/natives/BedrockModule.ts +20 -0
- package/src/BedrockModule/native-modules/natives/closeView.ts +25 -0
- package/src/BedrockModule/native-modules/natives/generateHapticFeedback/index.ts +27 -0
- package/src/BedrockModule/native-modules/natives/generateHapticFeedback/types.ts +38 -0
- package/src/BedrockModule/native-modules/natives/getLocale.ts +46 -0
- package/src/BedrockModule/native-modules/natives/getNetworkStatus/index.ts +59 -0
- package/src/BedrockModule/native-modules/natives/getNetworkStatus/types.ts +1 -0
- package/src/BedrockModule/native-modules/natives/getPlatformOS.ts +37 -0
- package/src/BedrockModule/native-modules/natives/getSchemeUri.ts +27 -0
- package/src/BedrockModule/native-modules/natives/index.ts +11 -0
- package/src/BedrockModule/native-modules/natives/openURL.ts +40 -0
- package/src/BedrockModule/native-modules/natives/setIosSwipeGestureEnabled.ts +43 -0
- package/src/BedrockModule/native-modules/natives/setScreenAwakeMode.ts +66 -0
- package/src/BedrockModule/native-modules/natives/setSecureScreen.ts +31 -0
- package/src/BedrockModule/native-modules/natives/share.ts +36 -0
- package/src/async-bridges.ts +3 -0
- package/src/event-bridges.ts +2 -0
- package/src/index.ts +16 -0
- package/src/types.ts +108 -0
- package/src/utils/compareVersion.spec.ts +176 -0
- package/src/utils/compareVersion.ts +104 -0
- package/src/utils/generateUUID.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -164,11 +164,39 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventD
|
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
+
// src/AppsInTossModule/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
|
|
168
|
+
import { GraniteEventDefinition as GraniteEventDefinition4 } from "@granite-js/react-native";
|
|
169
|
+
var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDefinition4 {
|
|
170
|
+
name = "onVisibilityChangedByTransparentServiceWeb";
|
|
171
|
+
subscription = null;
|
|
172
|
+
remove() {
|
|
173
|
+
this.subscription?.remove();
|
|
174
|
+
this.subscription = null;
|
|
175
|
+
}
|
|
176
|
+
listener(options, onEvent, onError) {
|
|
177
|
+
const subscription = nativeEventEmitter.addListener("visibilityChangedByTransparentServiceWeb", (params) => {
|
|
178
|
+
if (this.isVisibilityChangedByTransparentServiceWebResult(params)) {
|
|
179
|
+
if (params.callbackId === options.callbackId) {
|
|
180
|
+
onEvent(params.isVisible);
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
onError(new Error("Invalid visibility changed by transparent service web result"));
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
this.subscription = subscription;
|
|
187
|
+
}
|
|
188
|
+
isVisibilityChangedByTransparentServiceWebResult(params) {
|
|
189
|
+
return typeof params === "object" && typeof params.callbackId === "string" && typeof params.isVisible === "boolean";
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
167
193
|
// src/AppsInTossModule/native-event-emitter/appsInTossEvent.ts
|
|
168
194
|
var appsInTossEvent = new GraniteEvent([
|
|
169
|
-
new AppBridgeCallbackEvent(),
|
|
170
195
|
new UpdateLocationEvent(),
|
|
171
|
-
new EntryMessageExitedEvent()
|
|
196
|
+
new EntryMessageExitedEvent(),
|
|
197
|
+
// Internal events
|
|
198
|
+
new AppBridgeCallbackEvent(),
|
|
199
|
+
new VisibilityChangedByTransparentServiceWebEvent()
|
|
172
200
|
]);
|
|
173
201
|
|
|
174
202
|
// src/AppsInTossModule/native-event-emitter/startUpdateLocation.ts
|
|
@@ -176,14 +204,6 @@ function startUpdateLocation(eventParams) {
|
|
|
176
204
|
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
177
205
|
}
|
|
178
206
|
|
|
179
|
-
// src/AppsInTossModule/native-modules/ads/googleAdMob.ts
|
|
180
|
-
import { noop } from "es-toolkit";
|
|
181
|
-
|
|
182
|
-
// src/AppsInTossModule/native-modules/getOperationalEnvironment.ts
|
|
183
|
-
function getOperationalEnvironment() {
|
|
184
|
-
return AppsInTossModule.operationalEnvironment;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
207
|
// src/AppsInTossModule/native-modules/isMinVersionSupported.ts
|
|
188
208
|
import { Platform } from "react-native";
|
|
189
209
|
|
|
@@ -275,6 +295,42 @@ function isMinVersionSupported(minVersions) {
|
|
|
275
295
|
return compareVersions(currentVersion, minVersion) >= 0;
|
|
276
296
|
}
|
|
277
297
|
|
|
298
|
+
// src/AppsInTossModule/native-event-emitter/contactsViral.ts
|
|
299
|
+
function contactsViral(params) {
|
|
300
|
+
const isSupported = isMinVersionSupported({
|
|
301
|
+
android: "5.223.0",
|
|
302
|
+
ios: "5.223.0"
|
|
303
|
+
});
|
|
304
|
+
if (!isSupported) {
|
|
305
|
+
return () => {
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const { onEvent, onError, options } = params;
|
|
309
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("contactsViral", options, {
|
|
310
|
+
onRewardFromContactsViral: (result) => {
|
|
311
|
+
onEvent({ type: "sendViral", data: result });
|
|
312
|
+
},
|
|
313
|
+
onSuccess: (result) => {
|
|
314
|
+
onEvent({ type: "close", data: result });
|
|
315
|
+
},
|
|
316
|
+
onError
|
|
317
|
+
});
|
|
318
|
+
return unregisterCallbacks;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/AppsInTossModule/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
|
|
322
|
+
function onVisibilityChangedByTransparentServiceWeb(eventParams) {
|
|
323
|
+
return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/AppsInTossModule/native-modules/ads/googleAdMob.ts
|
|
327
|
+
import { noop } from "es-toolkit";
|
|
328
|
+
|
|
329
|
+
// src/AppsInTossModule/native-modules/getOperationalEnvironment.ts
|
|
330
|
+
function getOperationalEnvironment() {
|
|
331
|
+
return AppsInTossModule.operationalEnvironment;
|
|
332
|
+
}
|
|
333
|
+
|
|
278
334
|
// src/AppsInTossModule/native-modules/ads/googleAdMob.ts
|
|
279
335
|
function loadAdMobInterstitialAd(params) {
|
|
280
336
|
if (!loadAdMobInterstitialAd.isSupported()) {
|
|
@@ -382,22 +438,54 @@ async function checkoutPayment(options) {
|
|
|
382
438
|
return AppsInTossModule.checkoutPayment({ params: options });
|
|
383
439
|
}
|
|
384
440
|
|
|
385
|
-
// src/AppsInTossModule/native-modules/
|
|
386
|
-
async function
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
441
|
+
// src/AppsInTossModule/native-modules/appLogin.ts
|
|
442
|
+
async function appLogin() {
|
|
443
|
+
return AppsInTossModule.appLogin({});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// src/AppsInTossModule/native-modules/eventLog.ts
|
|
447
|
+
function normalizeParams(params) {
|
|
448
|
+
return Object.fromEntries(
|
|
449
|
+
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
async function eventLog(params) {
|
|
453
|
+
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
454
|
+
console.log("[eventLogDebug]", {
|
|
455
|
+
log_name: params.log_name,
|
|
456
|
+
log_type: params.log_type,
|
|
457
|
+
params: normalizeParams(params.params)
|
|
458
|
+
});
|
|
459
|
+
return;
|
|
390
460
|
}
|
|
391
|
-
|
|
461
|
+
const isSupported = isMinVersionSupported({
|
|
462
|
+
android: "5.208.0",
|
|
463
|
+
ios: "5.208.0"
|
|
464
|
+
});
|
|
465
|
+
if (!isSupported) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
return AppsInTossModule.eventLog({
|
|
469
|
+
log_name: params.log_name,
|
|
470
|
+
log_type: params.log_type,
|
|
471
|
+
params: normalizeParams(params.params)
|
|
472
|
+
});
|
|
392
473
|
}
|
|
393
474
|
|
|
394
|
-
// src/AppsInTossModule/native-modules/
|
|
395
|
-
|
|
396
|
-
|
|
475
|
+
// src/AppsInTossModule/native-modules/fetchAlbumPhotos.ts
|
|
476
|
+
var DEFAULT_MAX_COUNT = 10;
|
|
477
|
+
var DEFAULT_MAX_WIDTH = 1024;
|
|
478
|
+
async function fetchAlbumPhotos(options) {
|
|
479
|
+
const permissionStatus = await requestPermission({ name: "photos", access: "read" });
|
|
397
480
|
if (permissionStatus === "denied") {
|
|
398
|
-
throw new Error("\
|
|
481
|
+
throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
399
482
|
}
|
|
400
|
-
|
|
483
|
+
const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
|
|
484
|
+
...options,
|
|
485
|
+
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
486
|
+
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
487
|
+
});
|
|
488
|
+
return albumPhotos;
|
|
401
489
|
}
|
|
402
490
|
|
|
403
491
|
// src/AppsInTossModule/native-modules/fetchContacts.ts
|
|
@@ -414,20 +502,13 @@ async function fetchContacts(options) {
|
|
|
414
502
|
};
|
|
415
503
|
}
|
|
416
504
|
|
|
417
|
-
// src/AppsInTossModule/native-modules/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
async function fetchAlbumPhotos(options) {
|
|
421
|
-
const permissionStatus = await requestPermission({ name: "photos", access: "read" });
|
|
505
|
+
// src/AppsInTossModule/native-modules/getClipboardText.ts
|
|
506
|
+
async function getClipboardText() {
|
|
507
|
+
const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
|
|
422
508
|
if (permissionStatus === "denied") {
|
|
423
|
-
throw new Error("\
|
|
509
|
+
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
424
510
|
}
|
|
425
|
-
|
|
426
|
-
...options,
|
|
427
|
-
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
428
|
-
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
429
|
-
});
|
|
430
|
-
return albumPhotos;
|
|
511
|
+
return AppsInTossModule.getClipboardText({});
|
|
431
512
|
}
|
|
432
513
|
|
|
433
514
|
// src/AppsInTossModule/native-modules/getCurrentLocation.ts
|
|
@@ -440,6 +521,51 @@ async function getCurrentLocation(options) {
|
|
|
440
521
|
return position;
|
|
441
522
|
}
|
|
442
523
|
|
|
524
|
+
// src/AppsInTossModule/native-modules/getDeviceId.ts
|
|
525
|
+
function getDeviceId() {
|
|
526
|
+
return AppsInTossModule.deviceId;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// src/AppsInTossModule/native-modules/getTossAppVersion.ts
|
|
530
|
+
function getTossAppVersion() {
|
|
531
|
+
return AppsInTossModule.tossAppVersion;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// src/AppsInTossModule/native-modules/getTossShareLink.ts
|
|
535
|
+
async function getTossShareLink(path) {
|
|
536
|
+
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
537
|
+
const shareUrl = new URL(shareLink);
|
|
538
|
+
shareUrl.searchParams.set("deep_link_value", path);
|
|
539
|
+
shareUrl.searchParams.set("af_dp", path);
|
|
540
|
+
return shareUrl.toString();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/AppsInTossModule/native-modules/iap.ts
|
|
544
|
+
async function createOneTimePurchaseOrder(params) {
|
|
545
|
+
const isSupported = isMinVersionSupported({
|
|
546
|
+
android: "5.219.0",
|
|
547
|
+
ios: "5.219.0"
|
|
548
|
+
});
|
|
549
|
+
if (!isSupported) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
return AppsInTossModule.iapCreateOneTimePurchaseOrder(params);
|
|
553
|
+
}
|
|
554
|
+
async function getProductItemList() {
|
|
555
|
+
const isSupported = isMinVersionSupported({
|
|
556
|
+
android: "5.219.0",
|
|
557
|
+
ios: "5.219.0"
|
|
558
|
+
});
|
|
559
|
+
if (!isSupported) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
return AppsInTossModule.iapGetProductItemList({});
|
|
563
|
+
}
|
|
564
|
+
var IAP = {
|
|
565
|
+
createOneTimePurchaseOrder,
|
|
566
|
+
getProductItemList
|
|
567
|
+
};
|
|
568
|
+
|
|
443
569
|
// src/AppsInTossModule/native-modules/openCamera.ts
|
|
444
570
|
async function openCamera(options) {
|
|
445
571
|
const permissionStatus = await requestPermission({ name: "camera", access: "access" });
|
|
@@ -450,19 +576,38 @@ async function openCamera(options) {
|
|
|
450
576
|
return photo;
|
|
451
577
|
}
|
|
452
578
|
|
|
453
|
-
// src/AppsInTossModule/native-modules/
|
|
454
|
-
async function
|
|
455
|
-
|
|
579
|
+
// src/AppsInTossModule/native-modules/saveBase64Data.ts
|
|
580
|
+
async function saveBase64Data(params) {
|
|
581
|
+
const isSupported = isMinVersionSupported({
|
|
582
|
+
android: "5.218.0",
|
|
583
|
+
ios: "5.216.0"
|
|
584
|
+
});
|
|
585
|
+
if (!isSupported) {
|
|
586
|
+
console.warn("saveBase64Data is not supported in this app version");
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
await AppsInTossModule.saveBase64Data(params);
|
|
456
590
|
}
|
|
457
591
|
|
|
458
|
-
// src/AppsInTossModule/native-modules/
|
|
459
|
-
function
|
|
460
|
-
|
|
592
|
+
// src/AppsInTossModule/native-modules/setClipboardText.ts
|
|
593
|
+
async function setClipboardText(text) {
|
|
594
|
+
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
595
|
+
if (permissionStatus === "denied") {
|
|
596
|
+
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
597
|
+
}
|
|
598
|
+
return AppsInTossModule.setClipboardText({ text });
|
|
461
599
|
}
|
|
462
600
|
|
|
463
|
-
// src/AppsInTossModule/native-modules/
|
|
464
|
-
function
|
|
465
|
-
|
|
601
|
+
// src/AppsInTossModule/native-modules/setDeviceOrientation.ts
|
|
602
|
+
async function setDeviceOrientation(options) {
|
|
603
|
+
const isSupported = isMinVersionSupported({
|
|
604
|
+
android: "5.215.0",
|
|
605
|
+
ios: "5.215.0"
|
|
606
|
+
});
|
|
607
|
+
if (!isSupported) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
return AppsInTossModule.setDeviceOrientation(options);
|
|
466
611
|
}
|
|
467
612
|
|
|
468
613
|
// src/AppsInTossModule/native-modules/storage.ts
|
|
@@ -488,67 +633,46 @@ var Storage = {
|
|
|
488
633
|
clearItems
|
|
489
634
|
};
|
|
490
635
|
|
|
491
|
-
// src/AppsInTossModule/native-modules/
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
});
|
|
636
|
+
// src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts
|
|
637
|
+
import { openURL } from "@granite-js/react-native";
|
|
638
|
+
|
|
639
|
+
// src/AppsInTossModule/constants.ts
|
|
640
|
+
var GAME_CENTER_MIN_VERSION = {
|
|
641
|
+
android: "5.221.0",
|
|
642
|
+
ios: "5.221.0"
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
// src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts
|
|
646
|
+
async function openGameCenterLeaderboard() {
|
|
647
|
+
if (!isMinVersionSupported(GAME_CENTER_MIN_VERSION)) {
|
|
504
648
|
return;
|
|
505
649
|
}
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
});
|
|
510
|
-
if (!isSupported) {
|
|
511
|
-
return;
|
|
650
|
+
const appName = global.__granite?.app?.name;
|
|
651
|
+
if (appName == null) {
|
|
652
|
+
throw new Error("Cannot get app name");
|
|
512
653
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
});
|
|
654
|
+
const url = new URL("servicetoss://game-center/leaderboard?_navbar=hide");
|
|
655
|
+
url.searchParams.set("appName", appName);
|
|
656
|
+
url.searchParams.set("referrer", `appsintoss.${appName}`);
|
|
657
|
+
return openURL(url.toString());
|
|
518
658
|
}
|
|
519
659
|
|
|
520
|
-
// src/AppsInTossModule/native-modules/
|
|
521
|
-
async function
|
|
522
|
-
const
|
|
523
|
-
const shareUrl = new URL(shareLink);
|
|
524
|
-
shareUrl.searchParams.set("deep_link_value", path);
|
|
525
|
-
shareUrl.searchParams.set("af_dp", path);
|
|
526
|
-
return shareUrl.toString();
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
// src/AppsInTossModule/native-modules/setDeviceOrientation.ts
|
|
530
|
-
async function setDeviceOrientation(options) {
|
|
531
|
-
const isSupported = isMinVersionSupported({
|
|
532
|
-
android: "5.215.0",
|
|
533
|
-
ios: "5.215.0"
|
|
534
|
-
});
|
|
660
|
+
// src/AppsInTossModule/native-modules/getGameCenterGameProfile.ts
|
|
661
|
+
async function getGameCenterGameProfile() {
|
|
662
|
+
const isSupported = isMinVersionSupported(GAME_CENTER_MIN_VERSION);
|
|
535
663
|
if (!isSupported) {
|
|
536
664
|
return;
|
|
537
665
|
}
|
|
538
|
-
return AppsInTossModule.
|
|
666
|
+
return AppsInTossModule.getGameCenterGameProfile({});
|
|
539
667
|
}
|
|
540
668
|
|
|
541
|
-
// src/AppsInTossModule/native-modules/
|
|
542
|
-
async function
|
|
543
|
-
const isSupported = isMinVersionSupported(
|
|
544
|
-
android: "5.218.0",
|
|
545
|
-
ios: "5.216.0"
|
|
546
|
-
});
|
|
669
|
+
// src/AppsInTossModule/native-modules/submitGameCenterLeaderBoardScore.ts
|
|
670
|
+
async function submitGameCenterLeaderBoardScore(params) {
|
|
671
|
+
const isSupported = isMinVersionSupported(GAME_CENTER_MIN_VERSION);
|
|
547
672
|
if (!isSupported) {
|
|
548
|
-
console.warn("saveBase64Data is not supported in this app version");
|
|
549
673
|
return;
|
|
550
674
|
}
|
|
551
|
-
|
|
675
|
+
return AppsInTossModule.submitGameCenterLeaderBoardScore(params);
|
|
552
676
|
}
|
|
553
677
|
|
|
554
678
|
// src/AppsInTossModule/native-modules/index.ts
|
|
@@ -624,7 +748,7 @@ async function setIosSwipeGestureEnabled(options) {
|
|
|
624
748
|
|
|
625
749
|
// src/BedrockModule/native-modules/natives/openURL.ts
|
|
626
750
|
import { Linking } from "react-native";
|
|
627
|
-
function
|
|
751
|
+
function openURL2(url) {
|
|
628
752
|
return Linking.openURL(url);
|
|
629
753
|
}
|
|
630
754
|
|
|
@@ -639,15 +763,15 @@ import { NativeModules as NativeModules2 } from "react-native";
|
|
|
639
763
|
var BedrockCoreModule = NativeModules2.BedrockCoreModule;
|
|
640
764
|
|
|
641
765
|
// src/types.ts
|
|
642
|
-
var
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
return
|
|
650
|
-
})(
|
|
766
|
+
var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
|
|
767
|
+
Accuracy2[Accuracy2["Lowest"] = 1] = "Lowest";
|
|
768
|
+
Accuracy2[Accuracy2["Low"] = 2] = "Low";
|
|
769
|
+
Accuracy2[Accuracy2["Balanced"] = 3] = "Balanced";
|
|
770
|
+
Accuracy2[Accuracy2["High"] = 4] = "High";
|
|
771
|
+
Accuracy2[Accuracy2["Highest"] = 5] = "Highest";
|
|
772
|
+
Accuracy2[Accuracy2["BestForNavigation"] = 6] = "BestForNavigation";
|
|
773
|
+
return Accuracy2;
|
|
774
|
+
})(Accuracy || {});
|
|
651
775
|
|
|
652
776
|
// src/AppsInTossModule/native-modules/tossCore.ts
|
|
653
777
|
import { NativeModules as NativeModules3 } from "react-native";
|
|
@@ -672,11 +796,12 @@ var INTERNAL__module = {
|
|
|
672
796
|
tossCoreEventLog
|
|
673
797
|
};
|
|
674
798
|
export {
|
|
675
|
-
|
|
799
|
+
Accuracy,
|
|
676
800
|
AppsInTossModule,
|
|
677
801
|
BedrockCoreModule,
|
|
678
802
|
BedrockModule,
|
|
679
803
|
GoogleAdMob,
|
|
804
|
+
IAP,
|
|
680
805
|
AppsInTossModuleInstance as INTERNAL__AppsInTossModule,
|
|
681
806
|
INTERNAL__module,
|
|
682
807
|
Storage,
|
|
@@ -684,6 +809,7 @@ export {
|
|
|
684
809
|
appLogin,
|
|
685
810
|
appsInTossEvent,
|
|
686
811
|
closeView,
|
|
812
|
+
contactsViral,
|
|
687
813
|
eventLog,
|
|
688
814
|
fetchAlbumPhotos,
|
|
689
815
|
fetchContacts,
|
|
@@ -691,6 +817,7 @@ export {
|
|
|
691
817
|
getClipboardText,
|
|
692
818
|
getCurrentLocation,
|
|
693
819
|
getDeviceId,
|
|
820
|
+
getGameCenterGameProfile,
|
|
694
821
|
getLocale,
|
|
695
822
|
getNetworkStatus,
|
|
696
823
|
getOperationalEnvironment,
|
|
@@ -699,8 +826,10 @@ export {
|
|
|
699
826
|
getTossAppVersion,
|
|
700
827
|
getTossShareLink,
|
|
701
828
|
isMinVersionSupported,
|
|
829
|
+
onVisibilityChangedByTransparentServiceWeb,
|
|
702
830
|
openCamera,
|
|
703
|
-
|
|
831
|
+
openGameCenterLeaderboard,
|
|
832
|
+
openURL2 as openURL,
|
|
704
833
|
saveBase64Data,
|
|
705
834
|
setClipboardText,
|
|
706
835
|
setDeviceOrientation,
|
|
@@ -708,5 +837,6 @@ export {
|
|
|
708
837
|
setScreenAwakeMode,
|
|
709
838
|
setSecureScreen,
|
|
710
839
|
share,
|
|
711
|
-
startUpdateLocation
|
|
840
|
+
startUpdateLocation,
|
|
841
|
+
submitGameCenterLeaderBoardScore
|
|
712
842
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/native-modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "Native Modules for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -26,16 +26,15 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
|
-
"src
|
|
30
|
-
"src/constant-bridges.ts",
|
|
31
|
-
"src/event-bridges.ts"
|
|
29
|
+
"src"
|
|
32
30
|
],
|
|
33
31
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@granite-js/
|
|
32
|
+
"@babel/runtime": "^7",
|
|
33
|
+
"@granite-js/native": "0.1.20",
|
|
34
|
+
"@granite-js/react-native": "0.1.20",
|
|
36
35
|
"@types/react": "18.3.3",
|
|
37
36
|
"dts-bundle-generator": "^9.5.1",
|
|
38
|
-
"esbuild": "
|
|
37
|
+
"esbuild": "0.25.5",
|
|
39
38
|
"picocolors": "^1.1.1",
|
|
40
39
|
"react": "18.2.0",
|
|
41
40
|
"react-native": "0.72.6",
|
|
@@ -54,5 +53,5 @@
|
|
|
54
53
|
"publishConfig": {
|
|
55
54
|
"access": "public"
|
|
56
55
|
},
|
|
57
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1cf9898b323a17c789ff9f5d75e8c6ab68fe4a95"
|
|
58
57
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraniteEvent } from '@granite-js/react-native';
|
|
2
|
+
import { EntryMessageExitedEvent } from './event-plugins/EntryMessageExitedEvent';
|
|
3
|
+
import { UpdateLocationEvent } from './event-plugins/UpdateLocationEvent';
|
|
4
|
+
import { AppBridgeCallbackEvent } from './internal/AppBridgeCallbackEvent';
|
|
5
|
+
import { VisibilityChangedByTransparentServiceWebEvent } from './internal/VisibilityChangedByTransparentServiceWebEvent';
|
|
6
|
+
|
|
7
|
+
export const appsInTossEvent = new GraniteEvent([
|
|
8
|
+
new UpdateLocationEvent(),
|
|
9
|
+
new EntryMessageExitedEvent(),
|
|
10
|
+
// Internal events
|
|
11
|
+
new AppBridgeCallbackEvent(),
|
|
12
|
+
new VisibilityChangedByTransparentServiceWebEvent(),
|
|
13
|
+
]);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { INTERNAL__appBridgeHandler } from './internal/appBridge';
|
|
2
|
+
import { isMinVersionSupported } from '../native-modules/isMinVersionSupported';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* @category 친구초대
|
|
7
|
+
* @name RewardFromContactsViralEvent
|
|
8
|
+
* @description 친구에게 공유하기를 완료했을 때 지급할 리워드 정보를 담는 타입이에요. 이 타입을 사용하면 공유가 완료됐을 때 지급할 리워드 정보를 확인할 수 있어요.
|
|
9
|
+
* @property {'sendViral'} type - 이벤트의 타입이에요. `'sendViral'`은 사용자가 친구에게 공유를 완료했을 때 돌아와요.
|
|
10
|
+
* @property {Object} data - 지급할 리워드 관련 정보를 담고 있어요.
|
|
11
|
+
* @property {number} data.rewardAmount - 지급할 리워드 수량이에요. 앱인토스 콘솔에서 설정한 수량 및 금액 값이에요.
|
|
12
|
+
* @property {string} data.rewardUnit - 리워드의 단위예요. 앱인토스 콘솔에 설정된 리워드 이름인 '하트', '보석' 등이 리워드 단위예요.
|
|
13
|
+
*/
|
|
14
|
+
type RewardFromContactsViralEvent = {
|
|
15
|
+
type: 'sendViral';
|
|
16
|
+
data: {
|
|
17
|
+
rewardAmount: number;
|
|
18
|
+
rewardUnit: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
* @category 친구초대
|
|
25
|
+
* @name ContactsViralSuccessEvent
|
|
26
|
+
* @description 연락처 공유 모듈이 정상적으로 종료됐을 때 전달되는 이벤트 객체예요. 종료 이유와 함께 리워드 상태 및 남은 친구 수 등 관련 정보를 제공해요.
|
|
27
|
+
* @property {'close'} type - 이벤트의 타입이에요. `'close'`는 공유 모듈이 종료됐을 때 돌아와요.
|
|
28
|
+
* @property {Object} data - 모듈 종료와 관련된 세부 정보를 담고 있어요.
|
|
29
|
+
* @property {'clickBackButton' | 'noReward'} data.closeReason - 모듈이 종료된 이유예요. `'clickBackButton'`은 사용자가 뒤로 가기 버튼을 눌러 종료한 경우이고, `'noReward'`는 받을 수 있는 리워드가 없어서 종료된 경우예요.
|
|
30
|
+
* @property {number} data.sentRewardAmount - 사용자가 받은 전체 리워드 수량이에요.
|
|
31
|
+
* @property {number} data.sendableRewardsCount - 아직 공유할 수 있는 친구 수예요.
|
|
32
|
+
* @property {number} data.sentRewardsCount - 사용자가 공유를 완료한 친구 수예요.
|
|
33
|
+
* @property {string} data.rewardUnit - 리워드의 단위예요. 앱인토스 콘솔에 설정된 리워드 이름인 '하트', '보석' 등이 리워드 단위예요.
|
|
34
|
+
*/
|
|
35
|
+
type ContactsViralSuccessEvent = {
|
|
36
|
+
type: 'close';
|
|
37
|
+
data: {
|
|
38
|
+
closeReason: 'clickBackButton' | 'noReward';
|
|
39
|
+
sentRewardAmount?: number;
|
|
40
|
+
sendableRewardsCount?: number;
|
|
41
|
+
sentRewardsCount: number;
|
|
42
|
+
rewardUnit?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type ContactsViralEvent = RewardFromContactsViralEvent | ContactsViralSuccessEvent;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
* @category 친구초대
|
|
51
|
+
* @name ContactsViralOption
|
|
52
|
+
* @description [연락처 공유 기능](/react-native/reference/native-modules/친구초대/contactsViral.html)을 사용할 때 필요한 옵션이에요.
|
|
53
|
+
* @property {string} moduleId - 공유 리워드를 구분하는 UUID 형식의 고유 ID예요. 앱인토스 콘솔의 미니앱 > 공유 리워드 메뉴에서 확인할 수 있어요.
|
|
54
|
+
*/
|
|
55
|
+
type ContactsViralOption = {
|
|
56
|
+
moduleId: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
* @category 친구초대
|
|
62
|
+
* @name ContactsViralParams
|
|
63
|
+
* @description `ContactsViralParams`는 연락처 공유 기능을 사용할 때 전달해야 하는 파라미터 타입이에요. 옵션을 설정하고, 이벤트 및 에러 처리 콜백을 지정할 수 있어요.
|
|
64
|
+
* @property {ContactsViralOption} options - 공유 기능에 사용할 옵션 객체예요.
|
|
65
|
+
* @property {(event: ContactsViralEvent) => void} onEvent - 공유 이벤트가 발생했을 때 실행되는 함수예요. [`RewardFromContactsViralEvent`](/bedrock/reference/native-modules/친구초대/RewardFromContactsViralEvent.html) 또는 [`ContactsViralSuccessEvent`](/react-native/reference/native-modules/친구초대/ContactsViralSuccessEvent.html) 타입의 이벤트 객체가 전달돼요.
|
|
66
|
+
* @property {(error: unknown) => void} onError - 예기치 않은 에러가 발생했을 때 실행되는 함수예요.
|
|
67
|
+
*/
|
|
68
|
+
export interface ContactsViralParams {
|
|
69
|
+
options: ContactsViralOption;
|
|
70
|
+
onEvent: (event: ContactsViralEvent) => void;
|
|
71
|
+
onError: (error: unknown) => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
* @category 친구초대
|
|
77
|
+
* @name contactsViral
|
|
78
|
+
* @description 친구에게 공유하고 리워드를 받을 수 있는 기능을 제공해요. 사용자가 친구에게 공유를 완료하면 앱브릿지가 이벤트를 통해 리워드 정보를 전달해요.
|
|
79
|
+
* @param {ContactsViralParams} params - 연락처 공유 기능을 실행할 때 사용하는 파라미터예요. 옵션 설정과 이벤트 핸들러를 포함해요. 자세한 내용은 [ContactsViralParams](/bedrock/reference/native-modules/친구초대/ContactsViralParams.html) 문서를 참고하세요.
|
|
80
|
+
* @returns {() => void} 앱브릿지 cleanup 함수를 반환해요. 공유 기능이 끝나면 반드시 이 함수를 호출해서 리소스를 해제해야 해요.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ### 친구에게 공유하고 리워드 받기
|
|
84
|
+
*
|
|
85
|
+
* ```tsx
|
|
86
|
+
* import { useCallback } from 'react';
|
|
87
|
+
* import { Button } from 'react-native';
|
|
88
|
+
* import { contactsViral } from '@apps-in-toss/framework';
|
|
89
|
+
*
|
|
90
|
+
* function ContactsViralButton({ moduleId }: { moduleId: string }) {
|
|
91
|
+
* const handleContactsViral = useCallback(() => {
|
|
92
|
+
* try {
|
|
93
|
+
* const cleanup = contactsViral({
|
|
94
|
+
* options: { moduleId: moduleId.trim() },
|
|
95
|
+
* onEvent: (event) => {
|
|
96
|
+
* if (event.type === 'sendViral') {
|
|
97
|
+
* console.log('리워드 지급:', event.data.rewardAmount, event.data.rewardUnit);
|
|
98
|
+
* } else if (event.type === 'close') {
|
|
99
|
+
* console.log('모듈 종료:', event.data.closeReason);
|
|
100
|
+
* }
|
|
101
|
+
* },
|
|
102
|
+
* onError: (error) => {
|
|
103
|
+
* console.error('에러 발생:', error);
|
|
104
|
+
* },
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* return cleanup;
|
|
108
|
+
* } catch (error) {
|
|
109
|
+
* console.error('실행 중 에러:', error);
|
|
110
|
+
* }
|
|
111
|
+
* }, [moduleId]);
|
|
112
|
+
*
|
|
113
|
+
* return <Button title="친구에게 공유하고 리워드 받기" onPress={handleContactsViral} />;
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function contactsViral(params: ContactsViralParams) {
|
|
118
|
+
const isSupported = isMinVersionSupported({
|
|
119
|
+
android: '5.223.0',
|
|
120
|
+
ios: '5.223.0',
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
if (!isSupported) {
|
|
124
|
+
return () => {};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const { onEvent, onError, options } = params;
|
|
128
|
+
|
|
129
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod('contactsViral', options, {
|
|
130
|
+
onRewardFromContactsViral: (result: RewardFromContactsViralEvent['data']) => {
|
|
131
|
+
onEvent({ type: 'sendViral', data: result });
|
|
132
|
+
},
|
|
133
|
+
onSuccess: (result: ContactsViralSuccessEvent['data']) => {
|
|
134
|
+
onEvent({ type: 'close', data: result });
|
|
135
|
+
},
|
|
136
|
+
onError,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return unregisterCallbacks;
|
|
140
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GraniteEventDefinition } from '@granite-js/react-native';
|
|
2
|
+
|
|
3
|
+
export class EntryMessageExitedEvent extends GraniteEventDefinition<undefined, undefined> {
|
|
4
|
+
name = 'entryMessageExited' as const;
|
|
5
|
+
|
|
6
|
+
remove() {}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
listener(_: undefined) {}
|
|
10
|
+
}
|