peachsim 0.1.2506 → 0.1.2508
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-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +6 -7
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-XZUDN4QR.mjs → acorn-BRFY4OCR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-G672VJTQ.mjs → chunk-3CASS5F2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5P5VBFTM.mjs → chunk-4J7PR7J4.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-HZA43Q35.mjs → chunk-5CJCFWBO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PONPBEQH.mjs → chunk-5WZSDCC6.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-C6JZCDZY.mjs → chunk-7PDQ4EDO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NX4TD2WN.mjs → chunk-DKMC6FHN.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-DZCYIAFZ.mjs → chunk-EXAZFNI2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CQKLVSDC.mjs → chunk-GYL3CMU5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VA6BZ74L.mjs → chunk-IO3B7PXN.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-4XEEEXVS.mjs → chunk-KQAH6FJT.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-XHQEMGV5.mjs → chunk-KR36EQ3P.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MQ2CPZZE.mjs → chunk-LEUK45QW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TPDNXR5E.mjs → chunk-NAREQ6ED.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WN6HLB6S.mjs → chunk-P5GY2C5O.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XWFTUW6V.mjs → chunk-PMBYCF2T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YZTVS6TA.mjs → chunk-SBQWKKCZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SK3VKARW.mjs → chunk-TZAWNPFU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZLHOXGXM.mjs → chunk-WWCSJUVN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-A3PWDUAH.mjs → chunk-XCVEYOAK.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-2AG2ATQI.mjs → chunk-XVVF7CYX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-REBWFWL6.mjs → chunk-Y6Z3Q2O2.mjs} +12 -12
- package/dist-lib/esm-chunks/{metro-layout-parser-M4H2AKUB.mjs → metro-layout-parser-TERD7GLK.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-GQ2SUIG4.mjs → swift-package-prebuilt-DMFF47JE.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-NRMGEVEK.mjs → swift-sdk-app-module-DJ4DETKZ.mjs} +13 -13
- package/dist-lib/esm-chunks/{swift-sdk-image-6CFRAVEB.mjs → swift-sdk-image-TNCCQDUL.mjs} +13 -13
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-K2TJZRUK.mjs → swift-sdk-image-producer-GQK57FF3.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +2 -2
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +10 -11
- package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +160 -131
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +79 -79
- package/dist-lib/public-origins-lib.json +72 -70
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +7 -7
- package/dist-lib/skills.cjs +10 -11
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +10 -10
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +5 -5
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +7 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/kotlin-module.ts +2 -3
package/dist-lib/kotlin-host.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2508 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1001,16 +1001,16 @@ async function resolveAndroidGradleSources(request) {
|
|
|
1001
1001
|
includeDependencySources = false
|
|
1002
1002
|
} = request;
|
|
1003
1003
|
if (projectDirs.length === 0) return [];
|
|
1004
|
-
if (!
|
|
1004
|
+
if (!import_node_path11.default.isAbsolute(root) || projectDirs.some((dir) => !import_node_path11.default.isAbsolute(dir)))
|
|
1005
1005
|
throw new Error("Android Gradle source selection requires absolute project paths");
|
|
1006
1006
|
if (!variant) throw new Error("Android Gradle source selection requires a variant");
|
|
1007
|
-
root =
|
|
1008
|
-
const projects = [...new Set(projectDirs.map((dir) =>
|
|
1009
|
-
const parent =
|
|
1010
|
-
|
|
1011
|
-
const work =
|
|
1012
|
-
const task = `peachAndroidSources${(0,
|
|
1013
|
-
const script =
|
|
1007
|
+
root = import_node_fs12.default.realpathSync(root);
|
|
1008
|
+
const projects = [...new Set(projectDirs.map((dir) => import_node_fs12.default.realpathSync(dir)))];
|
|
1009
|
+
const parent = import_node_path11.default.join(kotlinHome(), "gradle-sources");
|
|
1010
|
+
import_node_fs12.default.mkdirSync(parent, { recursive: true });
|
|
1011
|
+
const work = import_node_fs12.default.mkdtempSync(import_node_path11.default.join(parent, ".query-"));
|
|
1012
|
+
const task = `peachAndroidSources${(0, import_node_crypto8.randomBytes)(8).toString("hex")}`;
|
|
1013
|
+
const script = import_node_path11.default.join(work, "sources.gradle");
|
|
1014
1014
|
const encoded = Buffer.from(
|
|
1015
1015
|
JSON.stringify({
|
|
1016
1016
|
root,
|
|
@@ -1024,12 +1024,12 @@ async function resolveAndroidGradleSources(request) {
|
|
|
1024
1024
|
task
|
|
1025
1025
|
})
|
|
1026
1026
|
).toString("base64");
|
|
1027
|
-
|
|
1027
|
+
import_node_fs12.default.writeFileSync(script, modelQuery.replace("__PEACH_REQUEST__", encoded));
|
|
1028
1028
|
try {
|
|
1029
1029
|
await run4(
|
|
1030
1030
|
"bash",
|
|
1031
1031
|
[
|
|
1032
|
-
|
|
1032
|
+
import_node_path11.default.join(root, "gradlew"),
|
|
1033
1033
|
"--init-script",
|
|
1034
1034
|
script,
|
|
1035
1035
|
`${task}All`,
|
|
@@ -1048,19 +1048,19 @@ async function resolveAndroidGradleSources(request) {
|
|
|
1048
1048
|
);
|
|
1049
1049
|
return projects.map((projectDir, index) => {
|
|
1050
1050
|
const value = JSON.parse(
|
|
1051
|
-
|
|
1051
|
+
import_node_fs12.default.readFileSync(import_node_path11.default.join(work, `${index}.json`), "utf8")
|
|
1052
1052
|
);
|
|
1053
1053
|
if (!isRecord(value) || value.projectDir !== projectDir || value.variant !== variant || typeof value.projectPath !== "string" || value.applicationId !== null && typeof value.applicationId !== "string" || typeof value.namespace !== "string" || !value.namespace || value.targetSdk !== null && (typeof value.targetSdk !== "number" || !Number.isInteger(value.targetSdk) || value.targetSdk <= 0))
|
|
1054
1054
|
throw new Error("Gradle printed an invalid Android project source model");
|
|
1055
1055
|
const paths = (field) => {
|
|
1056
1056
|
const list = value[field];
|
|
1057
|
-
if (!Array.isArray(list) || !list.every((file) => typeof file === "string" &&
|
|
1057
|
+
if (!Array.isArray(list) || !list.every((file) => typeof file === "string" && import_node_path11.default.isAbsolute(file)))
|
|
1058
1058
|
throw new Error(`Gradle printed invalid Android ${field} paths`);
|
|
1059
1059
|
return list.map(String);
|
|
1060
1060
|
};
|
|
1061
1061
|
const linkedResource = (field) => {
|
|
1062
1062
|
const file = value[field];
|
|
1063
|
-
if (typeof file !== "string" || !
|
|
1063
|
+
if (typeof file !== "string" || !import_node_path11.default.isAbsolute(file) || !import_node_fs12.default.statSync(file, { throwIfNoEntry: false })?.isFile())
|
|
1064
1064
|
throw new Error(`Gradle did not produce ${field} for ${projectDir}:${variant}`);
|
|
1065
1065
|
return file;
|
|
1066
1066
|
};
|
|
@@ -1109,14 +1109,14 @@ async function resolveAndroidGradleSources(request) {
|
|
|
1109
1109
|
};
|
|
1110
1110
|
});
|
|
1111
1111
|
} finally {
|
|
1112
|
-
|
|
1112
|
+
import_node_fs12.default.rmSync(work, { recursive: true, force: true });
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
function readDependencySources(value) {
|
|
1116
1116
|
if (!Array.isArray(value)) throw new Error("Gradle printed invalid dependency sources");
|
|
1117
1117
|
const coordinates = /* @__PURE__ */ new Set();
|
|
1118
1118
|
return value.map((entry) => {
|
|
1119
|
-
if (!isRecord(entry) || typeof entry.group !== "string" || !entry.group || typeof entry.name !== "string" || !entry.name || typeof entry.version !== "string" || !entry.version || typeof entry.archive !== "string" || !
|
|
1119
|
+
if (!isRecord(entry) || typeof entry.group !== "string" || !entry.group || typeof entry.name !== "string" || !entry.name || typeof entry.version !== "string" || !entry.version || typeof entry.archive !== "string" || !import_node_path11.default.isAbsolute(entry.archive) || !import_node_fs12.default.statSync(entry.archive, { throwIfNoEntry: false })?.isFile())
|
|
1120
1120
|
throw new Error("Gradle printed an invalid dependency sources archive");
|
|
1121
1121
|
const coordinate = `${entry.group}:${entry.name}:${entry.version}`;
|
|
1122
1122
|
if (coordinates.has(coordinate))
|
|
@@ -1130,19 +1130,19 @@ function readDependencySources(value) {
|
|
|
1130
1130
|
};
|
|
1131
1131
|
});
|
|
1132
1132
|
}
|
|
1133
|
-
var
|
|
1133
|
+
var import_node_child_process8, import_node_crypto8, import_node_fs12, import_node_path11, import_node_util5, run4, modelQuery;
|
|
1134
1134
|
var init_android_gradle_sources = __esm({
|
|
1135
1135
|
"src/android-gradle-sources.ts"() {
|
|
1136
1136
|
"use strict";
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1137
|
+
import_node_child_process8 = require("node:child_process");
|
|
1138
|
+
import_node_crypto8 = require("node:crypto");
|
|
1139
|
+
import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
1140
|
+
import_node_path11 = __toESM(require("node:path"), 1);
|
|
1141
|
+
import_node_util5 = require("node:util");
|
|
1142
1142
|
init_forked_script_contract();
|
|
1143
1143
|
init_is_record();
|
|
1144
1144
|
init_kotlin_toolchain();
|
|
1145
|
-
run4 = (0,
|
|
1145
|
+
run4 = (0, import_node_util5.promisify)(import_node_child_process8.execFile);
|
|
1146
1146
|
modelQuery = `
|
|
1147
1147
|
import groovy.json.JsonOutput
|
|
1148
1148
|
import groovy.json.JsonSlurper
|
|
@@ -1324,12 +1324,12 @@ __export(kotlin_host_exports, {
|
|
|
1324
1324
|
serveKotlinRequest: () => serveKotlinRequest
|
|
1325
1325
|
});
|
|
1326
1326
|
module.exports = __toCommonJS(kotlin_host_exports);
|
|
1327
|
-
var
|
|
1328
|
-
var
|
|
1329
|
-
var
|
|
1327
|
+
var import_node_child_process9 = require("node:child_process");
|
|
1328
|
+
var import_node_crypto9 = require("node:crypto");
|
|
1329
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
1330
1330
|
var import_node_module = require("node:module");
|
|
1331
|
-
var
|
|
1332
|
-
var
|
|
1331
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
1332
|
+
var import_node_util6 = require("node:util");
|
|
1333
1333
|
|
|
1334
1334
|
// ../peach-globals/src/kotlinDiscoveryContract.ts
|
|
1335
1335
|
var KOTLIN_PACKAGE_PATH = "/__peach/kotlin-package";
|
|
@@ -1909,10 +1909,9 @@ function viewModelClasses(rows) {
|
|
|
1909
1909
|
}
|
|
1910
1910
|
|
|
1911
1911
|
// src/kotlin-module.ts
|
|
1912
|
-
var
|
|
1913
|
-
var
|
|
1914
|
-
var
|
|
1915
|
-
var import_node_url = require("node:url");
|
|
1912
|
+
var import_node_crypto7 = require("node:crypto");
|
|
1913
|
+
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
1914
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
1916
1915
|
|
|
1917
1916
|
// cli/standalone.ts
|
|
1918
1917
|
var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_STANDALONE__;
|
|
@@ -1920,36 +1919,66 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
1920
1919
|
// src/kotlin-module.ts
|
|
1921
1920
|
init_home_paths();
|
|
1922
1921
|
init_is_record();
|
|
1922
|
+
|
|
1923
|
+
// src/swift-toolchain.ts
|
|
1924
|
+
var import_node_child_process7 = require("node:child_process");
|
|
1925
|
+
var import_node_crypto6 = require("node:crypto");
|
|
1926
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
1927
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
1928
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
1929
|
+
var import_promises3 = require("node:stream/promises");
|
|
1930
|
+
var import_node_url = require("node:url");
|
|
1931
|
+
var import_node_util4 = require("node:util");
|
|
1932
|
+
var import_node_zlib3 = __toESM(require("node:zlib"), 1);
|
|
1933
|
+
|
|
1934
|
+
// src/swiftTargetContract.ts
|
|
1935
|
+
var wasmThreadFlags = [
|
|
1936
|
+
"-pthread",
|
|
1937
|
+
"-matomics",
|
|
1938
|
+
"-mbulk-memory",
|
|
1939
|
+
"-ftls-model=local-exec"
|
|
1940
|
+
];
|
|
1941
|
+
var swiftWasmThreadFlags = wasmThreadFlags.flatMap((flag) => ["-Xcc", flag]);
|
|
1942
|
+
|
|
1943
|
+
// src/swift-toolchain.ts
|
|
1944
|
+
function peachsimPackageRoot() {
|
|
1945
|
+
let dir = __sootsim_import_meta_dirname;
|
|
1946
|
+
while (!import_node_fs10.default.existsSync(import_node_path9.default.join(dir, "package.json")) && dir !== import_node_path9.default.dirname(dir))
|
|
1947
|
+
dir = import_node_path9.default.dirname(dir);
|
|
1948
|
+
return dir;
|
|
1949
|
+
}
|
|
1950
|
+
var SWIFT_CACHE_HOLD_MS = 7 * 24 * 36e5;
|
|
1951
|
+
|
|
1952
|
+
// src/kotlin-module.ts
|
|
1923
1953
|
var installedRoot;
|
|
1924
1954
|
function peachKotlinModuleRoot() {
|
|
1925
|
-
if (!IS_STANDALONE)
|
|
1926
|
-
return import_node_path9.default.resolve(import_node_path9.default.dirname((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)), "..", "kotlin");
|
|
1955
|
+
if (!IS_STANDALONE) return import_node_path10.default.join(peachsimPackageRoot(), "kotlin");
|
|
1927
1956
|
if (installedRoot) return installedRoot;
|
|
1928
1957
|
const files = JSON.parse(__PEACH_BUNDLED_KOTLIN__);
|
|
1929
|
-
const digest = (0,
|
|
1930
|
-
const parent =
|
|
1931
|
-
const root =
|
|
1932
|
-
|
|
1933
|
-
if (!
|
|
1934
|
-
const pending =
|
|
1958
|
+
const digest = (0, import_node_crypto7.createHash)("sha256").update(__PEACH_BUNDLED_KOTLIN__).digest("hex");
|
|
1959
|
+
const parent = import_node_path10.default.join(rnxHomeDir(), "kotlin", "modules");
|
|
1960
|
+
const root = import_node_path10.default.join(parent, digest);
|
|
1961
|
+
import_node_fs11.default.mkdirSync(parent, { recursive: true });
|
|
1962
|
+
if (!import_node_fs11.default.existsSync(root)) {
|
|
1963
|
+
const pending = import_node_fs11.default.mkdtempSync(import_node_path10.default.join(parent, ".install-"));
|
|
1935
1964
|
try {
|
|
1936
1965
|
for (const [name, contents] of Object.entries(files)) {
|
|
1937
|
-
const file =
|
|
1938
|
-
|
|
1939
|
-
|
|
1966
|
+
const file = import_node_path10.default.join(pending, name);
|
|
1967
|
+
import_node_fs11.default.mkdirSync(import_node_path10.default.dirname(file), { recursive: true });
|
|
1968
|
+
import_node_fs11.default.writeFileSync(file, Buffer.from(contents, "base64"));
|
|
1940
1969
|
}
|
|
1941
1970
|
try {
|
|
1942
|
-
|
|
1971
|
+
import_node_fs11.default.renameSync(pending, root);
|
|
1943
1972
|
} catch (error) {
|
|
1944
1973
|
if (!isRecord(error) || error.code !== "EEXIST" && error.code !== "ENOTEMPTY")
|
|
1945
1974
|
throw error;
|
|
1946
1975
|
}
|
|
1947
1976
|
} finally {
|
|
1948
|
-
|
|
1977
|
+
import_node_fs11.default.rmSync(pending, { recursive: true, force: true });
|
|
1949
1978
|
}
|
|
1950
1979
|
}
|
|
1951
1980
|
for (const [name, contents] of Object.entries(files)) {
|
|
1952
|
-
if (!
|
|
1981
|
+
if (!import_node_fs11.default.readFileSync(import_node_path10.default.join(root, name)).equals(Buffer.from(contents, "base64")))
|
|
1953
1982
|
throw new Error(`packaged Kotlin module differs from this CLI: ${name}`);
|
|
1954
1983
|
}
|
|
1955
1984
|
installedRoot = root;
|
|
@@ -1957,20 +1986,20 @@ function peachKotlinModuleRoot() {
|
|
|
1957
1986
|
}
|
|
1958
1987
|
|
|
1959
1988
|
// src/kotlin-host.ts
|
|
1960
|
-
var run5 = (0,
|
|
1989
|
+
var run5 = (0, import_node_util6.promisify)(import_node_child_process9.execFile);
|
|
1961
1990
|
function loadKotlinSdk(moduleRoot, toolchain) {
|
|
1962
1991
|
return installKotlinSdkArchive(
|
|
1963
|
-
|
|
1992
|
+
import_node_fs13.default.readFileSync(import_node_path12.default.join(moduleRoot, "sdk.tar.gz")),
|
|
1964
1993
|
toolchain.compiler
|
|
1965
1994
|
);
|
|
1966
1995
|
}
|
|
1967
1996
|
var KOTLIN_ARTIFACT_PREFIX = "/__peach/kotlin-artifact/";
|
|
1968
1997
|
function appKotlinLanguage(root) {
|
|
1969
|
-
const reactNative =
|
|
1970
|
-
(0, import_node_module.createRequire)(
|
|
1998
|
+
const reactNative = import_node_path12.default.dirname(
|
|
1999
|
+
(0, import_node_module.createRequire)(import_node_path12.default.join(root, "package.json")).resolve("react-native/package.json")
|
|
1971
2000
|
);
|
|
1972
|
-
const versions =
|
|
1973
|
-
|
|
2001
|
+
const versions = import_node_fs13.default.readFileSync(
|
|
2002
|
+
import_node_path12.default.join(reactNative, "gradle", "libs.versions.toml"),
|
|
1974
2003
|
"utf8"
|
|
1975
2004
|
);
|
|
1976
2005
|
const match = /^kotlin\s*=\s*"(\d+)\.(\d+)/m.exec(versions);
|
|
@@ -1992,9 +2021,9 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
1992
2021
|
function kotlinSources(root, skip = SKIP_DIRS) {
|
|
1993
2022
|
const sources = [];
|
|
1994
2023
|
const walk = (dir) => {
|
|
1995
|
-
for (const entry of
|
|
2024
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true })) {
|
|
1996
2025
|
if (entry.name.startsWith(".") || skip.has(entry.name)) continue;
|
|
1997
|
-
const full =
|
|
2026
|
+
const full = import_node_path12.default.join(dir, entry.name);
|
|
1998
2027
|
if (entry.isDirectory()) walk(full);
|
|
1999
2028
|
else if (entry.isFile() && entry.name.endsWith(".kt")) sources.push(full);
|
|
2000
2029
|
}
|
|
@@ -2064,7 +2093,7 @@ function entrySource(ids) {
|
|
|
2064
2093
|
var BUILD_FORMAT = 23;
|
|
2065
2094
|
var builds = /* @__PURE__ */ new Map();
|
|
2066
2095
|
function buildsDir() {
|
|
2067
|
-
return
|
|
2096
|
+
return import_node_path12.default.join(kotlinHome(), "builds");
|
|
2068
2097
|
}
|
|
2069
2098
|
async function kotlinArtifact(root, moduleRoot, origin, target = "app") {
|
|
2070
2099
|
const { kotlinSourceId, nativeSourceContract, renderKotlinSourceGlue } = await import("vxrn/native-source-contract");
|
|
@@ -2077,7 +2106,7 @@ async function kotlinArtifact(root, moduleRoot, origin, target = "app") {
|
|
|
2077
2106
|
const viewIds = [];
|
|
2078
2107
|
let usesCompose = false;
|
|
2079
2108
|
for (const file of sources) {
|
|
2080
|
-
const source =
|
|
2109
|
+
const source = import_node_fs13.default.readFileSync(file, "utf8");
|
|
2081
2110
|
if (/\bandroidx\.compose\./.test(source)) usesCompose = true;
|
|
2082
2111
|
const contract = nativeSourceContract(file, source);
|
|
2083
2112
|
if (contract.modules.length === 0 && contract.views.length === 0) continue;
|
|
@@ -2167,11 +2196,11 @@ function readExpoTypes(output) {
|
|
|
2167
2196
|
}
|
|
2168
2197
|
var toolScans = /* @__PURE__ */ new Map();
|
|
2169
2198
|
async function scanSources(tool, parse3, toolchain, moduleRoot, files) {
|
|
2170
|
-
const digest = (0,
|
|
2199
|
+
const digest = (0, import_node_crypto9.createHash)("sha256").update(JSON.stringify(toolchain.compiler));
|
|
2171
2200
|
const sdk = await loadKotlinSdk(moduleRoot, toolchain);
|
|
2172
|
-
digest.update(
|
|
2201
|
+
digest.update(import_node_fs13.default.readFileSync(import_node_path12.default.join(moduleRoot, "sdk.tar.gz")));
|
|
2173
2202
|
digest.update(tool);
|
|
2174
|
-
for (const file of files) digest.update(`${file}\0${
|
|
2203
|
+
for (const file of files) digest.update(`${file}\0${import_node_fs13.default.readFileSync(file, "utf8")}\0`);
|
|
2175
2204
|
const key = digest.digest("hex");
|
|
2176
2205
|
let scan = toolScans.get(key);
|
|
2177
2206
|
if (!scan) {
|
|
@@ -2186,7 +2215,7 @@ async function scanSources(tool, parse3, toolchain, moduleRoot, files) {
|
|
|
2186
2215
|
async function scanExpoTypes(toolchain, moduleRoot, sources) {
|
|
2187
2216
|
const candidates = sources.filter(
|
|
2188
2217
|
(file) => /\bRecord\b|\benum\s+class\b|\bExpoComposeView\b|\bExpoView\b|\bComposeProps\b|:\s*(?:[A-Za-z0-9_.]+\.)?(?:View|FrameLayout|LinearLayout|ViewGroup)\b/.test(
|
|
2189
|
-
|
|
2218
|
+
import_node_fs13.default.readFileSync(file, "utf8")
|
|
2190
2219
|
)
|
|
2191
2220
|
);
|
|
2192
2221
|
if (candidates.length === 0) return [];
|
|
@@ -2375,7 +2404,7 @@ function expoTypeSources(files) {
|
|
|
2375
2404
|
)
|
|
2376
2405
|
];
|
|
2377
2406
|
if (edits.length > 0 || views.length > 0) {
|
|
2378
|
-
let text =
|
|
2407
|
+
let text = import_node_fs13.default.readFileSync(file.file, "utf8").replaceAll("\r\n", "\n");
|
|
2379
2408
|
for (const { range, owner, field } of edits.sort((a, b) => b.range[0] - a.range[0]))
|
|
2380
2409
|
text = `${text.slice(0, range[0])}dev.peach.expo.PeachExpoTypes.initial(${owner}::class, ${literal(field.key)}, ${field.required}) { ${text.slice(range[0], range[1])} }${text.slice(range[1])}`;
|
|
2381
2410
|
if (views.length > 0) {
|
|
@@ -2391,7 +2420,7 @@ function expoTypeSources(files) {
|
|
|
2391
2420
|
`${file.package ? `${file.package}.` : ""}peachExpoViews${index}()`
|
|
2392
2421
|
);
|
|
2393
2422
|
}
|
|
2394
|
-
const name = `PeachExpoSource_${index}_${
|
|
2423
|
+
const name = `PeachExpoSource_${index}_${import_node_path12.default.basename(file.file)}`;
|
|
2395
2424
|
generated[name] = text;
|
|
2396
2425
|
origins[name] = file.file;
|
|
2397
2426
|
}
|
|
@@ -2433,7 +2462,7 @@ async function expoKotlinArtifact(root, moduleRoot, origin, modules) {
|
|
|
2433
2462
|
const language = appKotlinLanguage(root);
|
|
2434
2463
|
const scanned = await scanExpoTypes(toolchain, moduleRoot, modules.sources);
|
|
2435
2464
|
const usesCompose = scanned.some((file) => file.views.length > 0) || modules.sources.some(
|
|
2436
|
-
(file) => /\bandroidx\.compose\./.test(
|
|
2465
|
+
(file) => /\bandroidx\.compose\./.test(import_node_fs13.default.readFileSync(file, "utf8"))
|
|
2437
2466
|
);
|
|
2438
2467
|
const types = expoTypeSources(scanned);
|
|
2439
2468
|
const rewritten = new Set(Object.values(types.origins));
|
|
@@ -2664,7 +2693,7 @@ function appResourceSources(app) {
|
|
|
2664
2693
|
entries: app.drawables.map((drawable) => ({
|
|
2665
2694
|
name: drawable.name,
|
|
2666
2695
|
init: `listOf(
|
|
2667
|
-
${drawable.files.map((file) => drawableInit(file,
|
|
2696
|
+
${drawable.files.map((file) => drawableInit(file, import_node_path12.default.relative(app.moduleDir, file.file))).join(",\n")}
|
|
2668
2697
|
)`
|
|
2669
2698
|
}))
|
|
2670
2699
|
},
|
|
@@ -2788,7 +2817,7 @@ function drawableInit(drawable, file) {
|
|
|
2788
2817
|
if (drawable.kind === "xml") return `PeachDrawable.Xml(${where})`;
|
|
2789
2818
|
if (drawable.kind === "bitmap")
|
|
2790
2819
|
return `PeachDrawable.Bitmap(${where}, ${drawable.ninePatch}, ${literal(
|
|
2791
|
-
|
|
2820
|
+
import_node_fs13.default.readFileSync(drawable.file).toString("base64")
|
|
2792
2821
|
)})`;
|
|
2793
2822
|
const vector = drawable.vector;
|
|
2794
2823
|
const float = (value) => `${value}f`;
|
|
@@ -2853,8 +2882,8 @@ async function compileKotlin(input, origin) {
|
|
|
2853
2882
|
javaSpecs = []
|
|
2854
2883
|
} = input;
|
|
2855
2884
|
const sdk = await loadKotlinSdk(moduleRoot, toolchain);
|
|
2856
|
-
const plugin =
|
|
2857
|
-
const sdkLibrary =
|
|
2885
|
+
const plugin = import_node_path12.default.join(sdk.root, "plugin.jar");
|
|
2886
|
+
const sdkLibrary = import_node_path12.default.join(sdk.root, `${sdkProfile}.klib`);
|
|
2858
2887
|
const javaRead = javaSpecs.length ? await readJavaModuleSpecs(javaSpecs, sdk.root, await ensureToolchain(toolchain)) : null;
|
|
2859
2888
|
const java = javaRead && javaRead.specs.some((spec) => !spec.application) ? { ...javaRead, specs: javaRead.specs.filter((spec) => !spec.application) } : null;
|
|
2860
2889
|
const applicationJava = javaRead?.specs.filter((spec) => spec.application) ?? [];
|
|
@@ -2882,10 +2911,10 @@ async function compileKotlin(input, origin) {
|
|
|
2882
2911
|
};
|
|
2883
2912
|
const inputs = sources.map((file) => ({
|
|
2884
2913
|
file,
|
|
2885
|
-
bytes:
|
|
2914
|
+
bytes: import_node_fs13.default.readFileSync(file)
|
|
2886
2915
|
}));
|
|
2887
2916
|
const { composeArchive, ...compilerInputs } = toolchain;
|
|
2888
|
-
const digest = (0,
|
|
2917
|
+
const digest = (0, import_node_crypto9.createHash)("sha256");
|
|
2889
2918
|
digest.update(
|
|
2890
2919
|
JSON.stringify({
|
|
2891
2920
|
format: BUILD_FORMAT,
|
|
@@ -2899,7 +2928,7 @@ async function compileKotlin(input, origin) {
|
|
|
2899
2928
|
})
|
|
2900
2929
|
);
|
|
2901
2930
|
for (const { file, bytes } of inputs)
|
|
2902
|
-
digest.update(
|
|
2931
|
+
digest.update(import_node_path12.default.relative(root, file)).update("\0").update(bytes).update("\0");
|
|
2903
2932
|
if (viewModels) digest.update(viewModels.toolClass);
|
|
2904
2933
|
for (const [name, text] of Object.entries(generated))
|
|
2905
2934
|
digest.update(`${name}\0${text}\0`);
|
|
@@ -2908,28 +2937,28 @@ async function compileKotlin(input, origin) {
|
|
|
2908
2937
|
url: `${origin}${KOTLIN_ARTIFACT_PREFIX}${hash}/app.mjs`,
|
|
2909
2938
|
hash
|
|
2910
2939
|
};
|
|
2911
|
-
const out =
|
|
2912
|
-
if (
|
|
2940
|
+
const out = import_node_path12.default.join(buildsDir(), hash);
|
|
2941
|
+
if (import_node_fs13.default.existsSync(import_node_path12.default.join(out, "js", "app.wasm"))) return artifact;
|
|
2913
2942
|
const pending = builds.get(hash);
|
|
2914
2943
|
if (pending) return pending;
|
|
2915
2944
|
const build = (async () => {
|
|
2916
2945
|
const ready = await ensureToolchain(toolchain);
|
|
2917
2946
|
const { kotlinc } = ready;
|
|
2918
|
-
const libraries = [...ready.libraries, sdkLibrary,
|
|
2947
|
+
const libraries = [...ready.libraries, sdkLibrary, import_node_path12.default.join(sdk.root, "java.klib")];
|
|
2919
2948
|
const compose = usesCompose ? await ensureCompose(toolchain) : null;
|
|
2920
2949
|
if (compose) libraries.push(...compose.libraries);
|
|
2921
|
-
|
|
2922
|
-
const work =
|
|
2923
|
-
const javaLibrary = java ?
|
|
2950
|
+
import_node_fs13.default.mkdirSync(buildsDir(), { recursive: true });
|
|
2951
|
+
const work = import_node_fs13.default.mkdtempSync(import_node_path12.default.join(buildsDir(), `${hash}-`));
|
|
2952
|
+
const javaLibrary = java ? import_node_path12.default.join(work, "java-abi", "java-abi.klib") : null;
|
|
2924
2953
|
if (javaLibrary) libraries.push(javaLibrary);
|
|
2925
|
-
const generatedDir =
|
|
2926
|
-
|
|
2954
|
+
const generatedDir = import_node_path12.default.join(work, "generated");
|
|
2955
|
+
import_node_fs13.default.mkdirSync(generatedDir);
|
|
2927
2956
|
for (const [name, text] of Object.entries(generated))
|
|
2928
|
-
|
|
2957
|
+
import_node_fs13.default.writeFileSync(import_node_path12.default.join(generatedDir, name), text);
|
|
2929
2958
|
const compiledSources = inputs.map(({ file, bytes }, index) => {
|
|
2930
|
-
const target =
|
|
2931
|
-
|
|
2932
|
-
|
|
2959
|
+
const target = import_node_path12.default.join(work, "sources", String(index), import_node_path12.default.basename(file));
|
|
2960
|
+
import_node_fs13.default.mkdirSync(import_node_path12.default.dirname(target), { recursive: true });
|
|
2961
|
+
import_node_fs13.default.writeFileSync(target, bytes);
|
|
2933
2962
|
return { file, target };
|
|
2934
2963
|
});
|
|
2935
2964
|
const common = [
|
|
@@ -2938,19 +2967,19 @@ async function compileKotlin(input, origin) {
|
|
|
2938
2967
|
"-Xallow-kotlin-package",
|
|
2939
2968
|
"-Xwasm-target=js",
|
|
2940
2969
|
"-libraries",
|
|
2941
|
-
libraries.join(
|
|
2970
|
+
libraries.join(import_node_path12.default.delimiter)
|
|
2942
2971
|
];
|
|
2943
2972
|
const compileKlib = (outputDir) => run5(
|
|
2944
2973
|
kotlinc,
|
|
2945
2974
|
[
|
|
2946
2975
|
...common,
|
|
2947
2976
|
`-Xplugin=${plugin}`,
|
|
2948
|
-
`-Xfriend-modules=${[sdkLibrary, ...javaLibrary ? [javaLibrary] : []].join(
|
|
2977
|
+
`-Xfriend-modules=${[sdkLibrary, ...javaLibrary ? [javaLibrary] : []].join(import_node_path12.default.delimiter)}`,
|
|
2949
2978
|
...usesCompose ? [
|
|
2950
|
-
`-Xplugin=${
|
|
2979
|
+
`-Xplugin=${import_node_path12.default.resolve(import_node_path12.default.dirname(kotlinc), "../lib/compose-compiler-plugin.jar")}`
|
|
2951
2980
|
] : [],
|
|
2952
2981
|
...usesSerialization ? [
|
|
2953
|
-
`-Xplugin=${
|
|
2982
|
+
`-Xplugin=${import_node_path12.default.resolve(import_node_path12.default.dirname(kotlinc), "../lib/kotlinx-serialization-compiler-plugin.jar")}`
|
|
2954
2983
|
] : [],
|
|
2955
2984
|
"-language-version",
|
|
2956
2985
|
language,
|
|
@@ -2964,7 +2993,7 @@ async function compileKotlin(input, origin) {
|
|
|
2964
2993
|
"-ir-output-name",
|
|
2965
2994
|
"app",
|
|
2966
2995
|
...compiledSources.map(({ target }) => target),
|
|
2967
|
-
...Object.keys(generated).map((name) =>
|
|
2996
|
+
...Object.keys(generated).map((name) => import_node_path12.default.join(generatedDir, name))
|
|
2968
2997
|
],
|
|
2969
2998
|
{ maxBuffer: 16 * 1024 * 1024 }
|
|
2970
2999
|
);
|
|
@@ -2983,49 +3012,49 @@ async function compileKotlin(input, origin) {
|
|
|
2983
3012
|
if (viewModels && inputs.some(
|
|
2984
3013
|
({ file, bytes }) => sources.includes(file) && bytes.includes("ViewModel")
|
|
2985
3014
|
)) {
|
|
2986
|
-
await compileKlib(
|
|
3015
|
+
await compileKlib(import_node_path12.default.join(work, "abi"));
|
|
2987
3016
|
const stdout = await runKotlinTool(
|
|
2988
3017
|
ready,
|
|
2989
3018
|
sdk.root,
|
|
2990
3019
|
viewModels.toolClass,
|
|
2991
|
-
[
|
|
3020
|
+
[import_node_path12.default.join(work, "abi")],
|
|
2992
3021
|
64 * 1024 * 1024
|
|
2993
3022
|
);
|
|
2994
|
-
|
|
2995
|
-
|
|
3023
|
+
import_node_fs13.default.writeFileSync(
|
|
3024
|
+
import_node_path12.default.join(generatedDir, viewModels.file),
|
|
2996
3025
|
viewModels.render(viewModelClasses(readAbiClasses(stdout)))
|
|
2997
3026
|
);
|
|
2998
3027
|
}
|
|
2999
|
-
await compileKlib(
|
|
3028
|
+
await compileKlib(import_node_path12.default.join(work, "klib"));
|
|
3000
3029
|
await run5(
|
|
3001
3030
|
kotlinc,
|
|
3002
3031
|
[
|
|
3003
3032
|
...common,
|
|
3004
3033
|
"-nowarn",
|
|
3005
3034
|
"-Xpartial-linkage-loglevel=error",
|
|
3006
|
-
`-Xinclude=${
|
|
3035
|
+
`-Xinclude=${import_node_path12.default.join(work, "klib")}`,
|
|
3007
3036
|
"-Xir-produce-js",
|
|
3008
3037
|
"-Xir-dce",
|
|
3009
3038
|
"-ir-output-dir",
|
|
3010
|
-
|
|
3039
|
+
import_node_path12.default.join(work, "js"),
|
|
3011
3040
|
"-ir-output-name",
|
|
3012
3041
|
"app"
|
|
3013
3042
|
],
|
|
3014
3043
|
{ maxBuffer: 16 * 1024 * 1024 }
|
|
3015
3044
|
);
|
|
3016
3045
|
if (compose) {
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
kotlinSkikoSource(
|
|
3046
|
+
import_node_fs13.default.writeFileSync(
|
|
3047
|
+
import_node_path12.default.join(work, "js", "skiko.mjs"),
|
|
3048
|
+
kotlinSkikoSource(import_node_fs13.default.readFileSync(compose.loader))
|
|
3020
3049
|
);
|
|
3021
3050
|
}
|
|
3022
3051
|
if (usesCompose) {
|
|
3023
3052
|
for (const library of toolchain.composeJsLibraries) {
|
|
3024
3053
|
let imported = false;
|
|
3025
|
-
for (const file of
|
|
3054
|
+
for (const file of import_node_fs13.default.readdirSync(import_node_path12.default.join(work, "js"))) {
|
|
3026
3055
|
if (!file.endsWith(".mjs")) continue;
|
|
3027
|
-
const target =
|
|
3028
|
-
const source =
|
|
3056
|
+
const target = import_node_path12.default.join(work, "js", file);
|
|
3057
|
+
const source = import_node_fs13.default.readFileSync(target, "utf8");
|
|
3029
3058
|
let next = source;
|
|
3030
3059
|
for (const quote of ["'", '"'])
|
|
3031
3060
|
next = next.replaceAll(
|
|
@@ -3033,11 +3062,11 @@ async function compileKotlin(input, origin) {
|
|
|
3033
3062
|
`from ${quote}./${library.file}${quote}`
|
|
3034
3063
|
);
|
|
3035
3064
|
if (next === source) continue;
|
|
3036
|
-
|
|
3065
|
+
import_node_fs13.default.writeFileSync(target, next);
|
|
3037
3066
|
imported = true;
|
|
3038
3067
|
}
|
|
3039
3068
|
if (!imported) continue;
|
|
3040
|
-
const archive =
|
|
3069
|
+
const archive = import_node_path12.default.join(
|
|
3041
3070
|
kotlinHome(),
|
|
3042
3071
|
toolchain.compiler.version,
|
|
3043
3072
|
library.name
|
|
@@ -3046,24 +3075,24 @@ async function compileKotlin(input, origin) {
|
|
|
3046
3075
|
const { stdout } = await run5("tar", ["-xOf", archive, library.archiveEntry], {
|
|
3047
3076
|
maxBuffer: 16 * 1024 * 1024
|
|
3048
3077
|
});
|
|
3049
|
-
|
|
3078
|
+
import_node_fs13.default.writeFileSync(import_node_path12.default.join(work, "js", library.file), stdout);
|
|
3050
3079
|
}
|
|
3051
3080
|
}
|
|
3052
3081
|
} catch (error) {
|
|
3053
|
-
|
|
3082
|
+
import_node_fs13.default.rmSync(work, { recursive: true, force: true });
|
|
3054
3083
|
let output = isRecord(error) ? `${String(error.stderr ?? "")}${String(error.stdout ?? "")}` : "";
|
|
3055
3084
|
for (const [name, source] of Object.entries(origins))
|
|
3056
|
-
output = output.replaceAll(
|
|
3085
|
+
output = output.replaceAll(import_node_path12.default.join(generatedDir, name), source);
|
|
3057
3086
|
for (const [index, spec] of applicationJava.entries())
|
|
3058
3087
|
output = output.replaceAll(
|
|
3059
|
-
|
|
3088
|
+
import_node_path12.default.join(generatedDir, `JavaApplication${index}.kt`),
|
|
3060
3089
|
spec.file
|
|
3061
3090
|
);
|
|
3062
3091
|
for (const { file, target } of compiledSources)
|
|
3063
|
-
output = output.replaceAll(target, file).replaceAll(
|
|
3092
|
+
output = output.replaceAll(target, file).replaceAll(import_node_path12.default.relative(process.cwd(), target), file);
|
|
3064
3093
|
for (const [index, spec] of (java?.specs ?? []).entries())
|
|
3065
3094
|
output = output.replaceAll(
|
|
3066
|
-
|
|
3095
|
+
import_node_path12.default.join(work, "java-abi", `Spec${index}.kt`),
|
|
3067
3096
|
spec.file
|
|
3068
3097
|
);
|
|
3069
3098
|
output = output.replace(
|
|
@@ -3076,20 +3105,20 @@ ${output.trim() || (error instanceof Error ? error.message : String(error))}`
|
|
|
3076
3105
|
);
|
|
3077
3106
|
}
|
|
3078
3107
|
const seams = [kotlinNodeDetection];
|
|
3079
|
-
const js =
|
|
3108
|
+
const js = import_node_fs13.default.readdirSync(import_node_path12.default.join(work, "js")).filter((file) => file.endsWith(".mjs"));
|
|
3080
3109
|
if (js.some(
|
|
3081
|
-
(file) =>
|
|
3110
|
+
(file) => import_node_fs13.default.readFileSync(import_node_path12.default.join(work, "js", file), "utf8").includes("'kotlinx.coroutines.")
|
|
3082
3111
|
))
|
|
3083
3112
|
seams.push(kotlinCoroutineDispatcher);
|
|
3084
3113
|
for (const [from, to] of seams) {
|
|
3085
3114
|
let patched = 0;
|
|
3086
3115
|
for (const file of js) {
|
|
3087
|
-
const target =
|
|
3088
|
-
const text =
|
|
3116
|
+
const target = import_node_path12.default.join(work, "js", file);
|
|
3117
|
+
const text = import_node_fs13.default.readFileSync(target, "utf8");
|
|
3089
3118
|
const next = text.replaceAll(from, to);
|
|
3090
3119
|
if (next !== text) {
|
|
3091
3120
|
patched++;
|
|
3092
|
-
|
|
3121
|
+
import_node_fs13.default.writeFileSync(target, next);
|
|
3093
3122
|
}
|
|
3094
3123
|
}
|
|
3095
3124
|
if (patched === 0)
|
|
@@ -3097,11 +3126,11 @@ ${output.trim() || (error instanceof Error ? error.message : String(error))}`
|
|
|
3097
3126
|
`kotlin output no longer contains ${from}; recheck how it detects its host in Peach`
|
|
3098
3127
|
);
|
|
3099
3128
|
}
|
|
3100
|
-
const entry =
|
|
3101
|
-
const entrySource2 =
|
|
3102
|
-
const importsPath =
|
|
3129
|
+
const entry = import_node_path12.default.join(work, "js/app.mjs");
|
|
3130
|
+
const entrySource2 = import_node_fs13.default.readFileSync(entry, "utf8");
|
|
3131
|
+
const importsPath = import_node_path12.default.join(work, "js/app.import-object.mjs");
|
|
3103
3132
|
const importsFactory = kotlinInstanceSource(
|
|
3104
|
-
|
|
3133
|
+
import_node_fs13.default.readFileSync(importsPath, "utf8"),
|
|
3105
3134
|
"createKotlinImportObject"
|
|
3106
3135
|
);
|
|
3107
3136
|
const runtimeFactory = kotlinInstanceSource(
|
|
@@ -3109,9 +3138,9 @@ ${output.trim() || (error instanceof Error ? error.message : String(error))}`
|
|
|
3109
3138
|
"createKotlinInstance",
|
|
3110
3139
|
/* @__PURE__ */ new Map([["./app.import-object.mjs", "createKotlinImportObject"]])
|
|
3111
3140
|
);
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3141
|
+
import_node_fs13.default.writeFileSync(importsPath, importsFactory.source);
|
|
3142
|
+
import_node_fs13.default.writeFileSync(import_node_path12.default.join(work, "js/app-runtime.mjs"), runtimeFactory.source);
|
|
3143
|
+
import_node_fs13.default.writeFileSync(
|
|
3115
3144
|
entry,
|
|
3116
3145
|
[
|
|
3117
3146
|
"import { createKotlinInstance } from './app-runtime.mjs';",
|
|
@@ -3124,10 +3153,10 @@ ${output.trim() || (error instanceof Error ? error.message : String(error))}`
|
|
|
3124
3153
|
].join("\n")
|
|
3125
3154
|
);
|
|
3126
3155
|
try {
|
|
3127
|
-
|
|
3156
|
+
import_node_fs13.default.renameSync(work, out);
|
|
3128
3157
|
} catch (error) {
|
|
3129
|
-
if (!
|
|
3130
|
-
|
|
3158
|
+
if (!import_node_fs13.default.existsSync(import_node_path12.default.join(out, "js", "app.wasm"))) throw error;
|
|
3159
|
+
import_node_fs13.default.rmSync(work, { recursive: true, force: true });
|
|
3131
3160
|
}
|
|
3132
3161
|
return artifact;
|
|
3133
3162
|
})().finally(() => builds.delete(hash));
|
|
@@ -3139,24 +3168,24 @@ var CONTENT_TYPES = {
|
|
|
3139
3168
|
".wasm": "application/wasm"
|
|
3140
3169
|
};
|
|
3141
3170
|
function kotlinArtifactFiles(hash) {
|
|
3142
|
-
const dir =
|
|
3143
|
-
return
|
|
3144
|
-
const contentType = CONTENT_TYPES[
|
|
3171
|
+
const dir = import_node_path12.default.join(buildsDir(), hash, "js");
|
|
3172
|
+
return import_node_fs13.default.readdirSync(dir).sort().map((name) => {
|
|
3173
|
+
const contentType = CONTENT_TYPES[import_node_path12.default.extname(name)];
|
|
3145
3174
|
if (!contentType) throw new Error(`unexpected kotlin artifact file ${name}`);
|
|
3146
|
-
return { name, bytes:
|
|
3175
|
+
return { name, bytes: import_node_fs13.default.readFileSync(import_node_path12.default.join(dir, name)), contentType };
|
|
3147
3176
|
});
|
|
3148
3177
|
}
|
|
3149
3178
|
function serveKotlinArtifact(pathname, res) {
|
|
3150
3179
|
if (!pathname.startsWith(KOTLIN_ARTIFACT_PREFIX)) return false;
|
|
3151
3180
|
const [hash, file, ...rest] = pathname.slice(KOTLIN_ARTIFACT_PREFIX.length).split("/");
|
|
3152
|
-
const type = file ? CONTENT_TYPES[
|
|
3181
|
+
const type = file ? CONTENT_TYPES[import_node_path12.default.extname(file)] : void 0;
|
|
3153
3182
|
if (!hash || !/^[0-9a-f]+$/.test(hash) || !file || rest.length > 0 || !type || file.includes("..")) {
|
|
3154
3183
|
res.statusCode = 404;
|
|
3155
3184
|
res.end("not a kotlin artifact");
|
|
3156
3185
|
return true;
|
|
3157
3186
|
}
|
|
3158
|
-
const target =
|
|
3159
|
-
if (!
|
|
3187
|
+
const target = import_node_path12.default.join(buildsDir(), hash, "js", file);
|
|
3188
|
+
if (!import_node_fs13.default.existsSync(target)) {
|
|
3160
3189
|
res.statusCode = 404;
|
|
3161
3190
|
res.end(`kotlin artifact ${hash}/${file} was not built`);
|
|
3162
3191
|
return true;
|
|
@@ -3164,7 +3193,7 @@ function serveKotlinArtifact(pathname, res) {
|
|
|
3164
3193
|
res.setHeader("access-control-allow-origin", "*");
|
|
3165
3194
|
res.setHeader("content-type", type);
|
|
3166
3195
|
res.setHeader("cache-control", "public, max-age=31536000, immutable");
|
|
3167
|
-
res.end(
|
|
3196
|
+
res.end(import_node_fs13.default.readFileSync(target));
|
|
3168
3197
|
return true;
|
|
3169
3198
|
}
|
|
3170
3199
|
async function serveKotlinRequest(pathname, res, app) {
|