@apps-in-toss/framework 0.0.0-dev.1742183674302 → 0.0.0-dev.1742356516217
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 +42 -26
- package/dist/index.d.cts +50 -33
- package/dist/index.d.ts +50 -33
- package/dist/index.js +42 -27
- package/package.json +20 -10
- package/src/async-bridges.ts +7 -0
- package/src/constant-bridges.ts +1 -0
- package/src/event-bridges.ts +1 -0
- package/src/bridges.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(src_exports, {
|
|
|
39
39
|
fetchContacts: () => fetchContacts,
|
|
40
40
|
getClipboardText: () => getClipboardText,
|
|
41
41
|
getCurrentLocation: () => getCurrentLocation,
|
|
42
|
+
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
42
43
|
openCamera: () => openCamera,
|
|
43
44
|
setClipboardText: () => setClipboardText,
|
|
44
45
|
startUpdateLocation: () => startUpdateLocation,
|
|
@@ -72,12 +73,6 @@ var AppsInToss = {
|
|
|
72
73
|
registerApp
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
// src/native-event-emitter/index.ts
|
|
76
|
-
var native_event_emitter_exports = {};
|
|
77
|
-
__export(native_event_emitter_exports, {
|
|
78
|
-
startUpdateLocation: () => startUpdateLocation
|
|
79
|
-
});
|
|
80
|
-
|
|
81
76
|
// src/native-event-emitter/bedrock-event.ts
|
|
82
77
|
var import_react_native_bedrock3 = require("react-native-bedrock");
|
|
83
78
|
|
|
@@ -151,18 +146,6 @@ function startUpdateLocation(eventParams) {
|
|
|
151
146
|
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
152
147
|
}
|
|
153
148
|
|
|
154
|
-
// src/native-modules/index.ts
|
|
155
|
-
var native_modules_exports = {};
|
|
156
|
-
__export(native_modules_exports, {
|
|
157
|
-
appLogin: () => appLogin,
|
|
158
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
159
|
-
fetchContacts: () => fetchContacts,
|
|
160
|
-
getClipboardText: () => getClipboardText,
|
|
161
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
162
|
-
openCamera: () => openCamera,
|
|
163
|
-
setClipboardText: () => setClipboardText
|
|
164
|
-
});
|
|
165
|
-
|
|
166
149
|
// src/native-modules/setClipboardText.ts
|
|
167
150
|
async function setClipboardText(text) {
|
|
168
151
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -252,18 +235,47 @@ async function appLogin() {
|
|
|
252
235
|
return AppsInTossModule.appLogin({});
|
|
253
236
|
}
|
|
254
237
|
|
|
238
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
239
|
+
function getOperationalEnvironment() {
|
|
240
|
+
return AppsInTossModule.operationalEnvironment;
|
|
241
|
+
}
|
|
242
|
+
|
|
255
243
|
// src/components/WebView.tsx
|
|
256
244
|
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
257
245
|
var import_react = require("react");
|
|
258
246
|
var import_react_native_bedrock4 = require("react-native-bedrock");
|
|
259
|
-
var
|
|
260
|
-
var
|
|
247
|
+
var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
|
|
248
|
+
var bedrockConstantBridges = __toESM(require("react-native-bedrock/constant-bridges"), 1);
|
|
249
|
+
|
|
250
|
+
// src/async-bridges.ts
|
|
251
|
+
var async_bridges_exports = {};
|
|
252
|
+
__export(async_bridges_exports, {
|
|
253
|
+
appLogin: () => appLogin,
|
|
254
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
255
|
+
fetchContacts: () => fetchContacts,
|
|
256
|
+
getClipboardText: () => getClipboardText,
|
|
257
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
258
|
+
openCamera: () => openCamera,
|
|
259
|
+
setClipboardText: () => setClipboardText
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// src/constant-bridges.ts
|
|
263
|
+
var constant_bridges_exports = {};
|
|
264
|
+
__export(constant_bridges_exports, {
|
|
265
|
+
getOperationalEnvironment: () => getOperationalEnvironment
|
|
266
|
+
});
|
|
261
267
|
|
|
262
268
|
// src/env.ts
|
|
263
269
|
var env = {
|
|
264
270
|
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
265
271
|
};
|
|
266
272
|
|
|
273
|
+
// src/event-bridges.ts
|
|
274
|
+
var event_bridges_exports = {};
|
|
275
|
+
__export(event_bridges_exports, {
|
|
276
|
+
startUpdateLocation: () => startUpdateLocation
|
|
277
|
+
});
|
|
278
|
+
|
|
267
279
|
// src/components/WebView.tsx
|
|
268
280
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
269
281
|
function WebView({ local, onMessage, ...props }) {
|
|
@@ -271,7 +283,7 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
271
283
|
if (__DEV__) {
|
|
272
284
|
return `http://${local.host}:${local.port}`;
|
|
273
285
|
}
|
|
274
|
-
const url = new URL(
|
|
286
|
+
const url = new URL(AppsInTossModule.getWebBundleURL({}).url);
|
|
275
287
|
const deploymentId = env.getDeploymentId();
|
|
276
288
|
if (deploymentId) {
|
|
277
289
|
url.searchParams.set("_deploymentId", deploymentId);
|
|
@@ -281,15 +293,18 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
281
293
|
const handler = (0, import_react_native_bedrock4.useBridgeHandler)({
|
|
282
294
|
onMessage,
|
|
283
295
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
284
|
-
eventListenerMap:
|
|
296
|
+
eventListenerMap: event_bridges_exports,
|
|
285
297
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
286
298
|
// @ts-expect-error
|
|
287
|
-
constantHandlerMap:
|
|
299
|
+
constantHandlerMap: {
|
|
300
|
+
...bedrockConstantBridges,
|
|
301
|
+
...constant_bridges_exports
|
|
302
|
+
},
|
|
288
303
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
289
304
|
// @ts-expect-error
|
|
290
|
-
|
|
291
|
-
...
|
|
292
|
-
...
|
|
305
|
+
asyncHandlerMap: {
|
|
306
|
+
...bedrockAsyncBridges,
|
|
307
|
+
...async_bridges_exports
|
|
293
308
|
}
|
|
294
309
|
});
|
|
295
310
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -355,6 +370,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
355
370
|
fetchContacts,
|
|
356
371
|
getClipboardText,
|
|
357
372
|
getCurrentLocation,
|
|
373
|
+
getOperationalEnvironment,
|
|
358
374
|
openCamera,
|
|
359
375
|
setClipboardText,
|
|
360
376
|
startUpdateLocation,
|
package/dist/index.d.cts
CHANGED
|
@@ -18,7 +18,7 @@ interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @public
|
|
21
|
-
* @category
|
|
21
|
+
* @category 위치 정보
|
|
22
22
|
* @name Accuracy
|
|
23
23
|
* @description 위치 정확도 옵션이에요.
|
|
24
24
|
*/
|
|
@@ -50,7 +50,7 @@ declare enum Accuracy {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* @public
|
|
53
|
-
* @category
|
|
53
|
+
* @category 위치 정보
|
|
54
54
|
* @name Location
|
|
55
55
|
* @description 위치 정보를 나타내는 객체예요.
|
|
56
56
|
*/
|
|
@@ -75,7 +75,7 @@ interface Location {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* @public
|
|
78
|
-
* @category
|
|
78
|
+
* @category 위치 정보
|
|
79
79
|
* @name LocationCoords
|
|
80
80
|
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
81
81
|
*/
|
|
@@ -143,9 +143,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* @public
|
|
146
|
-
* @
|
|
147
|
-
* @category AppsInTossModules
|
|
148
|
-
* @kind function
|
|
146
|
+
* @category 위치 정보
|
|
149
147
|
* @name startUpdateLocation
|
|
150
148
|
* @description 디바이스의 위치 정보를 지속적으로 감지하고, 위치가 변경되면 콜백을 실행하는 함수예요. 콜백 함수를 등록하면 위치가 변경될 때마다 자동으로 호출돼요.
|
|
151
149
|
* 실시간 위치 추적이 필요한 기능을 구현할 때 사용할 수 있어요. 예를 들어 지도 앱에서 사용자의 현재 위치를 실시간으로 업데이트할 때, 운동 앱에서 사용자의 이동 거리를 기록할 때 등이에요.
|
|
@@ -210,9 +208,7 @@ declare function startUpdateLocation(eventParams: {
|
|
|
210
208
|
|
|
211
209
|
/**
|
|
212
210
|
* @public
|
|
213
|
-
* @
|
|
214
|
-
* @category AppsInTossModules
|
|
215
|
-
* @kind function
|
|
211
|
+
* @category 클립보드
|
|
216
212
|
* @name setClipboardText
|
|
217
213
|
* @description 텍스트를 클립보드에 복사해서 사용자가 다른 곳에 붙여 넣기 할 수 있어요.
|
|
218
214
|
* @param {Promise<void>} text - 클립보드에 복사할 텍스트예요. 문자열 형식으로 입력해요.
|
|
@@ -243,9 +239,7 @@ declare function setClipboardText(text: string): Promise<void>;
|
|
|
243
239
|
|
|
244
240
|
/**
|
|
245
241
|
* @public
|
|
246
|
-
* @
|
|
247
|
-
* @category AppsInTossModules
|
|
248
|
-
* @kind function
|
|
242
|
+
* @category 클립보드
|
|
249
243
|
* @name getClipboardText
|
|
250
244
|
* @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
|
|
251
245
|
* @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
|
|
@@ -293,9 +287,7 @@ interface ContactEntity {
|
|
|
293
287
|
}
|
|
294
288
|
/**
|
|
295
289
|
* @public
|
|
296
|
-
* @
|
|
297
|
-
* @category AppsInTossModules
|
|
298
|
-
* @kind function
|
|
290
|
+
* @category 연락처
|
|
299
291
|
* @name fetchContacts
|
|
300
292
|
* @description 사용자의 연락처 목록을 페이지 단위로 가져오는 함수예요.
|
|
301
293
|
* @param size - 한 번에 가져올 연락처 개수예요. 예를 들어, 10을 전달하면 최대 10개의 연락처를 가져와요.
|
|
@@ -386,9 +378,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
386
378
|
}
|
|
387
379
|
/**
|
|
388
380
|
* @public
|
|
389
|
-
* @
|
|
390
|
-
* @category AppsInTossModules
|
|
391
|
-
* @kind function
|
|
381
|
+
* @category 사진
|
|
392
382
|
* @name fetchAlbumPhotos
|
|
393
383
|
* @description
|
|
394
384
|
* 사용자의 앨범에서 사진 목록을 불러오는 함수예요.
|
|
@@ -446,9 +436,7 @@ interface GetCurrentLocationOptions {
|
|
|
446
436
|
}
|
|
447
437
|
/**
|
|
448
438
|
* @public
|
|
449
|
-
* @
|
|
450
|
-
* @category AppsInTossModules
|
|
451
|
-
* @kind function
|
|
439
|
+
* @category 위치 정보
|
|
452
440
|
* @name getCurrentLocation
|
|
453
441
|
* @description 디바이스의 현재 위치 정보를 가져오는 함수예요.
|
|
454
442
|
* 위치 기반 서비스를 구현할 때 사용되고, 한 번만 호출되어 현재 위치를 즉시 반환해요.
|
|
@@ -510,9 +498,7 @@ interface OpenCameraOptions {
|
|
|
510
498
|
}
|
|
511
499
|
/**
|
|
512
500
|
* @public
|
|
513
|
-
* @
|
|
514
|
-
* @category AppsInTossModules
|
|
515
|
-
* @kind function
|
|
501
|
+
* @category 카메라
|
|
516
502
|
* @name openCamera
|
|
517
503
|
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
518
504
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
@@ -561,9 +547,7 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
561
547
|
|
|
562
548
|
/**
|
|
563
549
|
* @public
|
|
564
|
-
* @
|
|
565
|
-
* @category AppsInTossModules
|
|
566
|
-
* @kind function
|
|
550
|
+
* @category 로그인
|
|
567
551
|
* @name appLogin
|
|
568
552
|
* @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
|
|
569
553
|
* @example
|
|
@@ -576,9 +560,9 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
576
560
|
*
|
|
577
561
|
* function Page() {
|
|
578
562
|
* const handleLogin = async () => {
|
|
579
|
-
* const { authorizationCode } = await appLogin();
|
|
563
|
+
* const { authorizationCode, referrer } = await appLogin();
|
|
580
564
|
*
|
|
581
|
-
* // 획득한 인가 코드(`authorizationCode`)
|
|
565
|
+
* // 획득한 인가 코드(`authorizationCode`)와 `referrer`를 서버로 전달해요.
|
|
582
566
|
* }
|
|
583
567
|
*
|
|
584
568
|
* return <Button title="로그인" onPress={handleLogin} />;
|
|
@@ -587,8 +571,43 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
587
571
|
*/
|
|
588
572
|
declare function appLogin(): Promise<{
|
|
589
573
|
authorizationCode: string;
|
|
574
|
+
referrer: "DEFAULT" | "SANDBOX";
|
|
590
575
|
}>;
|
|
591
576
|
|
|
577
|
+
/**
|
|
578
|
+
* @public
|
|
579
|
+
* @category 환경 확인
|
|
580
|
+
* @kind function
|
|
581
|
+
* @name getOperationalEnvironment
|
|
582
|
+
* @description
|
|
583
|
+
* 현재 실행 중인 앱의 운영 환경을 확인해요.
|
|
584
|
+
* 토스 앱에서 실행 중이라면 `'toss'`, 샌드박스 환경에서 실행 중이라면 `'sandbox'`를 반환해요.
|
|
585
|
+
*
|
|
586
|
+
* 운영 환경은 앱이 실행되는 컨텍스트를 의미하며, 특정 기능의 사용 가능 여부를 판단하는 데 활용할 수 있어요.
|
|
587
|
+
*
|
|
588
|
+
* @returns {'toss' | 'sandbox'}
|
|
589
|
+
* 현재 운영 환경을 나타내는 문자열이에요.
|
|
590
|
+
* - `'toss'`: 토스 앱에서 실행 중이에요.
|
|
591
|
+
* - `'sandbox'`: 샌드박스 환경에서 실행 중이에요.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ### 현재 운영 환경 확인하기
|
|
595
|
+
*
|
|
596
|
+
* ```tsx
|
|
597
|
+
* import { getOperationalEnvironment } from '@apps-in-toss/framework';
|
|
598
|
+
* import { Text } from 'react-native';
|
|
599
|
+
*
|
|
600
|
+
* function EnvironmentInfo() {
|
|
601
|
+
* const environment = getOperationalEnvironment();
|
|
602
|
+
*
|
|
603
|
+
* return (
|
|
604
|
+
* <Text>현재 운영 환경: {environment}</Text>
|
|
605
|
+
* );
|
|
606
|
+
* }
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
declare function getOperationalEnvironment(): 'toss' | 'sandbox';
|
|
610
|
+
|
|
592
611
|
interface WebViewProps extends Omit<WebViewProps$1, 'cacheEnabled' | 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
593
612
|
local: {
|
|
594
613
|
port: number;
|
|
@@ -600,9 +619,7 @@ declare function WebView({ local, onMessage, ...props }: WebViewProps): react_js
|
|
|
600
619
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
601
620
|
/**
|
|
602
621
|
* @public
|
|
603
|
-
* @
|
|
604
|
-
* @category AppsInTossModules
|
|
605
|
-
* @kind function
|
|
622
|
+
* @category 위치 정보
|
|
606
623
|
* @name useGeolocation
|
|
607
624
|
* @description 디바이스의 위치 정보를 반환하는 훅이에요. 위치가 변경되면 값도 변경돼요.
|
|
608
625
|
* GPS 정보를 활용해 현재 위치를 감지하고, 사용자의 이동에 따라 자동으로 업데이트돼요.
|
|
@@ -649,4 +666,4 @@ declare const env: {
|
|
|
649
666
|
getDeploymentId: () => string | undefined;
|
|
650
667
|
};
|
|
651
668
|
|
|
652
|
-
export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
|
669
|
+
export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @public
|
|
21
|
-
* @category
|
|
21
|
+
* @category 위치 정보
|
|
22
22
|
* @name Accuracy
|
|
23
23
|
* @description 위치 정확도 옵션이에요.
|
|
24
24
|
*/
|
|
@@ -50,7 +50,7 @@ declare enum Accuracy {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* @public
|
|
53
|
-
* @category
|
|
53
|
+
* @category 위치 정보
|
|
54
54
|
* @name Location
|
|
55
55
|
* @description 위치 정보를 나타내는 객체예요.
|
|
56
56
|
*/
|
|
@@ -75,7 +75,7 @@ interface Location {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* @public
|
|
78
|
-
* @category
|
|
78
|
+
* @category 위치 정보
|
|
79
79
|
* @name LocationCoords
|
|
80
80
|
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
81
81
|
*/
|
|
@@ -143,9 +143,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* @public
|
|
146
|
-
* @
|
|
147
|
-
* @category AppsInTossModules
|
|
148
|
-
* @kind function
|
|
146
|
+
* @category 위치 정보
|
|
149
147
|
* @name startUpdateLocation
|
|
150
148
|
* @description 디바이스의 위치 정보를 지속적으로 감지하고, 위치가 변경되면 콜백을 실행하는 함수예요. 콜백 함수를 등록하면 위치가 변경될 때마다 자동으로 호출돼요.
|
|
151
149
|
* 실시간 위치 추적이 필요한 기능을 구현할 때 사용할 수 있어요. 예를 들어 지도 앱에서 사용자의 현재 위치를 실시간으로 업데이트할 때, 운동 앱에서 사용자의 이동 거리를 기록할 때 등이에요.
|
|
@@ -210,9 +208,7 @@ declare function startUpdateLocation(eventParams: {
|
|
|
210
208
|
|
|
211
209
|
/**
|
|
212
210
|
* @public
|
|
213
|
-
* @
|
|
214
|
-
* @category AppsInTossModules
|
|
215
|
-
* @kind function
|
|
211
|
+
* @category 클립보드
|
|
216
212
|
* @name setClipboardText
|
|
217
213
|
* @description 텍스트를 클립보드에 복사해서 사용자가 다른 곳에 붙여 넣기 할 수 있어요.
|
|
218
214
|
* @param {Promise<void>} text - 클립보드에 복사할 텍스트예요. 문자열 형식으로 입력해요.
|
|
@@ -243,9 +239,7 @@ declare function setClipboardText(text: string): Promise<void>;
|
|
|
243
239
|
|
|
244
240
|
/**
|
|
245
241
|
* @public
|
|
246
|
-
* @
|
|
247
|
-
* @category AppsInTossModules
|
|
248
|
-
* @kind function
|
|
242
|
+
* @category 클립보드
|
|
249
243
|
* @name getClipboardText
|
|
250
244
|
* @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
|
|
251
245
|
* @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
|
|
@@ -293,9 +287,7 @@ interface ContactEntity {
|
|
|
293
287
|
}
|
|
294
288
|
/**
|
|
295
289
|
* @public
|
|
296
|
-
* @
|
|
297
|
-
* @category AppsInTossModules
|
|
298
|
-
* @kind function
|
|
290
|
+
* @category 연락처
|
|
299
291
|
* @name fetchContacts
|
|
300
292
|
* @description 사용자의 연락처 목록을 페이지 단위로 가져오는 함수예요.
|
|
301
293
|
* @param size - 한 번에 가져올 연락처 개수예요. 예를 들어, 10을 전달하면 최대 10개의 연락처를 가져와요.
|
|
@@ -386,9 +378,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
386
378
|
}
|
|
387
379
|
/**
|
|
388
380
|
* @public
|
|
389
|
-
* @
|
|
390
|
-
* @category AppsInTossModules
|
|
391
|
-
* @kind function
|
|
381
|
+
* @category 사진
|
|
392
382
|
* @name fetchAlbumPhotos
|
|
393
383
|
* @description
|
|
394
384
|
* 사용자의 앨범에서 사진 목록을 불러오는 함수예요.
|
|
@@ -446,9 +436,7 @@ interface GetCurrentLocationOptions {
|
|
|
446
436
|
}
|
|
447
437
|
/**
|
|
448
438
|
* @public
|
|
449
|
-
* @
|
|
450
|
-
* @category AppsInTossModules
|
|
451
|
-
* @kind function
|
|
439
|
+
* @category 위치 정보
|
|
452
440
|
* @name getCurrentLocation
|
|
453
441
|
* @description 디바이스의 현재 위치 정보를 가져오는 함수예요.
|
|
454
442
|
* 위치 기반 서비스를 구현할 때 사용되고, 한 번만 호출되어 현재 위치를 즉시 반환해요.
|
|
@@ -510,9 +498,7 @@ interface OpenCameraOptions {
|
|
|
510
498
|
}
|
|
511
499
|
/**
|
|
512
500
|
* @public
|
|
513
|
-
* @
|
|
514
|
-
* @category AppsInTossModules
|
|
515
|
-
* @kind function
|
|
501
|
+
* @category 카메라
|
|
516
502
|
* @name openCamera
|
|
517
503
|
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
518
504
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
@@ -561,9 +547,7 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
561
547
|
|
|
562
548
|
/**
|
|
563
549
|
* @public
|
|
564
|
-
* @
|
|
565
|
-
* @category AppsInTossModules
|
|
566
|
-
* @kind function
|
|
550
|
+
* @category 로그인
|
|
567
551
|
* @name appLogin
|
|
568
552
|
* @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
|
|
569
553
|
* @example
|
|
@@ -576,9 +560,9 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
576
560
|
*
|
|
577
561
|
* function Page() {
|
|
578
562
|
* const handleLogin = async () => {
|
|
579
|
-
* const { authorizationCode } = await appLogin();
|
|
563
|
+
* const { authorizationCode, referrer } = await appLogin();
|
|
580
564
|
*
|
|
581
|
-
* // 획득한 인가 코드(`authorizationCode`)
|
|
565
|
+
* // 획득한 인가 코드(`authorizationCode`)와 `referrer`를 서버로 전달해요.
|
|
582
566
|
* }
|
|
583
567
|
*
|
|
584
568
|
* return <Button title="로그인" onPress={handleLogin} />;
|
|
@@ -587,8 +571,43 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
587
571
|
*/
|
|
588
572
|
declare function appLogin(): Promise<{
|
|
589
573
|
authorizationCode: string;
|
|
574
|
+
referrer: "DEFAULT" | "SANDBOX";
|
|
590
575
|
}>;
|
|
591
576
|
|
|
577
|
+
/**
|
|
578
|
+
* @public
|
|
579
|
+
* @category 환경 확인
|
|
580
|
+
* @kind function
|
|
581
|
+
* @name getOperationalEnvironment
|
|
582
|
+
* @description
|
|
583
|
+
* 현재 실행 중인 앱의 운영 환경을 확인해요.
|
|
584
|
+
* 토스 앱에서 실행 중이라면 `'toss'`, 샌드박스 환경에서 실행 중이라면 `'sandbox'`를 반환해요.
|
|
585
|
+
*
|
|
586
|
+
* 운영 환경은 앱이 실행되는 컨텍스트를 의미하며, 특정 기능의 사용 가능 여부를 판단하는 데 활용할 수 있어요.
|
|
587
|
+
*
|
|
588
|
+
* @returns {'toss' | 'sandbox'}
|
|
589
|
+
* 현재 운영 환경을 나타내는 문자열이에요.
|
|
590
|
+
* - `'toss'`: 토스 앱에서 실행 중이에요.
|
|
591
|
+
* - `'sandbox'`: 샌드박스 환경에서 실행 중이에요.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ### 현재 운영 환경 확인하기
|
|
595
|
+
*
|
|
596
|
+
* ```tsx
|
|
597
|
+
* import { getOperationalEnvironment } from '@apps-in-toss/framework';
|
|
598
|
+
* import { Text } from 'react-native';
|
|
599
|
+
*
|
|
600
|
+
* function EnvironmentInfo() {
|
|
601
|
+
* const environment = getOperationalEnvironment();
|
|
602
|
+
*
|
|
603
|
+
* return (
|
|
604
|
+
* <Text>현재 운영 환경: {environment}</Text>
|
|
605
|
+
* );
|
|
606
|
+
* }
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
declare function getOperationalEnvironment(): 'toss' | 'sandbox';
|
|
610
|
+
|
|
592
611
|
interface WebViewProps extends Omit<WebViewProps$1, 'cacheEnabled' | 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
593
612
|
local: {
|
|
594
613
|
port: number;
|
|
@@ -600,9 +619,7 @@ declare function WebView({ local, onMessage, ...props }: WebViewProps): react_js
|
|
|
600
619
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
601
620
|
/**
|
|
602
621
|
* @public
|
|
603
|
-
* @
|
|
604
|
-
* @category AppsInTossModules
|
|
605
|
-
* @kind function
|
|
622
|
+
* @category 위치 정보
|
|
606
623
|
* @name useGeolocation
|
|
607
624
|
* @description 디바이스의 위치 정보를 반환하는 훅이에요. 위치가 변경되면 값도 변경돼요.
|
|
608
625
|
* GPS 정보를 활용해 현재 위치를 감지하고, 사용자의 이동에 따라 자동으로 업데이트돼요.
|
|
@@ -649,4 +666,4 @@ declare const env: {
|
|
|
649
666
|
getDeploymentId: () => string | undefined;
|
|
650
667
|
};
|
|
651
668
|
|
|
652
|
-
export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
|
669
|
+
export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.js
CHANGED
|
@@ -30,12 +30,6 @@ var AppsInToss = {
|
|
|
30
30
|
registerApp
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
// src/native-event-emitter/index.ts
|
|
34
|
-
var native_event_emitter_exports = {};
|
|
35
|
-
__export(native_event_emitter_exports, {
|
|
36
|
-
startUpdateLocation: () => startUpdateLocation
|
|
37
|
-
});
|
|
38
|
-
|
|
39
33
|
// src/native-event-emitter/bedrock-event.ts
|
|
40
34
|
import { BedrockEvent } from "react-native-bedrock";
|
|
41
35
|
|
|
@@ -109,18 +103,6 @@ function startUpdateLocation(eventParams) {
|
|
|
109
103
|
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
// src/native-modules/index.ts
|
|
113
|
-
var native_modules_exports = {};
|
|
114
|
-
__export(native_modules_exports, {
|
|
115
|
-
appLogin: () => appLogin,
|
|
116
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
117
|
-
fetchContacts: () => fetchContacts,
|
|
118
|
-
getClipboardText: () => getClipboardText,
|
|
119
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
120
|
-
openCamera: () => openCamera,
|
|
121
|
-
setClipboardText: () => setClipboardText
|
|
122
|
-
});
|
|
123
|
-
|
|
124
106
|
// src/native-modules/setClipboardText.ts
|
|
125
107
|
async function setClipboardText(text) {
|
|
126
108
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -210,20 +192,49 @@ async function appLogin() {
|
|
|
210
192
|
return AppsInTossModule.appLogin({});
|
|
211
193
|
}
|
|
212
194
|
|
|
195
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
196
|
+
function getOperationalEnvironment() {
|
|
197
|
+
return AppsInTossModule.operationalEnvironment;
|
|
198
|
+
}
|
|
199
|
+
|
|
213
200
|
// src/components/WebView.tsx
|
|
214
201
|
import {
|
|
215
202
|
WebView as OriginalWebView
|
|
216
203
|
} from "@react-native-bedrock/native/react-native-webview";
|
|
217
204
|
import { useMemo } from "react";
|
|
218
|
-
import {
|
|
219
|
-
import * as
|
|
220
|
-
import * as
|
|
205
|
+
import { useBridgeHandler } from "react-native-bedrock";
|
|
206
|
+
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
207
|
+
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
208
|
+
|
|
209
|
+
// src/async-bridges.ts
|
|
210
|
+
var async_bridges_exports = {};
|
|
211
|
+
__export(async_bridges_exports, {
|
|
212
|
+
appLogin: () => appLogin,
|
|
213
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
214
|
+
fetchContacts: () => fetchContacts,
|
|
215
|
+
getClipboardText: () => getClipboardText,
|
|
216
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
217
|
+
openCamera: () => openCamera,
|
|
218
|
+
setClipboardText: () => setClipboardText
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// src/constant-bridges.ts
|
|
222
|
+
var constant_bridges_exports = {};
|
|
223
|
+
__export(constant_bridges_exports, {
|
|
224
|
+
getOperationalEnvironment: () => getOperationalEnvironment
|
|
225
|
+
});
|
|
221
226
|
|
|
222
227
|
// src/env.ts
|
|
223
228
|
var env = {
|
|
224
229
|
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
225
230
|
};
|
|
226
231
|
|
|
232
|
+
// src/event-bridges.ts
|
|
233
|
+
var event_bridges_exports = {};
|
|
234
|
+
__export(event_bridges_exports, {
|
|
235
|
+
startUpdateLocation: () => startUpdateLocation
|
|
236
|
+
});
|
|
237
|
+
|
|
227
238
|
// src/components/WebView.tsx
|
|
228
239
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
229
240
|
function WebView({ local, onMessage, ...props }) {
|
|
@@ -231,7 +242,7 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
231
242
|
if (__DEV__) {
|
|
232
243
|
return `http://${local.host}:${local.port}`;
|
|
233
244
|
}
|
|
234
|
-
const url = new URL(
|
|
245
|
+
const url = new URL(AppsInTossModule.getWebBundleURL({}).url);
|
|
235
246
|
const deploymentId = env.getDeploymentId();
|
|
236
247
|
if (deploymentId) {
|
|
237
248
|
url.searchParams.set("_deploymentId", deploymentId);
|
|
@@ -241,15 +252,18 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
241
252
|
const handler = useBridgeHandler({
|
|
242
253
|
onMessage,
|
|
243
254
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
244
|
-
eventListenerMap:
|
|
255
|
+
eventListenerMap: event_bridges_exports,
|
|
245
256
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
246
257
|
// @ts-expect-error
|
|
247
|
-
constantHandlerMap:
|
|
258
|
+
constantHandlerMap: {
|
|
259
|
+
...bedrockConstantBridges,
|
|
260
|
+
...constant_bridges_exports
|
|
261
|
+
},
|
|
248
262
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
249
263
|
// @ts-expect-error
|
|
250
|
-
|
|
251
|
-
...
|
|
252
|
-
...
|
|
264
|
+
asyncHandlerMap: {
|
|
265
|
+
...bedrockAsyncBridges,
|
|
266
|
+
...async_bridges_exports
|
|
253
267
|
}
|
|
254
268
|
});
|
|
255
269
|
return /* @__PURE__ */ jsx2(
|
|
@@ -314,6 +328,7 @@ export {
|
|
|
314
328
|
fetchContacts,
|
|
315
329
|
getClipboardText,
|
|
316
330
|
getCurrentLocation,
|
|
331
|
+
getOperationalEnvironment,
|
|
317
332
|
openCamera,
|
|
318
333
|
setClipboardText,
|
|
319
334
|
startUpdateLocation,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-dev.
|
|
4
|
+
"version": "0.0.0-dev.1742356516217",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -23,9 +23,17 @@
|
|
|
23
23
|
"import": "./dist/plugins/index.js",
|
|
24
24
|
"require": "./dist/plugins/index.cjs"
|
|
25
25
|
},
|
|
26
|
-
"./bridges": {
|
|
27
|
-
"types": "./src/bridges.ts",
|
|
28
|
-
"default": "./src/bridges.ts"
|
|
26
|
+
"./async-bridges": {
|
|
27
|
+
"types": "./src/async-bridges.ts",
|
|
28
|
+
"default": "./src/async-bridges.ts"
|
|
29
|
+
},
|
|
30
|
+
"./constant-bridges": {
|
|
31
|
+
"types": "./src/constant-bridges.ts",
|
|
32
|
+
"default": "./src/constant-bridges.ts"
|
|
33
|
+
},
|
|
34
|
+
"./event-bridges": {
|
|
35
|
+
"types": "./src/event-bridges.ts",
|
|
36
|
+
"default": "./src/event-bridges.ts"
|
|
29
37
|
},
|
|
30
38
|
"./jest": {
|
|
31
39
|
"types": "./dist/jest/index.d.ts",
|
|
@@ -36,7 +44,9 @@
|
|
|
36
44
|
},
|
|
37
45
|
"files": [
|
|
38
46
|
"dist/**/*",
|
|
39
|
-
"src/bridges.ts",
|
|
47
|
+
"src/async-bridges.ts",
|
|
48
|
+
"src/constant-bridges.ts",
|
|
49
|
+
"src/event-bridges.ts",
|
|
40
50
|
"hermesc/**/*",
|
|
41
51
|
"plugins.d.ts",
|
|
42
52
|
"jest.d.ts"
|
|
@@ -45,11 +55,11 @@
|
|
|
45
55
|
"ait": "./bin/ait.js"
|
|
46
56
|
},
|
|
47
57
|
"dependencies": {
|
|
48
|
-
"@apps-in-toss/cli": "0.0.0-dev.
|
|
58
|
+
"@apps-in-toss/cli": "0.0.0-dev.1742356516217"
|
|
49
59
|
},
|
|
50
60
|
"devDependencies": {
|
|
51
|
-
"@react-native-bedrock/mpack-next": "0.0.
|
|
52
|
-
"@react-native-bedrock/native": "0.0.
|
|
61
|
+
"@react-native-bedrock/mpack-next": "0.0.0-dev.1742356297662",
|
|
62
|
+
"@react-native-bedrock/native": "0.0.0-dev.1742356297662",
|
|
53
63
|
"@ryoppippi/unplugin-typia": "^2.0.3",
|
|
54
64
|
"@toss-design-system/react-native": "^0",
|
|
55
65
|
"@types/archiver": "^6.0.3",
|
|
@@ -62,7 +72,7 @@
|
|
|
62
72
|
"picocolors": "^1.1.1",
|
|
63
73
|
"react": "18.2.0",
|
|
64
74
|
"react-native": "0.72.6",
|
|
65
|
-
"react-native-bedrock": "0.0.
|
|
75
|
+
"react-native-bedrock": "0.0.0-dev.1742356297662",
|
|
66
76
|
"tsup": "^8.3.5",
|
|
67
77
|
"typescript": "4.9.5",
|
|
68
78
|
"typia": "^8.0.1",
|
|
@@ -80,5 +90,5 @@
|
|
|
80
90
|
"publishConfig": {
|
|
81
91
|
"access": "public"
|
|
82
92
|
},
|
|
83
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "d6fa75da12f2a0d221f0a268b49054e415450c1f"
|
|
84
94
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './native-modules/setClipboardText.js';
|
|
2
|
+
export * from './native-modules/getClipboardText.js';
|
|
3
|
+
export * from './native-modules/fetchContacts.js';
|
|
4
|
+
export * from './native-modules/fetchAlbumPhotos.js';
|
|
5
|
+
export * from './native-modules/getCurrentLocation.js';
|
|
6
|
+
export * from './native-modules/openCamera.js';
|
|
7
|
+
export * from './native-modules/appLogin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './native-modules/getOperationalEnvironment.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './native-event-emitter/startUpdateLocation.js';
|
package/src/bridges.ts
DELETED