@apps-in-toss/framework 0.0.11 → 0.0.12

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 CHANGED
@@ -199,14 +199,6 @@ async function fetchAlbumPhotos(options) {
199
199
  maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
200
200
  maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
201
201
  });
202
- if (options.base64) {
203
- return albumPhotos.map((photo) => {
204
- return {
205
- ...photo,
206
- dataUri: `data:image/jpeg;base64,${photo.dataUri}`
207
- };
208
- });
209
- }
210
202
  return albumPhotos;
211
203
  }
212
204
 
@@ -265,6 +257,11 @@ __export(constant_bridges_exports, {
265
257
  getOperationalEnvironment: () => getOperationalEnvironment
266
258
  });
267
259
 
260
+ // src/env.ts
261
+ var env = {
262
+ getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
263
+ };
264
+
268
265
  // src/event-bridges.ts
269
266
  var event_bridges_exports = {};
270
267
  __export(event_bridges_exports, {
@@ -278,7 +275,12 @@ function WebView({ local, onMessage, ...props }) {
278
275
  if (__DEV__) {
279
276
  return `http://${local.host}:${local.port}`;
280
277
  }
281
- return AppsInTossModule.getWebBundleURL({}).url;
278
+ const url = new URL(AppsInTossModule.getWebBundleURL({}).url);
279
+ const deploymentId = env.getDeploymentId();
280
+ if (deploymentId) {
281
+ url.searchParams.set("_deploymentId", deploymentId);
282
+ }
283
+ return url.toString();
282
284
  }, [local]);
283
285
  const handler = (0, import_react_native_bedrock4.useBridgeHandler)({
284
286
  onMessage,
@@ -302,9 +304,13 @@ function WebView({ local, onMessage, ...props }) {
302
304
  {
303
305
  ref: handler.ref,
304
306
  ...props,
305
- source: { uri },
307
+ source: {
308
+ uri
309
+ },
306
310
  sharedCookiesEnabled: true,
307
311
  thirdPartyCookiesEnabled: true,
312
+ cacheEnabled: false,
313
+ cacheMode: "LOAD_NO_CACHE",
308
314
  onMessage: handler.onMessage,
309
315
  injectedJavaScript: handler.injectedJavaScript,
310
316
  injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
@@ -335,11 +341,6 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
335
341
  return location;
336
342
  }
337
343
 
338
- // src/env.ts
339
- var env = {
340
- getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
341
- };
342
-
343
344
  // src/types.ts
344
345
  var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
345
346
  Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
package/dist/index.d.cts CHANGED
@@ -300,17 +300,36 @@ interface ContactEntity {
300
300
  * - `nextOffset`: 다음 호출에 사용할 오프셋 값이에요. 더 가져올 연락처가 없으면 `null`이에요.
301
301
  * - `done`: 모든 연락처를 다 가져왔는지 여부를 나타내요. 모두 가져왔다면 `true`예요.
302
302
  *
303
+ * @signature
304
+ * ```typescript
305
+ * function fetchContacts({ size, offset, query }: {
306
+ * size: number;
307
+ * offset: number;
308
+ * query?: {
309
+ * contains?: string;
310
+ * };
311
+ * }): Promise<{
312
+ * result: ContactEntity[];
313
+ * nextOffset: number | null;
314
+ * done: boolean;
315
+ * }>;
316
+ * ```
317
+ *
303
318
  * @example
304
319
  * ### 특정 문자열이 포함된 연락처 목록 가져오기
305
320
  *
306
321
  * ```tsx
307
322
  * import React, { useState } from 'react';
308
323
  * import { View, Text, Button } from 'react-native';
309
- * import { fetchContacts } from '@apps-in-toss/framework';
324
+ * import { fetchContacts, ContactEntity } from '@apps-in-toss/framework';
310
325
  *
311
326
  * // 특정 문자열을 포함한 연락처 목록을 가져와 화면에 표시하는 컴포넌트
312
327
  * function ContactsList() {
313
- * const [contacts, setContacts] = useState({
328
+ * const [contacts, setContacts] = useState<{
329
+ * result: ContactEntity[];
330
+ * nextOffset: number | null;
331
+ * done: boolean;
332
+ * }>({
314
333
  * result: [],
315
334
  * nextOffset: null,
316
335
  * done: false,
@@ -326,7 +345,7 @@ interface ContactEntity {
326
345
  * const response = await fetchContacts({
327
346
  * size: 10,
328
347
  * offset: contacts.nextOffset ?? 0,
329
- * query: { contains: '홍길동' },
348
+ * query: { contains: '' },
330
349
  * });
331
350
  * setContacts((prev) => ({
332
351
  * result: [...prev.result, ...response.result],
@@ -399,6 +418,8 @@ interface FetchAlbumPhotosOptions {
399
418
  * import { View, Image, Button } from 'react-native';
400
419
  * import { fetchAlbumPhotos } from '@apps-in-toss/framework';
401
420
  *
421
+ * const base64 = true;
422
+ *
402
423
  * // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
403
424
  * function AlbumPhotoList() {
404
425
  * const [albumPhotos, setAlbumPhotos] = useState([]);
@@ -406,7 +427,7 @@ interface FetchAlbumPhotosOptions {
406
427
  * const handlePress = async () => {
407
428
  * try {
408
429
  * const response = await fetchAlbumPhotos({
409
- * base64: true,
430
+ * base64,
410
431
  * maxWidth: 360,
411
432
  * });
412
433
  * setAlbumPhotos((prev) => ([...prev, ...response]));
@@ -417,9 +438,12 @@ interface FetchAlbumPhotosOptions {
417
438
  *
418
439
  * return (
419
440
  * <View>
420
- * {albumPhotos.map((image) => (
421
- * <Image source={{ uri: image.dataUri }} key={image.id} />
422
- * ))}
441
+ * {albumPhotos.map((image) => {
442
+ * // base64 형식으로 반환된 이미지를 표시하려면 데이터 URL 스키마 Prefix를 붙여야해요.
443
+ * const imageUri = base64 ? 'data:image/jpeg;base64,' + image.dataUri : image.dataUri;
444
+ *
445
+ * return <Image source={{ uri: imageUri }} key={image.id} />;
446
+ * })}
423
447
  * <Button title="앨범 가져오기" onPress={handlePress} />
424
448
  * </View>
425
449
  * );
@@ -517,23 +541,28 @@ interface OpenCameraOptions {
517
541
  * import { View, Text, Button, Image } from 'react-native';
518
542
  * import { openCamera } from '@apps-in-toss/framework';
519
543
  *
544
+ * const base64 = true;
545
+ *
520
546
  * // 카메라를 실행하고 촬영된 이미지를 화면에 표시하는 컴포넌트
521
547
  * function Camera() {
522
548
  * const [image, setImage] = useState(null);
523
549
  *
524
550
  * const handlePress = async () => {
525
551
  * try {
526
- * const response = await openCamera({ base64: false });
552
+ * const response = await openCamera({ base64 });
527
553
  * setImage(response);
528
554
  * } catch (error) {
529
555
  * console.error('사진을 가져오는 데 실패했어요:', error);
530
556
  * }
531
557
  * };
532
558
  *
559
+ * // base64 형식으로 반환된 이미지를 표시하려면 데이터 URL 스키마 Prefix를 붙여야해요.
560
+ * const imageUri = base64 ? 'data:image/jpeg;base64,' + image.dataUri : image.dataUri;
561
+ *
533
562
  * return (
534
563
  * <View>
535
564
  * {image ? (
536
- * <Image source={{ uri: image.dataUri }} style={{ width: 200, height: 200 }} />
565
+ * <Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
537
566
  * ) : (
538
567
  * <Text>사진이 없어요</Text>
539
568
  * )}
@@ -608,7 +637,7 @@ declare function appLogin(): Promise<{
608
637
  */
609
638
  declare function getOperationalEnvironment(): 'toss' | 'sandbox';
610
639
 
611
- interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
640
+ interface WebViewProps extends Omit<WebViewProps$1, 'cacheEnabled' | 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
612
641
  local: {
613
642
  port: number;
614
643
  host: number;
package/dist/index.d.ts CHANGED
@@ -300,17 +300,36 @@ interface ContactEntity {
300
300
  * - `nextOffset`: 다음 호출에 사용할 오프셋 값이에요. 더 가져올 연락처가 없으면 `null`이에요.
301
301
  * - `done`: 모든 연락처를 다 가져왔는지 여부를 나타내요. 모두 가져왔다면 `true`예요.
302
302
  *
303
+ * @signature
304
+ * ```typescript
305
+ * function fetchContacts({ size, offset, query }: {
306
+ * size: number;
307
+ * offset: number;
308
+ * query?: {
309
+ * contains?: string;
310
+ * };
311
+ * }): Promise<{
312
+ * result: ContactEntity[];
313
+ * nextOffset: number | null;
314
+ * done: boolean;
315
+ * }>;
316
+ * ```
317
+ *
303
318
  * @example
304
319
  * ### 특정 문자열이 포함된 연락처 목록 가져오기
305
320
  *
306
321
  * ```tsx
307
322
  * import React, { useState } from 'react';
308
323
  * import { View, Text, Button } from 'react-native';
309
- * import { fetchContacts } from '@apps-in-toss/framework';
324
+ * import { fetchContacts, ContactEntity } from '@apps-in-toss/framework';
310
325
  *
311
326
  * // 특정 문자열을 포함한 연락처 목록을 가져와 화면에 표시하는 컴포넌트
312
327
  * function ContactsList() {
313
- * const [contacts, setContacts] = useState({
328
+ * const [contacts, setContacts] = useState<{
329
+ * result: ContactEntity[];
330
+ * nextOffset: number | null;
331
+ * done: boolean;
332
+ * }>({
314
333
  * result: [],
315
334
  * nextOffset: null,
316
335
  * done: false,
@@ -326,7 +345,7 @@ interface ContactEntity {
326
345
  * const response = await fetchContacts({
327
346
  * size: 10,
328
347
  * offset: contacts.nextOffset ?? 0,
329
- * query: { contains: '홍길동' },
348
+ * query: { contains: '' },
330
349
  * });
331
350
  * setContacts((prev) => ({
332
351
  * result: [...prev.result, ...response.result],
@@ -399,6 +418,8 @@ interface FetchAlbumPhotosOptions {
399
418
  * import { View, Image, Button } from 'react-native';
400
419
  * import { fetchAlbumPhotos } from '@apps-in-toss/framework';
401
420
  *
421
+ * const base64 = true;
422
+ *
402
423
  * // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
403
424
  * function AlbumPhotoList() {
404
425
  * const [albumPhotos, setAlbumPhotos] = useState([]);
@@ -406,7 +427,7 @@ interface FetchAlbumPhotosOptions {
406
427
  * const handlePress = async () => {
407
428
  * try {
408
429
  * const response = await fetchAlbumPhotos({
409
- * base64: true,
430
+ * base64,
410
431
  * maxWidth: 360,
411
432
  * });
412
433
  * setAlbumPhotos((prev) => ([...prev, ...response]));
@@ -417,9 +438,12 @@ interface FetchAlbumPhotosOptions {
417
438
  *
418
439
  * return (
419
440
  * <View>
420
- * {albumPhotos.map((image) => (
421
- * <Image source={{ uri: image.dataUri }} key={image.id} />
422
- * ))}
441
+ * {albumPhotos.map((image) => {
442
+ * // base64 형식으로 반환된 이미지를 표시하려면 데이터 URL 스키마 Prefix를 붙여야해요.
443
+ * const imageUri = base64 ? 'data:image/jpeg;base64,' + image.dataUri : image.dataUri;
444
+ *
445
+ * return <Image source={{ uri: imageUri }} key={image.id} />;
446
+ * })}
423
447
  * <Button title="앨범 가져오기" onPress={handlePress} />
424
448
  * </View>
425
449
  * );
@@ -517,23 +541,28 @@ interface OpenCameraOptions {
517
541
  * import { View, Text, Button, Image } from 'react-native';
518
542
  * import { openCamera } from '@apps-in-toss/framework';
519
543
  *
544
+ * const base64 = true;
545
+ *
520
546
  * // 카메라를 실행하고 촬영된 이미지를 화면에 표시하는 컴포넌트
521
547
  * function Camera() {
522
548
  * const [image, setImage] = useState(null);
523
549
  *
524
550
  * const handlePress = async () => {
525
551
  * try {
526
- * const response = await openCamera({ base64: false });
552
+ * const response = await openCamera({ base64 });
527
553
  * setImage(response);
528
554
  * } catch (error) {
529
555
  * console.error('사진을 가져오는 데 실패했어요:', error);
530
556
  * }
531
557
  * };
532
558
  *
559
+ * // base64 형식으로 반환된 이미지를 표시하려면 데이터 URL 스키마 Prefix를 붙여야해요.
560
+ * const imageUri = base64 ? 'data:image/jpeg;base64,' + image.dataUri : image.dataUri;
561
+ *
533
562
  * return (
534
563
  * <View>
535
564
  * {image ? (
536
- * <Image source={{ uri: image.dataUri }} style={{ width: 200, height: 200 }} />
565
+ * <Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
537
566
  * ) : (
538
567
  * <Text>사진이 없어요</Text>
539
568
  * )}
@@ -608,7 +637,7 @@ declare function appLogin(): Promise<{
608
637
  */
609
638
  declare function getOperationalEnvironment(): 'toss' | 'sandbox';
610
639
 
611
- interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
640
+ interface WebViewProps extends Omit<WebViewProps$1, 'cacheEnabled' | 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
612
641
  local: {
613
642
  port: number;
614
643
  host: number;
package/dist/index.js CHANGED
@@ -156,14 +156,6 @@ async function fetchAlbumPhotos(options) {
156
156
  maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
157
157
  maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
158
158
  });
159
- if (options.base64) {
160
- return albumPhotos.map((photo) => {
161
- return {
162
- ...photo,
163
- dataUri: `data:image/jpeg;base64,${photo.dataUri}`
164
- };
165
- });
166
- }
167
159
  return albumPhotos;
168
160
  }
169
161
 
@@ -224,6 +216,11 @@ __export(constant_bridges_exports, {
224
216
  getOperationalEnvironment: () => getOperationalEnvironment
225
217
  });
226
218
 
219
+ // src/env.ts
220
+ var env = {
221
+ getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
222
+ };
223
+
227
224
  // src/event-bridges.ts
228
225
  var event_bridges_exports = {};
229
226
  __export(event_bridges_exports, {
@@ -237,7 +234,12 @@ function WebView({ local, onMessage, ...props }) {
237
234
  if (__DEV__) {
238
235
  return `http://${local.host}:${local.port}`;
239
236
  }
240
- return AppsInTossModule.getWebBundleURL({}).url;
237
+ const url = new URL(AppsInTossModule.getWebBundleURL({}).url);
238
+ const deploymentId = env.getDeploymentId();
239
+ if (deploymentId) {
240
+ url.searchParams.set("_deploymentId", deploymentId);
241
+ }
242
+ return url.toString();
241
243
  }, [local]);
242
244
  const handler = useBridgeHandler({
243
245
  onMessage,
@@ -261,9 +263,13 @@ function WebView({ local, onMessage, ...props }) {
261
263
  {
262
264
  ref: handler.ref,
263
265
  ...props,
264
- source: { uri },
266
+ source: {
267
+ uri
268
+ },
265
269
  sharedCookiesEnabled: true,
266
270
  thirdPartyCookiesEnabled: true,
271
+ cacheEnabled: false,
272
+ cacheMode: "LOAD_NO_CACHE",
267
273
  onMessage: handler.onMessage,
268
274
  injectedJavaScript: handler.injectedJavaScript,
269
275
  injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
@@ -294,11 +300,6 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
294
300
  return location;
295
301
  }
296
302
 
297
- // src/env.ts
298
- var env = {
299
- getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
300
- };
301
-
302
303
  // src/types.ts
303
304
  var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
304
305
  Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
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.11",
4
+ "version": "0.0.12",
5
5
  "description": "The framework for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -55,7 +55,7 @@
55
55
  "ait": "./bin/ait.js"
56
56
  },
57
57
  "dependencies": {
58
- "@apps-in-toss/cli": "0.0.11"
58
+ "@apps-in-toss/cli": "0.0.12"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@react-native-bedrock/mpack-next": "0.0.13",
@@ -90,5 +90,5 @@
90
90
  "publishConfig": {
91
91
  "access": "public"
92
92
  },
93
- "gitHead": "d0dfa84af3118a71ea3705c440e639fb5b1a010b"
93
+ "gitHead": "38b91e6f4a323333a6039119dd523fc44559bcae"
94
94
  }