@apps-in-toss/web-framework 0.0.22 → 0.0.23

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-web/index.js CHANGED
@@ -83,14 +83,397 @@ function getSafeAreaInsets() {
83
83
  return { top: getSafeAreaTop(), bottom: getSafeAreaBottom() };
84
84
  }
85
85
 
86
+ // src-web/googleAdMob.ts
87
+ import { createEventBridge, createConstantBridge as createConstantBridge2 } from "@apps-in-toss/bridge-core";
88
+ var GoogleAdMob = {
89
+ /**
90
+ * @public
91
+ * @category 광고
92
+ * @name loadAdMobInterstitialAd
93
+ * @description 앱 화면 전체를 덮는 전면 광고를 미리 불러와서, 광고가 필요한 시점에 바로 보여줄 수 있도록 준비하는 함수예요.
94
+ * @param {LoadAdMobInterstitialAdParams} params 광고를 불러올 때 사용할 설정 값이에요. 광고 ID와 광고의 동작에 대한 콜백을 설정할 수 있어요.
95
+ * @param {LoadAdMobInterstitialAdOptions} params.options 광고를 불러올 때 전달할 옵션 객체예요.
96
+ * @param {string} params.options.adUnitId 광고 단위 ID예요. 발급받은 전면 광고용 ID를 입력해요.
97
+ * @param {(event: LoadAdMobInterstitialAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고가 닫히거나 클릭됐을 때). 자세한 이벤트 타입은 [LoadAdMobInterstitialAdEvent](/react-native/reference/framework/광고/LoadAdMobInterstitialAdEvent.html)를 참고하세요.
98
+ * @param {(reason: unknown) => void} [params.onError] 광고를 불러오지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
99
+ * @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
100
+ *
101
+ * @example
102
+ * ### 뷰 진입 시 전면광고 불러오기
103
+ * ```tsx
104
+ * import { GoogleAdMob } from '@apps-in-toss/framework';
105
+ * import { useEffect } from 'react';
106
+ * import { View, Text } from 'react-native';
107
+ *
108
+ * const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
109
+ *
110
+ * function Page() {
111
+ * useEffect(() => {
112
+ * if (GoogleAdMob.loadAdMobInterstitialAd.isSupported() !== true) {
113
+ * return;
114
+ * }
115
+ *
116
+ * const cleanup = GoogleAdMob.loadAdMobInterstitialAd({
117
+ * options: {
118
+ * adUnitId: AD_UNIT_ID,
119
+ * },
120
+ * onEvent: (event) => {
121
+ * switch (event.type) {
122
+ * case 'loaded':
123
+ * console.log('광고 로드 성공', event.data);
124
+ * break;
125
+ *
126
+ * case 'clicked':
127
+ * console.log('광고 클릭');
128
+ * break;
129
+ *
130
+ * case 'dismissed':
131
+ * console.log('광고 닫힘');
132
+ * break;
133
+ *
134
+ * case 'failedToShow':
135
+ * console.log('광고 보여주기 실패');
136
+ * break;
137
+ *
138
+ * case 'impression':
139
+ * console.log('광고 노출');
140
+ * break;
141
+ *
142
+ * case 'show':
143
+ * console.log('광고 컨텐츠 보여졌음');
144
+ * break;
145
+ * }
146
+ * },
147
+ * onError: (error) => {
148
+ * console.error('광고 불러오기 실패', error);
149
+ * },
150
+ * });
151
+ *
152
+ * return cleanup;
153
+ * }, []);
154
+ *
155
+ * return (
156
+ * <View>
157
+ * <Text>Page</Text>
158
+ * </View>
159
+ * );
160
+ * }
161
+ * ```
162
+ */
163
+ loadAdMobInterstitialAd: Object.assign(
164
+ createEventBridge("loadAdMobInterstitialAd"),
165
+ {
166
+ isSupported: createConstantBridge2("loadAdMobInterstitialAd_isSupported")
167
+ }
168
+ ),
169
+ /**
170
+ * @public
171
+ * @category 광고
172
+ * @name showAdMobInterstitialAd
173
+ * @description 앱 화면 전체를 덮는 전면 광고를 사용자에게 노출해요. 이 함수는 `loadAdMobInterstitialAd` 로 미리 불러온 광고를 실제로 사용자에게 노출해요.
174
+ * @param {ShowAdMobInterstitialAdParams} params 광고를 보여주기 위해 사용할 설정 값이에요. 광고 ID와과 광고의 동작에 대한 콜백을 설정할 수 있어요.
175
+ * @param {ShowAdMobInterstitialAdOptions} params.options 광고를 보여줄 때 전달할 옵션 객체예요.
176
+ * @param {string} params.options.adUnitId 광고 단위 ID예요. `loadAdMobInterstitialAd` 로 불러온 전면 광고용 ID를 입력해요.
177
+ * @param {(event: ShowAdMobInterstitialAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고 노출을 요청했을 때). 자세한 이벤트 타입은 [ShowAdMobInterstitialAdEvent](/react-native/reference/framework/광고/ShowAdMobInterstitialAdEvent.html)를 참고하세요.
178
+ * @param {(reason: unknown) => void} [params.onError] 광고를 노출하지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
179
+ * @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
180
+ *
181
+ * @example
182
+ * ### 버튼 눌러 불러온 전면 광고 보여주기
183
+ * ```tsx
184
+ * import { GoogleAdMob } from '@apps-in-toss/framework';
185
+ * import { View, Text, Button } from 'react-native';
186
+ *
187
+ * const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
188
+ *
189
+ * function Page() {
190
+ * const handlePress = () => {
191
+ * if (GoogleAdMob.showAdMobInterstitialAd.isSupported() !== true) {
192
+ * return;
193
+ * }
194
+ *
195
+ * GoogleAdMob.showAdMobInterstitialAd({
196
+ * options: {
197
+ * adUnitId: AD_UNIT_ID,
198
+ * },
199
+ * onEvent: (event) => {
200
+ * switch (event.type) {
201
+ * case 'requested':
202
+ * console.log('광고 보여주기 요청 완료');
203
+ * break;
204
+ * }
205
+ * },
206
+ * onError: (error) => {
207
+ * console.error('광고 보여주기 실패', error);
208
+ * },
209
+ * });
210
+ * }
211
+ *
212
+ * return (
213
+ * <Button onPress={handlePress}>
214
+ * <Text>광고 보기</Text>
215
+ * </Button>
216
+ * );
217
+ * }
218
+ * ```
219
+ */
220
+ showAdMobInterstitialAd: Object.assign(
221
+ createEventBridge("showAdMobInterstitialAd"),
222
+ {
223
+ isSupported: createConstantBridge2("showAdMobInterstitialAd_isSupported")
224
+ }
225
+ ),
226
+ /**
227
+ * @public
228
+ * @category 광고
229
+ * @name loadAdMobRewardedAd
230
+ * @description 사용자가 광고를 끝까지 시청하면 리워드를 제공할 수 있는 보상형 광고를 미리 불러와서, 광고가 필요한 시점에 바로 보여줄 수 있도록 준비하는 함수예요.
231
+ * @param {LoadAdMobRewardedAdParams} params 광고를 불러올 때 사용할 설정 값이에요. 광고 ID와 광고의 동작에 대한 콜백을 설정할 수 있어요.
232
+ * @param {LoadAdMobRewardedAdOptions} params.options 광고를 불러올 때 전달할 옵션 객체예요.
233
+ * @param {string} params.options.adUnitId 광고 단위 ID예요. 발급받은 보상형 광고용 ID를 입력해요.
234
+ * @param {(event: LoadAdMobRewardedAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고가 닫히거나 클릭됐을 때). 자세한 이벤트 타입은 [LoadAdMobRewardedAdEvent](/react-native/reference/framework/광고/LoadAdMobRewardedAdEvent.html)를 참고하세요.
235
+ * @param {(reason: unknown) => void} [params.onError] 광고를 불러오지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
236
+ * @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
237
+ *
238
+ * @example
239
+ * ### 뷰 진입 시 보상형 광고 불러오기
240
+ * ```tsx
241
+ * import { GoogleAdMob } from '@apps-in-toss/framework';
242
+ * import { useEffect } from 'react';
243
+ * import { View, Text } from 'react-native';
244
+ *
245
+ * const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
246
+ *
247
+ * function Page() {
248
+ * useEffect(() => {
249
+ * if (GoogleAdMob.loadAdMobRewardedAd.isSupported() !== true) {
250
+ * return;
251
+ * }
252
+ *
253
+ * const cleanup = GoogleAdMob.loadAdMobRewardedAd({
254
+ * options: {
255
+ * adUnitId: AD_UNIT_ID,
256
+ * },
257
+ * onEvent: (event) => {
258
+ * switch (event.type) {
259
+ * case 'loaded':
260
+ * console.log('광고 로드 성공', event.data);
261
+ * break;
262
+ *
263
+ * case 'clicked':
264
+ * console.log('광고 클릭');
265
+ * break;
266
+ *
267
+ * case 'dismissed':
268
+ * console.log('광고 닫힘');
269
+ * break;
270
+ *
271
+ * case 'failedToShow':
272
+ * console.log('광고 보여주기 실패');
273
+ * break;
274
+ *
275
+ * case 'impression':
276
+ * console.log('광고 노출');
277
+ * break;
278
+ *
279
+ * case 'show':
280
+ * console.log('광고 컨텐츠 보여졌음');
281
+ * break;
282
+ *
283
+ * case 'userEarnedReward':
284
+ * console.log('사용자가 광고 시청을 완료했음');
285
+ * break;
286
+ * }
287
+ * },
288
+ * onError: (error) => {
289
+ * console.error('광고 불러오기 실패', error);
290
+ * },
291
+ * });
292
+ *
293
+ * return cleanup;
294
+ * }, []);
295
+ *
296
+ * return (
297
+ * <View>
298
+ * <Text>Page</Text>
299
+ * </View>
300
+ * );
301
+ * }
302
+ * ```
303
+ */
304
+ loadAdMobRewardedAd: Object.assign(createEventBridge("loadAdMobRewardedAd"), {
305
+ isSupported: createConstantBridge2("loadAdMobRewardedAd_isSupported")
306
+ }),
307
+ /**
308
+ * @public
309
+ * @category 광고
310
+ * @name showAdMobRewardedAd
311
+ * @description 사용자가 광고를 끝까지 보면 리워드를 받을 수 있도록, 보상형 광고를 화면에 보여줘요. 이 함수는 `loadAdMobRewardedAd` 로 미리 불러온 광고를 실제로 사용자에게 노출해요.
312
+ * @param {ShowAdMobRewardedAdParams} params 광고를 보여주기 위해 사용할 설정 값이에요. 광고 ID와 광고의 동작에 대한 콜백을 설정할 수 있어요.
313
+ * @param {ShowAdMobRewardedAdOptions} params.options 광고를 보여줄 때 전달할 옵션 객체예요.
314
+ * @param {string} params.options.adUnitId 광고 단위 ID예요. `loadAdMobRewardedAd` 로 불러온 보상형 광고용 ID를 입력해요.
315
+ * @param {(event: ShowAdMobRewardedAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고 노출을 요청했을 때). 자세한 이벤트 타입은 [ShowAdMobRewardedAdEvent](/react-native/reference/framework/광고/ShowAdMobRewardedAdEvent.html)를 참고하세요.
316
+ * @param {(reason: unknown) => void} [params.onError] 광고를 불러오지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
317
+ * @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
318
+ *
319
+ * @example
320
+ * ### 버튼 눌러 불러온 보상형 광고 보여주기
321
+ * ```tsx
322
+ * import { GoogleAdMob } from '@apps-in-toss/framework';
323
+ * import { View, Text, Button } from 'react-native';
324
+ *
325
+ * const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
326
+ *
327
+ * function Page() {
328
+ * const handlePress = () => {
329
+ * if (GoogleAdMob.showAdMobRewardedAd.isSupported() !== true) {
330
+ * return;
331
+ * }
332
+ *
333
+ * GoogleAdMob.showAdMobRewardedAd({
334
+ * options: {
335
+ * adUnitId: AD_UNIT_ID,
336
+ * },
337
+ * onEvent: (event) => {
338
+ * switch (event.type) {
339
+ * case 'requested':
340
+ * console.log('광고 보여주기 요청 완료');
341
+ * break;
342
+ * }
343
+ * },
344
+ * onError: (error) => {
345
+ * console.error('광고 보여주기 실패', error);
346
+ * },
347
+ * });
348
+ * }
349
+ *
350
+ * return (
351
+ * <Button onPress={handlePress}>
352
+ * <Text>광고 보기</Text>
353
+ * </Button>
354
+ * );
355
+ * }
356
+ * ```
357
+ */
358
+ showAdMobRewardedAd: Object.assign(createEventBridge("showAdMobRewardedAd"), {
359
+ isSupported: createConstantBridge2("showAdMobRewardedAd_isSupported")
360
+ })
361
+ };
362
+
86
363
  // src-web/bedrockEvent.ts
87
- import { createEventBridge } from "@apps-in-toss/bridge-core";
364
+ import { createEventBridge as createEventBridge2 } from "@apps-in-toss/bridge-core";
88
365
  var bedrockEvent = {
89
366
  addEventListener: (event, {
90
367
  onEvent,
91
368
  onError,
92
369
  options
93
- }) => createEventBridge(event)({
370
+ }) => createEventBridge2(event)({
371
+ onEvent,
372
+ onError: onError ?? (() => {
373
+ }),
374
+ options
375
+ })
376
+ };
377
+
378
+ // src-web/isMinVersionSupported.ts
379
+ import { createConstantBridge as createConstantBridge3 } from "@apps-in-toss/bridge-core";
380
+
381
+ // src-web/utils/compareVersion.ts
382
+ var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
383
+ var isWildcard = (val) => ["*", "x", "X"].includes(val);
384
+ var tryParse = (val) => {
385
+ const num = parseInt(val, 10);
386
+ return isNaN(num) ? val : num;
387
+ };
388
+ var coerceTypes = (a, b) => {
389
+ return typeof a === typeof b ? [a, b] : [String(a), String(b)];
390
+ };
391
+ var compareValues = (a, b) => {
392
+ if (isWildcard(a) || isWildcard(b)) {
393
+ return 0;
394
+ }
395
+ const [aVal, bVal] = coerceTypes(tryParse(a), tryParse(b));
396
+ if (aVal > bVal) {
397
+ return 1;
398
+ }
399
+ if (aVal < bVal) {
400
+ return -1;
401
+ }
402
+ return 0;
403
+ };
404
+ var parseVersion = (version) => {
405
+ if (typeof version !== "string") {
406
+ throw new TypeError("Invalid argument: expected a string");
407
+ }
408
+ const match = version.match(SEMVER_REGEX);
409
+ if (!match) {
410
+ throw new Error(`Invalid semver: '${version}'`);
411
+ }
412
+ const [, major, minor, patch, build, preRelease] = match;
413
+ return [major, minor, patch, build, preRelease];
414
+ };
415
+ var compareSegments = (a, b) => {
416
+ const maxLength = Math.max(a.length, b.length);
417
+ for (let i = 0; i < maxLength; i++) {
418
+ const segA = a[i] ?? "0";
419
+ const segB = b[i] ?? "0";
420
+ const result = compareValues(segA, segB);
421
+ if (result !== 0) {
422
+ return result;
423
+ }
424
+ }
425
+ return 0;
426
+ };
427
+ var compareVersions = (v1, v2) => {
428
+ const seg1 = parseVersion(v1);
429
+ const seg2 = parseVersion(v2);
430
+ const preRelease1 = seg1.pop();
431
+ const preRelease2 = seg2.pop();
432
+ const mainCompare = compareSegments(seg1, seg2);
433
+ if (mainCompare !== 0) {
434
+ return mainCompare;
435
+ }
436
+ if (preRelease1 && preRelease2) {
437
+ return compareSegments(preRelease1.split("."), preRelease2.split("."));
438
+ }
439
+ if (preRelease1) {
440
+ return -1;
441
+ }
442
+ if (preRelease2) {
443
+ return 1;
444
+ }
445
+ return 0;
446
+ };
447
+
448
+ // src-web/isMinVersionSupported.ts
449
+ function isMinVersionSupported(minVersions) {
450
+ const operationalEnvironment = createConstantBridge3("getOperationalEnvironment")();
451
+ if (operationalEnvironment === "sandbox") {
452
+ return true;
453
+ }
454
+ const currentVersion = createConstantBridge3("getTossAppVersion")();
455
+ const isIOS = createConstantBridge3("getPlatformOS")() === "ios";
456
+ const minVersion = isIOS ? minVersions.ios : minVersions.android;
457
+ if (minVersion === void 0) {
458
+ return false;
459
+ }
460
+ if (minVersion === "always") {
461
+ return true;
462
+ }
463
+ if (minVersion === "never") {
464
+ return false;
465
+ }
466
+ return compareVersions(currentVersion, minVersion) >= 0;
467
+ }
468
+
469
+ // src-web/appsInTossEvent.ts
470
+ import { createEventBridge as createEventBridge3 } from "@apps-in-toss/bridge-core";
471
+ var appsInTossEvent = {
472
+ addEventListener: (event, {
473
+ onEvent,
474
+ onError,
475
+ options
476
+ }) => createEventBridge3(event)({
94
477
  onEvent,
95
478
  onError: onError ?? (() => {
96
479
  }),
@@ -98,7 +481,10 @@ var bedrockEvent = {
98
481
  })
99
482
  };
100
483
  export {
484
+ GoogleAdMob,
101
485
  Storage,
486
+ appsInTossEvent,
102
487
  bedrockEvent,
103
- getSafeAreaInsets
488
+ getSafeAreaInsets,
489
+ isMinVersionSupported
104
490
  };
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@apps-in-toss/web-framework",
3
3
  "type": "module",
4
- "version": "0.0.22",
4
+ "version": "0.0.23",
5
5
  "description": "Web Framework for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
8
8
  "typecheck": "tsc --noEmit",
9
9
  "lint": "eslint .",
10
10
  "build": "tsup",
11
- "test:no-parallel": "vitest --no-watch",
11
+ "test": "vitest --no-watch",
12
+ "test:no-parallel": "vitest --no-watch --config=vitest.no-parallel.config.mts",
12
13
  "sync-bridge": "bridgepack build"
13
14
  },
14
15
  "main": "./dist-web/index.js",
@@ -51,9 +52,9 @@
51
52
  "config.d.ts"
52
53
  ],
53
54
  "devDependencies": {
54
- "@apps-in-toss-internal/bridgepack": "^0.0.22",
55
+ "@apps-in-toss-internal/bridgepack": "^0.0.23",
55
56
  "@apps-in-toss/bridge-core": "workspace:*",
56
- "@apps-in-toss/framework": "0.0.22",
57
+ "@apps-in-toss/framework": "0.0.23",
57
58
  "@babel/plugin-proposal-class-properties": "^7.16.7",
58
59
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
59
60
  "@babel/plugin-proposal-numeric-separator": "^7.16.7",
@@ -69,9 +70,9 @@
69
70
  "@babel/types": "^7.26.9",
70
71
  "@clack/prompts": "^0.10.0",
71
72
  "@hono/node-server": "^1.13.8",
72
- "@react-native-bedrock/cli": "0.0.21",
73
- "@react-native-bedrock/mpack-next": "0.0.21",
74
- "@react-native-bedrock/native": "0.0.21",
73
+ "@react-native-bedrock/cli": "0.0.22",
74
+ "@react-native-bedrock/mpack-next": "0.0.22",
75
+ "@react-native-bedrock/native": "0.0.22",
75
76
  "@toss-design-system/react-native": "^0.5.1",
76
77
  "@types/babel__core": "^7.20.5",
77
78
  "@types/babel__traverse": "^7",
@@ -92,7 +93,7 @@
92
93
  "picocolors": "^1.1.1",
93
94
  "react": "18.2.0",
94
95
  "react-native": "0.72.6",
95
- "react-native-bedrock": "0.0.21",
96
+ "react-native-bedrock": "0.0.22",
96
97
  "tsup": "^8.3.5",
97
98
  "typescript": "4.9.5",
98
99
  "uuidv7": "^1.0.2",
@@ -103,13 +104,13 @@
103
104
  "zod": "^3.24.1"
104
105
  },
105
106
  "dependencies": {
106
- "@apps-in-toss/bridge-core": "0.0.22",
107
- "@apps-in-toss/cli": "0.0.22",
108
- "@apps-in-toss/plugins": "0.0.22",
107
+ "@apps-in-toss/bridge-core": "0.0.23",
108
+ "@apps-in-toss/cli": "0.0.23",
109
+ "@apps-in-toss/plugins": "0.0.23",
109
110
  "@babel/core": "7.23.9"
110
111
  },
111
112
  "publishConfig": {
112
113
  "access": "public"
113
114
  },
114
- "gitHead": "2a6cea952ba0db69fc2f0c9a94a190b9dfabe8ef"
115
+ "gitHead": "92c6637381f3fc20dfa1870075f22ef108c62873"
115
116
  }