@apps-in-toss/framework 1.9.3 → 1.9.4
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 +14 -67
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -68
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -62,7 +62,9 @@ var import_react3 = require("react");
|
|
|
62
62
|
|
|
63
63
|
// src/env.ts
|
|
64
64
|
var env = {
|
|
65
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
65
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId,
|
|
66
|
+
getWebViewType: () => global.__appsInToss.webViewType,
|
|
67
|
+
getAppName: () => global.__granite.app.name
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
// src/hooks/useCaptureExitLog.ts
|
|
@@ -1439,6 +1441,7 @@ var import_native_modules24 = require("@apps-in-toss/native-modules");
|
|
|
1439
1441
|
var appsInTossAsyncBridges = __toESM(require("@apps-in-toss/native-modules/async-bridges"), 1);
|
|
1440
1442
|
var appsInTossConstantBridges = __toESM(require("@apps-in-toss/native-modules/constant-bridges"), 1);
|
|
1441
1443
|
var appsInTossEventBridges = __toESM(require("@apps-in-toss/native-modules/event-bridges"), 1);
|
|
1444
|
+
var import_user_scripts = require("@apps-in-toss/user-scripts");
|
|
1442
1445
|
var import_react_native_safe_area_context4 = require("@granite-js/native/react-native-safe-area-context");
|
|
1443
1446
|
var import_react_native39 = require("@granite-js/react-native");
|
|
1444
1447
|
var import_tds_react_native15 = require("@toss/tds-react-native");
|
|
@@ -2683,7 +2686,9 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2683
2686
|
/** TossAd */
|
|
2684
2687
|
fetchTossAd_isSupported: fetchTossAd.isSupported,
|
|
2685
2688
|
/** env */
|
|
2686
|
-
getDeploymentId: env.getDeploymentId
|
|
2689
|
+
getDeploymentId: env.getDeploymentId,
|
|
2690
|
+
getWebViewType: env.getWebViewType,
|
|
2691
|
+
getAppName: env.getAppName
|
|
2687
2692
|
},
|
|
2688
2693
|
asyncHandlerMap: {
|
|
2689
2694
|
...appsInTossAsyncBridges,
|
|
@@ -2721,7 +2726,11 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2721
2726
|
/** Toss Ads */
|
|
2722
2727
|
tossAdEventLog,
|
|
2723
2728
|
/** Private */
|
|
2724
|
-
memoryDebugLog: webViewMemoryDebugLog
|
|
2729
|
+
memoryDebugLog: webViewMemoryDebugLog,
|
|
2730
|
+
debugLog: async (event) => {
|
|
2731
|
+
import_react_native40.NativeModules.AppsInTossModule?.eventLog(event);
|
|
2732
|
+
import_react_native40.NativeModules.TossCoreModule?.eventLog(event);
|
|
2733
|
+
}
|
|
2725
2734
|
}
|
|
2726
2735
|
});
|
|
2727
2736
|
const headerPropForExternalWebView = (0, import_react28.useMemo)(() => {
|
|
@@ -2753,7 +2762,6 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2753
2762
|
import_react_native40.BackHandler.addEventListener("hardwareBackPress", callback);
|
|
2754
2763
|
return () => import_react_native40.BackHandler.removeEventListener("hardwareBackPress", callback);
|
|
2755
2764
|
}, [webBackHandler]);
|
|
2756
|
-
const globalScripts = useGlobalScripts();
|
|
2757
2765
|
const handleWebViewProcessDidTerminate = useHandleWebViewProcessDidTerminate(webViewRef);
|
|
2758
2766
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2759
2767
|
BaseWebView,
|
|
@@ -2782,8 +2790,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2782
2790
|
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
2783
2791
|
thirdPartyCookiesEnabled: true,
|
|
2784
2792
|
onMessage: handler.onMessage,
|
|
2785
|
-
injectedJavaScript:
|
|
2786
|
-
injectedJavaScriptBeforeContentLoaded:
|
|
2793
|
+
injectedJavaScript: import_user_scripts.afterDocumentLoad,
|
|
2794
|
+
injectedJavaScriptBeforeContentLoaded: [handler.injectedJavaScript, import_user_scripts.beforeDocumentLoad].join("\n"),
|
|
2787
2795
|
decelerationRate: import_react_native40.Platform.OS === "ios" ? 1 : void 0,
|
|
2788
2796
|
allowsBackForwardNavigationGestures,
|
|
2789
2797
|
onShouldStartLoadWithRequest: (event) => {
|
|
@@ -2814,67 +2822,6 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2814
2822
|
}
|
|
2815
2823
|
);
|
|
2816
2824
|
}
|
|
2817
|
-
function useGlobalScripts() {
|
|
2818
|
-
const global2 = getAppsInTossGlobals();
|
|
2819
|
-
const disableTextSelectionCSS = `
|
|
2820
|
-
const style = document.createElement('style');
|
|
2821
|
-
style.textContent = '*:not(input):not(textarea) { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }';
|
|
2822
|
-
document.head.appendChild(style);
|
|
2823
|
-
`;
|
|
2824
|
-
const applyGameResourcesCache = `
|
|
2825
|
-
(function () {
|
|
2826
|
-
if (typeof caches === 'undefined') {
|
|
2827
|
-
return;
|
|
2828
|
-
}
|
|
2829
|
-
const cacheKeyPrefix = '@apps-in-toss/caches/';
|
|
2830
|
-
const cacheKey = \`\${cacheKeyPrefix}${global2.deploymentId}\`;
|
|
2831
|
-
window.addEventListener('load', async () => {
|
|
2832
|
-
const keys = await caches.keys();
|
|
2833
|
-
for (const key of keys) {
|
|
2834
|
-
if (key.startsWith(cacheKeyPrefix) && key !== cacheKey) {
|
|
2835
|
-
await caches.delete(key);
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
});
|
|
2839
|
-
window.fetch = new Proxy(window.fetch, {
|
|
2840
|
-
async apply(originalFetch, thisArg, args) {
|
|
2841
|
-
const request = new Request(args[0], args[1]);
|
|
2842
|
-
if (!/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/.test(request.url)) {
|
|
2843
|
-
return await originalFetch.call(thisArg, request);
|
|
2844
|
-
}
|
|
2845
|
-
const cache = await caches.open(cacheKey);
|
|
2846
|
-
const cached = await cache.match(request);
|
|
2847
|
-
if (cached) {
|
|
2848
|
-
const eTag = cached.headers.get('ETag');
|
|
2849
|
-
const lastModified = cached.headers.get('Last-Modified');
|
|
2850
|
-
if (eTag) {
|
|
2851
|
-
request.headers.set('If-None-Match', eTag);
|
|
2852
|
-
}
|
|
2853
|
-
if (lastModified) {
|
|
2854
|
-
request.headers.set('If-Modified-Since', lastModified);
|
|
2855
|
-
}
|
|
2856
|
-
const revalidated = await originalFetch.call(thisArg, request);
|
|
2857
|
-
if (revalidated.status === 304) {
|
|
2858
|
-
return cached;
|
|
2859
|
-
}
|
|
2860
|
-
cache.put(request, revalidated.clone());
|
|
2861
|
-
return revalidated;
|
|
2862
|
-
}
|
|
2863
|
-
const response = await originalFetch.call(thisArg, request);
|
|
2864
|
-
cache.put(request, response.clone());
|
|
2865
|
-
return response;
|
|
2866
|
-
},
|
|
2867
|
-
});
|
|
2868
|
-
})();
|
|
2869
|
-
`;
|
|
2870
|
-
return {
|
|
2871
|
-
beforeLoad: mergeScripts(global2.webViewType === "game" && applyGameResourcesCache),
|
|
2872
|
-
afterLoad: mergeScripts(disableTextSelectionCSS)
|
|
2873
|
-
};
|
|
2874
|
-
}
|
|
2875
|
-
function mergeScripts(...scripts) {
|
|
2876
|
-
return scripts.filter((script) => typeof script === "string").join("\n");
|
|
2877
|
-
}
|
|
2878
2825
|
|
|
2879
2826
|
// src/index.ts
|
|
2880
2827
|
__reExport(src_exports, require("@apps-in-toss/analytics"), module.exports);
|
package/dist/index.d.cts
CHANGED
|
@@ -166,6 +166,8 @@ declare function useTopNavigation(): {
|
|
|
166
166
|
|
|
167
167
|
declare const env: {
|
|
168
168
|
getDeploymentId: () => string;
|
|
169
|
+
getWebViewType: () => "partner" | "external" | "game" | undefined;
|
|
170
|
+
getAppName: () => string;
|
|
169
171
|
};
|
|
170
172
|
|
|
171
173
|
declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
|
package/dist/index.d.ts
CHANGED
|
@@ -166,6 +166,8 @@ declare function useTopNavigation(): {
|
|
|
166
166
|
|
|
167
167
|
declare const env: {
|
|
168
168
|
getDeploymentId: () => string;
|
|
169
|
+
getWebViewType: () => "partner" | "external" | "game" | undefined;
|
|
170
|
+
getAppName: () => string;
|
|
169
171
|
};
|
|
170
172
|
|
|
171
173
|
declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,9 @@ import { useEffect as useEffect2 } from "react";
|
|
|
29
29
|
|
|
30
30
|
// src/env.ts
|
|
31
31
|
var env = {
|
|
32
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
32
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId,
|
|
33
|
+
getWebViewType: () => global.__appsInToss.webViewType,
|
|
34
|
+
getAppName: () => global.__granite.app.name
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
// src/hooks/useCaptureExitLog.ts
|
|
@@ -1419,12 +1421,13 @@ import {
|
|
|
1419
1421
|
import * as appsInTossAsyncBridges from "@apps-in-toss/native-modules/async-bridges";
|
|
1420
1422
|
import * as appsInTossConstantBridges from "@apps-in-toss/native-modules/constant-bridges";
|
|
1421
1423
|
import * as appsInTossEventBridges from "@apps-in-toss/native-modules/event-bridges";
|
|
1424
|
+
import { afterDocumentLoad, beforeDocumentLoad } from "@apps-in-toss/user-scripts";
|
|
1422
1425
|
import { useSafeAreaInsets as useSafeAreaInsets4 } from "@granite-js/native/react-native-safe-area-context";
|
|
1423
1426
|
import { getSchemeUri as getSchemeUri8 } from "@granite-js/react-native";
|
|
1424
1427
|
import { ExternalWebViewScreen, tdsEvent } from "@toss/tds-react-native";
|
|
1425
1428
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop3 } from "@toss/tds-react-native/private";
|
|
1426
1429
|
import { useEffect as useEffect13, useMemo as useMemo7, useRef as useRef6, useState as useState6 } from "react";
|
|
1427
|
-
import { BackHandler as BackHandler2, Linking, Platform as Platform6 } from "react-native";
|
|
1430
|
+
import { BackHandler as BackHandler2, Linking, NativeModules as NativeModules3, Platform as Platform6 } from "react-native";
|
|
1428
1431
|
|
|
1429
1432
|
// src/components/GameWebView.tsx
|
|
1430
1433
|
import { setIosSwipeGestureEnabled as setIosSwipeGestureEnabled3, getOperationalEnvironment as getOperationalEnvironment5 } from "@apps-in-toss/native-modules";
|
|
@@ -2671,7 +2674,9 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2671
2674
|
/** TossAd */
|
|
2672
2675
|
fetchTossAd_isSupported: fetchTossAd.isSupported,
|
|
2673
2676
|
/** env */
|
|
2674
|
-
getDeploymentId: env.getDeploymentId
|
|
2677
|
+
getDeploymentId: env.getDeploymentId,
|
|
2678
|
+
getWebViewType: env.getWebViewType,
|
|
2679
|
+
getAppName: env.getAppName
|
|
2675
2680
|
},
|
|
2676
2681
|
asyncHandlerMap: {
|
|
2677
2682
|
...appsInTossAsyncBridges,
|
|
@@ -2709,7 +2714,11 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2709
2714
|
/** Toss Ads */
|
|
2710
2715
|
tossAdEventLog,
|
|
2711
2716
|
/** Private */
|
|
2712
|
-
memoryDebugLog: webViewMemoryDebugLog
|
|
2717
|
+
memoryDebugLog: webViewMemoryDebugLog,
|
|
2718
|
+
debugLog: async (event) => {
|
|
2719
|
+
NativeModules3.AppsInTossModule?.eventLog(event);
|
|
2720
|
+
NativeModules3.TossCoreModule?.eventLog(event);
|
|
2721
|
+
}
|
|
2713
2722
|
}
|
|
2714
2723
|
});
|
|
2715
2724
|
const headerPropForExternalWebView = useMemo7(() => {
|
|
@@ -2741,7 +2750,6 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2741
2750
|
BackHandler2.addEventListener("hardwareBackPress", callback);
|
|
2742
2751
|
return () => BackHandler2.removeEventListener("hardwareBackPress", callback);
|
|
2743
2752
|
}, [webBackHandler]);
|
|
2744
|
-
const globalScripts = useGlobalScripts();
|
|
2745
2753
|
const handleWebViewProcessDidTerminate = useHandleWebViewProcessDidTerminate(webViewRef);
|
|
2746
2754
|
return /* @__PURE__ */ jsx19(
|
|
2747
2755
|
BaseWebView,
|
|
@@ -2770,8 +2778,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2770
2778
|
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
2771
2779
|
thirdPartyCookiesEnabled: true,
|
|
2772
2780
|
onMessage: handler.onMessage,
|
|
2773
|
-
injectedJavaScript:
|
|
2774
|
-
injectedJavaScriptBeforeContentLoaded:
|
|
2781
|
+
injectedJavaScript: afterDocumentLoad,
|
|
2782
|
+
injectedJavaScriptBeforeContentLoaded: [handler.injectedJavaScript, beforeDocumentLoad].join("\n"),
|
|
2775
2783
|
decelerationRate: Platform6.OS === "ios" ? 1 : void 0,
|
|
2776
2784
|
allowsBackForwardNavigationGestures,
|
|
2777
2785
|
onShouldStartLoadWithRequest: (event) => {
|
|
@@ -2802,67 +2810,6 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2802
2810
|
}
|
|
2803
2811
|
);
|
|
2804
2812
|
}
|
|
2805
|
-
function useGlobalScripts() {
|
|
2806
|
-
const global2 = getAppsInTossGlobals();
|
|
2807
|
-
const disableTextSelectionCSS = `
|
|
2808
|
-
const style = document.createElement('style');
|
|
2809
|
-
style.textContent = '*:not(input):not(textarea) { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }';
|
|
2810
|
-
document.head.appendChild(style);
|
|
2811
|
-
`;
|
|
2812
|
-
const applyGameResourcesCache = `
|
|
2813
|
-
(function () {
|
|
2814
|
-
if (typeof caches === 'undefined') {
|
|
2815
|
-
return;
|
|
2816
|
-
}
|
|
2817
|
-
const cacheKeyPrefix = '@apps-in-toss/caches/';
|
|
2818
|
-
const cacheKey = \`\${cacheKeyPrefix}${global2.deploymentId}\`;
|
|
2819
|
-
window.addEventListener('load', async () => {
|
|
2820
|
-
const keys = await caches.keys();
|
|
2821
|
-
for (const key of keys) {
|
|
2822
|
-
if (key.startsWith(cacheKeyPrefix) && key !== cacheKey) {
|
|
2823
|
-
await caches.delete(key);
|
|
2824
|
-
}
|
|
2825
|
-
}
|
|
2826
|
-
});
|
|
2827
|
-
window.fetch = new Proxy(window.fetch, {
|
|
2828
|
-
async apply(originalFetch, thisArg, args) {
|
|
2829
|
-
const request = new Request(args[0], args[1]);
|
|
2830
|
-
if (!/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/.test(request.url)) {
|
|
2831
|
-
return await originalFetch.call(thisArg, request);
|
|
2832
|
-
}
|
|
2833
|
-
const cache = await caches.open(cacheKey);
|
|
2834
|
-
const cached = await cache.match(request);
|
|
2835
|
-
if (cached) {
|
|
2836
|
-
const eTag = cached.headers.get('ETag');
|
|
2837
|
-
const lastModified = cached.headers.get('Last-Modified');
|
|
2838
|
-
if (eTag) {
|
|
2839
|
-
request.headers.set('If-None-Match', eTag);
|
|
2840
|
-
}
|
|
2841
|
-
if (lastModified) {
|
|
2842
|
-
request.headers.set('If-Modified-Since', lastModified);
|
|
2843
|
-
}
|
|
2844
|
-
const revalidated = await originalFetch.call(thisArg, request);
|
|
2845
|
-
if (revalidated.status === 304) {
|
|
2846
|
-
return cached;
|
|
2847
|
-
}
|
|
2848
|
-
cache.put(request, revalidated.clone());
|
|
2849
|
-
return revalidated;
|
|
2850
|
-
}
|
|
2851
|
-
const response = await originalFetch.call(thisArg, request);
|
|
2852
|
-
cache.put(request, response.clone());
|
|
2853
|
-
return response;
|
|
2854
|
-
},
|
|
2855
|
-
});
|
|
2856
|
-
})();
|
|
2857
|
-
`;
|
|
2858
|
-
return {
|
|
2859
|
-
beforeLoad: mergeScripts(global2.webViewType === "game" && applyGameResourcesCache),
|
|
2860
|
-
afterLoad: mergeScripts(disableTextSelectionCSS)
|
|
2861
|
-
};
|
|
2862
|
-
}
|
|
2863
|
-
function mergeScripts(...scripts) {
|
|
2864
|
-
return scripts.filter((script) => typeof script === "string").join("\n");
|
|
2865
|
-
}
|
|
2866
2813
|
|
|
2867
2814
|
// src/index.ts
|
|
2868
2815
|
export * from "@apps-in-toss/analytics";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.4",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
@@ -55,11 +55,12 @@
|
|
|
55
55
|
"ait": "./bin/ait.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@apps-in-toss/analytics": "1.9.
|
|
59
|
-
"@apps-in-toss/cli": "1.9.
|
|
60
|
-
"@apps-in-toss/native-modules": "1.9.
|
|
61
|
-
"@apps-in-toss/plugins": "1.9.
|
|
62
|
-
"@apps-in-toss/types": "1.9.
|
|
58
|
+
"@apps-in-toss/analytics": "1.9.4",
|
|
59
|
+
"@apps-in-toss/cli": "1.9.4",
|
|
60
|
+
"@apps-in-toss/native-modules": "1.9.4",
|
|
61
|
+
"@apps-in-toss/plugins": "1.9.4",
|
|
62
|
+
"@apps-in-toss/types": "1.9.4",
|
|
63
|
+
"@apps-in-toss/user-scripts": "^1.9.4",
|
|
63
64
|
"es-hangul": "^2.3.2"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|