@apps-in-toss/web-framework 0.0.13 → 0.0.14
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/cli/index.js +17 -11
- package/dist/prebuilt/dev.android.js +121 -73
- package/dist/prebuilt/dev.ios.js +121 -73
- package/dist/prebuilt/prod.android.js +1 -1
- package/dist/prebuilt/prod.ios.js +1 -1
- package/dist/prebuilt/prod.json +4 -4
- package/{src-web/index.d.ts → dist-web/bridge.d.ts} +2 -0
- package/{src-web/index.js → dist-web/bridge.js} +1 -1
- package/dist-web/checkoutPayment.d.ts +125 -0
- package/dist-web/executePayment.d.ts +266 -0
- package/dist-web/index.d.ts +70 -0
- package/dist-web/index.js +144 -0
- package/package.json +9 -9
- /package/{src-web → dist-web}/appLogin.d.ts +0 -0
- /package/{src-web → dist-web}/closeView.d.ts +0 -0
- /package/{src-web → dist-web}/fetchAlbumPhotos.d.ts +0 -0
- /package/{src-web → dist-web}/fetchContacts.d.ts +0 -0
- /package/{src-web → dist-web}/generateHapticFeedback.d.ts +0 -0
- /package/{src-web → dist-web}/getClipboardText.d.ts +0 -0
- /package/{src-web → dist-web}/getCurrentLocation.d.ts +0 -0
- /package/{src-web → dist-web}/getDeviceId.d.ts +0 -0
- /package/{src-web → dist-web}/getLocale.d.ts +0 -0
- /package/{src-web → dist-web}/getNetworkStatus.d.ts +0 -0
- /package/{src-web → dist-web}/getOperationalEnvironment.d.ts +0 -0
- /package/{src-web → dist-web}/getPlatformOS.d.ts +0 -0
- /package/{src-web → dist-web}/getSchemeUri.d.ts +0 -0
- /package/{src-web → dist-web}/openCamera.d.ts +0 -0
- /package/{src-web → dist-web}/setClipboardText.d.ts +0 -0
- /package/{src-web → dist-web}/setScreenAwakeMode.d.ts +0 -0
- /package/{src-web → dist-web}/setSecureScreen.d.ts +0 -0
- /package/{src-web → dist-web}/share.d.ts +0 -0
- /package/{src-web → dist-web}/startUpdateLocation.d.ts +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export * from './bridge.js'
|
|
2
|
+
|
|
3
|
+
// src-web/nativeWindow.ts
|
|
4
|
+
var NativeWindow = class {
|
|
5
|
+
get _window() {
|
|
6
|
+
return window;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* ReactNativeWebView를 이용해 메시지를 전송합니다.
|
|
10
|
+
* @param message 전송할 메시지(JSON 문자열)
|
|
11
|
+
* @example
|
|
12
|
+
* const nativeWindow = new NativeWindow();
|
|
13
|
+
* nativeWindow.postMessage({ type: 'method', functionName: 'getDeviceId', eventId: '123', args: [] });
|
|
14
|
+
*/
|
|
15
|
+
postMessage(message) {
|
|
16
|
+
const webView = this._window.ReactNativeWebView;
|
|
17
|
+
if (!webView) {
|
|
18
|
+
throw new Error("ReactNativeWebView is not available in browser environment");
|
|
19
|
+
}
|
|
20
|
+
webView.postMessage(JSON.stringify(message));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* __BEDROCK_NATIVE_EMITTER를 이용해 이벤트 리스너를 등록합니다.
|
|
24
|
+
* @param event 이벤트 이름
|
|
25
|
+
* @param callback 데이터가 도착했을 때 호출되는 콜백
|
|
26
|
+
* @returns 리스너 해제 함수
|
|
27
|
+
* @example
|
|
28
|
+
* const nativeWindow = new NativeWindow();
|
|
29
|
+
* const unsubscribe = nativeWindow.on('deviceInfo', (data) => {
|
|
30
|
+
* console.log('Device info received:', data);
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // 리스너 해제
|
|
34
|
+
* unsubscribe();
|
|
35
|
+
*/
|
|
36
|
+
on(event, callback) {
|
|
37
|
+
const emitter = this._window.__BEDROCK_NATIVE_EMITTER;
|
|
38
|
+
if (!emitter) {
|
|
39
|
+
throw new Error("__BEDROCK_NATIVE_EMITTER is not available");
|
|
40
|
+
}
|
|
41
|
+
return emitter.on(event, callback);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* __CONSTANT_HANDLER_MAP에 등록된 상수 값을 반환합니다.
|
|
45
|
+
* @param method 상수 핸들러 이름
|
|
46
|
+
* @returns 상수 값
|
|
47
|
+
* @example
|
|
48
|
+
* const nativeWindow = new NativeWindow();
|
|
49
|
+
* const deviceId = nativeWindow.getConstant('getDeviceId');
|
|
50
|
+
* console.log('Device ID:', deviceId);
|
|
51
|
+
*/
|
|
52
|
+
getConstant(method) {
|
|
53
|
+
const constantHandlerMap = this._window.__CONSTANT_HANDLER_MAP;
|
|
54
|
+
if (constantHandlerMap && method in constantHandlerMap) {
|
|
55
|
+
return constantHandlerMap[method];
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`${method} is not a constant handler`);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var nativeWindow = new NativeWindow();
|
|
61
|
+
var createEventId = () => Math.random().toString(36).substring(2, 15);
|
|
62
|
+
var deserializeError = (value) => {
|
|
63
|
+
if (value && value.__isError) {
|
|
64
|
+
const err = new Error(value.message);
|
|
65
|
+
err.name = value.name;
|
|
66
|
+
err.stack = value.stack;
|
|
67
|
+
return err;
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// src-web/createAsyncBridge.ts
|
|
73
|
+
function createAsyncBridge(method) {
|
|
74
|
+
return (args) => {
|
|
75
|
+
const eventId = createEventId();
|
|
76
|
+
const emitters = [];
|
|
77
|
+
const unsubscribe = () => {
|
|
78
|
+
for (const remove of emitters) {
|
|
79
|
+
remove();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
emitters.push(
|
|
84
|
+
nativeWindow.on(`${method}/resolve/${eventId}`, (data) => {
|
|
85
|
+
unsubscribe();
|
|
86
|
+
resolve(data);
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
emitters.push(
|
|
90
|
+
nativeWindow.on(`${method}/reject/${eventId}`, (error) => {
|
|
91
|
+
unsubscribe();
|
|
92
|
+
reject(deserializeError(error));
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
nativeWindow.postMessage({
|
|
96
|
+
type: "method",
|
|
97
|
+
functionName: method,
|
|
98
|
+
eventId,
|
|
99
|
+
args: [args]
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src-web/createConstantBridge.ts
|
|
106
|
+
function createConstantBridge(method) {
|
|
107
|
+
return () => {
|
|
108
|
+
return nativeWindow.getConstant(method);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src-web/createEventBridge.ts
|
|
113
|
+
function createEventBridge(method) {
|
|
114
|
+
return (args) => {
|
|
115
|
+
const eventId = createEventId();
|
|
116
|
+
const removes = [
|
|
117
|
+
nativeWindow.on(`${method}/onEvent/${eventId}`, (data) => {
|
|
118
|
+
args.onEvent(data);
|
|
119
|
+
}),
|
|
120
|
+
nativeWindow.on(`${method}/onError/${eventId}`, (error) => {
|
|
121
|
+
args.onError(deserializeError(error));
|
|
122
|
+
})
|
|
123
|
+
];
|
|
124
|
+
nativeWindow.postMessage({
|
|
125
|
+
type: "addEventListener",
|
|
126
|
+
functionName: method,
|
|
127
|
+
eventId,
|
|
128
|
+
args: args.options
|
|
129
|
+
});
|
|
130
|
+
return () => {
|
|
131
|
+
nativeWindow.postMessage({
|
|
132
|
+
type: "removeEventListener",
|
|
133
|
+
functionName: method,
|
|
134
|
+
eventId
|
|
135
|
+
});
|
|
136
|
+
removes.forEach((remove) => remove());
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
createAsyncBridge,
|
|
142
|
+
createConstantBridge,
|
|
143
|
+
createEventBridge
|
|
144
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"description": "Web Framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"build": "tsup",
|
|
11
11
|
"sync-bridge": "bridgepack build"
|
|
12
12
|
},
|
|
13
|
-
"main": "./
|
|
14
|
-
"types": "./
|
|
13
|
+
"main": "./dist-web/index.js",
|
|
14
|
+
"types": "./dist-web/index.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./
|
|
18
|
-
"default": "./
|
|
17
|
+
"types": "./dist-web/index.d.ts",
|
|
18
|
+
"default": "./dist-web/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./config": {
|
|
21
21
|
"types": "./dist/config/index.d.ts",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"dist",
|
|
47
47
|
"hermesc",
|
|
48
48
|
"bin.js",
|
|
49
|
-
"
|
|
49
|
+
"dist-web",
|
|
50
50
|
"config.d.ts"
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@apps-in-toss/framework": "0.0.
|
|
53
|
+
"@apps-in-toss/framework": "0.0.14",
|
|
54
54
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
55
55
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
56
56
|
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
|
|
@@ -95,11 +95,11 @@
|
|
|
95
95
|
"zod": "^3.24.1"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@apps-in-toss/cli": "0.0.
|
|
98
|
+
"@apps-in-toss/cli": "0.0.14",
|
|
99
99
|
"@babel/core": "7.23.9"
|
|
100
100
|
},
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "4ed1e356e1a1b3bb14ef33b2fcbd2466c9445b0f"
|
|
105
105
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|