@apps-in-toss/plugins 1.14.0 → 2.0.0

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
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../../.yarn/__virtual__/tsup-virtual-dc9661456a/0/cache/tsup-npm-8.4.0-f78d2622c9-c6636ffd6a.zip/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../../.yarn/__virtual__/tsup-virtual-5946fc3428/0/cache/tsup-npm-8.4.0-f78d2622c9-c6636ffd6a.zip/node_modules/tsup/assets/cjs_shims.js
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
- "../../../.yarn/__virtual__/tsup-virtual-dc9661456a/0/cache/tsup-npm-8.4.0-f78d2622c9-c6636ffd6a.zip/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "../../../.yarn/__virtual__/tsup-virtual-5946fc3428/0/cache/tsup-npm-8.4.0-f78d2622c9-c6636ffd6a.zip/node_modules/tsup/assets/cjs_shims.js"() {
40
40
  "use strict";
41
41
  getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
42
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -64,11 +64,11 @@ var require_validateReport = __commonJS({
64
64
  Object.defineProperty(exports2, "__esModule", { value: true });
65
65
  exports2._validateReport = void 0;
66
66
  var _validateReport2 = (array) => {
67
- const reportable = (path8) => {
67
+ const reportable = (path9) => {
68
68
  if (array.length === 0)
69
69
  return true;
70
70
  const last = array[array.length - 1].path;
71
- return path8.length > last.length || last.substring(0, path8.length) !== path8;
71
+ return path9.length > last.length || last.substring(0, path9.length) !== path9;
72
72
  };
73
73
  return (exceptable, error2) => {
74
74
  var _a;
@@ -124,24 +124,24 @@ var require_createStandardSchema = __commonJS({
124
124
  PathParserState2[PathParserState2["StringKey"] = 2] = "StringKey";
125
125
  PathParserState2[PathParserState2["NumberKey"] = 3] = "NumberKey";
126
126
  })(PathParserState || (PathParserState = {}));
127
- var typiaPathToStandardSchemaPath = (path8) => {
128
- if (!path8.startsWith("$input")) {
129
- throw new Error(`Invalid path: ${JSON.stringify(path8)}`);
127
+ var typiaPathToStandardSchemaPath = (path9) => {
128
+ if (!path9.startsWith("$input")) {
129
+ throw new Error(`Invalid path: ${JSON.stringify(path9)}`);
130
130
  }
131
131
  const segments = [];
132
132
  let currentSegment = "";
133
133
  let state = PathParserState.Start;
134
134
  let index = "$input".length - 1;
135
- while (index < path8.length - 1) {
135
+ while (index < path9.length - 1) {
136
136
  index++;
137
- const char = path8[index];
137
+ const char = path9[index];
138
138
  if (state === PathParserState.Property) {
139
139
  if (char === "." || char === "[") {
140
140
  segments.push({
141
141
  key: currentSegment
142
142
  });
143
143
  state = PathParserState.Start;
144
- } else if (index === path8.length - 1) {
144
+ } else if (index === path9.length - 1) {
145
145
  currentSegment += char;
146
146
  segments.push({
147
147
  key: currentSegment
@@ -159,9 +159,9 @@ var require_createStandardSchema = __commonJS({
159
159
  index += 2;
160
160
  state = PathParserState.Start;
161
161
  } else if (char === "\\") {
162
- currentSegment += path8[index];
162
+ currentSegment += path9[index];
163
163
  index++;
164
- currentSegment += path8[index];
164
+ currentSegment += path9[index];
165
165
  } else {
166
166
  currentSegment += char;
167
167
  }
@@ -176,11 +176,11 @@ var require_createStandardSchema = __commonJS({
176
176
  currentSegment += char;
177
177
  }
178
178
  }
179
- if (state === PathParserState.Start && index < path8.length - 1) {
180
- const newChar = path8[index];
179
+ if (state === PathParserState.Start && index < path9.length - 1) {
180
+ const newChar = path9[index];
181
181
  currentSegment = "";
182
182
  if (newChar === "[") {
183
- if (path8[index + 1] === '"') {
183
+ if (path9[index + 1] === '"') {
184
184
  state = PathParserState.StringKey;
185
185
  index++;
186
186
  currentSegment = '"';
@@ -195,7 +195,7 @@ var require_createStandardSchema = __commonJS({
195
195
  }
196
196
  }
197
197
  if (state !== PathParserState.Start) {
198
- throw new Error(`Failed to parse path: ${JSON.stringify(path8)}`);
198
+ throw new Error(`Failed to parse path: ${JSON.stringify(path9)}`);
199
199
  }
200
200
  return segments;
201
201
  };
@@ -208,7 +208,7 @@ var require_package = __commonJS({
208
208
  module2.exports = {
209
209
  name: "@apps-in-toss/plugins",
210
210
  type: "module",
211
- version: "1.14.0",
211
+ version: "2.0.0",
212
212
  description: "The plugins for Apps In Toss",
213
213
  scripts: {
214
214
  test: "vitest --run",
@@ -245,15 +245,16 @@ var require_package = __commonJS({
245
245
  vitest: "^3.2.4"
246
246
  },
247
247
  dependencies: {
248
- "@apps-in-toss/ait-format": "^1.0.0",
249
- "@granite-js/plugin-core": "0.1.31",
250
- "@granite-js/plugin-micro-frontend": "0.1.31",
251
- "@granite-js/plugin-sentry": "0.1.31",
252
- "@granite-js/utils": "0.1.31",
248
+ "@apps-in-toss/ait-format": "1.0.0",
249
+ "@apps-in-toss/plugin-compat": "workspace:*",
250
+ "@granite-js/plugin-core": "catalog:granite-js",
251
+ "@granite-js/plugin-micro-frontend": "catalog:granite-js",
252
+ "@granite-js/plugin-sentry": "catalog:granite-js",
253
+ "@granite-js/utils": "catalog:granite-js",
253
254
  archiver: "^7.0.1",
254
255
  connect: "^3.7.0",
255
- esbuild: "0.25.5",
256
- execa: "9.3.0",
256
+ esbuild: "catalog:tooling",
257
+ execa: "catalog:tooling",
257
258
  picocolors: "^1.1.1",
258
259
  uuidv7: "^1.0.2"
259
260
  }
@@ -268,6 +269,7 @@ __export(index_exports, {
268
269
  appsInToss: () => appsInToss,
269
270
  appsInTossAppJson: () => appsInTossAppJson,
270
271
  appsInTossCreateArtifact: () => appsInTossCreateArtifact,
272
+ appsInTossCrypto: () => appsInTossCrypto,
271
273
  appsInTossDevServer: () => appsInTossDevServer,
272
274
  appsInTossEsbuildConfig: () => appsInTossEsbuildConfig,
273
275
  appsInTossMetroConfig: () => appsInTossMetroConfig,
@@ -275,7 +277,10 @@ __export(index_exports, {
275
277
  bedrockCompat: () => bedrockCompat,
276
278
  collectDependencyVersions: () => collectDependencyVersions,
277
279
  createArtifact: () => createArtifact,
280
+ cryptoPolyfillContent: () => cryptoPolyfillContent,
281
+ getAppsInTossBuildPlugins: () => getAppsInTossBuildPlugins,
278
282
  getRuntimeSetupScript: () => getRuntimeSetupScript,
283
+ getSdkVersion: () => getSdkVersion,
279
284
  nativeModuleProxyContent: () => nativeModuleProxyContent,
280
285
  reactNativeModuleProxyContent: () => reactNativeModuleProxyContent,
281
286
  requireMicroFrontendRuntime: () => requireMicroFrontendRuntime,
@@ -290,34 +295,38 @@ init_cjs_shims();
290
295
 
291
296
  // src/appsInToss.ts
292
297
  init_cjs_shims();
293
- var import_path5 = __toESM(require("path"), 1);
298
+ var import_path6 = __toESM(require("path"), 1);
299
+ var import_plugin_compat = require("@apps-in-toss/plugin-compat");
294
300
  var import_plugin_micro_frontend = require("@granite-js/plugin-micro-frontend");
295
- var import_utils5 = require("@granite-js/utils");
301
+ var import_utils6 = require("@granite-js/utils");
296
302
 
297
303
  // src/constants.ts
298
304
  init_cjs_shims();
299
- var REACT_NATIVE_VERSION = "0.72.6";
305
+ var REACT_NATIVE_VERSION = "0.84.0";
300
306
  var APP_MANIFEST_NAME = "app.json";
301
307
  var MICRO_FRONTEND_HOST_NAME = "apps-in-toss-host";
302
308
  var MICRO_FRONTEND_REMOTE_NAME = "apps-in-toss-service";
303
309
  var MICRO_FRONTEND_REMOTE_EXPOSE_PATH = "./ServiceEntry";
304
310
  var HOST_CONTEXT_IDENTIFIER = "__appsInTossHost";
305
311
  var SERVICE_CONTEXT_IDENTIFIER = "__appsInToss";
306
- var SHRED_PACKAGES = [
312
+ var getSharedPackages = ({ reactNativeVersion }) => [
307
313
  "@react-native-community/blur",
308
314
  "@react-navigation/native",
309
315
  "@react-navigation/native-stack",
316
+ "@sentry/react-native",
310
317
  "@shopify/flash-list",
311
- "lottie-react-native",
312
318
  "react-native-safe-area-context",
313
319
  "react-native-screens",
314
- "react-native-fast-image",
315
320
  "react-native-svg",
316
321
  "react-native-gesture-handler",
317
322
  "react-native",
318
323
  "react",
319
- "react-native-video",
320
- "react-native-webview"
324
+ "react-native-webview",
325
+ "@granite-js/image",
326
+ "@granite-js/lottie",
327
+ "@granite-js/video",
328
+ ...reactNativeVersion === "0.84" ? ["brick-module", "@react-navigation/elements"] : [],
329
+ ...reactNativeVersion === "0.72" ? ["react-native-fast-image", "lottie-react-native", "react-native-video"] : []
321
330
  ];
322
331
 
323
332
  // src/log.ts
@@ -345,7 +354,8 @@ async function appsInTossAppJson(options) {
345
354
  const appJsonPath = import_path.default.join(packageRoot, ".granite", APP_MANIFEST_NAME);
346
355
  const appJsonObject = {
347
356
  appName,
348
- permissions: options.permissions
357
+ permissions: options.permissions,
358
+ ...options.appType != null ? { appType: options.appType } : {}
349
359
  };
350
360
  await import_node_fs.default.promises.mkdir(import_path.default.dirname(appJsonPath), { recursive: true });
351
361
  try {
@@ -353,7 +363,8 @@ async function appsInTossAppJson(options) {
353
363
  const existingAppJsonObject = JSON.parse(existingAppJson);
354
364
  Object.assign(appJsonObject, existingAppJsonObject, {
355
365
  appName,
356
- permissions: appJsonObject.permissions
366
+ permissions: appJsonObject.permissions,
367
+ ...options.appType != null ? { appType: options.appType } : {}
357
368
  });
358
369
  } catch {
359
370
  }
@@ -443,8 +454,8 @@ async function resolvePackageVersions(rootDir, packageNames) {
443
454
  function createVirtualEntry(packageNames) {
444
455
  return packageNames.map((packageName) => `import '${packageName}';`).join("\n");
445
456
  }
446
- function extractPackagePath(path8, packageName) {
447
- const normalizedPath = normalizePath(path8);
457
+ function extractPackagePath(path9, packageName) {
458
+ const normalizedPath = normalizePath(path9);
448
459
  if (normalizedPath.endsWith("/package.json")) {
449
460
  return normalizedPath.replace(/\/package\.json$/, "");
450
461
  }
@@ -454,8 +465,8 @@ function extractPackagePath(path8, packageName) {
454
465
  }
455
466
  throw new Error(`Failed to extract path: ${packageName}`);
456
467
  }
457
- function normalizePath(path8) {
458
- return path8.replace(/\\/g, "/");
468
+ function normalizePath(path9) {
469
+ return path9.replace(/\\/g, "/");
459
470
  }
460
471
  async function getPackageVersion(packagePath) {
461
472
  const packageJson = JSON.parse(await fs2.readFile(path2.join(packagePath, "package.json"), "utf-8"));
@@ -483,13 +494,14 @@ function getUnityMetaDataEnv() {
483
494
 
484
495
  // src/utils/createArtifact.ts
485
496
  async function createArtifact(options) {
486
- const { bundleFiles, outfile, appJsonPath, reactNativeVersion, sdkVersion, isGame } = options;
497
+ const { bundleFiles, outfile, appJsonPath, reactNativeVersion, sdkVersion, isGame, isWeb } = options;
487
498
  const unityMetaData = getUnityMetaDataEnv();
488
499
  const appJsonContent = await fs3.readFile(appJsonPath, "utf-8");
489
500
  const appJson = JSON.parse(appJsonContent);
490
- const runtime = reactNativeVersion.replace(/\./g, "_");
491
501
  const namedBundleFiles = bundleFiles.map((bundle) => {
492
- const extension = import_path2.default.extname(bundle.path);
502
+ const originalName = import_path2.default.basename(bundle.path);
503
+ const extension = import_path2.default.extname(originalName);
504
+ const runtime = (bundle.runtimeVersion ?? reactNativeVersion).replace(new RegExp(/\./g), "_");
493
505
  return {
494
506
  path: bundle.path,
495
507
  name: `bundle.${bundle.platform}.${runtime}${extension === ".map" ? ".js.map" : extension}`
@@ -501,13 +513,13 @@ async function createArtifact(options) {
501
513
  createdBy: "@apps-in-toss/plugins"
502
514
  });
503
515
  writer.setMetadata({
504
- platform: import_ait_format.PlatformType.REACT_NATIVE,
516
+ platform: isWeb ? import_ait_format.PlatformType.WEB : import_ait_format.PlatformType.REACT_NATIVE,
505
517
  runtimeVersion: reactNativeVersion,
506
518
  isGame,
507
519
  sdkVersion,
508
520
  bundleFiles: namedBundleFiles.map(({ name }) => name),
509
521
  packageJson: options.packageJson,
510
- extra: { unityMetaData }
522
+ extra: { unityMetaData, ...options.extra }
511
523
  });
512
524
  for (const permission of appJson.permissions ?? []) {
513
525
  writer.addPermission(permission.name, permission.access);
@@ -526,7 +538,7 @@ async function createArtifact(options) {
526
538
  }
527
539
 
528
540
  // src/plugins/artifact.ts
529
- function appsInTossCreateArtifact(deploymentId, buildOption) {
541
+ function appsInTossCreateArtifact(deploymentId, buildOption, reactNativeVersion = REACT_NATIVE_VERSION) {
530
542
  const packageRoot = (0, import_utils2.getPackageRoot)();
531
543
  return {
532
544
  name: "apps-in-toss:create-artifact",
@@ -540,7 +552,7 @@ function appsInTossCreateArtifact(deploymentId, buildOption) {
540
552
  log("\uC571 \uBE4C\uB4DC \uC911...");
541
553
  const { dependencies, devDependencies } = await collectDependencyVersions(cwd);
542
554
  const artifactOutfile = await createArtifact({
543
- reactNativeVersion: REACT_NATIVE_VERSION,
555
+ reactNativeVersion,
544
556
  deploymentId,
545
557
  sdkVersion: buildOption.sdkVersion,
546
558
  isGame: buildOption.isGame,
@@ -556,7 +568,8 @@ function appsInTossCreateArtifact(deploymentId, buildOption) {
556
568
  }
557
569
  ]).flat(),
558
570
  outfile: import_path3.default.join(cwd, `${appName}.ait`),
559
- appJsonPath: import_path3.default.join(packageRoot, ".granite", APP_MANIFEST_NAME)
571
+ appJsonPath: import_path3.default.join(packageRoot, ".granite", APP_MANIFEST_NAME),
572
+ isWeb: buildOption.isWeb
560
573
  });
561
574
  if (!artifactOutfile) {
562
575
  throw new Error("\uC544\uD2F0\uD329\uD2B8 \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.");
@@ -724,6 +737,52 @@ function bedrockCompat({ isHost }) {
724
737
  };
725
738
  }
726
739
 
740
+ // src/plugins/crypto.ts
741
+ init_cjs_shims();
742
+ var import_fs2 = __toESM(require("fs"), 1);
743
+ var import_path5 = __toESM(require("path"), 1);
744
+ var import_utils4 = require("@granite-js/utils");
745
+ var cryptoPolyfillContent = `
746
+ (function (global) {
747
+ if (!global.__decrypt &&
748
+ global.nativeModuleProxy &&
749
+ global.nativeModuleProxy.TossCoreCryptoModule &&
750
+ global.nativeModuleProxy.TossCoreCryptoModule.decrypt) {
751
+ global.__decrypt = global.nativeModuleProxy.TossCoreCryptoModule.decrypt;
752
+ }
753
+ })(
754
+ typeof globalThis !== 'undefined'
755
+ ? globalThis
756
+ : typeof global !== 'undefined'
757
+ ? global
758
+ : typeof window !== 'undefined'
759
+ ? window
760
+ : this
761
+ );
762
+ `;
763
+ function appsInTossCrypto({ isHost }) {
764
+ const metroPolyfillPath = import_path5.default.join((0, import_utils4.getLocalTempDirectoryPath)((0, import_utils4.getPackageRoot)()), "metro-crypto-polyfill.js");
765
+ import_fs2.default.writeFileSync(metroPolyfillPath, cryptoPolyfillContent);
766
+ return {
767
+ name: "apps-in-toss-crypto-plugin",
768
+ config: {
769
+ ...isHost ? {
770
+ esbuild: {
771
+ banner: {
772
+ js: cryptoPolyfillContent
773
+ }
774
+ }
775
+ } : {},
776
+ metro: {
777
+ serializer: {
778
+ // Metro 단일 번들 환경에서는 Host/Remote 구분 없이 항상 polyfill 필요
779
+ getPolyfills: () => [metroPolyfillPath]
780
+ }
781
+ }
782
+ }
783
+ };
784
+ }
785
+
727
786
  // src/plugins/devServer.ts
728
787
  init_cjs_shims();
729
788
 
@@ -846,7 +905,7 @@ var __typia_transform__isFormatUuid = __toESM(require_isFormatUuid(), 1);
846
905
  var __typia_transform__validateReport = __toESM(require_validateReport(), 1);
847
906
  var __typia_transform__createStandardSchema = __toESM(require_createStandardSchema(), 1);
848
907
  var validateAppManifest = (() => {
849
- const _io0 = (input) => "string" === typeof input.appName && (Array.isArray(input.permissions) && input.permissions.every((elem) => "object" === typeof elem && null !== elem && _iu0(elem))) && ("object" === typeof input._metadata && null !== input._metadata && _io6(input._metadata));
908
+ const _io0 = (input) => "string" === typeof input.appName && (void 0 === input.appType || "general" === input.appType || "game" === input.appType) && (Array.isArray(input.permissions) && input.permissions.every((elem) => "object" === typeof elem && null !== elem && _iu0(elem))) && ("object" === typeof input._metadata && null !== input._metadata && _io6(input._metadata));
850
909
  const _io1 = (input) => "clipboard" === input.name && ("read" === input.access || "write" === input.access);
851
910
  const _io2 = (input) => "geolocation" === input.name && "access" === input.access;
852
911
  const _io3 = (input) => "contacts" === input.name && ("read" === input.access || "write" === input.access);
@@ -871,6 +930,10 @@ var validateAppManifest = (() => {
871
930
  path: _path + ".appName",
872
931
  expected: "string",
873
932
  value: input.appName
933
+ }), void 0 === input.appType || "general" === input.appType || "game" === input.appType || _report(_exceptionable, {
934
+ path: _path + ".appType",
935
+ expected: '("game" | "general" | undefined)',
936
+ value: input.appType
874
937
  }), (Array.isArray(input.permissions) || _report(_exceptionable, {
875
938
  path: _path + ".permissions",
876
939
  expected: "Array<Permission>",
@@ -1013,7 +1076,7 @@ var validateAppManifest = (() => {
1013
1076
  });
1014
1077
  })();
1015
1078
  var validateAppInTossPluginOptions = (() => {
1016
- const _io0 = (input) => (void 0 === input.appType || "general" === input.appType || "game" === input.appType) && ("object" === typeof input.brand && null !== input.brand && _io1(input.brand)) && (Array.isArray(input.permissions) && input.permissions.every((elem) => "object" === typeof elem && null !== elem && _iu0(elem))) && (void 0 === input.navigationBar || "object" === typeof input.navigationBar && null !== input.navigationBar && false === Array.isArray(input.navigationBar) && _io7(input.navigationBar));
1079
+ const _io0 = (input) => (void 0 === input.target || "0.72.6" === input.target || "0.84.0" === input.target) && (void 0 === input.appType || "general" === input.appType || "game" === input.appType) && ("object" === typeof input.brand && null !== input.brand && _io1(input.brand)) && (Array.isArray(input.permissions) && input.permissions.every((elem) => "object" === typeof elem && null !== elem && _iu0(elem))) && (void 0 === input.navigationBar || "object" === typeof input.navigationBar && null !== input.navigationBar && false === Array.isArray(input.navigationBar) && _io7(input.navigationBar));
1017
1080
  const _io1 = (input) => "string" === typeof input.displayName && "string" === typeof input.primaryColor && "string" === typeof input.icon;
1018
1081
  const _io2 = (input) => "clipboard" === input.name && ("read" === input.access || "write" === input.access);
1019
1082
  const _io3 = (input) => "geolocation" === input.name && "access" === input.access;
@@ -1047,7 +1110,11 @@ var validateAppInTossPluginOptions = (() => {
1047
1110
  else
1048
1111
  return false;
1049
1112
  })();
1050
- const _vo0 = (input, _path, _exceptionable = true) => [void 0 === input.appType || "general" === input.appType || "game" === input.appType || _report(_exceptionable, {
1113
+ const _vo0 = (input, _path, _exceptionable = true) => [void 0 === input.target || "0.72.6" === input.target || "0.84.0" === input.target || _report(_exceptionable, {
1114
+ path: _path + ".target",
1115
+ expected: '("0.72.6" | "0.84.0" | undefined)',
1116
+ value: input.target
1117
+ }), void 0 === input.appType || "general" === input.appType || "game" === input.appType || _report(_exceptionable, {
1051
1118
  path: _path + ".appType",
1052
1119
  expected: '("game" | "general" | undefined)',
1053
1120
  value: input.appType
@@ -1278,21 +1345,23 @@ var validateAppInTossPluginOptions = (() => {
1278
1345
  init_cjs_shims();
1279
1346
  var import_uuidv7 = require("uuidv7");
1280
1347
  function generateDeploymentId() {
1348
+ if (process.env.AIT_DEPLOYMENT_ID != null && process.env.AIT_DEPLOYMENT_ID.length > 0) {
1349
+ return process.env.AIT_DEPLOYMENT_ID;
1350
+ }
1281
1351
  return (0, import_uuidv7.uuidv7)();
1282
1352
  }
1283
1353
 
1284
- // src/utils/getSdkVersion.ts
1354
+ // src/utils/getReactNativeTarget.ts
1285
1355
  init_cjs_shims();
1286
- function getSdkVersion() {
1287
- const packageJson = require_package();
1288
- return packageJson.version;
1356
+ function getReactNativeTarget(target) {
1357
+ return target ?? REACT_NATIVE_VERSION;
1289
1358
  }
1290
1359
 
1291
1360
  // src/utils/setupRuntimeSetupScript.ts
1292
1361
  init_cjs_shims();
1293
1362
  var import_node_fs2 = __toESM(require("fs"), 1);
1294
1363
  var import_node_path = __toESM(require("path"), 1);
1295
- var import_utils4 = require("@granite-js/utils");
1364
+ var import_utils5 = require("@granite-js/utils");
1296
1365
  var import_esbuild = require("esbuild");
1297
1366
  function setupRuntimeSetupScript(config) {
1298
1367
  const script = getRuntimeSetupScript(
@@ -1337,7 +1406,7 @@ function getRuntimeSetupScript(metadata, identifier) {
1337
1406
  }).code;
1338
1407
  }
1339
1408
  function writeRuntimeSetupScript(script) {
1340
- const packageRoot = (0, import_utils4.getPackageRoot)();
1409
+ const packageRoot = (0, import_utils5.getPackageRoot)();
1341
1410
  const granitePath = import_node_path.default.join(packageRoot, ".granite");
1342
1411
  try {
1343
1412
  import_node_fs2.default.accessSync(granitePath);
@@ -1409,6 +1478,10 @@ function getMicroFrontendCompatScript() {
1409
1478
  }
1410
1479
 
1411
1480
  // src/appsInToss.ts
1481
+ function getAppsInTossBuildPlugins(options) {
1482
+ const plugins = [appsInTossDevServer(options), appsInTossPostNotice()];
1483
+ return plugins;
1484
+ }
1412
1485
  function withAppsInTossCommon(plugins, options) {
1413
1486
  const { contents, path: envScriptPath } = setupRuntimeSetupScript({
1414
1487
  appType: options.appType,
@@ -1416,6 +1489,8 @@ function withAppsInTossCommon(plugins, options) {
1416
1489
  deploymentId: options.deploymentId,
1417
1490
  navigationBar: options.navigationBar
1418
1491
  });
1492
+ const target = getReactNativeTarget(options.target);
1493
+ const reactNativeVersion = target.startsWith("0.72") ? "0.72" : "0.84";
1419
1494
  return [
1420
1495
  requireMicroFrontendRuntime(),
1421
1496
  (0, import_plugin_micro_frontend.microFrontend)({
@@ -1423,15 +1498,20 @@ function withAppsInTossCommon(plugins, options) {
1423
1498
  exposes: {
1424
1499
  [MICRO_FRONTEND_REMOTE_EXPOSE_PATH]: options.exposePath
1425
1500
  },
1426
- shared: SHRED_PACKAGES,
1501
+ shared: getSharedPackages({
1502
+ reactNativeVersion
1503
+ }),
1427
1504
  reactNativeBasePath: options.reactNativeBasePath
1428
1505
  }),
1429
1506
  appsInTossAppJson(options),
1507
+ (0, import_plugin_compat.reactNativeCompatibilityPlugin)({ target, rootDir: options.root }),
1508
+ (0, import_plugin_compat.reactNativeReverseCompatibilityPlugin)({ target, rootDir: options.root, isHost: false }),
1430
1509
  appsInTossEsbuildConfig(contents),
1431
1510
  appsInTossMetroConfig(envScriptPath),
1432
1511
  bedrockCompat({ isHost: false }),
1512
+ reactNativeVersion === "0.84" ? appsInTossCrypto({ isHost: false }) : null,
1433
1513
  ...plugins
1434
- ];
1514
+ ].filter((plugin) => plugin !== null);
1435
1515
  }
1436
1516
  function appsInToss(options) {
1437
1517
  const result = validateAppInTossPluginOptions(options);
@@ -1440,22 +1520,14 @@ function appsInToss(options) {
1440
1520
  process.exit(1);
1441
1521
  }
1442
1522
  const deploymentId = generateDeploymentId();
1443
- const root = (0, import_utils5.getPackageRoot)();
1444
- const sdkVersion = getSdkVersion();
1445
- const buildOptions = {
1446
- sdkVersion,
1447
- isGame: result.data.appType === "game"
1448
- };
1449
- return withAppsInTossCommon(
1450
- [appsInTossDevServer(options), appsInTossCreateArtifact(deploymentId, buildOptions), appsInTossPostNotice()],
1451
- {
1452
- ...options,
1453
- root,
1454
- deploymentId,
1455
- exposePath: import_path5.default.join(root, "./src/_app.tsx"),
1456
- navigationBar: result.data.navigationBar
1457
- }
1458
- );
1523
+ const root = (0, import_utils6.getPackageRoot)();
1524
+ return withAppsInTossCommon(getAppsInTossBuildPlugins(options), {
1525
+ ...options,
1526
+ root,
1527
+ deploymentId,
1528
+ exposePath: import_path6.default.join(root, "./src/_app.tsx"),
1529
+ navigationBar: result.data.navigationBar
1530
+ });
1459
1531
  }
1460
1532
 
1461
1533
  // src/analytics.ts
@@ -1518,12 +1590,20 @@ function analytics() {
1518
1590
  }
1519
1591
  };
1520
1592
  }
1593
+
1594
+ // src/utils/getSdkVersion.ts
1595
+ init_cjs_shims();
1596
+ function getSdkVersion() {
1597
+ const packageJson = require_package();
1598
+ return packageJson.version;
1599
+ }
1521
1600
  // Annotate the CommonJS export names for ESM import in node:
1522
1601
  0 && (module.exports = {
1523
1602
  analytics,
1524
1603
  appsInToss,
1525
1604
  appsInTossAppJson,
1526
1605
  appsInTossCreateArtifact,
1606
+ appsInTossCrypto,
1527
1607
  appsInTossDevServer,
1528
1608
  appsInTossEsbuildConfig,
1529
1609
  appsInTossMetroConfig,
@@ -1531,7 +1611,10 @@ function analytics() {
1531
1611
  bedrockCompat,
1532
1612
  collectDependencyVersions,
1533
1613
  createArtifact,
1614
+ cryptoPolyfillContent,
1615
+ getAppsInTossBuildPlugins,
1534
1616
  getRuntimeSetupScript,
1617
+ getSdkVersion,
1535
1618
  nativeModuleProxyContent,
1536
1619
  reactNativeModuleProxyContent,
1537
1620
  requireMicroFrontendRuntime,
package/dist/index.d.cts CHANGED
@@ -27,6 +27,7 @@ type CameraPermission = {
27
27
  type Permission = ClipboardPermission | GeolocationPermission | ContactsPermission | PhotosPermission | CameraPermission;
28
28
  type AppManifest = {
29
29
  appName: string;
30
+ appType?: 'general' | 'game';
30
31
  permissions: Permission[];
31
32
  _metadata: {
32
33
  bundleFiles: string[];
@@ -49,6 +50,7 @@ interface InitialAccessoryButton {
49
50
  }
50
51
  declare const validateAppManifest: ((input: unknown) => typia.IValidation<AppManifest>) & _standard_schema_spec.StandardSchemaV1<unknown, AppManifest>;
51
52
  interface AppsInTossPluginOptions {
53
+ target?: '0.72.6' | '0.84.0';
52
54
  appType?: 'general' | 'game';
53
55
  brand: {
54
56
  displayName: string;
@@ -64,6 +66,7 @@ interface AppsInTossPluginOptions {
64
66
  }
65
67
  declare const validateAppInTossPluginOptions: ((input: unknown) => typia.IValidation<AppsInTossPluginOptions>) & _standard_schema_spec.StandardSchemaV1<unknown, AppsInTossPluginOptions>;
66
68
 
69
+ declare function getAppsInTossBuildPlugins(options: Pick<AppsInTossPluginOptions, 'permissions'>): GranitePluginCore[];
67
70
  declare function withAppsInTossCommon(plugins: (GranitePluginCore | Promise<GranitePluginCore>)[], options: AppsInTossPluginOptions & {
68
71
  root: string;
69
72
  deploymentId: string;
@@ -92,6 +95,7 @@ interface CreateArtifactOptions {
92
95
  bundleFiles: {
93
96
  path: string;
94
97
  platform: 'ios' | 'android';
98
+ runtimeVersion?: string;
95
99
  }[];
96
100
  reactNativeVersion: string;
97
101
  sdkVersion: string;
@@ -100,10 +104,12 @@ interface CreateArtifactOptions {
100
104
  outfile: string;
101
105
  deploymentId: AppsInTossBuildMetadata['deploymentId'];
102
106
  packageJson: AppsInTossBuildMetadata['packageJson'];
107
+ isWeb: boolean;
103
108
  additionalFilesToZip?: {
104
109
  path: string;
105
110
  name: string;
106
111
  }[];
112
+ extra?: Record<string, unknown>;
107
113
  }
108
114
  declare function createArtifact(options: CreateArtifactOptions): Promise<string>;
109
115
 
@@ -127,12 +133,15 @@ declare function collectDependencyVersions(rootDir: string): Promise<{
127
133
  devDependencies: Record<string, string>;
128
134
  }>;
129
135
 
130
- declare function appsInTossAppJson(options: Pick<AppsInTossPluginOptions, 'permissions'>): Promise<GranitePluginCore>;
136
+ declare function getSdkVersion(): string;
137
+
138
+ declare function appsInTossAppJson(options: Pick<AppsInTossPluginOptions, 'permissions' | 'appType'>): Promise<GranitePluginCore>;
131
139
 
132
140
  declare function appsInTossCreateArtifact(deploymentId: string, buildOption: {
133
141
  isGame: boolean;
134
142
  sdkVersion: string;
135
- }): GranitePluginCore;
143
+ isWeb: boolean;
144
+ }, reactNativeVersion?: string): GranitePluginCore;
136
145
 
137
146
  declare function appsInTossEsbuildConfig(envScript: string): GranitePluginCore;
138
147
  declare function appsInTossMetroConfig(envScriptPath: string): GranitePluginCore;
@@ -153,10 +162,28 @@ declare function bedrockCompat({ isHost }: {
153
162
  isHost: boolean;
154
163
  }): GranitePluginCore;
155
164
 
165
+ /**
166
+ * TossCoreCryptoModule의 decrypt 메서드를 global.__decrypt로 노출하는 polyfill 코드
167
+ *
168
+ * - global.__decrypt가 이미 존재하는 경우 덮어쓰지 않음
169
+ * - TossCoreCryptoModule.decrypt가 존재할 때만 할당하여 런타임 에러 방지
170
+ */
171
+ declare const cryptoPolyfillContent = "\n(function (global) {\n if (!global.__decrypt &&\n global.nativeModuleProxy &&\n global.nativeModuleProxy.TossCoreCryptoModule &&\n global.nativeModuleProxy.TossCoreCryptoModule.decrypt) {\n global.__decrypt = global.nativeModuleProxy.TossCoreCryptoModule.decrypt;\n }\n})(\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : this\n);\n";
172
+ /**
173
+ * TossCoreCryptoModule을 전역에서 접근 가능하도록 설정하는 Granite 플러그인
174
+ *
175
+ * @param isHost - Host 번들 여부
176
+ * - true: Host 번들 (esbuild banner에 polyfill 포함)
177
+ * - false: Remote 번들 (esbuild banner에서 제외, Host에서 이미 로드됨)
178
+ */
179
+ declare function appsInTossCrypto({ isHost }: {
180
+ isHost: boolean;
181
+ }): GranitePluginCore;
182
+
156
183
  declare function appsInTossDevServer(options: Pick<AppsInTossPluginOptions, 'permissions'>): GranitePluginCore;
157
184
 
158
185
  declare function appsInTossPostNotice(): GranitePluginCore;
159
186
 
160
187
  declare function requireMicroFrontendRuntime(): GranitePluginCore;
161
188
 
162
- export { type AppManifest, type AppsInTossPluginOptions, type BuildResult, type CreateArtifactOptions, type InitialAccessoryButton, type Permission, analytics, appsInToss, appsInTossAppJson, appsInTossCreateArtifact, appsInTossDevServer, appsInTossEsbuildConfig, appsInTossMetroConfig, appsInTossPostNotice, bedrockCompat, collectDependencyVersions, createArtifact, getRuntimeSetupScript, nativeModuleProxyContent, reactNativeModuleProxyContent, requireMicroFrontendRuntime, setupHostRuntimeSetupScript, setupRuntimeSetupScript, validateAppInTossPluginOptions, validateAppManifest, withAppsInTossCommon };
189
+ export { type AppManifest, type AppsInTossPluginOptions, type BuildResult, type CreateArtifactOptions, type InitialAccessoryButton, type Permission, analytics, appsInToss, appsInTossAppJson, appsInTossCreateArtifact, appsInTossCrypto, appsInTossDevServer, appsInTossEsbuildConfig, appsInTossMetroConfig, appsInTossPostNotice, bedrockCompat, collectDependencyVersions, createArtifact, cryptoPolyfillContent, getAppsInTossBuildPlugins, getRuntimeSetupScript, getSdkVersion, nativeModuleProxyContent, reactNativeModuleProxyContent, requireMicroFrontendRuntime, setupHostRuntimeSetupScript, setupRuntimeSetupScript, validateAppInTossPluginOptions, validateAppManifest, withAppsInTossCommon };