peachsim 0.1.2441 → 0.1.2457
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/README.md +4 -49
- package/cli/app-catalog.ts +8 -7
- package/cli/app-stubs.ts +98 -70
- package/cli/cloud-box-artifact.ts +2 -5
- package/cli/cloud-client.ts +12 -1
- package/cli/commands/box.ts +41 -2
- package/cli/commands/compat.ts +5 -3
- package/cli/commands/cpu-profile.ts +11 -14
- package/cli/commands/diagnose.ts +5 -18
- package/cli/commands/inspect/describe.ts +4 -8
- package/cli/commands/maestro-generate.ts +4 -8
- package/cli/commands/mode.ts +3 -19
- package/cli/commands/perf.ts +3 -19
- package/cli/commands/permissions.ts +2 -6
- package/cli/commands/platform.ts +22 -14
- package/cli/commands/react.ts +7 -21
- package/cli/commands/record-three.ts +6 -10
- package/cli/commands/record.ts +38 -62
- package/cli/commands/screenshot-command.ts +8 -25
- package/cli/commands/storage.ts +4 -16
- package/cli/commands/three-mode.ts +6 -10
- package/cli/outbound-endpoints.ts +4 -5
- package/cli/parse-args.ts +45 -0
- package/cli/remote-metro.ts +1 -1
- package/cli/remote-simulators.ts +5 -1
- package/cli/send-to-box.ts +3 -1
- package/detox/index.ts +20 -1
- package/dist-lib/agent-daemon-client.cjs +2 -2
- 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 +240 -316
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +14 -1
- package/dist-lib/cloud-contract.mjs +5 -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 -6
- package/dist-lib/config.mjs +5 -9
- package/dist-lib/detox/index.cjs +17 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-FRQNHKFC.mjs → acorn-73XUBXBT.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-IRMC5BCX.mjs → chunk-7V2QJGVI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PMGJ7FLI.mjs → chunk-BHQEYJAF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BAYRN7ZL.mjs → chunk-DSPFMVBM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4HEUXQGM.mjs → chunk-GA73RJSG.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-ABMB3G7I.mjs → chunk-IGBAFWZ3.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-ZCMAKWHN.mjs → chunk-IKZDUGT6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VAQJQDWI.mjs → chunk-IP5ZV36U.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-O4EOBXAP.mjs → chunk-KGHQ4GK2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4BZ3Z3IQ.mjs → chunk-KY63O76W.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-QYYJESMK.mjs → chunk-LJ74MO6Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DJMWTW2B.mjs → chunk-LJX42YVT.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XO5GX4PI.mjs → chunk-O4KAW2JJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6A6JEVIF.mjs → chunk-OIFM356B.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NPLEBOWJ.mjs → chunk-P63DPATT.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VCAJFWZD.mjs → chunk-SCCOZKCP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QUBR7LHU.mjs → chunk-TAZL253K.mjs} +41 -15
- package/dist-lib/esm-chunks/{chunk-ORYS5CC4.mjs → chunk-UBXCWZL3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4ZRMJ5YO.mjs → chunk-ZQWWO33G.mjs} +14 -2
- package/dist-lib/esm-chunks/{metro-layout-parser-AUAVE5VL.mjs → metro-layout-parser-HNQRTPVE.mjs} +3 -3
- package/dist-lib/expo-swift-bundle.cjs +197 -336
- 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 +276 -381
- package/dist-lib/host/fetch-proxy-handler.cjs +35 -43
- 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 +4 -2
- package/dist-lib/index.cjs +2 -105
- package/dist-lib/kotlin-host.cjs +6 -4
- 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 +2 -2
- package/dist-lib/native-app-identity-project.mjs +12 -12
- 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 +64 -64
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +107 -85
- 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 +310 -310
- package/dist-lib/swift-compile.cjs +37 -11
- package/dist-lib/swift-compile.mjs +8 -8
- 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-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 +14770 -0
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +2790 -0
- 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/prism.wasm +0 -0
- 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 +3710 -0
- 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-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +0 -3
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/text-line-break.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/text-paint.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/text-runs.d.ts +6 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +22 -14
- package/skills/peach-setup/references/native-config.md +3 -3
- package/src/app-config.ts +7 -15
- package/src/cloud-contract.ts +35 -0
- package/src/config.ts +2 -6
- package/src/estree-walk.ts +13 -0
- package/src/host/network-policy.ts +4 -1
- package/src/index.ts +0 -1
- package/src/one-native-app-config.ts +14 -15
- package/src/podspec-prism.ts +7 -1
- package/src/process-group.ts +4 -1
- package/src/process-table.ts +6 -1
- package/src/swift-compile.ts +38 -8
- package/src/swift-host.ts +10 -4
- package/cli/commands/box/bundle-plane.ts +0 -154
- package/dist-lib/jump-to-source-babel.cjs +0 -131
- package/dist-lib/jump-to-source-native.cjs +0 -235
- package/src/java-static-imports.ts +0 -68
- package/src/jump-to-source-babel.ts +0 -143
- package/src/jump-to-source-native.ts +0 -200
- package/src/kotlin-jvm-sources.ts +0 -35
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// ProjectFilePlane over an already-built bundle held in memory.
|
|
2
|
-
//
|
|
3
|
-
// a prebuilt Box has no sources, so there is no checkout to index and nothing
|
|
4
|
-
// on disk to stay in step with: the whole project is the bundle the page boots.
|
|
5
|
-
// CheckoutFilePlane cannot serve this because it asks git what belongs to the
|
|
6
|
-
// project, and a bundle produced by a build lives outside any checkout.
|
|
7
|
-
//
|
|
8
|
-
// the bundle is split here rather than by the caller, so the one place that
|
|
9
|
-
// decides where the parts go is the one place that decides how big they are.
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
PREBUILT_BUNDLE_DEVICE_PATH,
|
|
13
|
-
PREBUILT_BUNDLE_INITIAL_URL_PATH,
|
|
14
|
-
PREBUILT_BUNDLE_NATIVE_ASSETS_MANIFEST_PATH,
|
|
15
|
-
PREBUILT_BUNDLE_NATIVE_RENDERER_PATH,
|
|
16
|
-
PREBUILT_BUNDLE_UPDATE_PATH,
|
|
17
|
-
prebuiltAppFontsPartPath,
|
|
18
|
-
prebuiltNativeAssetPartPath,
|
|
19
|
-
PREBUILT_BUNDLE_PART_BYTES,
|
|
20
|
-
prebuiltBundlePartPath,
|
|
21
|
-
type PrebuiltNativeAssetEntry,
|
|
22
|
-
type PrebuiltBundleUpdate,
|
|
23
|
-
} from '@peach/box/template'
|
|
24
|
-
import type { NativeRenderer } from '../../../src/config'
|
|
25
|
-
import type { CloudBoxNativeAsset } from '../../cloud-box-artifact.ts'
|
|
26
|
-
import type { ProjectFileMeta, ProjectFilePlane } from '@peach/box/plane'
|
|
27
|
-
|
|
28
|
-
export class BundleFilePlane implements ProjectFilePlane {
|
|
29
|
-
private readonly parts = new Map<string, Uint8Array>()
|
|
30
|
-
private readonly entries = new Map<string, ProjectFileMeta>()
|
|
31
|
-
|
|
32
|
-
constructor(
|
|
33
|
-
bundle: Uint8Array,
|
|
34
|
-
private readonly device: string | null,
|
|
35
|
-
private readonly initialUrl: string | null,
|
|
36
|
-
private readonly appFonts = '',
|
|
37
|
-
private readonly nativeRenderer?: NativeRenderer,
|
|
38
|
-
nativeAssets: readonly CloudBoxNativeAsset[] = [],
|
|
39
|
-
update?: PrebuiltBundleUpdate,
|
|
40
|
-
) {
|
|
41
|
-
if (bundle.byteLength === 0) throw new Error('a Box bundle cannot be empty')
|
|
42
|
-
if (update)
|
|
43
|
-
this.record(
|
|
44
|
-
PREBUILT_BUNDLE_UPDATE_PATH,
|
|
45
|
-
new TextEncoder().encode(JSON.stringify(update)),
|
|
46
|
-
)
|
|
47
|
-
if (appFonts)
|
|
48
|
-
this.recordParts(new TextEncoder().encode(appFonts), prebuiltAppFontsPartPath)
|
|
49
|
-
if (device) this.record(PREBUILT_BUNDLE_DEVICE_PATH, new TextEncoder().encode(device))
|
|
50
|
-
if (initialUrl)
|
|
51
|
-
this.record(PREBUILT_BUNDLE_INITIAL_URL_PATH, new TextEncoder().encode(initialUrl))
|
|
52
|
-
if (nativeRenderer !== undefined)
|
|
53
|
-
this.record(
|
|
54
|
-
PREBUILT_BUNDLE_NATIVE_RENDERER_PATH,
|
|
55
|
-
new TextEncoder().encode(nativeRenderer),
|
|
56
|
-
)
|
|
57
|
-
if (nativeAssets.length) {
|
|
58
|
-
const manifest: PrebuiltNativeAssetEntry[] = nativeAssets.map((asset, index) => ({
|
|
59
|
-
url: asset.url,
|
|
60
|
-
contentType: asset.contentType,
|
|
61
|
-
parts: this.recordParts(
|
|
62
|
-
asset.bytes,
|
|
63
|
-
(part) => prebuiltNativeAssetPartPath(index, part),
|
|
64
|
-
true,
|
|
65
|
-
),
|
|
66
|
-
}))
|
|
67
|
-
this.record(
|
|
68
|
-
PREBUILT_BUNDLE_NATIVE_ASSETS_MANIFEST_PATH,
|
|
69
|
-
new TextEncoder().encode(JSON.stringify(manifest)),
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
this.recordParts(bundle, prebuiltBundlePartPath)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
withBundle(
|
|
76
|
-
bundle: Uint8Array,
|
|
77
|
-
nativeAssets: readonly CloudBoxNativeAsset[],
|
|
78
|
-
update: PrebuiltBundleUpdate,
|
|
79
|
-
): BundleFilePlane {
|
|
80
|
-
return new BundleFilePlane(
|
|
81
|
-
bundle,
|
|
82
|
-
this.device,
|
|
83
|
-
this.initialUrl,
|
|
84
|
-
this.appFonts,
|
|
85
|
-
this.nativeRenderer,
|
|
86
|
-
nativeAssets,
|
|
87
|
-
update,
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// returns how many parts it wrote
|
|
92
|
-
private recordParts(
|
|
93
|
-
content: Uint8Array,
|
|
94
|
-
partPath: (index: number) => string,
|
|
95
|
-
binary = false,
|
|
96
|
-
): number {
|
|
97
|
-
let index = 0
|
|
98
|
-
for (
|
|
99
|
-
let offset = 0;
|
|
100
|
-
offset < content.byteLength;
|
|
101
|
-
offset += PREBUILT_BUNDLE_PART_BYTES, index++
|
|
102
|
-
) {
|
|
103
|
-
this.record(
|
|
104
|
-
partPath(index),
|
|
105
|
-
content.subarray(offset, offset + PREBUILT_BUNDLE_PART_BYTES),
|
|
106
|
-
binary,
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
return index
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private record(path: string, content: Uint8Array, binary = false): void {
|
|
113
|
-
this.parts.set(path, content)
|
|
114
|
-
this.entries.set(path, {
|
|
115
|
-
size: content.byteLength,
|
|
116
|
-
readOnly: false,
|
|
117
|
-
// a Metro bundle is JavaScript. the flag is what decides whether a shell
|
|
118
|
-
// may overwrite a file with text, and marking it binary would make the
|
|
119
|
-
// bundle unwritable from inside the box for no reason. compiled native
|
|
120
|
-
// modules are binary.
|
|
121
|
-
binary,
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
index(): ReadonlyMap<string, ProjectFileMeta> {
|
|
126
|
-
return this.entries
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// nothing else can change this plane, so the index is already current.
|
|
130
|
-
refresh(): Promise<void> {
|
|
131
|
-
return Promise.resolve()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async read(path: string): Promise<string> {
|
|
135
|
-
return new TextDecoder().decode(await this.readBytes(path))
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
readBytes(path: string): Promise<Uint8Array> {
|
|
139
|
-
const part = this.parts.get(path)
|
|
140
|
-
if (!part) return Promise.reject(new Error(`no such file: ${path}`))
|
|
141
|
-
return Promise.resolve(part)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
write(path: string, content: Uint8Array): Promise<void> {
|
|
145
|
-
this.record(path, content)
|
|
146
|
-
return Promise.resolve()
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
delete(path: string): Promise<void> {
|
|
150
|
-
this.parts.delete(path)
|
|
151
|
-
this.entries.delete(path)
|
|
152
|
-
return Promise.resolve()
|
|
153
|
-
}
|
|
154
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/*! peach v0.1.2441 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
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
|
-
"use strict";
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/jump-to-source-babel.ts
|
|
23
|
-
var jump_to_source_babel_exports = {};
|
|
24
|
-
__export(jump_to_source_babel_exports, {
|
|
25
|
-
default: () => sootsimJumpToSourceBabelPlugin,
|
|
26
|
-
sootsimJumpToSourceBabelPlugin: () => sootsimJumpToSourceBabelPlugin
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(jump_to_source_babel_exports);
|
|
29
|
-
function normalizeSourcePath(path) {
|
|
30
|
-
const queryStart = path.indexOf("?");
|
|
31
|
-
const clean = queryStart >= 0 ? path.slice(0, queryStart) : path;
|
|
32
|
-
return clean.replace(/\\/g, "/");
|
|
33
|
-
}
|
|
34
|
-
function matchesPath(path, matcher) {
|
|
35
|
-
return typeof matcher === "string" ? path.includes(matcher) : matcher.test(path);
|
|
36
|
-
}
|
|
37
|
-
function shouldStampFile(filename, options) {
|
|
38
|
-
const normalized = normalizeSourcePath(filename);
|
|
39
|
-
if (normalized.includes("/node_modules/")) return false;
|
|
40
|
-
if (normalized.includes("/dist/") || normalized.includes("/build/")) return false;
|
|
41
|
-
if (options.exclude?.some((matcher) => matchesPath(normalized, matcher))) return false;
|
|
42
|
-
if (options.include?.length) {
|
|
43
|
-
return options.include.some((matcher) => matchesPath(normalized, matcher));
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
function sootsimJumpToSourceBabelPlugin(api, options = {}) {
|
|
48
|
-
const t = api.types;
|
|
49
|
-
const attrName = options.attrName || "srcloc";
|
|
50
|
-
const stamped = /* @__PURE__ */ new WeakSet();
|
|
51
|
-
return {
|
|
52
|
-
name: "sootsim-jump-to-source",
|
|
53
|
-
visitor: {
|
|
54
|
-
JSXElement: {
|
|
55
|
-
exit(path, state) {
|
|
56
|
-
if (options.enabled === false) return;
|
|
57
|
-
const filename = state.filename;
|
|
58
|
-
if (!filename || !shouldStampFile(filename, options)) return;
|
|
59
|
-
const node = path.node;
|
|
60
|
-
if (stamped.has(node)) return;
|
|
61
|
-
stamped.add(node);
|
|
62
|
-
const opening = node.openingElement;
|
|
63
|
-
const name = opening.name;
|
|
64
|
-
if (t.isJSXNamespacedName(name)) return;
|
|
65
|
-
if (opening.attributes.some(
|
|
66
|
-
(attr) => t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: attrName })
|
|
67
|
-
))
|
|
68
|
-
return;
|
|
69
|
-
const loc = opening.loc?.start;
|
|
70
|
-
if (!loc) return;
|
|
71
|
-
const source = `${normalizeSourcePath(filename)}:${loc.line}:${loc.column + 1}`;
|
|
72
|
-
if (t.isJSXIdentifier(name) && /^[a-z]/.test(name.name)) {
|
|
73
|
-
opening.attributes.push(
|
|
74
|
-
t.jsxAttribute(t.jsxIdentifier(attrName), t.stringLiteral(source))
|
|
75
|
-
);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const fn = path.getFunctionParent();
|
|
79
|
-
const parameterDefault = Boolean(
|
|
80
|
-
fn && opening.start != null && fn.node.body.start != null && opening.start < fn.node.body.start
|
|
81
|
-
);
|
|
82
|
-
const type = path.scope.generateUidIdentifier("PeachSourceType");
|
|
83
|
-
if (!parameterDefault) path.scope.push({ id: type });
|
|
84
|
-
function expression(tag) {
|
|
85
|
-
return t.isJSXIdentifier(tag) ? t.identifier(tag.name) : t.memberExpression(
|
|
86
|
-
expression(tag.object),
|
|
87
|
-
t.identifier(tag.property.name)
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
const originalType = expression(name);
|
|
91
|
-
const alias = t.jsxIdentifier(type.name);
|
|
92
|
-
opening.name = alias;
|
|
93
|
-
if (node.closingElement) node.closingElement.name = alias;
|
|
94
|
-
opening.attributes.push(
|
|
95
|
-
t.jsxSpreadAttribute(
|
|
96
|
-
t.conditionalExpression(
|
|
97
|
-
t.binaryExpression(
|
|
98
|
-
"===",
|
|
99
|
-
t.unaryExpression("typeof", type),
|
|
100
|
-
t.stringLiteral("symbol")
|
|
101
|
-
),
|
|
102
|
-
t.nullLiteral(),
|
|
103
|
-
t.objectExpression([
|
|
104
|
-
t.objectProperty(t.stringLiteral(attrName), t.stringLiteral(source))
|
|
105
|
-
])
|
|
106
|
-
)
|
|
107
|
-
)
|
|
108
|
-
);
|
|
109
|
-
const replacement = parameterDefault ? t.callExpression(t.arrowFunctionExpression([type], node), [originalType]) : t.logicalExpression(
|
|
110
|
-
"&&",
|
|
111
|
-
t.logicalExpression(
|
|
112
|
-
"||",
|
|
113
|
-
t.assignmentExpression("=", type, originalType),
|
|
114
|
-
t.booleanLiteral(true)
|
|
115
|
-
),
|
|
116
|
-
node
|
|
117
|
-
);
|
|
118
|
-
if (path.parentPath.isJSXElement() || path.parentPath.isJSXFragment()) {
|
|
119
|
-
path.replaceWith(t.jsxExpressionContainer(replacement));
|
|
120
|
-
} else {
|
|
121
|
-
path.replaceWith(replacement);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
-
0 && (module.exports = {
|
|
130
|
-
sootsimJumpToSourceBabelPlugin
|
|
131
|
-
});
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/*! peach v0.1.2441 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
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
|
-
"use strict";
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
-
|
|
32
|
-
// src/jump-to-source-native.ts
|
|
33
|
-
var jump_to_source_native_exports = {};
|
|
34
|
-
__export(jump_to_source_native_exports, {
|
|
35
|
-
createJumpToSourceNativeTransform: () => createJumpToSourceNativeTransform,
|
|
36
|
-
default: () => jump_to_source_native_default,
|
|
37
|
-
jumpToSourceNativePlugin: () => jumpToSourceNativePlugin,
|
|
38
|
-
stampJsxSourceLocations: () => stampJsxSourceLocations
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(jump_to_source_native_exports);
|
|
41
|
-
var import_magic_string = __toESM(require("peachsim/vendor/magic-string"), 1);
|
|
42
|
-
var import_oxc_parser2 = require("oxc-parser");
|
|
43
|
-
|
|
44
|
-
// src/visit-parsed-program.ts
|
|
45
|
-
var import_oxc_parser = require("oxc-parser");
|
|
46
|
-
|
|
47
|
-
// src/is-record.ts
|
|
48
|
-
function isRecord(value) {
|
|
49
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/visit-parsed-program.ts
|
|
53
|
-
function visitParsedProgram(program, visitor) {
|
|
54
|
-
const enterByType = /* @__PURE__ */ new Map();
|
|
55
|
-
const exitByType = /* @__PURE__ */ new Map();
|
|
56
|
-
for (const key of Object.keys(visitor)) {
|
|
57
|
-
const handler = Reflect.get(visitor, key);
|
|
58
|
-
if (typeof handler !== "function") continue;
|
|
59
|
-
const invoke = (node) => {
|
|
60
|
-
handler(node);
|
|
61
|
-
};
|
|
62
|
-
if (key.endsWith(":exit")) exitByType.set(key.slice(0, -5), invoke);
|
|
63
|
-
else enterByType.set(key, invoke);
|
|
64
|
-
}
|
|
65
|
-
if (enterByType.size === 0 && exitByType.size === 0) return;
|
|
66
|
-
const hasExit = exitByType.size > 0;
|
|
67
|
-
function visit(value) {
|
|
68
|
-
if (Array.isArray(value)) {
|
|
69
|
-
for (let i = 0; i < value.length; i++) visit(value[i]);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!isRecord(value) || typeof value.type !== "string") return;
|
|
73
|
-
const keys = import_oxc_parser.visitorKeys[value.type];
|
|
74
|
-
if (!keys) return;
|
|
75
|
-
const enter = enterByType.get(value.type);
|
|
76
|
-
if (enter) enter(value);
|
|
77
|
-
for (let i = 0; i < keys.length; i++) visit(value[keys[i]]);
|
|
78
|
-
if (hasExit) {
|
|
79
|
-
const exit = exitByType.get(value.type);
|
|
80
|
-
if (exit) exit(value);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
visit(program);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// src/jump-to-source-native.ts
|
|
87
|
-
function matchesPath(path, matcher) {
|
|
88
|
-
return typeof matcher === "string" ? path.includes(matcher) : matcher.test(path);
|
|
89
|
-
}
|
|
90
|
-
function stampJsxSourceLocations(code, filename, options = {}) {
|
|
91
|
-
if (options.enabled === false || !filename || !code.includes("<")) return null;
|
|
92
|
-
const source = filename.split("?")[0].replace(/\\/g, "/");
|
|
93
|
-
if (source.includes("/node_modules/") || source.includes("/dist/") || source.includes("/build/"))
|
|
94
|
-
return null;
|
|
95
|
-
if (options.exclude?.some((matcher) => matchesPath(source, matcher))) return null;
|
|
96
|
-
if (options.include?.length && !options.include.some((matcher) => matchesPath(source, matcher)))
|
|
97
|
-
return null;
|
|
98
|
-
const { program, errors } = (0, import_oxc_parser2.parseSync)(source, code, {
|
|
99
|
-
lang: source.endsWith(".tsx") ? "tsx" : source.endsWith(".ts") ? "ts" : "jsx"
|
|
100
|
-
});
|
|
101
|
-
if (errors.length) return null;
|
|
102
|
-
const attrName = options.attrName || "srcloc";
|
|
103
|
-
const lineStarts = [0];
|
|
104
|
-
for (let i = 0; i < code.length; i++) {
|
|
105
|
-
if (code.charCodeAt(i) === 10) lineStarts.push(i + 1);
|
|
106
|
-
}
|
|
107
|
-
const magic = new import_magic_string.default(code);
|
|
108
|
-
let stamped = false;
|
|
109
|
-
let nextType = 0;
|
|
110
|
-
const usedTypeNames = new Set(code.match(/\b_PeachSourceType\d+\b/g) ?? []);
|
|
111
|
-
const scopes = [{ body: program, names: [] }];
|
|
112
|
-
const allScopes = [...scopes];
|
|
113
|
-
const elements = [];
|
|
114
|
-
const childElements = /* @__PURE__ */ new WeakSet();
|
|
115
|
-
const enterElement = (node) => {
|
|
116
|
-
elements.push(node);
|
|
117
|
-
for (const child of node.children) {
|
|
118
|
-
if (child.type === "JSXElement") childElements.add(child);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const enterFunction = (node) => {
|
|
122
|
-
const scope = { body: node.body ?? program, names: [] };
|
|
123
|
-
scopes.push(scope);
|
|
124
|
-
allScopes.push(scope);
|
|
125
|
-
};
|
|
126
|
-
const exitFunction = () => {
|
|
127
|
-
scopes.pop();
|
|
128
|
-
};
|
|
129
|
-
visitParsedProgram(program, {
|
|
130
|
-
FunctionDeclaration: enterFunction,
|
|
131
|
-
"FunctionDeclaration:exit": exitFunction,
|
|
132
|
-
FunctionExpression: enterFunction,
|
|
133
|
-
"FunctionExpression:exit": exitFunction,
|
|
134
|
-
ArrowFunctionExpression: enterFunction,
|
|
135
|
-
"ArrowFunctionExpression:exit": exitFunction,
|
|
136
|
-
JSXElement: enterElement,
|
|
137
|
-
"JSXElement:exit"() {
|
|
138
|
-
elements.pop();
|
|
139
|
-
},
|
|
140
|
-
JSXFragment: enterElement,
|
|
141
|
-
"JSXFragment:exit"() {
|
|
142
|
-
elements.pop();
|
|
143
|
-
},
|
|
144
|
-
JSXOpeningElement(node) {
|
|
145
|
-
const name = node.name;
|
|
146
|
-
if (name.type === "JSXNamespacedName") return;
|
|
147
|
-
if (node.attributes.some(
|
|
148
|
-
(attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === attrName
|
|
149
|
-
))
|
|
150
|
-
return;
|
|
151
|
-
let lo = 0;
|
|
152
|
-
let hi = lineStarts.length - 1;
|
|
153
|
-
while (lo < hi) {
|
|
154
|
-
const mid = lo + hi + 1 >> 1;
|
|
155
|
-
if (lineStarts[mid] <= node.start) lo = mid;
|
|
156
|
-
else hi = mid - 1;
|
|
157
|
-
}
|
|
158
|
-
const location = `${source}:${lo + 1}:${node.start - lineStarts[lo] + 1}`;
|
|
159
|
-
if (name.type === "JSXIdentifier" && /^[a-z]/.test(name.name)) {
|
|
160
|
-
magic.appendLeft(
|
|
161
|
-
node.end - (node.selfClosing ? 2 : 1),
|
|
162
|
-
` ${attrName}={${JSON.stringify(location)}}`
|
|
163
|
-
);
|
|
164
|
-
} else {
|
|
165
|
-
const scope = scopes[scopes.length - 1];
|
|
166
|
-
const parameterDefault = node.start < scope.body.start || node.end > scope.body.end;
|
|
167
|
-
const element = elements[elements.length - 1];
|
|
168
|
-
if (element.type !== "JSXElement") return;
|
|
169
|
-
const isChild = childElements.has(element);
|
|
170
|
-
let type;
|
|
171
|
-
do {
|
|
172
|
-
type = `_PeachSourceType${nextType++}`;
|
|
173
|
-
} while (usedTypeNames.has(type));
|
|
174
|
-
if (!parameterDefault) scope.names.push(type);
|
|
175
|
-
const originalType = code.slice(name.start, name.end);
|
|
176
|
-
magic.appendLeft(
|
|
177
|
-
element.start,
|
|
178
|
-
`${isChild ? "{" : ""}${parameterDefault ? `((${type}) => ` : `(((${type} = ${originalType}) || true) && `}`
|
|
179
|
-
);
|
|
180
|
-
magic.appendLeft(
|
|
181
|
-
element.end,
|
|
182
|
-
`${parameterDefault ? `)(${originalType})` : ")"}${isChild ? "}" : ""}`
|
|
183
|
-
);
|
|
184
|
-
magic.overwrite(name.start, name.end, type);
|
|
185
|
-
if (element.closingElement) {
|
|
186
|
-
const closing = element.closingElement.name;
|
|
187
|
-
magic.overwrite(closing.start, closing.end, type);
|
|
188
|
-
}
|
|
189
|
-
magic.appendLeft(
|
|
190
|
-
node.end - (node.selfClosing ? 2 : 1),
|
|
191
|
-
` {...(typeof ${type} === "symbol" ? null : {${JSON.stringify(attrName)}: ${JSON.stringify(location)}})}`
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
stamped = true;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
for (const { body, names } of allScopes) {
|
|
198
|
-
if (!names.length) continue;
|
|
199
|
-
const declaration = `var ${names.join(", ")};`;
|
|
200
|
-
if (body.type === "Program" || body.type === "BlockStatement") {
|
|
201
|
-
let start = body.type === "Program" ? program.hashbang ? code.indexOf("\n", program.hashbang.end) + 1 : 0 : body.start + 1;
|
|
202
|
-
for (const statement of body.body) {
|
|
203
|
-
if (statement.type !== "ExpressionStatement" || statement.expression.type !== "Literal" || typeof statement.expression.value !== "string")
|
|
204
|
-
break;
|
|
205
|
-
start = statement.end;
|
|
206
|
-
}
|
|
207
|
-
magic.prependLeft(start, declaration);
|
|
208
|
-
} else {
|
|
209
|
-
magic.prependLeft(body.start, `{${declaration} return (`);
|
|
210
|
-
magic.appendLeft(body.end, ");}");
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return stamped ? magic.toString() : null;
|
|
214
|
-
}
|
|
215
|
-
function createJumpToSourceNativeTransform(options = {}) {
|
|
216
|
-
return function jumpToSourceNativeTransform(code, ctx) {
|
|
217
|
-
return stampJsxSourceLocations(code, ctx.filename, options);
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function jumpToSourceNativePlugin(options = {}) {
|
|
221
|
-
return {
|
|
222
|
-
name: "sootsim-jump-to-source",
|
|
223
|
-
transform(code, id) {
|
|
224
|
-
const stamped = stampJsxSourceLocations(code, id, options);
|
|
225
|
-
return stamped == null ? null : { code: stamped, map: null };
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
var jump_to_source_native_default = createJumpToSourceNativeTransform();
|
|
230
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
-
0 && (module.exports = {
|
|
232
|
-
createJumpToSourceNativeTransform,
|
|
233
|
-
jumpToSourceNativePlugin,
|
|
234
|
-
stampJsxSourceLocations
|
|
235
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Kotlin/JVM imports a Java class's statics, its own or inherited, by the
|
|
2
|
-
// class name. Translated Java classes hold statics in a companion, so each such
|
|
3
|
-
// import names the companion that declares the member. Tables are KlibClasses
|
|
4
|
-
// output: class, fun and property rows.
|
|
5
|
-
export type JavaStatics = {
|
|
6
|
-
supertypes: Map<string, string[]>
|
|
7
|
-
members: Map<string, Set<string>>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function readJavaStatics(tables: string[]): JavaStatics {
|
|
11
|
-
const supertypes = new Map<string, string[]>()
|
|
12
|
-
const members = new Map<string, Set<string>>()
|
|
13
|
-
for (const table of tables) {
|
|
14
|
-
for (const row of table.split('\n')) {
|
|
15
|
-
const [kind, owner, name, rest] = row.split('\t')
|
|
16
|
-
if (kind === 'class') supertypes.set(owner, rest ? rest.split(',') : [])
|
|
17
|
-
else if ((kind === 'fun' || kind === 'property') && owner.endsWith('.Companion')) {
|
|
18
|
-
const type = owner.slice(0, -'.Companion'.length)
|
|
19
|
-
members.set(type, (members.get(type) ?? new Set()).add(name))
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return { supertypes, members }
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function declaringCompanion(
|
|
27
|
-
statics: JavaStatics,
|
|
28
|
-
type: string,
|
|
29
|
-
name: string,
|
|
30
|
-
): string | null {
|
|
31
|
-
if (statics.members.get(type)?.has(name)) return `${type}.Companion`
|
|
32
|
-
for (const parent of statics.supertypes.get(type) ?? []) {
|
|
33
|
-
const found = declaringCompanion(statics, parent, name)
|
|
34
|
-
if (found) return found
|
|
35
|
-
}
|
|
36
|
-
return null
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const IMPORT = /^(\s*import\s+)([\w.`]+?)(\.\*|\s+as\s+\w+)?(\s*;?\s*(?:\/\/.*)?)$/
|
|
40
|
-
|
|
41
|
-
export function rewriteJavaStaticImports(source: string, statics: JavaStatics): string {
|
|
42
|
-
const lines = source.split('\n')
|
|
43
|
-
let changed = false
|
|
44
|
-
for (const [index, line] of lines.entries()) {
|
|
45
|
-
const match = IMPORT.exec(line)
|
|
46
|
-
if (!match) continue
|
|
47
|
-
const [, lead, target, suffix = '', tail] = match
|
|
48
|
-
const star = suffix === '.*'
|
|
49
|
-
const type = star ? target : target.slice(0, target.lastIndexOf('.'))
|
|
50
|
-
if (!statics.supertypes.has(type)) continue
|
|
51
|
-
if (star) {
|
|
52
|
-
if (!statics.members.has(type)) continue
|
|
53
|
-
lines[index] = `${lead}${target}.*; import ${type}.Companion.*${tail}`
|
|
54
|
-
changed = true
|
|
55
|
-
continue
|
|
56
|
-
}
|
|
57
|
-
const name = target.slice(type.length + 1)
|
|
58
|
-
const companion = declaringCompanion(statics, type, name)
|
|
59
|
-
if (!companion) continue
|
|
60
|
-
const rewritten = `import ${companion}.${name}${suffix}`
|
|
61
|
-
// the same name may also be a nested class, which the original import keeps
|
|
62
|
-
lines[index] = statics.supertypes.has(target)
|
|
63
|
-
? `${lead}${target}${suffix}; ${rewritten}${tail}`
|
|
64
|
-
: `${lead}${companion}.${name}${suffix}${tail}`
|
|
65
|
-
changed = true
|
|
66
|
-
}
|
|
67
|
-
return changed ? lines.join('\n') : source
|
|
68
|
-
}
|