@apps-in-toss/framework 0.0.22 → 0.0.24
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 +686 -165
- package/dist/index.d.cts +664 -343
- package/dist/index.d.ts +664 -343
- package/dist/index.js +653 -137
- package/package.json +10 -8
- package/src/async-bridges.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -4,84 +4,219 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
// src/index.ts
|
|
8
|
+
import { Analytics as InternalAnalytics } from "@apps-in-toss/analytics";
|
|
9
|
+
|
|
7
10
|
// src/core/registerApp.tsx
|
|
11
|
+
import { Analytics } from "@apps-in-toss/analytics";
|
|
8
12
|
import { TDSProvider } from "@toss-design-system/react-native";
|
|
9
|
-
import { Bedrock } from "react-native-bedrock";
|
|
13
|
+
import { Bedrock as Bedrock2 } from "react-native-bedrock";
|
|
10
14
|
|
|
11
|
-
// src/core/
|
|
12
|
-
import { useBridge } from "@toss-design-system/react-native";
|
|
15
|
+
// src/core/components/AppEvent.tsx
|
|
13
16
|
import { useEffect } from "react";
|
|
17
|
+
import { Bedrock, getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
|
|
14
18
|
|
|
15
|
-
// src/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
// src/env.ts
|
|
20
|
+
var env = {
|
|
21
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/native-modules/tossCore.ts
|
|
25
|
+
import { NativeModules as NativeModules2 } from "react-native";
|
|
26
|
+
|
|
27
|
+
// src/native-modules/isMinVersionSupported.ts
|
|
28
|
+
import { Platform } from "react-native";
|
|
29
|
+
|
|
30
|
+
// src/native-modules/AppsInTossModule.ts
|
|
31
|
+
import { NativeModules } from "react-native";
|
|
32
|
+
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
33
|
+
var AppsInTossModule = AppsInTossModuleInstance;
|
|
34
|
+
|
|
35
|
+
// src/utils/compareVersion.ts
|
|
36
|
+
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
37
|
+
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
38
|
+
var tryParse = (val) => {
|
|
39
|
+
const num = parseInt(val, 10);
|
|
40
|
+
return isNaN(num) ? val : num;
|
|
41
|
+
};
|
|
42
|
+
var coerceTypes = (a, b) => {
|
|
43
|
+
return typeof a === typeof b ? [a, b] : [String(a), String(b)];
|
|
44
|
+
};
|
|
45
|
+
var compareValues = (a, b) => {
|
|
46
|
+
if (isWildcard(a) || isWildcard(b)) {
|
|
47
|
+
return 0;
|
|
19
48
|
}
|
|
20
|
-
|
|
21
|
-
|
|
49
|
+
const [aVal, bVal] = coerceTypes(tryParse(a), tryParse(b));
|
|
50
|
+
if (aVal > bVal) {
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
if (aVal < bVal) {
|
|
54
|
+
return -1;
|
|
55
|
+
}
|
|
56
|
+
return 0;
|
|
57
|
+
};
|
|
58
|
+
var parseVersion = (version) => {
|
|
59
|
+
if (typeof version !== "string") {
|
|
60
|
+
throw new TypeError("Invalid argument: expected a string");
|
|
61
|
+
}
|
|
62
|
+
const match = version.match(SEMVER_REGEX);
|
|
63
|
+
if (!match) {
|
|
64
|
+
throw new Error(`Invalid semver: '${version}'`);
|
|
65
|
+
}
|
|
66
|
+
const [, major, minor, patch, build, preRelease] = match;
|
|
67
|
+
return [major, minor, patch, build, preRelease];
|
|
68
|
+
};
|
|
69
|
+
var compareSegments = (a, b) => {
|
|
70
|
+
const maxLength = Math.max(a.length, b.length);
|
|
71
|
+
for (let i = 0; i < maxLength; i++) {
|
|
72
|
+
const segA = a[i] ?? "0";
|
|
73
|
+
const segB = b[i] ?? "0";
|
|
74
|
+
const result = compareValues(segA, segB);
|
|
75
|
+
if (result !== 0) {
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
};
|
|
81
|
+
var compareVersions = (v1, v2) => {
|
|
82
|
+
const seg1 = parseVersion(v1);
|
|
83
|
+
const seg2 = parseVersion(v2);
|
|
84
|
+
const preRelease1 = seg1.pop();
|
|
85
|
+
const preRelease2 = seg2.pop();
|
|
86
|
+
const mainCompare = compareSegments(seg1, seg2);
|
|
87
|
+
if (mainCompare !== 0) {
|
|
88
|
+
return mainCompare;
|
|
89
|
+
}
|
|
90
|
+
if (preRelease1 && preRelease2) {
|
|
91
|
+
return compareSegments(preRelease1.split("."), preRelease2.split("."));
|
|
92
|
+
}
|
|
93
|
+
if (preRelease1) {
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
|
96
|
+
if (preRelease2) {
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
return 0;
|
|
100
|
+
};
|
|
22
101
|
|
|
23
|
-
// src/
|
|
24
|
-
function
|
|
25
|
-
|
|
102
|
+
// src/native-modules/isMinVersionSupported.ts
|
|
103
|
+
function isMinVersionSupported(minVersions) {
|
|
104
|
+
const operationalEnvironment2 = AppsInTossModule.operationalEnvironment;
|
|
105
|
+
if (operationalEnvironment2 === "sandbox") {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
const currentVersion = AppsInTossModule.tossAppVersion;
|
|
109
|
+
const isIOS = Platform.OS === "ios";
|
|
110
|
+
const minVersion = isIOS ? minVersions.ios : minVersions.android;
|
|
111
|
+
if (minVersion === void 0) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (minVersion === "always") {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (minVersion === "never") {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return compareVersions(currentVersion, minVersion) >= 0;
|
|
26
121
|
}
|
|
27
122
|
|
|
28
|
-
// src/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
123
|
+
// src/native-modules/tossCore.ts
|
|
124
|
+
var TossCoreModule = NativeModules2.TossCoreModule;
|
|
125
|
+
function tossCoreEventLog(params) {
|
|
126
|
+
const supported = isMinVersionSupported({ ios: "5.210.0", android: "5.210.0" });
|
|
127
|
+
if (!supported) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
TossCoreModule.eventLog({
|
|
131
|
+
params: {
|
|
132
|
+
log_name: params.log_name,
|
|
133
|
+
log_type: params.log_type,
|
|
134
|
+
params: params.params
|
|
135
|
+
}
|
|
136
|
+
});
|
|
41
137
|
}
|
|
42
138
|
|
|
43
|
-
// src/core/
|
|
44
|
-
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function registerApp(container, { context }) {
|
|
53
|
-
return Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
|
|
54
|
-
appName: getAppName(),
|
|
55
|
-
context,
|
|
56
|
-
defaultScreenOption: {
|
|
57
|
-
statusBarStyle: "dark"
|
|
139
|
+
// src/core/hooks/useReferrer.ts
|
|
140
|
+
import { useMemo } from "react";
|
|
141
|
+
import { getSchemeUri } from "react-native-bedrock";
|
|
142
|
+
function useReferrer() {
|
|
143
|
+
return useMemo(() => {
|
|
144
|
+
try {
|
|
145
|
+
return new URL(getSchemeUri()).searchParams.get("referrer");
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
58
148
|
}
|
|
59
|
-
});
|
|
149
|
+
}, []);
|
|
60
150
|
}
|
|
61
|
-
|
|
151
|
+
|
|
152
|
+
// src/core/components/AppEvent.tsx
|
|
153
|
+
var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
|
|
154
|
+
function isPrivateScheme() {
|
|
62
155
|
try {
|
|
63
|
-
return
|
|
64
|
-
} catch
|
|
65
|
-
|
|
66
|
-
throw error;
|
|
156
|
+
return new URL(getSchemeUri2()).protocol === "intoss-private:";
|
|
157
|
+
} catch {
|
|
158
|
+
return false;
|
|
67
159
|
}
|
|
68
160
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
161
|
+
function EntryAppEvent() {
|
|
162
|
+
const referrer = useReferrer() ?? "";
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
tossCoreEventLog({
|
|
165
|
+
log_name: "appsintoss_app_visit::impression__enter_appsintoss",
|
|
166
|
+
log_type: "info",
|
|
167
|
+
params: {
|
|
168
|
+
is_transform: true,
|
|
169
|
+
schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
|
|
170
|
+
referrer,
|
|
171
|
+
deployment_id: env.getDeploymentId(),
|
|
172
|
+
app_name: Bedrock.appName,
|
|
173
|
+
is_private: isPrivateScheme()
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}, [referrer]);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
function SystemAppEvent({ ...initialProps }) {
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
tossCoreEventLog({
|
|
182
|
+
log_name: "AppsInTossInitialProps",
|
|
183
|
+
log_type: "debug",
|
|
184
|
+
params: {
|
|
185
|
+
...initialProps,
|
|
186
|
+
schemeUri: getSchemeUri2(),
|
|
187
|
+
deployment_id: env.getDeploymentId(),
|
|
188
|
+
app_name: Bedrock.appName,
|
|
189
|
+
is_private: isPrivateScheme()
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}, [initialProps]);
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
var AppEvent = {
|
|
196
|
+
Entry: EntryAppEvent,
|
|
197
|
+
System: SystemAppEvent
|
|
73
198
|
};
|
|
74
199
|
|
|
75
|
-
// src/
|
|
200
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
201
|
+
import { useBridge } from "@toss-design-system/react-native";
|
|
202
|
+
import { useEffect as useEffect2 } from "react";
|
|
203
|
+
|
|
204
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
76
205
|
import { BedrockEvent } from "react-native-bedrock";
|
|
77
206
|
|
|
78
|
-
// src/native-event-emitter/event-plugins/
|
|
207
|
+
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
79
208
|
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
209
|
+
var EntryMessageExitedEvent = class extends BedrockEventDefinition {
|
|
210
|
+
name = "entryMessageExited";
|
|
211
|
+
remove() {
|
|
212
|
+
}
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
214
|
+
listener(_) {
|
|
215
|
+
}
|
|
216
|
+
};
|
|
80
217
|
|
|
81
|
-
// src/native-
|
|
82
|
-
import {
|
|
83
|
-
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
84
|
-
var AppsInTossModule = AppsInTossModuleInstance;
|
|
218
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
219
|
+
import { BedrockEventDefinition as BedrockEventDefinition2 } from "react-native-bedrock";
|
|
85
220
|
|
|
86
221
|
// src/native-modules/getPermission.ts
|
|
87
222
|
function getPermission(permission) {
|
|
@@ -110,7 +245,7 @@ import { NativeEventEmitter } from "react-native";
|
|
|
110
245
|
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
111
246
|
|
|
112
247
|
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
113
|
-
var UpdateLocationEvent = class extends
|
|
248
|
+
var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
114
249
|
name = "updateLocationEvent";
|
|
115
250
|
subscriptionCount = 0;
|
|
116
251
|
ref = {
|
|
@@ -137,24 +272,148 @@ var UpdateLocationEvent = class extends BedrockEventDefinition {
|
|
|
137
272
|
}
|
|
138
273
|
};
|
|
139
274
|
|
|
140
|
-
// src/native-event-emitter/
|
|
141
|
-
|
|
275
|
+
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
276
|
+
import { BedrockEventDefinition as BedrockEventDefinition3 } from "react-native-bedrock";
|
|
142
277
|
|
|
143
|
-
// src/
|
|
144
|
-
function
|
|
145
|
-
return
|
|
278
|
+
// src/utils/generateUUID.ts
|
|
279
|
+
function generateUUID(placeholder) {
|
|
280
|
+
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
146
281
|
}
|
|
147
282
|
|
|
148
|
-
// src/native-
|
|
149
|
-
|
|
150
|
-
|
|
283
|
+
// src/native-event-emitter/internal/appBridge.ts
|
|
284
|
+
var INTERNAL__callbacks = /* @__PURE__ */ new Map();
|
|
285
|
+
function invokeAppBridgeCallback(id, ...args) {
|
|
286
|
+
const callback = INTERNAL__callbacks.get(id);
|
|
287
|
+
callback?.call(null, ...args);
|
|
288
|
+
return Boolean(callback);
|
|
289
|
+
}
|
|
290
|
+
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
291
|
+
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
292
|
+
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
293
|
+
const promise = AppsInTossModuleInstance[methodName]({
|
|
294
|
+
params,
|
|
295
|
+
callbacks: callbackMap
|
|
296
|
+
});
|
|
297
|
+
void promise.then(onSuccess).catch(onError);
|
|
298
|
+
return unregisterAll;
|
|
299
|
+
}
|
|
300
|
+
function registerCallbacks(callbacks) {
|
|
301
|
+
const callbackMap = {};
|
|
302
|
+
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
303
|
+
const id = registerCallback(callback, callbackName);
|
|
304
|
+
callbackMap[callbackName] = id;
|
|
305
|
+
}
|
|
306
|
+
const unregisterAll = () => {
|
|
307
|
+
Object.values(callbackMap).forEach(unregisterCallback);
|
|
308
|
+
};
|
|
309
|
+
return { callbackMap, unregisterAll };
|
|
310
|
+
}
|
|
311
|
+
function registerCallback(callback, name = "unnamed") {
|
|
312
|
+
const uniqueId = generateUUID();
|
|
313
|
+
const callbackId = `${uniqueId}__${name}`;
|
|
314
|
+
INTERNAL__callbacks.set(callbackId, callback);
|
|
315
|
+
return callbackId;
|
|
316
|
+
}
|
|
317
|
+
function unregisterCallback(id) {
|
|
318
|
+
INTERNAL__callbacks.delete(id);
|
|
319
|
+
}
|
|
320
|
+
function getCallbackIds() {
|
|
321
|
+
return Array.from(INTERNAL__callbacks.keys());
|
|
322
|
+
}
|
|
323
|
+
var INTERNAL__appBridgeHandler = {
|
|
324
|
+
invokeAppBridgeCallback,
|
|
325
|
+
invokeAppBridgeMethod,
|
|
326
|
+
registerCallback,
|
|
327
|
+
unregisterCallback,
|
|
328
|
+
getCallbackIds
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
332
|
+
var UNSAFE__nativeEventEmitter = nativeEventEmitter;
|
|
333
|
+
var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends BedrockEventDefinition3 {
|
|
334
|
+
static INTERNAL__appBridgeSubscription;
|
|
335
|
+
name = "appBridgeCallbackEvent";
|
|
336
|
+
constructor() {
|
|
337
|
+
super();
|
|
338
|
+
this.registerAppBridgeCallbackEventListener();
|
|
339
|
+
}
|
|
340
|
+
remove() {
|
|
341
|
+
}
|
|
342
|
+
listener() {
|
|
343
|
+
}
|
|
344
|
+
registerAppBridgeCallbackEventListener() {
|
|
345
|
+
if (_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription != null) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription = UNSAFE__nativeEventEmitter.addListener(
|
|
349
|
+
"appBridgeCallback",
|
|
350
|
+
this.ensureInvokeAppBridgeCallback
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
ensureInvokeAppBridgeCallback(result) {
|
|
354
|
+
if (typeof result === "object" && typeof result.name === "string") {
|
|
355
|
+
INTERNAL__appBridgeHandler.invokeAppBridgeCallback(result.name, result.params);
|
|
356
|
+
} else {
|
|
357
|
+
console.warn("Invalid app bridge callback result:", result);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
363
|
+
var appsInTossEvent = new BedrockEvent([
|
|
364
|
+
new AppBridgeCallbackEvent(),
|
|
365
|
+
new UpdateLocationEvent(),
|
|
366
|
+
new EntryMessageExitedEvent()
|
|
367
|
+
]);
|
|
368
|
+
|
|
369
|
+
// src/core/utils/getAppsInTossGlobals.ts
|
|
370
|
+
function getAppsInTossGlobals() {
|
|
371
|
+
if (global.__appsInToss == null) {
|
|
372
|
+
throw new Error("invalid apps-in-toss globals");
|
|
373
|
+
}
|
|
374
|
+
return global.__appsInToss;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// src/core/utils/toIcon.ts
|
|
378
|
+
function toIcon(source) {
|
|
379
|
+
return source.startsWith("http") ? { source: { uri: source } } : { name: source };
|
|
151
380
|
}
|
|
152
381
|
|
|
153
|
-
// src/
|
|
154
|
-
|
|
155
|
-
|
|
382
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
383
|
+
function useAppsInTossBridge() {
|
|
384
|
+
const controller = useBridge();
|
|
385
|
+
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
386
|
+
useEffect2(() => {
|
|
387
|
+
const commonProps = {
|
|
388
|
+
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
389
|
+
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
390
|
+
color: appsInTossGlobals2.brandPrimaryColor,
|
|
391
|
+
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
392
|
+
};
|
|
393
|
+
controller.open({
|
|
394
|
+
...commonProps,
|
|
395
|
+
onExited: () => {
|
|
396
|
+
appsInTossEvent.emit("entryMessageExited", void 0);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}, []);
|
|
156
400
|
}
|
|
157
401
|
|
|
402
|
+
// src/async-bridges.ts
|
|
403
|
+
var async_bridges_exports = {};
|
|
404
|
+
__export(async_bridges_exports, {
|
|
405
|
+
appLogin: () => appLogin,
|
|
406
|
+
checkoutPayment: () => checkoutPayment,
|
|
407
|
+
eventLog: () => eventLog,
|
|
408
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
409
|
+
fetchContacts: () => fetchContacts,
|
|
410
|
+
getClipboardText: () => getClipboardText,
|
|
411
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
412
|
+
getTossShareLink: () => getTossShareLink,
|
|
413
|
+
openCamera: () => openCamera,
|
|
414
|
+
setClipboardText: () => setClipboardText
|
|
415
|
+
});
|
|
416
|
+
|
|
158
417
|
// src/native-modules/setClipboardText.ts
|
|
159
418
|
async function setClipboardText(text) {
|
|
160
419
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -236,11 +495,209 @@ async function appLogin() {
|
|
|
236
495
|
return AppsInTossModule.appLogin({});
|
|
237
496
|
}
|
|
238
497
|
|
|
498
|
+
// src/native-modules/checkoutPayment.ts
|
|
499
|
+
async function checkoutPayment(options) {
|
|
500
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/native-modules/eventLog.ts
|
|
504
|
+
function normalizeParams(params) {
|
|
505
|
+
return Object.fromEntries(
|
|
506
|
+
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
async function eventLog(params) {
|
|
510
|
+
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
511
|
+
console.log("[eventLogDebug]", {
|
|
512
|
+
log_name: params.log_name,
|
|
513
|
+
log_type: params.log_type,
|
|
514
|
+
params: normalizeParams(params.params)
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const isSupported = isMinVersionSupported({
|
|
519
|
+
android: "5.208.0",
|
|
520
|
+
ios: "5.208.0"
|
|
521
|
+
});
|
|
522
|
+
if (!isSupported) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
return AppsInTossModule.eventLog({
|
|
526
|
+
log_name: params.log_name,
|
|
527
|
+
log_type: params.log_type,
|
|
528
|
+
params: normalizeParams(params.params)
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/native-modules/getTossShareLink.ts
|
|
533
|
+
async function getTossShareLink(path) {
|
|
534
|
+
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
535
|
+
const shareUrl = new URL(shareLink);
|
|
536
|
+
shareUrl.searchParams.set("deep_link_value", path);
|
|
537
|
+
shareUrl.searchParams.set("af_dp", path);
|
|
538
|
+
return shareUrl.toString();
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// src/core/registerApp.tsx
|
|
542
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
543
|
+
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
544
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
545
|
+
/* @__PURE__ */ jsx(AppEvent.Entry, {}),
|
|
546
|
+
/* @__PURE__ */ jsx(AppEvent.System, { ...initialProps }),
|
|
547
|
+
/* @__PURE__ */ jsx(Container, { ...initialProps, children: /* @__PURE__ */ jsx(TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ jsx(TDSContainer, { ...initialProps, children }) }) })
|
|
548
|
+
] });
|
|
549
|
+
}
|
|
550
|
+
function TDSContainer({ children }) {
|
|
551
|
+
useAppsInTossBridge();
|
|
552
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
553
|
+
}
|
|
554
|
+
function registerApp(container, { context, analytics }) {
|
|
555
|
+
Analytics.init({
|
|
556
|
+
logger: (params) => void eventLog(params),
|
|
557
|
+
debug: analytics?.debug ?? __DEV__
|
|
558
|
+
});
|
|
559
|
+
return Bedrock2.registerApp(AppsInTossContainer.bind(null, container), {
|
|
560
|
+
appName: getAppName(),
|
|
561
|
+
context,
|
|
562
|
+
router: {
|
|
563
|
+
screenContainer: Analytics.Screen,
|
|
564
|
+
defaultScreenOption: {
|
|
565
|
+
statusBarStyle: "dark"
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
function getAppName() {
|
|
571
|
+
try {
|
|
572
|
+
return global.__bedrock.app.name;
|
|
573
|
+
} catch (error) {
|
|
574
|
+
console.error("unexpected error occurred while getting app name");
|
|
575
|
+
throw error;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/core/index.ts
|
|
580
|
+
var AppsInToss = {
|
|
581
|
+
registerApp
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
585
|
+
function startUpdateLocation(eventParams) {
|
|
586
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
|
|
590
|
+
function noop() {
|
|
591
|
+
}
|
|
592
|
+
|
|
239
593
|
// src/native-modules/getOperationalEnvironment.ts
|
|
240
594
|
function getOperationalEnvironment() {
|
|
241
595
|
return AppsInTossModule.operationalEnvironment;
|
|
242
596
|
}
|
|
243
597
|
|
|
598
|
+
// src/native-modules/ads/googleAdMob.ts
|
|
599
|
+
function loadAdMobInterstitialAd(params) {
|
|
600
|
+
if (!loadAdMobInterstitialAd.isSupported()) {
|
|
601
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
602
|
+
return noop;
|
|
603
|
+
}
|
|
604
|
+
const { onEvent, onError, options } = params;
|
|
605
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobInterstitialAd", options, {
|
|
606
|
+
onAdClicked: () => {
|
|
607
|
+
onEvent({ type: "clicked" });
|
|
608
|
+
},
|
|
609
|
+
onAdDismissed: () => {
|
|
610
|
+
onEvent({ type: "dismissed" });
|
|
611
|
+
},
|
|
612
|
+
onAdFailedToShow: () => {
|
|
613
|
+
onEvent({ type: "failedToShow" });
|
|
614
|
+
},
|
|
615
|
+
onAdImpression: () => {
|
|
616
|
+
onEvent({ type: "impression" });
|
|
617
|
+
},
|
|
618
|
+
onAdShow: () => {
|
|
619
|
+
onEvent({ type: "show" });
|
|
620
|
+
},
|
|
621
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
622
|
+
onError
|
|
623
|
+
});
|
|
624
|
+
return unregisterCallbacks;
|
|
625
|
+
}
|
|
626
|
+
function showAdMobInterstitialAd(params) {
|
|
627
|
+
if (!showAdMobInterstitialAd.isSupported()) {
|
|
628
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
629
|
+
return noop;
|
|
630
|
+
}
|
|
631
|
+
const { onEvent, onError, options } = params;
|
|
632
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobInterstitialAd", options, {
|
|
633
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
634
|
+
onError
|
|
635
|
+
});
|
|
636
|
+
return unregisterCallbacks;
|
|
637
|
+
}
|
|
638
|
+
function loadAdMobRewardedAd(params) {
|
|
639
|
+
if (!loadAdMobRewardedAd.isSupported()) {
|
|
640
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
641
|
+
return noop;
|
|
642
|
+
}
|
|
643
|
+
const { onEvent, onError, options } = params;
|
|
644
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
645
|
+
onAdClicked: () => {
|
|
646
|
+
onEvent({ type: "clicked" });
|
|
647
|
+
},
|
|
648
|
+
onAdDismissed: () => {
|
|
649
|
+
onEvent({ type: "dismissed" });
|
|
650
|
+
},
|
|
651
|
+
onAdFailedToShow: () => {
|
|
652
|
+
onEvent({ type: "failedToShow" });
|
|
653
|
+
},
|
|
654
|
+
onAdImpression: () => {
|
|
655
|
+
onEvent({ type: "impression" });
|
|
656
|
+
},
|
|
657
|
+
onAdShow: () => {
|
|
658
|
+
onEvent({ type: "show" });
|
|
659
|
+
},
|
|
660
|
+
onUserEarnedReward: () => {
|
|
661
|
+
onEvent({ type: "userEarnedReward" });
|
|
662
|
+
},
|
|
663
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
664
|
+
onError
|
|
665
|
+
});
|
|
666
|
+
return unregisterCallbacks;
|
|
667
|
+
}
|
|
668
|
+
function showAdMobRewardedAd(params) {
|
|
669
|
+
if (!showAdMobRewardedAd.isSupported()) {
|
|
670
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
671
|
+
return noop;
|
|
672
|
+
}
|
|
673
|
+
const { onEvent, onError, options } = params;
|
|
674
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobRewardedAd", options, {
|
|
675
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
676
|
+
onError
|
|
677
|
+
});
|
|
678
|
+
return unregisterCallbacks;
|
|
679
|
+
}
|
|
680
|
+
var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
681
|
+
var IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
682
|
+
var UNSUPPORTED_ERROR_MESSAGE = "This feature is not supported in the current environment";
|
|
683
|
+
var ENVIRONMENT = getOperationalEnvironment();
|
|
684
|
+
function createIsSupported() {
|
|
685
|
+
return () => {
|
|
686
|
+
if (ENVIRONMENT !== "toss") {
|
|
687
|
+
console.warn("Google AdMob is not supported in the current environment");
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
return isMinVersionSupported({
|
|
691
|
+
android: ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION,
|
|
692
|
+
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
693
|
+
});
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
loadAdMobInterstitialAd.isSupported = createIsSupported();
|
|
697
|
+
loadAdMobRewardedAd.isSupported = createIsSupported();
|
|
698
|
+
showAdMobInterstitialAd.isSupported = createIsSupported();
|
|
699
|
+
showAdMobRewardedAd.isSupported = createIsSupported();
|
|
700
|
+
|
|
244
701
|
// src/native-modules/getTossAppVersion.ts
|
|
245
702
|
function getTossAppVersion() {
|
|
246
703
|
return AppsInTossModule.tossAppVersion;
|
|
@@ -274,19 +731,15 @@ var Storage = {
|
|
|
274
731
|
clearItems
|
|
275
732
|
};
|
|
276
733
|
|
|
277
|
-
// src/native-modules/getTossShareLink.ts
|
|
278
|
-
async function getTossShareLink(path) {
|
|
279
|
-
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
280
|
-
const shareUrl = new URL(shareLink);
|
|
281
|
-
shareUrl.searchParams.set("deep_link_value", path);
|
|
282
|
-
shareUrl.searchParams.set("af_dp", path);
|
|
283
|
-
return shareUrl.toString();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
734
|
// src/native-modules/index.ts
|
|
287
735
|
var TossPay = {
|
|
288
|
-
checkoutPayment
|
|
289
|
-
|
|
736
|
+
checkoutPayment
|
|
737
|
+
};
|
|
738
|
+
var GoogleAdMob = {
|
|
739
|
+
loadAdMobInterstitialAd,
|
|
740
|
+
showAdMobInterstitialAd,
|
|
741
|
+
loadAdMobRewardedAd,
|
|
742
|
+
showAdMobRewardedAd
|
|
290
743
|
};
|
|
291
744
|
|
|
292
745
|
// src/components/WebView.tsx
|
|
@@ -295,8 +748,8 @@ import {
|
|
|
295
748
|
ExternalWebViewScreen
|
|
296
749
|
} from "@toss-design-system/react-native";
|
|
297
750
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
|
|
298
|
-
import { useMemo as
|
|
299
|
-
import { getSchemeUri, useBedrockEvent } from "react-native-bedrock";
|
|
751
|
+
import { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
752
|
+
import { getSchemeUri as getSchemeUri4, useBedrockEvent } from "react-native-bedrock";
|
|
300
753
|
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
301
754
|
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
302
755
|
|
|
@@ -306,24 +759,24 @@ import {
|
|
|
306
759
|
} from "@react-native-bedrock/native/react-native-webview";
|
|
307
760
|
import { useDialog } from "@toss-design-system/react-native";
|
|
308
761
|
import { josa } from "es-hangul";
|
|
309
|
-
import { forwardRef, useCallback, useEffect as
|
|
310
|
-
import { BackHandler, Platform as
|
|
762
|
+
import { forwardRef, useCallback, useEffect as useEffect3 } from "react";
|
|
763
|
+
import { BackHandler, Platform as Platform5, View as View3 } from "react-native";
|
|
311
764
|
import { closeView, setIosSwipeGestureEnabled } from "react-native-bedrock";
|
|
312
765
|
|
|
313
766
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
314
767
|
import { SvgXml } from "@react-native-bedrock/native/react-native-svg";
|
|
315
768
|
import { PageNavbar } from "@toss-design-system/react-native";
|
|
316
|
-
import { Platform as
|
|
769
|
+
import { Platform as Platform4, TouchableOpacity, View as View2 } from "react-native";
|
|
317
770
|
|
|
318
771
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
319
772
|
import { StyleSheet, View } from "react-native";
|
|
320
773
|
|
|
321
774
|
// src/components/GameWebViewNavigationBar/byPlatform.ts
|
|
322
|
-
import { Platform } from "react-native";
|
|
775
|
+
import { Platform as Platform2 } from "react-native";
|
|
323
776
|
function byPlatform({
|
|
324
777
|
...props
|
|
325
778
|
}) {
|
|
326
|
-
return (props[
|
|
779
|
+
return (props[Platform2.OS] ?? props.fallback)();
|
|
327
780
|
}
|
|
328
781
|
|
|
329
782
|
// src/components/GameWebViewNavigationBar/constants.ts
|
|
@@ -357,34 +810,34 @@ var styles = StyleSheet.create({
|
|
|
357
810
|
|
|
358
811
|
// src/components/GameWebViewNavigationBar/useSafeAreaTop.ts
|
|
359
812
|
import { useSafeAreaInsets } from "@react-native-bedrock/native/react-native-safe-area-context";
|
|
360
|
-
import { Platform as
|
|
813
|
+
import { Platform as Platform3 } from "react-native";
|
|
361
814
|
function useSafeAreaTop() {
|
|
362
815
|
const safeAreaInsets = useSafeAreaInsets();
|
|
363
|
-
const hasDynamicIsland =
|
|
816
|
+
const hasDynamicIsland = Platform3.OS === "ios" && safeAreaInsets.top > 50;
|
|
364
817
|
const safeAreaTop = hasDynamicIsland ? safeAreaInsets.top - 5 : safeAreaInsets.top;
|
|
365
818
|
return safeAreaTop;
|
|
366
819
|
}
|
|
367
820
|
|
|
368
821
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
369
|
-
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
822
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
370
823
|
var originXML = '<svg fill="none" height="30" viewBox="0 0 30 30" width="30" xmlns="https://www.w3.org/2000/svg"><rect fill="#031832" fill-opacity=".46" height="30" rx="15" width="30"/><rect height="29.5" rx="14.75" stroke="#d9d9ff" stroke-opacity=".11" stroke-width=".5" width="29.5" x=".25" y=".25"/><path clip-rule="evenodd" d="m16.5119 15.0014 4.7092-4.7092c.0929-.0928.1666-.2031.2169-.32441.0503-.12134.0762-.25141.0762-.38276.0001-.13136-.0258-.26144-.076-.38281s-.1239-.23166-.2167-.32457c-.0929-.09291-.2031-.16662-.3245-.21692-.1213-.05031-.2514-.07622-.3827-.07626-.1314-.00004-.2615.0258-.3828.07603-.1214.05023-.2317.12388-.3246.21673l-4.7092 4.70997-4.71-4.70997c-.1897-.17718-.4408-.27373-.70034-.26927s-.5072.10959-.69069.2932c-.1835.1836-.28848.43132-.29279.69087-.00432.25954.09238.51057.26968.70017l4.71004 4.7092-4.71004 4.7092c-.1392.1401-.23385.3183-.27204.5121-.0382.1939-.01823.3946.05739.5771s.20351.3386.36759.4486.35702.169.55456.1697c.25583 0 .51164-.0975.70664-.2925l4.71-4.71 4.7092 4.71c.0927.093.2029.1668.3243.2172.1213.0504.2514.0763.3828.0763s.2614-.0259.3828-.0763c.1213-.0504.2315-.1242.3243-.2172.0929-.0929.1667-.2032.217-.3246s.0762-.2515.0762-.3829-.0259-.2616-.0762-.383-.1241-.2317-.217-.3245z" fill="#fdfdfe" fill-opacity=".89" fill-rule="evenodd"/></svg>';
|
|
371
824
|
function GameNavigationBar({ onClose }) {
|
|
372
825
|
const safeAreaTop = useSafeAreaTop();
|
|
373
|
-
return /* @__PURE__ */
|
|
826
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
374
827
|
/* @__PURE__ */ jsx3(PageNavbar, { preference: { type: "none" } }),
|
|
375
828
|
/* @__PURE__ */ jsx3(
|
|
376
829
|
View2,
|
|
377
830
|
{
|
|
378
831
|
style: {
|
|
379
832
|
width: "100%",
|
|
380
|
-
height:
|
|
833
|
+
height: Platform4.OS === "ios" ? 44 : 54,
|
|
381
834
|
flexDirection: "row",
|
|
382
835
|
alignItems: "center",
|
|
383
836
|
justifyContent: "flex-end",
|
|
384
837
|
position: "absolute",
|
|
385
838
|
zIndex: 9999,
|
|
386
839
|
marginTop: safeAreaTop,
|
|
387
|
-
paddingRight:
|
|
840
|
+
paddingRight: Platform4.OS === "ios" ? 10 : 8
|
|
388
841
|
},
|
|
389
842
|
pointerEvents: "box-none",
|
|
390
843
|
children: /* @__PURE__ */ jsx3(HeaderRight, { children: /* @__PURE__ */ jsx3(
|
|
@@ -395,7 +848,7 @@ function GameNavigationBar({ onClose }) {
|
|
|
395
848
|
accessible: true,
|
|
396
849
|
accessibilityLabel: "\uAC8C\uC784\uC885\uB8CC",
|
|
397
850
|
style: {
|
|
398
|
-
padding:
|
|
851
|
+
padding: Platform4.OS === "ios" ? 7 : 9
|
|
399
852
|
},
|
|
400
853
|
onPress: onClose,
|
|
401
854
|
children: /* @__PURE__ */ jsx3(SvgXml, { xml: originXML, width: 30, height: 30 })
|
|
@@ -407,7 +860,7 @@ function GameNavigationBar({ onClose }) {
|
|
|
407
860
|
}
|
|
408
861
|
|
|
409
862
|
// src/components/GameWebView.tsx
|
|
410
|
-
import { Fragment as Fragment3, jsx as jsx4, jsxs as
|
|
863
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
411
864
|
var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
412
865
|
const { openConfirm } = useDialog();
|
|
413
866
|
const { brandDisplayName } = getAppsInTossGlobals();
|
|
@@ -422,8 +875,8 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
422
875
|
closeView();
|
|
423
876
|
}
|
|
424
877
|
}, [brandDisplayName, openConfirm]);
|
|
425
|
-
|
|
426
|
-
if (
|
|
878
|
+
useEffect3(() => {
|
|
879
|
+
if (Platform5.OS === "ios") {
|
|
427
880
|
setIosSwipeGestureEnabled({ isEnabled: false });
|
|
428
881
|
return () => {
|
|
429
882
|
setIosSwipeGestureEnabled({ isEnabled: true });
|
|
@@ -431,7 +884,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
431
884
|
}
|
|
432
885
|
return;
|
|
433
886
|
}, []);
|
|
434
|
-
|
|
887
|
+
useEffect3(() => {
|
|
435
888
|
const backHandler = () => {
|
|
436
889
|
handleClose();
|
|
437
890
|
return true;
|
|
@@ -441,29 +894,14 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
441
894
|
BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
442
895
|
};
|
|
443
896
|
}, [handleClose]);
|
|
444
|
-
return /* @__PURE__ */
|
|
897
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
445
898
|
/* @__PURE__ */ jsx4(GameNavigationBar, { onClose: handleClose }),
|
|
446
899
|
/* @__PURE__ */ jsx4(View3, { style: { flex: 1 }, children: /* @__PURE__ */ jsx4(PlainWebView, { ref, ...props }) })
|
|
447
900
|
] });
|
|
448
901
|
});
|
|
449
902
|
|
|
450
|
-
// src/async-bridges.ts
|
|
451
|
-
var async_bridges_exports = {};
|
|
452
|
-
__export(async_bridges_exports, {
|
|
453
|
-
appLogin: () => appLogin,
|
|
454
|
-
checkoutPayment: () => checkoutPayment,
|
|
455
|
-
executePayment: () => executePayment,
|
|
456
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
457
|
-
fetchContacts: () => fetchContacts,
|
|
458
|
-
getClipboardText: () => getClipboardText,
|
|
459
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
460
|
-
getTossShareLink: () => getTossShareLink,
|
|
461
|
-
openCamera: () => openCamera,
|
|
462
|
-
setClipboardText: () => setClipboardText
|
|
463
|
-
});
|
|
464
|
-
|
|
465
903
|
// src/bridge-handler/useBridgeHandler.tsx
|
|
466
|
-
import { useCallback as useCallback2, useMemo, useRef } from "react";
|
|
904
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useRef } from "react";
|
|
467
905
|
function serializeError(error) {
|
|
468
906
|
return JSON.stringify(error, (_, value) => {
|
|
469
907
|
if (value instanceof Error) {
|
|
@@ -484,15 +922,16 @@ function methodHandler({
|
|
|
484
922
|
handlerMap,
|
|
485
923
|
injectJavaScript
|
|
486
924
|
}) {
|
|
487
|
-
const func =
|
|
488
|
-
const result = await handlerMap[functionName](...args2);
|
|
489
|
-
return result;
|
|
490
|
-
};
|
|
925
|
+
const func = handlerMap[functionName];
|
|
491
926
|
if (!func) {
|
|
492
927
|
console.error(`${functionName} is not a function`);
|
|
493
928
|
return;
|
|
494
929
|
}
|
|
495
|
-
|
|
930
|
+
const wrappedFunc = async (...args2) => {
|
|
931
|
+
const result = await func(...args2);
|
|
932
|
+
return result;
|
|
933
|
+
};
|
|
934
|
+
wrappedFunc(...args).then((result) => {
|
|
496
935
|
injectJavaScript?.(`
|
|
497
936
|
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/resolve/${eventId}', ${JSON.stringify(result, null, 0)});
|
|
498
937
|
`);
|
|
@@ -512,7 +951,7 @@ function useBridgeHandler({
|
|
|
512
951
|
injectedJavaScript: originalInjectedJavaScript
|
|
513
952
|
}) {
|
|
514
953
|
const ref = useRef(null);
|
|
515
|
-
const injectedJavaScript =
|
|
954
|
+
const injectedJavaScript = useMemo2(
|
|
516
955
|
() => [
|
|
517
956
|
`window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
|
|
518
957
|
Object.entries(constantHandlerMap).reduce(
|
|
@@ -596,20 +1035,64 @@ __export(constant_bridges_exports, {
|
|
|
596
1035
|
getTossAppVersion: () => getTossAppVersion
|
|
597
1036
|
});
|
|
598
1037
|
|
|
599
|
-
// src/env.ts
|
|
600
|
-
var env = {
|
|
601
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
602
|
-
};
|
|
603
|
-
|
|
604
1038
|
// src/event-bridges.ts
|
|
605
1039
|
var event_bridges_exports = {};
|
|
606
1040
|
__export(event_bridges_exports, {
|
|
607
1041
|
startUpdateLocation: () => startUpdateLocation
|
|
608
1042
|
});
|
|
609
1043
|
|
|
1044
|
+
// src/utils/log.ts
|
|
1045
|
+
import { getSchemeUri as getSchemeUri3 } from "react-native-bedrock";
|
|
1046
|
+
|
|
1047
|
+
// src/utils/extractDateFromUUIDv7.ts
|
|
1048
|
+
var extractDateFromUUIDv7 = (uuid) => {
|
|
1049
|
+
const timestampHex = uuid.split("-").join("").slice(0, 12);
|
|
1050
|
+
const timestamp = Number.parseInt(timestampHex, 16);
|
|
1051
|
+
return new Date(timestamp);
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
// src/utils/log.ts
|
|
1055
|
+
var getGroupId = (url) => {
|
|
1056
|
+
try {
|
|
1057
|
+
const urlObject = new URL(url);
|
|
1058
|
+
return {
|
|
1059
|
+
groupId: urlObject.pathname,
|
|
1060
|
+
search: urlObject.search.startsWith("?") ? urlObject.search.substring(1) : urlObject.search
|
|
1061
|
+
};
|
|
1062
|
+
} catch {
|
|
1063
|
+
return {
|
|
1064
|
+
groupId: "unknown",
|
|
1065
|
+
search: "unknown"
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
var getReferrer = () => {
|
|
1070
|
+
try {
|
|
1071
|
+
const referrer = new URL(getSchemeUri3());
|
|
1072
|
+
return referrer.searchParams.get("referrer");
|
|
1073
|
+
} catch {
|
|
1074
|
+
return "";
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
var trackScreen = (url) => {
|
|
1078
|
+
const { groupId, search } = getGroupId(url);
|
|
1079
|
+
const log = {
|
|
1080
|
+
log_type: "screen",
|
|
1081
|
+
log_name: `${groupId}::screen`,
|
|
1082
|
+
params: {
|
|
1083
|
+
search,
|
|
1084
|
+
referrer: getReferrer(),
|
|
1085
|
+
deployment_id: env.getDeploymentId(),
|
|
1086
|
+
deployment_timestamp: extractDateFromUUIDv7(env.getDeploymentId()).getTime()
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
return eventLog(log);
|
|
1090
|
+
};
|
|
1091
|
+
|
|
610
1092
|
// src/components/WebView.tsx
|
|
611
1093
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
612
1094
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
1095
|
+
var operationalEnvironment = getOperationalEnvironment();
|
|
613
1096
|
var TYPES = ["partner", "external", "game"];
|
|
614
1097
|
var WEBVIEW_TYPES = {
|
|
615
1098
|
partner: PartnerWebViewScreen,
|
|
@@ -618,7 +1101,7 @@ var WEBVIEW_TYPES = {
|
|
|
618
1101
|
};
|
|
619
1102
|
function mergeSchemeQueryParamsInto(url) {
|
|
620
1103
|
const baseUrl = new URL(url);
|
|
621
|
-
const schemeUrl = new URL(
|
|
1104
|
+
const schemeUrl = new URL(getSchemeUri4());
|
|
622
1105
|
baseUrl.pathname = schemeUrl.pathname;
|
|
623
1106
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
624
1107
|
baseUrl.searchParams.set(key, value);
|
|
@@ -643,7 +1126,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
643
1126
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
644
1127
|
}
|
|
645
1128
|
const bedrockEvent = useBedrockEvent();
|
|
646
|
-
const uri =
|
|
1129
|
+
const uri = useMemo3(() => getWebViewUri(local), [local]);
|
|
647
1130
|
const top = useSafeAreaTop2();
|
|
648
1131
|
const bottom = useSafeAreaBottom();
|
|
649
1132
|
const handler = useBridgeHandler({
|
|
@@ -651,7 +1134,16 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
651
1134
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
652
1135
|
eventListenerMap: {
|
|
653
1136
|
...event_bridges_exports,
|
|
654
|
-
backEvent: ({ onEvent, onError, options }) => bedrockEvent.addEventListener("backEvent", { onEvent, onError, options })
|
|
1137
|
+
backEvent: ({ onEvent, onError, options }) => bedrockEvent.addEventListener("backEvent", { onEvent, onError, options }),
|
|
1138
|
+
entryMessageExited: ({ onEvent, onError }) => appsInTossEvent.addEventListener("entryMessageExited", { onEvent, onError }),
|
|
1139
|
+
updateLocationEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("updateLocationEvent", { onEvent, onError, options }),
|
|
1140
|
+
/** @internal */
|
|
1141
|
+
appBridgeCallbackEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("appBridgeCallbackEvent", { onEvent, onError, options }),
|
|
1142
|
+
/** AdMob */
|
|
1143
|
+
loadAdMobInterstitialAd: GoogleAdMob.loadAdMobInterstitialAd,
|
|
1144
|
+
showAdMobInterstitialAd: GoogleAdMob.showAdMobInterstitialAd,
|
|
1145
|
+
loadAdMobRewardedAd: GoogleAdMob.loadAdMobRewardedAd,
|
|
1146
|
+
showAdMobRewardedAd: GoogleAdMob.showAdMobRewardedAd
|
|
655
1147
|
},
|
|
656
1148
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
657
1149
|
// @ts-expect-error
|
|
@@ -659,7 +1151,14 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
659
1151
|
...bedrockConstantBridges,
|
|
660
1152
|
...constant_bridges_exports,
|
|
661
1153
|
getSafeAreaTop: () => top,
|
|
662
|
-
getSafeAreaBottom: () => bottom
|
|
1154
|
+
getSafeAreaBottom: () => bottom,
|
|
1155
|
+
/** AdMob */
|
|
1156
|
+
loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
|
|
1157
|
+
showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
|
|
1158
|
+
loadAdMobRewardedAd_isSupported: GoogleAdMob.loadAdMobRewardedAd.isSupported,
|
|
1159
|
+
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported,
|
|
1160
|
+
/** env */
|
|
1161
|
+
getDeploymentId: env.getDeploymentId
|
|
663
1162
|
},
|
|
664
1163
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
665
1164
|
// @ts-expect-error
|
|
@@ -675,7 +1174,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
675
1174
|
clearItems: Storage.clearItems
|
|
676
1175
|
}
|
|
677
1176
|
});
|
|
678
|
-
const baseProps =
|
|
1177
|
+
const baseProps = useMemo3(() => {
|
|
679
1178
|
switch (type) {
|
|
680
1179
|
case "partner": {
|
|
681
1180
|
const headerOnlyProp = {
|
|
@@ -705,10 +1204,12 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
705
1204
|
}
|
|
706
1205
|
}, [type, props]);
|
|
707
1206
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
1207
|
+
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
1208
|
+
const handleNavigationStateChange = useCallback3((event) => {
|
|
1209
|
+
if (event.url) {
|
|
1210
|
+
trackScreen(event.url);
|
|
1211
|
+
}
|
|
1212
|
+
}, []);
|
|
712
1213
|
return /* @__PURE__ */ jsx5(
|
|
713
1214
|
BaseWebView,
|
|
714
1215
|
{
|
|
@@ -717,9 +1218,10 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
717
1218
|
...baseProps,
|
|
718
1219
|
source: { uri },
|
|
719
1220
|
sharedCookiesEnabled: true,
|
|
720
|
-
webviewDebuggingEnabled,
|
|
1221
|
+
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
721
1222
|
thirdPartyCookiesEnabled: true,
|
|
722
1223
|
onMessage: handler.onMessage,
|
|
1224
|
+
onNavigationStateChange: handleNavigationStateChange,
|
|
723
1225
|
injectedJavaScript: handler.injectedJavaScript,
|
|
724
1226
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
725
1227
|
}
|
|
@@ -733,12 +1235,12 @@ function ensureValue(value, name) {
|
|
|
733
1235
|
}
|
|
734
1236
|
|
|
735
1237
|
// src/hooks/useGeolocation.ts
|
|
736
|
-
import { useState, useEffect as
|
|
1238
|
+
import { useState, useEffect as useEffect4 } from "react";
|
|
737
1239
|
import { useVisibility } from "react-native-bedrock";
|
|
738
1240
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
739
1241
|
const isVisible = useVisibility();
|
|
740
1242
|
const [location, setLocation] = useState(null);
|
|
741
|
-
|
|
1243
|
+
useEffect4(() => {
|
|
742
1244
|
if (!isVisible) {
|
|
743
1245
|
return;
|
|
744
1246
|
}
|
|
@@ -765,14 +1267,27 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
765
1267
|
Accuracy3[Accuracy3["BestForNavigation"] = 6] = "BestForNavigation";
|
|
766
1268
|
return Accuracy3;
|
|
767
1269
|
})(Accuracy2 || {});
|
|
1270
|
+
|
|
1271
|
+
// src/index.ts
|
|
1272
|
+
export * from "@apps-in-toss/analytics";
|
|
1273
|
+
var Analytics2 = {
|
|
1274
|
+
init: InternalAnalytics.init,
|
|
1275
|
+
Impression: InternalAnalytics.Impression,
|
|
1276
|
+
Press: InternalAnalytics.Press,
|
|
1277
|
+
Area: InternalAnalytics.Area
|
|
1278
|
+
};
|
|
768
1279
|
export {
|
|
769
1280
|
Accuracy2 as Accuracy,
|
|
1281
|
+
Analytics2 as Analytics,
|
|
770
1282
|
AppsInToss,
|
|
1283
|
+
GoogleAdMob,
|
|
771
1284
|
Storage,
|
|
772
1285
|
TossPay,
|
|
773
1286
|
WebView,
|
|
774
1287
|
appLogin,
|
|
1288
|
+
appsInTossEvent,
|
|
775
1289
|
env,
|
|
1290
|
+
eventLog,
|
|
776
1291
|
fetchAlbumPhotos,
|
|
777
1292
|
fetchContacts,
|
|
778
1293
|
getClipboardText,
|
|
@@ -781,6 +1296,7 @@ export {
|
|
|
781
1296
|
getOperationalEnvironment,
|
|
782
1297
|
getTossAppVersion,
|
|
783
1298
|
getTossShareLink,
|
|
1299
|
+
isMinVersionSupported,
|
|
784
1300
|
openCamera,
|
|
785
1301
|
setClipboardText,
|
|
786
1302
|
startUpdateLocation,
|