@apps-in-toss/plugins 1.14.1 → 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 +152 -71
- package/dist/index.d.cts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +155 -78
- package/dist/internal.cjs +89 -275
- package/dist/internal.d.cts +3 -1
- package/dist/internal.d.ts +3 -1
- package/dist/internal.js +95 -283
- package/package.json +7 -6
package/dist/internal.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,100 +27,47 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// package.json
|
|
34
|
-
var require_package = __commonJS({
|
|
35
|
-
"package.json"(exports2, module2) {
|
|
36
|
-
module2.exports = {
|
|
37
|
-
name: "@apps-in-toss/plugins",
|
|
38
|
-
type: "module",
|
|
39
|
-
version: "1.14.1",
|
|
40
|
-
description: "The plugins for Apps In Toss",
|
|
41
|
-
scripts: {
|
|
42
|
-
test: "vitest --run",
|
|
43
|
-
typecheck: "tsc --noEmit",
|
|
44
|
-
lint: "eslint .",
|
|
45
|
-
build: "tsup"
|
|
46
|
-
},
|
|
47
|
-
main: "./dist/index.cjs",
|
|
48
|
-
module: "./dist/index.js",
|
|
49
|
-
types: "./dist/index.d.ts",
|
|
50
|
-
exports: {
|
|
51
|
-
".": {
|
|
52
|
-
types: "./dist/index.d.ts",
|
|
53
|
-
import: "./dist/index.js",
|
|
54
|
-
require: "./dist/index.cjs"
|
|
55
|
-
},
|
|
56
|
-
"./internal": {
|
|
57
|
-
types: "./dist/internal.d.ts",
|
|
58
|
-
import: "./dist/internal.js",
|
|
59
|
-
require: "./dist/internal.cjs"
|
|
60
|
-
},
|
|
61
|
-
"./package.json": "./package.json"
|
|
62
|
-
},
|
|
63
|
-
files: [
|
|
64
|
-
"dist/**/*"
|
|
65
|
-
],
|
|
66
|
-
devDependencies: {
|
|
67
|
-
"@ryoppippi/unplugin-typia": "^2.6.5",
|
|
68
|
-
"@types/archiver": "^6.0.3",
|
|
69
|
-
"@types/connect": "^3",
|
|
70
|
-
tsup: "^8.4.0",
|
|
71
|
-
typescript: "5.8.3",
|
|
72
|
-
typia: "^9.3.0",
|
|
73
|
-
vitest: "^3.2.4"
|
|
74
|
-
},
|
|
75
|
-
dependencies: {
|
|
76
|
-
"@apps-in-toss/ait-format": "^1.0.0",
|
|
77
|
-
"@granite-js/plugin-core": "0.1.31",
|
|
78
|
-
"@granite-js/plugin-micro-frontend": "0.1.31",
|
|
79
|
-
"@granite-js/plugin-sentry": "0.1.31",
|
|
80
|
-
"@granite-js/utils": "0.1.31",
|
|
81
|
-
archiver: "^7.0.1",
|
|
82
|
-
connect: "^3.7.0",
|
|
83
|
-
esbuild: "0.25.5",
|
|
84
|
-
execa: "9.3.0",
|
|
85
|
-
picocolors: "^1.1.1",
|
|
86
|
-
uuidv7: "^1.0.2"
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
30
|
// src/internal.ts
|
|
93
31
|
var internal_exports = {};
|
|
94
32
|
__export(internal_exports, {
|
|
95
|
-
appsInTossHost: () => appsInTossHost
|
|
33
|
+
appsInTossHost: () => appsInTossHost,
|
|
34
|
+
getAppsInTossHostBuildPlugins: () => getAppsInTossHostBuildPlugins
|
|
96
35
|
});
|
|
97
36
|
module.exports = __toCommonJS(internal_exports);
|
|
98
37
|
|
|
99
|
-
// ../../../.yarn/__virtual__/tsup-virtual-
|
|
38
|
+
// ../../../.yarn/__virtual__/tsup-virtual-5946fc3428/0/cache/tsup-npm-8.4.0-f78d2622c9-c6636ffd6a.zip/node_modules/tsup/assets/cjs_shims.js
|
|
100
39
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
101
40
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
102
41
|
|
|
103
42
|
// src/appsInTossHost.ts
|
|
43
|
+
var import_plugin_compat = require("@apps-in-toss/plugin-compat");
|
|
104
44
|
var import_plugin_micro_frontend = require("@granite-js/plugin-micro-frontend");
|
|
105
45
|
var import_plugin_sentry = require("@granite-js/plugin-sentry");
|
|
46
|
+
var import_utils6 = require("@granite-js/utils");
|
|
106
47
|
|
|
107
48
|
// src/constants.ts
|
|
108
|
-
var REACT_NATIVE_VERSION = "0.
|
|
49
|
+
var REACT_NATIVE_VERSION = "0.84.0";
|
|
109
50
|
var APP_MANIFEST_NAME = "app.json";
|
|
110
51
|
var MICRO_FRONTEND_HOST_NAME = "apps-in-toss-host";
|
|
111
52
|
var HOST_CONTEXT_IDENTIFIER = "__appsInTossHost";
|
|
112
|
-
var
|
|
53
|
+
var getSharedPackages = ({ reactNativeVersion }) => [
|
|
113
54
|
"@react-native-community/blur",
|
|
114
55
|
"@react-navigation/native",
|
|
115
56
|
"@react-navigation/native-stack",
|
|
57
|
+
"@sentry/react-native",
|
|
116
58
|
"@shopify/flash-list",
|
|
117
|
-
"lottie-react-native",
|
|
118
59
|
"react-native-safe-area-context",
|
|
119
60
|
"react-native-screens",
|
|
120
|
-
"react-native-fast-image",
|
|
121
61
|
"react-native-svg",
|
|
122
62
|
"react-native-gesture-handler",
|
|
123
63
|
"react-native",
|
|
124
64
|
"react",
|
|
125
|
-
"react-native-
|
|
126
|
-
"
|
|
65
|
+
"react-native-webview",
|
|
66
|
+
"@granite-js/image",
|
|
67
|
+
"@granite-js/lottie",
|
|
68
|
+
"@granite-js/video",
|
|
69
|
+
...reactNativeVersion === "0.84" ? ["brick-module", "@react-navigation/elements"] : [],
|
|
70
|
+
...reactNativeVersion === "0.72" ? ["react-native-fast-image", "lottie-react-native", "react-native-video"] : []
|
|
127
71
|
];
|
|
128
72
|
|
|
129
73
|
// src/plugins/appJson.ts
|
|
@@ -136,7 +80,8 @@ async function appsInTossAppJson(options) {
|
|
|
136
80
|
const appJsonPath = import_path.default.join(packageRoot, ".granite", APP_MANIFEST_NAME);
|
|
137
81
|
const appJsonObject = {
|
|
138
82
|
appName,
|
|
139
|
-
permissions: options.permissions
|
|
83
|
+
permissions: options.permissions,
|
|
84
|
+
...options.appType != null ? { appType: options.appType } : {}
|
|
140
85
|
};
|
|
141
86
|
await import_node_fs.default.promises.mkdir(import_path.default.dirname(appJsonPath), { recursive: true });
|
|
142
87
|
try {
|
|
@@ -144,7 +89,8 @@ async function appsInTossAppJson(options) {
|
|
|
144
89
|
const existingAppJsonObject = JSON.parse(existingAppJson);
|
|
145
90
|
Object.assign(appJsonObject, existingAppJsonObject, {
|
|
146
91
|
appName,
|
|
147
|
-
permissions: appJsonObject.permissions
|
|
92
|
+
permissions: appJsonObject.permissions,
|
|
93
|
+
...options.appType != null ? { appType: options.appType } : {}
|
|
148
94
|
});
|
|
149
95
|
} catch {
|
|
150
96
|
}
|
|
@@ -168,7 +114,6 @@ async function appsInTossAppJson(options) {
|
|
|
168
114
|
}
|
|
169
115
|
|
|
170
116
|
// src/plugins/artifact.ts
|
|
171
|
-
var import_path3 = __toESM(require("path"), 1);
|
|
172
117
|
var import_plugin_core = require("@granite-js/plugin-core");
|
|
173
118
|
var import_utils2 = require("@granite-js/utils");
|
|
174
119
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
@@ -176,193 +121,13 @@ var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
|
176
121
|
// src/log.ts
|
|
177
122
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
178
123
|
var TAG = import_picocolors.default.bold(import_picocolors.default.cyan("[AppsInToss]"));
|
|
179
|
-
function log(...args) {
|
|
180
|
-
console.log(TAG, ...args);
|
|
181
|
-
}
|
|
182
124
|
|
|
183
125
|
// src/utils/collectDependencyVersions.ts
|
|
184
|
-
var fs2 = __toESM(require("fs/promises"), 1);
|
|
185
|
-
var path2 = __toESM(require("path"), 1);
|
|
186
126
|
var esbuild = __toESM(require("esbuild"), 1);
|
|
187
|
-
async function collectDependencyVersions(rootDir) {
|
|
188
|
-
const packageJsonPath = path2.join(rootDir, "package.json");
|
|
189
|
-
const packageJson = JSON.parse(await fs2.readFile(packageJsonPath, "utf8"));
|
|
190
|
-
const [dependencies, devDependencies] = await Promise.all([
|
|
191
|
-
resolvePackageVersions(rootDir, Object.keys(packageJson.dependencies)),
|
|
192
|
-
resolvePackageVersions(rootDir, Object.keys(packageJson.devDependencies))
|
|
193
|
-
]);
|
|
194
|
-
return { dependencies, devDependencies };
|
|
195
|
-
}
|
|
196
|
-
async function resolvePackageVersions(rootDir, packageNames) {
|
|
197
|
-
const results = {};
|
|
198
|
-
await esbuild.build({
|
|
199
|
-
stdin: { contents: createVirtualEntry(packageNames) },
|
|
200
|
-
bundle: true,
|
|
201
|
-
write: false,
|
|
202
|
-
logLevel: "silent",
|
|
203
|
-
plugins: [
|
|
204
|
-
{
|
|
205
|
-
name: "collect-package-version",
|
|
206
|
-
setup(build2) {
|
|
207
|
-
const RESOLVING = Symbol();
|
|
208
|
-
build2.onResolve({ filter: /.*/ }, async (args) => {
|
|
209
|
-
if (args.pluginData === RESOLVING) {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
const resolveOptions = {
|
|
213
|
-
importer: args.importer,
|
|
214
|
-
kind: args.kind,
|
|
215
|
-
resolveDir: rootDir,
|
|
216
|
-
pluginData: RESOLVING
|
|
217
|
-
};
|
|
218
|
-
let result = await build2.resolve(path2.join(args.path, "package.json"), resolveOptions);
|
|
219
|
-
if (result.errors.length) {
|
|
220
|
-
result = await build2.resolve(args.path, resolveOptions);
|
|
221
|
-
}
|
|
222
|
-
if (result.errors.length) {
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
225
|
-
const packageName = args.path;
|
|
226
|
-
const packagePath = extractPackagePath(result.path, packageName);
|
|
227
|
-
if (packagePath) {
|
|
228
|
-
results[packageName] = await getPackageVersion(packagePath);
|
|
229
|
-
}
|
|
230
|
-
return result;
|
|
231
|
-
});
|
|
232
|
-
build2.onLoad({ filter: /.*/ }, () => ({ contents: "// empty source" }));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
]
|
|
236
|
-
});
|
|
237
|
-
return results;
|
|
238
|
-
}
|
|
239
|
-
function createVirtualEntry(packageNames) {
|
|
240
|
-
return packageNames.map((packageName) => `import '${packageName}';`).join("\n");
|
|
241
|
-
}
|
|
242
|
-
function extractPackagePath(path7, packageName) {
|
|
243
|
-
const normalizedPath = normalizePath(path7);
|
|
244
|
-
if (normalizedPath.endsWith("/package.json")) {
|
|
245
|
-
return normalizedPath.replace(/\/package\.json$/, "");
|
|
246
|
-
}
|
|
247
|
-
const match = normalizedPath.match(new RegExp(`(.*?node_modules/${packageName})/.*$`));
|
|
248
|
-
if (match) {
|
|
249
|
-
return match[1];
|
|
250
|
-
}
|
|
251
|
-
throw new Error(`Failed to extract path: ${packageName}`);
|
|
252
|
-
}
|
|
253
|
-
function normalizePath(path7) {
|
|
254
|
-
return path7.replace(/\\/g, "/");
|
|
255
|
-
}
|
|
256
|
-
async function getPackageVersion(packagePath) {
|
|
257
|
-
const packageJson = JSON.parse(await fs2.readFile(path2.join(packagePath, "package.json"), "utf-8"));
|
|
258
|
-
return packageJson.version;
|
|
259
|
-
}
|
|
260
127
|
|
|
261
128
|
// src/utils/createArtifact.ts
|
|
262
|
-
var fs3 = __toESM(require("fs/promises"), 1);
|
|
263
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
264
129
|
var import_ait_format = require("@apps-in-toss/ait-format");
|
|
265
130
|
|
|
266
|
-
// src/utils/getUnityMetaDataEnv.ts
|
|
267
|
-
function getUnityMetaDataEnv() {
|
|
268
|
-
const metaData = process.env.UNITY_METADATA;
|
|
269
|
-
if (!metaData) return {};
|
|
270
|
-
try {
|
|
271
|
-
return JSON.parse(metaData);
|
|
272
|
-
} catch (e) {
|
|
273
|
-
console.warn("UNITY_METADATA is not a valid JSON:", e);
|
|
274
|
-
return {};
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// src/utils/createArtifact.ts
|
|
279
|
-
async function createArtifact(options) {
|
|
280
|
-
const { bundleFiles, outfile, appJsonPath, reactNativeVersion, sdkVersion, isGame, isWeb } = options;
|
|
281
|
-
const unityMetaData = getUnityMetaDataEnv();
|
|
282
|
-
const appJsonContent = await fs3.readFile(appJsonPath, "utf-8");
|
|
283
|
-
const appJson = JSON.parse(appJsonContent);
|
|
284
|
-
const runtime = reactNativeVersion.replace(/\./g, "_");
|
|
285
|
-
const namedBundleFiles = bundleFiles.map((bundle) => {
|
|
286
|
-
const extension = import_path2.default.extname(bundle.path);
|
|
287
|
-
return {
|
|
288
|
-
path: bundle.path,
|
|
289
|
-
name: `bundle.${bundle.platform}.${runtime}${extension === ".map" ? ".js.map" : extension}`
|
|
290
|
-
};
|
|
291
|
-
});
|
|
292
|
-
const writer = import_ait_format.AppsInTossBundle.writer({
|
|
293
|
-
deploymentId: options.deploymentId,
|
|
294
|
-
appName: appJson.appName,
|
|
295
|
-
createdBy: "@apps-in-toss/plugins"
|
|
296
|
-
});
|
|
297
|
-
writer.setMetadata({
|
|
298
|
-
platform: isWeb ? import_ait_format.PlatformType.WEB : import_ait_format.PlatformType.REACT_NATIVE,
|
|
299
|
-
runtimeVersion: reactNativeVersion,
|
|
300
|
-
isGame,
|
|
301
|
-
sdkVersion,
|
|
302
|
-
bundleFiles: namedBundleFiles.map(({ name }) => name),
|
|
303
|
-
packageJson: options.packageJson,
|
|
304
|
-
extra: { unityMetaData }
|
|
305
|
-
});
|
|
306
|
-
for (const permission of appJson.permissions ?? []) {
|
|
307
|
-
writer.addPermission(permission.name, permission.access);
|
|
308
|
-
}
|
|
309
|
-
for (const bundle of namedBundleFiles) {
|
|
310
|
-
const content = await fs3.readFile(bundle.path);
|
|
311
|
-
writer.addFile(bundle.name, new Uint8Array(content));
|
|
312
|
-
}
|
|
313
|
-
for (const file of options.additionalFilesToZip ?? []) {
|
|
314
|
-
const content = await fs3.readFile(file.path);
|
|
315
|
-
writer.addFile(file.name, new Uint8Array(content));
|
|
316
|
-
}
|
|
317
|
-
const buffer = await writer.toBuffer();
|
|
318
|
-
await fs3.writeFile(outfile, buffer);
|
|
319
|
-
return outfile;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// src/plugins/artifact.ts
|
|
323
|
-
function appsInTossCreateArtifact(deploymentId, buildOption) {
|
|
324
|
-
const packageRoot = (0, import_utils2.getPackageRoot)();
|
|
325
|
-
return {
|
|
326
|
-
name: "apps-in-toss:create-artifact",
|
|
327
|
-
build: {
|
|
328
|
-
order: "post",
|
|
329
|
-
handler: async ({ buildResults, appName, cwd }) => {
|
|
330
|
-
const buildFailed = buildResults.some(import_plugin_core.isBuildFailure);
|
|
331
|
-
if (buildFailed) {
|
|
332
|
-
throw new Error("\uBC88\uB4E4 \uBE4C\uB4DC \uC2E4\uD328");
|
|
333
|
-
}
|
|
334
|
-
log("\uC571 \uBE4C\uB4DC \uC911...");
|
|
335
|
-
const { dependencies, devDependencies } = await collectDependencyVersions(cwd);
|
|
336
|
-
const artifactOutfile = await createArtifact({
|
|
337
|
-
reactNativeVersion: REACT_NATIVE_VERSION,
|
|
338
|
-
deploymentId,
|
|
339
|
-
sdkVersion: buildOption.sdkVersion,
|
|
340
|
-
isGame: buildOption.isGame,
|
|
341
|
-
packageJson: { dependencies, devDependencies },
|
|
342
|
-
bundleFiles: buildResults.filter(import_plugin_core.isBuildSuccess).map(({ outfile, sourcemapOutfile, platform }) => [
|
|
343
|
-
{
|
|
344
|
-
path: outfile,
|
|
345
|
-
platform
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
path: sourcemapOutfile,
|
|
349
|
-
platform
|
|
350
|
-
}
|
|
351
|
-
]).flat(),
|
|
352
|
-
outfile: import_path3.default.join(cwd, `${appName}.ait`),
|
|
353
|
-
appJsonPath: import_path3.default.join(packageRoot, ".granite", APP_MANIFEST_NAME),
|
|
354
|
-
isWeb: buildOption.isWeb
|
|
355
|
-
});
|
|
356
|
-
if (!artifactOutfile) {
|
|
357
|
-
throw new Error("\uC544\uD2F0\uD329\uD2B8 \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.");
|
|
358
|
-
}
|
|
359
|
-
const filename = import_path3.default.basename(artifactOutfile);
|
|
360
|
-
log(`\u2705 ${import_picocolors2.default.green(`${filename}`)} \uBE4C\uB4DC \uC644\uB8CC`);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
131
|
// src/plugins/build.ts
|
|
367
132
|
function appsInTossEsbuildConfig(envScript) {
|
|
368
133
|
return {
|
|
@@ -391,7 +156,7 @@ function appsInTossMetroConfig(envScriptPath) {
|
|
|
391
156
|
|
|
392
157
|
// src/plugins/compat.ts
|
|
393
158
|
var import_fs = __toESM(require("fs"), 1);
|
|
394
|
-
var
|
|
159
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
395
160
|
var import_utils3 = require("@granite-js/utils");
|
|
396
161
|
var nativeModuleProxyContent = `
|
|
397
162
|
(function () {
|
|
@@ -498,7 +263,7 @@ var reactNativeModuleProxyContent = `
|
|
|
498
263
|
);
|
|
499
264
|
`;
|
|
500
265
|
function bedrockCompat({ isHost }) {
|
|
501
|
-
const metroPolyfillContent =
|
|
266
|
+
const metroPolyfillContent = import_path2.default.join((0, import_utils3.getLocalTempDirectoryPath)((0, import_utils3.getPackageRoot)()), "metro-native-module-proxy.js");
|
|
502
267
|
import_fs.default.writeFileSync(metroPolyfillContent, nativeModuleProxyContent);
|
|
503
268
|
return {
|
|
504
269
|
name: "bedrock-compat-plugin",
|
|
@@ -517,6 +282,51 @@ function bedrockCompat({ isHost }) {
|
|
|
517
282
|
};
|
|
518
283
|
}
|
|
519
284
|
|
|
285
|
+
// src/plugins/crypto.ts
|
|
286
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
287
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
288
|
+
var import_utils4 = require("@granite-js/utils");
|
|
289
|
+
var cryptoPolyfillContent = `
|
|
290
|
+
(function (global) {
|
|
291
|
+
if (!global.__decrypt &&
|
|
292
|
+
global.nativeModuleProxy &&
|
|
293
|
+
global.nativeModuleProxy.TossCoreCryptoModule &&
|
|
294
|
+
global.nativeModuleProxy.TossCoreCryptoModule.decrypt) {
|
|
295
|
+
global.__decrypt = global.nativeModuleProxy.TossCoreCryptoModule.decrypt;
|
|
296
|
+
}
|
|
297
|
+
})(
|
|
298
|
+
typeof globalThis !== 'undefined'
|
|
299
|
+
? globalThis
|
|
300
|
+
: typeof global !== 'undefined'
|
|
301
|
+
? global
|
|
302
|
+
: typeof window !== 'undefined'
|
|
303
|
+
? window
|
|
304
|
+
: this
|
|
305
|
+
);
|
|
306
|
+
`;
|
|
307
|
+
function appsInTossCrypto({ isHost }) {
|
|
308
|
+
const metroPolyfillPath = import_path3.default.join((0, import_utils4.getLocalTempDirectoryPath)((0, import_utils4.getPackageRoot)()), "metro-crypto-polyfill.js");
|
|
309
|
+
import_fs2.default.writeFileSync(metroPolyfillPath, cryptoPolyfillContent);
|
|
310
|
+
return {
|
|
311
|
+
name: "apps-in-toss-crypto-plugin",
|
|
312
|
+
config: {
|
|
313
|
+
...isHost ? {
|
|
314
|
+
esbuild: {
|
|
315
|
+
banner: {
|
|
316
|
+
js: cryptoPolyfillContent
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
} : {},
|
|
320
|
+
metro: {
|
|
321
|
+
serializer: {
|
|
322
|
+
// Metro 단일 번들 환경에서는 Host/Remote 구분 없이 항상 polyfill 필요
|
|
323
|
+
getPolyfills: () => [metroPolyfillPath]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
520
330
|
// src/utils/createServerPermissionsMiddleware.ts
|
|
521
331
|
function createServerPermissionsMiddleware(permissions) {
|
|
522
332
|
const parsedPermissions = parsePermissions(permissions);
|
|
@@ -598,19 +408,21 @@ function requireMicroFrontendRuntime() {
|
|
|
598
408
|
// src/utils/generateDeploymentId.ts
|
|
599
409
|
var import_uuidv7 = require("uuidv7");
|
|
600
410
|
function generateDeploymentId() {
|
|
411
|
+
if (process.env.AIT_DEPLOYMENT_ID != null && process.env.AIT_DEPLOYMENT_ID.length > 0) {
|
|
412
|
+
return process.env.AIT_DEPLOYMENT_ID;
|
|
413
|
+
}
|
|
601
414
|
return (0, import_uuidv7.uuidv7)();
|
|
602
415
|
}
|
|
603
416
|
|
|
604
|
-
// src/utils/
|
|
605
|
-
function
|
|
606
|
-
|
|
607
|
-
return packageJson.version;
|
|
417
|
+
// src/utils/getReactNativeTarget.ts
|
|
418
|
+
function getReactNativeTarget(target) {
|
|
419
|
+
return target ?? REACT_NATIVE_VERSION;
|
|
608
420
|
}
|
|
609
421
|
|
|
610
422
|
// src/utils/setupRuntimeSetupScript.ts
|
|
611
423
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
612
424
|
var import_node_path = __toESM(require("path"), 1);
|
|
613
|
-
var
|
|
425
|
+
var import_utils5 = require("@granite-js/utils");
|
|
614
426
|
var import_esbuild = require("esbuild");
|
|
615
427
|
function setupHostRuntimeSetupScript(metadata) {
|
|
616
428
|
const script = getRuntimeSetupScript(metadata, HOST_CONTEXT_IDENTIFIER);
|
|
@@ -640,7 +452,7 @@ function getRuntimeSetupScript(metadata, identifier) {
|
|
|
640
452
|
}).code;
|
|
641
453
|
}
|
|
642
454
|
function writeRuntimeSetupScript(script) {
|
|
643
|
-
const packageRoot = (0,
|
|
455
|
+
const packageRoot = (0, import_utils5.getPackageRoot)();
|
|
644
456
|
const granitePath = import_node_path.default.join(packageRoot, ".granite");
|
|
645
457
|
try {
|
|
646
458
|
import_node_fs2.default.accessSync(granitePath);
|
|
@@ -713,18 +525,18 @@ function getMicroFrontendCompatScript() {
|
|
|
713
525
|
|
|
714
526
|
// src/appsInTossHost.ts
|
|
715
527
|
var PERMISSIONS = [];
|
|
528
|
+
function getAppsInTossHostBuildPlugins() {
|
|
529
|
+
const plugins = [appsInTossDevServer({ permissions: PERMISSIONS })];
|
|
530
|
+
return plugins;
|
|
531
|
+
}
|
|
716
532
|
function appsInTossHost(options) {
|
|
717
533
|
const deploymentId = generateDeploymentId();
|
|
534
|
+
const reactNativeTarget = getReactNativeTarget(options.target);
|
|
535
|
+
const reactNativeVersion = reactNativeTarget.startsWith("0.72") ? "0.72" : "0.84";
|
|
718
536
|
const { contents, path: envFilePath } = setupHostRuntimeSetupScript({
|
|
719
537
|
deploymentId,
|
|
720
538
|
environment: getHostEnvironment()
|
|
721
539
|
});
|
|
722
|
-
const sdkVersion = getSdkVersion();
|
|
723
|
-
const buildOptions = {
|
|
724
|
-
sdkVersion,
|
|
725
|
-
isGame: false,
|
|
726
|
-
isWeb: false
|
|
727
|
-
};
|
|
728
540
|
return [
|
|
729
541
|
requireMicroFrontendRuntime(),
|
|
730
542
|
(0, import_plugin_micro_frontend.microFrontend)({
|
|
@@ -733,19 +545,20 @@ function appsInTossHost(options) {
|
|
|
733
545
|
host: options?.remote?.host ?? "localhost",
|
|
734
546
|
port: options?.remote?.port ?? 8082
|
|
735
547
|
},
|
|
736
|
-
shared:
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
)
|
|
548
|
+
shared: getSharedPackages({
|
|
549
|
+
reactNativeVersion
|
|
550
|
+
}).reduce((prev, curr) => ({ ...prev, [curr]: { eager: true } }), {})
|
|
740
551
|
}),
|
|
552
|
+
(0, import_plugin_compat.reactNativeCompatibilityPlugin)({ target: reactNativeTarget, rootDir: (0, import_utils6.getPackageRoot)() }),
|
|
553
|
+
(0, import_plugin_compat.reactNativeReverseCompatibilityPlugin)({ target: reactNativeTarget, rootDir: (0, import_utils6.getPackageRoot)(), isHost: true }),
|
|
741
554
|
appsInTossAppJson({ permissions: PERMISSIONS }),
|
|
742
|
-
|
|
743
|
-
appsInTossCreateArtifact(deploymentId, buildOptions),
|
|
555
|
+
...getAppsInTossHostBuildPlugins(),
|
|
744
556
|
appsInTossEsbuildConfig(contents),
|
|
745
557
|
appsInTossMetroConfig(envFilePath),
|
|
746
558
|
bedrockCompat({ isHost: true }),
|
|
559
|
+
reactNativeVersion === "0.84" ? appsInTossCrypto({ isHost: true }) : null,
|
|
747
560
|
(0, import_plugin_sentry.sentry)({ useClient: false })
|
|
748
|
-
];
|
|
561
|
+
].filter((plugin) => plugin !== null);
|
|
749
562
|
}
|
|
750
563
|
function getHostEnvironment() {
|
|
751
564
|
const environment = process.env.HOST_ENV;
|
|
@@ -759,5 +572,6 @@ function getHostEnvironment() {
|
|
|
759
572
|
}
|
|
760
573
|
// Annotate the CommonJS export names for ESM import in node:
|
|
761
574
|
0 && (module.exports = {
|
|
762
|
-
appsInTossHost
|
|
575
|
+
appsInTossHost,
|
|
576
|
+
getAppsInTossHostBuildPlugins
|
|
763
577
|
});
|
package/dist/internal.d.cts
CHANGED
|
@@ -5,7 +5,9 @@ interface AppsInTossHostOptions {
|
|
|
5
5
|
host: string;
|
|
6
6
|
port: number;
|
|
7
7
|
}>;
|
|
8
|
+
target?: '0.72.6' | '0.84.0';
|
|
8
9
|
}
|
|
10
|
+
declare function getAppsInTossHostBuildPlugins(): GranitePluginCore[];
|
|
9
11
|
declare function appsInTossHost(options: AppsInTossHostOptions): (GranitePluginCore | Promise<GranitePluginCore>)[];
|
|
10
12
|
|
|
11
|
-
export { type AppsInTossHostOptions, appsInTossHost };
|
|
13
|
+
export { type AppsInTossHostOptions, appsInTossHost, getAppsInTossHostBuildPlugins };
|
package/dist/internal.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ interface AppsInTossHostOptions {
|
|
|
5
5
|
host: string;
|
|
6
6
|
port: number;
|
|
7
7
|
}>;
|
|
8
|
+
target?: '0.72.6' | '0.84.0';
|
|
8
9
|
}
|
|
10
|
+
declare function getAppsInTossHostBuildPlugins(): GranitePluginCore[];
|
|
9
11
|
declare function appsInTossHost(options: AppsInTossHostOptions): (GranitePluginCore | Promise<GranitePluginCore>)[];
|
|
10
12
|
|
|
11
|
-
export { type AppsInTossHostOptions, appsInTossHost };
|
|
13
|
+
export { type AppsInTossHostOptions, appsInTossHost, getAppsInTossHostBuildPlugins };
|