@apps-in-toss/framework 0.0.0-dev.1741934253781 → 0.0.0-dev.1742352748804
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 +47 -38
- package/dist/index.d.cts +51 -34
- package/dist/index.d.ts +51 -34
- package/dist/index.js +47 -39
- 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,17 +235,41 @@ 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);
|
|
261
249
|
|
|
262
|
-
// src/
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
});
|
|
267
|
+
|
|
268
|
+
// src/event-bridges.ts
|
|
269
|
+
var event_bridges_exports = {};
|
|
270
|
+
__export(event_bridges_exports, {
|
|
271
|
+
startUpdateLocation: () => startUpdateLocation
|
|
272
|
+
});
|
|
266
273
|
|
|
267
274
|
// src/components/WebView.tsx
|
|
268
275
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -271,20 +278,23 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
271
278
|
if (__DEV__) {
|
|
272
279
|
return `http://${local.host}:${local.port}`;
|
|
273
280
|
}
|
|
274
|
-
return
|
|
281
|
+
return AppsInTossModule.getWebBundleURL({}).url;
|
|
275
282
|
}, [local]);
|
|
276
283
|
const handler = (0, import_react_native_bedrock4.useBridgeHandler)({
|
|
277
284
|
onMessage,
|
|
278
285
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
279
|
-
eventListenerMap:
|
|
286
|
+
eventListenerMap: event_bridges_exports,
|
|
280
287
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
281
288
|
// @ts-expect-error
|
|
282
|
-
constantHandlerMap:
|
|
289
|
+
constantHandlerMap: {
|
|
290
|
+
...bedrockConstantBridges,
|
|
291
|
+
...constant_bridges_exports
|
|
292
|
+
},
|
|
283
293
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
284
294
|
// @ts-expect-error
|
|
285
|
-
|
|
286
|
-
...
|
|
287
|
-
...
|
|
295
|
+
asyncHandlerMap: {
|
|
296
|
+
...bedrockAsyncBridges,
|
|
297
|
+
...async_bridges_exports
|
|
288
298
|
}
|
|
289
299
|
});
|
|
290
300
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -292,16 +302,9 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
292
302
|
{
|
|
293
303
|
ref: handler.ref,
|
|
294
304
|
...props,
|
|
295
|
-
source: {
|
|
296
|
-
uri,
|
|
297
|
-
headers: {
|
|
298
|
-
"x-mini-deployment-id": env.getDeploymentId()
|
|
299
|
-
}
|
|
300
|
-
},
|
|
305
|
+
source: { uri },
|
|
301
306
|
sharedCookiesEnabled: true,
|
|
302
307
|
thirdPartyCookiesEnabled: true,
|
|
303
|
-
cacheEnabled: false,
|
|
304
|
-
cacheMode: "LOAD_NO_CACHE",
|
|
305
308
|
onMessage: handler.onMessage,
|
|
306
309
|
injectedJavaScript: handler.injectedJavaScript,
|
|
307
310
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
@@ -332,6 +335,11 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
|
332
335
|
return location;
|
|
333
336
|
}
|
|
334
337
|
|
|
338
|
+
// src/env.ts
|
|
339
|
+
var env = {
|
|
340
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
341
|
+
};
|
|
342
|
+
|
|
335
343
|
// src/types.ts
|
|
336
344
|
var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
337
345
|
Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
|
|
@@ -353,6 +361,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
353
361
|
fetchContacts,
|
|
354
362
|
getClipboardText,
|
|
355
363
|
getCurrentLocation,
|
|
364
|
+
getOperationalEnvironment,
|
|
356
365
|
openCamera,
|
|
357
366
|
setClipboardText,
|
|
358
367
|
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,9 +571,44 @@ 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
|
|
|
592
|
-
|
|
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
|
+
|
|
611
|
+
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
593
612
|
local: {
|
|
594
613
|
port: number;
|
|
595
614
|
host: 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,9 +571,44 @@ 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
|
|
|
592
|
-
|
|
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
|
+
|
|
611
|
+
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
593
612
|
local: {
|
|
594
613
|
port: number;
|
|
595
614
|
host: 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,19 +192,43 @@ 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";
|
|
221
208
|
|
|
222
|
-
// src/
|
|
223
|
-
var
|
|
224
|
-
|
|
225
|
-
|
|
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
|
+
});
|
|
226
|
+
|
|
227
|
+
// src/event-bridges.ts
|
|
228
|
+
var event_bridges_exports = {};
|
|
229
|
+
__export(event_bridges_exports, {
|
|
230
|
+
startUpdateLocation: () => startUpdateLocation
|
|
231
|
+
});
|
|
226
232
|
|
|
227
233
|
// src/components/WebView.tsx
|
|
228
234
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -231,20 +237,23 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
231
237
|
if (__DEV__) {
|
|
232
238
|
return `http://${local.host}:${local.port}`;
|
|
233
239
|
}
|
|
234
|
-
return
|
|
240
|
+
return AppsInTossModule.getWebBundleURL({}).url;
|
|
235
241
|
}, [local]);
|
|
236
242
|
const handler = useBridgeHandler({
|
|
237
243
|
onMessage,
|
|
238
244
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
239
|
-
eventListenerMap:
|
|
245
|
+
eventListenerMap: event_bridges_exports,
|
|
240
246
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
241
247
|
// @ts-expect-error
|
|
242
|
-
constantHandlerMap:
|
|
248
|
+
constantHandlerMap: {
|
|
249
|
+
...bedrockConstantBridges,
|
|
250
|
+
...constant_bridges_exports
|
|
251
|
+
},
|
|
243
252
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
244
253
|
// @ts-expect-error
|
|
245
|
-
|
|
246
|
-
...
|
|
247
|
-
...
|
|
254
|
+
asyncHandlerMap: {
|
|
255
|
+
...bedrockAsyncBridges,
|
|
256
|
+
...async_bridges_exports
|
|
248
257
|
}
|
|
249
258
|
});
|
|
250
259
|
return /* @__PURE__ */ jsx2(
|
|
@@ -252,16 +261,9 @@ function WebView({ local, onMessage, ...props }) {
|
|
|
252
261
|
{
|
|
253
262
|
ref: handler.ref,
|
|
254
263
|
...props,
|
|
255
|
-
source: {
|
|
256
|
-
uri,
|
|
257
|
-
headers: {
|
|
258
|
-
"x-mini-deployment-id": env.getDeploymentId()
|
|
259
|
-
}
|
|
260
|
-
},
|
|
264
|
+
source: { uri },
|
|
261
265
|
sharedCookiesEnabled: true,
|
|
262
266
|
thirdPartyCookiesEnabled: true,
|
|
263
|
-
cacheEnabled: false,
|
|
264
|
-
cacheMode: "LOAD_NO_CACHE",
|
|
265
267
|
onMessage: handler.onMessage,
|
|
266
268
|
injectedJavaScript: handler.injectedJavaScript,
|
|
267
269
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
@@ -292,6 +294,11 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
|
292
294
|
return location;
|
|
293
295
|
}
|
|
294
296
|
|
|
297
|
+
// src/env.ts
|
|
298
|
+
var env = {
|
|
299
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
300
|
+
};
|
|
301
|
+
|
|
295
302
|
// src/types.ts
|
|
296
303
|
var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
297
304
|
Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
|
|
@@ -312,6 +319,7 @@ export {
|
|
|
312
319
|
fetchContacts,
|
|
313
320
|
getClipboardText,
|
|
314
321
|
getCurrentLocation,
|
|
322
|
+
getOperationalEnvironment,
|
|
315
323
|
openCamera,
|
|
316
324
|
setClipboardText,
|
|
317
325
|
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.1742352748804",
|
|
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.1742352748804"
|
|
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.1742352527199",
|
|
62
|
+
"@react-native-bedrock/native": "0.0.0-dev.1742352527199",
|
|
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.1742352527199",
|
|
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": "ddb83b7938e852ecd5d08f076ac8bedfbf848a84"
|
|
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