peachsim 0.1.1655 → 0.1.1660
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/cli/app-config.ts +4 -0
- package/cli/app-stubs.ts +43 -6
- package/cli/commands/inspect/shared.ts +5 -2
- package/cli/commands/inspect/url.ts +2 -1
- package/cli/commands/screenshot.ts +5 -5
- package/cli/commands/state.ts +9 -6
- package/cli/outbound-endpoints.ts +9 -1
- package/cli/output-redaction.ts +49 -0
- package/detox/index.ts +0 -1
- 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 +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +12772 -1132
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +29 -5
- package/dist-lib/config.mjs +29 -5
- package/dist-lib/detox/index.cjs +19 -6
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +10411 -73
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +11220 -670
- package/dist-lib/host/fetch-proxy-handler.cjs +260 -197
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +653 -338
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +443 -312
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +548 -163
- package/dist-lib/native-app-identity-project.cjs +179 -33
- package/dist-lib/native-app-identity-project.mjs +179 -33
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +23 -23
- package/dist-lib/public-origins-lib.json +96 -63
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +12193 -1448
- package/dist-lib/swift-compile.cjs +10348 -172
- package/dist-lib/swift-compile.mjs +10348 -172
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +10411 -73
- package/dist-lib/vite.cjs +149 -163
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +14 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +21 -0
- package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +34 -0
- package/kotlin/README.md +38 -23
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +2 -12
- package/runtime-companion.json +1 -1
- package/src/bundleGlobalFooter.ts +0 -2
- package/src/config.ts +54 -2
- package/src/configured-bundle-producer.ts +7 -1
- package/src/host/fetch-proxy-handler.ts +14 -50
- package/src/host/rolldown-bundle-forward.ts +71 -0
- package/src/installed-package-versions.ts +54 -2
- package/src/kotlin-host.ts +138 -285
- package/src/kotlin-module.ts +4 -7
- package/src/kotlin-sdk.ts +81 -0
- package/src/kotlin-toolchain.ts +152 -0
- package/src/kotlin-view-models.ts +1 -1
- package/src/kotlinSdkContract.ts +113 -0
- package/src/nitro-adapter.lock.json +3 -3
- package/src/nitro-bundle.ts +18 -4
- package/src/nitro-compile.ts +5 -1
- package/src/nitro-source.ts +112 -28
- package/src/nitroContract.ts +16 -4
- package/src/stub-pattern-matcher.ts +4 -0
- package/src/swift-compile.ts +44 -14
- package/src/swift-host.ts +2 -1
- package/src/swift-objc-compile.ts +117 -4
- package/src/swift-objc-sdk.ts +10215 -59
- package/src/swift-objc-standin.ts +5 -2
- package/src/vite-plugin-one.ts +73 -134
- package/src/worker-system-chunks.ts +14 -4
- package/src/xcode-project.ts +261 -34
- package/kotlin/AndroidViewSources/android/content/Context.kt +0 -22
- package/kotlin/AndroidViewSources/android/content/res/Configuration.kt +0 -25
- package/kotlin/AndroidViewSources/android/content/res/Resources.kt +0 -72
- package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +0 -22
- package/kotlin/AndroidViewSources/android/graphics/Color.kt +0 -13
- package/kotlin/AndroidViewSources/android/graphics/Paint.kt +0 -18
- package/kotlin/AndroidViewSources/android/util/DisplayMetrics.kt +0 -12
- package/kotlin/AndroidViewSources/android/view/View.kt +0 -211
- package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +0 -61
- package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +0 -49
- package/kotlin/AndroidViewSources/dev/peach/app/JavaFormat.kt +0 -272
- package/kotlin/AppSources/android/app/Activity.kt +0 -174
- package/kotlin/AppSources/android/app/Application.kt +0 -11
- package/kotlin/AppSources/android/app/UiModeManager.kt +0 -9
- package/kotlin/AppSources/android/content/Intent.kt +0 -16
- package/kotlin/AppSources/android/os/Bundle.kt +0 -11
- package/kotlin/AppSources/android/util/SuperNotCalledException.kt +0 -3
- package/kotlin/AppSources/android/view/Window.kt +0 -182
- package/kotlin/AppSources/android/view/WindowInsets.kt +0 -9
- package/kotlin/AppSources/android/view/WindowInsetsController.kt +0 -17
- package/kotlin/AppSources/android/view/WindowManager.kt +0 -16
- package/kotlin/AppSources/android/window/BackEvent.kt +0 -24
- package/kotlin/AppSources/android/window/OnBackAnimationCallback.kt +0 -7
- package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +0 -84
- package/kotlin/AppSources/androidx/activity/ActivityFlags.kt +0 -9
- package/kotlin/AppSources/androidx/activity/ActivityViewModelLazy.kt +0 -21
- package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +0 -43
- package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +0 -122
- package/kotlin/AppSources/androidx/activity/EdgeToEdge.kt +0 -75
- package/kotlin/AppSources/androidx/activity/ExperimentalActivityApi.kt +0 -6
- package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +0 -69
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +0 -144
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +0 -7
- package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +0 -86
- package/kotlin/AppSources/androidx/activity/compose/ComponentActivity.kt +0 -29
- package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerCompat.kt +0 -38
- package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerDispatcherCompat.kt +0 -27
- package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +0 -15
- package/kotlin/AppSources/androidx/compose/ui/platform/AndroidCompositionLocals.kt +0 -27
- package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +0 -68
- package/kotlin/AppSources/androidx/compose/ui/res/ColorResources.kt +0 -16
- package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +0 -70
- package/kotlin/AppSources/androidx/compose/ui/res/StringResources.kt +0 -38
- package/kotlin/AppSources/androidx/core/view/WindowCompat.kt +0 -32
- package/kotlin/AppSources/androidx/lifecycle/AndroidViewModel.kt +0 -10
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +0 -388
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +0 -102
- package/kotlin/AppSources/dev/peach/app/PeachWindowHost.kt +0 -14
- package/kotlin/CompilerSources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +0 -1
- package/kotlin/CompilerSources/PeachJniIncoming.kt +0 -243
- package/kotlin/CompilerSources/PeachJniPlugin.kt +0 -116
- package/kotlin/ComposeSources/PeachComposeHost.kt +0 -724
- package/kotlin/ComposeSources/PeachMagnifier.kt +0 -185
- package/kotlin/ComposeSources/PeachSemantics.kt +0 -127
- package/kotlin/ExpoComposeSources/PeachAndroidView.kt +0 -103
- package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +0 -24
- package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +0 -28
- package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +0 -70
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +0 -516
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +0 -173
- package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +0 -20
- package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +0 -19
- package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +0 -198
- package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +0 -126
- package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +0 -132
- package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +0 -81
- package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +0 -98
- package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +0 -236
- package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +0 -12
- package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +0 -9
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +0 -50
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +0 -57
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +0 -19
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +0 -158
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +0 -8
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +0 -29
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +0 -9
- package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +0 -155
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +0 -91
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +0 -6
- package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +0 -68
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +0 -20
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +0 -72
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +0 -36
- package/kotlin/JniPlatformSources/androidx/annotation/CallSuper.kt +0 -5
- package/kotlin/JniPlatformSources/com/facebook/proguard/annotations/DoNotStrip.kt +0 -5
- package/kotlin/JniPlatformSources/dalvik/annotation/optimization/FastNative.kt +0 -5
- package/kotlin/JniPlatformSources/kotlin/Synchronized.kt +0 -6
- package/kotlin/JniPlatformSources/kotlin/jvm/JvmField.kt +0 -5
- package/kotlin/JniPlatformSources/kotlin/jvm/JvmStatic.kt +0 -5
- package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -66
- package/kotlin/JniSources/dev/peach/jni/IncomingBindings.kt +0 -157
- package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -77
- package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -89
- package/kotlin/Sources/android/os/Build.kt +0 -17
- package/kotlin/Sources/android/os/Handler.kt +0 -35
- package/kotlin/Sources/android/os/Looper.kt +0 -17
- package/kotlin/Sources/android/os/MessageQueue.kt +0 -56
- package/kotlin/Sources/android/os/SystemClock.kt +0 -14
- package/kotlin/Sources/android/util/Log.kt +0 -64
- package/kotlin/Sources/androidx/annotation/DrawableRes.kt +0 -14
- package/kotlin/Sources/androidx/annotation/Keep.kt +0 -4
- package/kotlin/Sources/dev/onejs/one/OneNativeSourceDispatch.kt +0 -7
- package/kotlin/Sources/dev/onejs/one/OneNativeSourceViewDispatch.kt +0 -13
- package/kotlin/Sources/dev/onejs/one/source/OneModule.kt +0 -4
- package/kotlin/Sources/java/lang/Runnable.kt +0 -6
- package/kotlin/Sources/java/security/MessageDigest.kt +0 -114
- package/kotlin/Sources/java/util/IllegalFormatCodePointException.kt +0 -10
- package/kotlin/Sources/java/util/IllegalFormatException.kt +0 -5
- package/kotlin/Sources/kotlin/text/StringFormat.kt +0 -9
- package/kotlin/Sources/org/json/JSON.kt +0 -307
- package/kotlin/tools/abi-classes.main.kts +0 -41
- package/kotlin/tools/expo-types.main.kts +0 -127
|
@@ -65,6 +65,7 @@ export function nativeInterfaceView(
|
|
|
65
65
|
if (process.platform !== 'darwin')
|
|
66
66
|
throw new Error('mixed framework declarations require the pinned native iOS SDK')
|
|
67
67
|
const xcrun = (args: string[]) =>
|
|
68
|
+
// runner-toolchain-platform: darwin
|
|
68
69
|
execFileSync('xcrun', args, {
|
|
69
70
|
encoding: 'utf8',
|
|
70
71
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
@@ -474,7 +475,7 @@ export function objcView(
|
|
|
474
475
|
),
|
|
475
476
|
}
|
|
476
477
|
: {}),
|
|
477
|
-
values: enumValues(graphs, surface, framework, toolchainBin, search, work),
|
|
478
|
+
values: enumValues(graphs, surface, framework, toolchainBin, search, work, original),
|
|
478
479
|
imports: [...imports].sort(),
|
|
479
480
|
}
|
|
480
481
|
}
|
|
@@ -604,6 +605,7 @@ function enumValues(
|
|
|
604
605
|
toolchainBin: string,
|
|
605
606
|
search: string[],
|
|
606
607
|
work: string,
|
|
608
|
+
original?: { flags: readonly string[]; target: string },
|
|
607
609
|
): Map<string, string> {
|
|
608
610
|
const wanted = new Map<string, string>()
|
|
609
611
|
for (const graph of graphs)
|
|
@@ -646,8 +648,9 @@ function enumValues(
|
|
|
646
648
|
`-fmodule-name=${surface.module}`,
|
|
647
649
|
'-fsyntax-only',
|
|
648
650
|
'-target',
|
|
649
|
-
IOS_SDK_TARGET,
|
|
651
|
+
original?.target ?? IOS_SDK_TARGET,
|
|
650
652
|
...flags,
|
|
653
|
+
...(original?.flags ?? []),
|
|
651
654
|
`-fmodules-cache-path=${path.join(work, 'clang-modules')}`,
|
|
652
655
|
'-Xclang',
|
|
653
656
|
'-ast-dump=json',
|
package/src/vite-plugin-one.ts
CHANGED
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
import fs from 'fs'
|
|
10
10
|
import { randomUUID } from 'node:crypto'
|
|
11
|
+
import http from 'node:http'
|
|
12
|
+
import https from 'node:https'
|
|
11
13
|
import { fileURLToPath } from 'node:url'
|
|
12
14
|
import path from 'path'
|
|
15
|
+
import { pipeline } from 'stream/promises'
|
|
13
16
|
import { WebSocket, WebSocketServer } from 'ws'
|
|
14
17
|
import { DEFAULT_SOOTSIM_BRIDGE_PORT } from './bridge-constants'
|
|
15
|
-
import { ROLLDOWN_INVENTORY_HEADER } from './bundleGlobalFooter'
|
|
16
18
|
import { getCliRuntime } from './cli-runtime'
|
|
17
19
|
import {
|
|
18
20
|
launchRnxDesktop,
|
|
@@ -22,6 +24,7 @@ import {
|
|
|
22
24
|
} from './dev-server-open'
|
|
23
25
|
import { isDaemonLockfileFresh, readDaemonLockfile } from './home-paths'
|
|
24
26
|
import { handleReplacementModuleRequest } from './host/replacement-module-handler'
|
|
27
|
+
import { forwardRolldownBundleResponse } from './host/rolldown-bundle-forward'
|
|
25
28
|
import { readInstalledNativePackageVersions } from './installed-package-versions'
|
|
26
29
|
import { configuredOneWidget } from './one-widget-metadata'
|
|
27
30
|
import {
|
|
@@ -49,6 +52,10 @@ function exposeHeader(res: ServerResponse, name: string) {
|
|
|
49
52
|
res.setHeader('access-control-expose-headers', [...names, name].join(', '))
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
// marks the plugin's own request for the bundle One builds, so the .bundle
|
|
56
|
+
// route forwards One's response instead of answering itself again.
|
|
57
|
+
const BUNDLE_SOURCE_REQUEST_HEADER = 'x-peach-bundle-source'
|
|
58
|
+
|
|
52
59
|
// every swift route sits under this prefix. the swift host (compiler client,
|
|
53
60
|
// resource packer, module glue) loads on the first request for one, so an app
|
|
54
61
|
// that imports no swift never evaluates it.
|
|
@@ -101,7 +108,14 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
101
108
|
|
|
102
109
|
async configureServer(server) {
|
|
103
110
|
if (options.enabled === false) return
|
|
104
|
-
//
|
|
111
|
+
// a native bundle carries the install it was built from, as hosted
|
|
112
|
+
// bundles do: any shell that launches it, including one that found this
|
|
113
|
+
// server by scanning, learns the installed native package versions. a
|
|
114
|
+
// page that fetches the bundle from this server directly (the shell at
|
|
115
|
+
// the plugin prefix, or a hosted page reaching this loopback server)
|
|
116
|
+
// gets the rolldown inventory the bundle proxy attaches for everyone
|
|
117
|
+
// else: the request is answered again by One's own handler and forwarded
|
|
118
|
+
// through the same producer. placed at the front of the stack so it runs
|
|
105
119
|
// ahead of One's .bundle handler even when one() precedes peachPlugin().
|
|
106
120
|
server.middlewares.use((req, res, next) => {
|
|
107
121
|
if (!(req.url ?? '').split('?')[0].endsWith('.bundle')) {
|
|
@@ -113,144 +127,66 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
113
127
|
JSON.stringify(readInstalledNativePackageVersions(server.config.root)),
|
|
114
128
|
)
|
|
115
129
|
exposeHeader(res, PACKAGE_VERSIONS_HEADER)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const origWrite = res.write.bind(res)
|
|
120
|
-
const origEnd = res.end.bind(res)
|
|
121
|
-
let pendingStatus: number | undefined
|
|
122
|
-
let pendingMessage: string | undefined
|
|
123
|
-
const flushHead = () => {
|
|
124
|
-
if (pendingStatus !== undefined && !res.headersSent) {
|
|
125
|
-
const code = pendingStatus
|
|
126
|
-
const msg = pendingMessage
|
|
127
|
-
pendingStatus = undefined
|
|
128
|
-
pendingMessage = undefined
|
|
129
|
-
if (typeof msg === 'string') origWriteHead(code, msg)
|
|
130
|
-
else origWriteHead(code)
|
|
131
|
-
}
|
|
130
|
+
if (req.method !== 'GET' || req.headers[BUNDLE_SOURCE_REQUEST_HEADER]) {
|
|
131
|
+
next()
|
|
132
|
+
return
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
res.removeHeader('content-length')
|
|
157
|
-
if (statusCode !== 200) res.removeHeader(ROLLDOWN_INVENTORY_HEADER)
|
|
158
|
-
return res
|
|
134
|
+
const address = server.httpServer?.address()
|
|
135
|
+
if (!address || typeof address !== 'object') {
|
|
136
|
+
next()
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
const loopback =
|
|
140
|
+
address.address === '::' || address.address === '0.0.0.0'
|
|
141
|
+
? '127.0.0.1'
|
|
142
|
+
: address.address
|
|
143
|
+
const authority = req.headers[':authority']
|
|
144
|
+
const options: https.RequestOptions = {
|
|
145
|
+
host: loopback,
|
|
146
|
+
port: address.port,
|
|
147
|
+
path: req.url,
|
|
148
|
+
method: 'GET',
|
|
149
|
+
headers: {
|
|
150
|
+
...Object.fromEntries(
|
|
151
|
+
Object.entries(req.headers).filter(([key]) => !key.startsWith(':')),
|
|
152
|
+
),
|
|
153
|
+
host:
|
|
154
|
+
req.headers.host ?? (typeof authority === 'string' ? authority : undefined),
|
|
155
|
+
'accept-encoding': 'identity',
|
|
156
|
+
[BUNDLE_SOURCE_REQUEST_HEADER]: '1',
|
|
159
157
|
},
|
|
160
|
-
|
|
161
|
-
const chunks: Buffer[] = []
|
|
162
|
-
let buffering = false
|
|
163
|
-
const isBufferEncoding = (value: unknown): value is BufferEncoding =>
|
|
164
|
-
typeof value === 'string' && Buffer.isEncoding(value)
|
|
165
|
-
const toBuffer = (chunk: unknown, encoding?: unknown): Buffer | null => {
|
|
166
|
-
if (chunk === undefined || chunk === null || typeof chunk === 'function')
|
|
167
|
-
return null
|
|
168
|
-
if (Buffer.isBuffer(chunk)) return chunk
|
|
169
|
-
if (chunk instanceof Uint8Array) return Buffer.from(chunk)
|
|
170
|
-
if (typeof chunk === 'string')
|
|
171
|
-
return Buffer.from(chunk, isBufferEncoding(encoding) ? encoding : 'utf8')
|
|
172
|
-
return null
|
|
158
|
+
rejectUnauthorized: false,
|
|
173
159
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return origWrite('')
|
|
179
|
-
}
|
|
180
|
-
if (!buffering) {
|
|
181
|
-
const lower = buf.toString('utf8').toLowerCase()
|
|
182
|
-
const contentType = String(res.getHeader('content-type') ?? '').toLowerCase()
|
|
160
|
+
const respond = (upstream: http.IncomingMessage) => {
|
|
161
|
+
res.statusCode = upstream.statusCode ?? 502
|
|
162
|
+
for (const [key, value] of Object.entries(upstream.headers)) {
|
|
163
|
+
const lowerKey = key.toLowerCase()
|
|
183
164
|
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
165
|
+
value === undefined ||
|
|
166
|
+
lowerKey === 'connection' ||
|
|
167
|
+
lowerKey === 'keep-alive' ||
|
|
168
|
+
lowerKey === 'transfer-encoding'
|
|
187
169
|
) {
|
|
188
|
-
|
|
170
|
+
continue
|
|
189
171
|
}
|
|
172
|
+
res.setHeader(key, value)
|
|
190
173
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
174
|
+
const forward =
|
|
175
|
+
res.statusCode === 200
|
|
176
|
+
? forwardRolldownBundleResponse(upstream, res)
|
|
177
|
+
: pipeline(upstream, res)
|
|
178
|
+
forward.catch((error: unknown) =>
|
|
179
|
+
res.destroy(error instanceof Error ? error : new Error(String(error))),
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
const upstreamReq = server.config.server.https
|
|
183
|
+
? https.request(options, respond)
|
|
184
|
+
: http.request(options, respond)
|
|
185
|
+
upstreamReq.once('error', next)
|
|
186
|
+
req.once('close', () => {
|
|
187
|
+
if (!res.writableFinished) upstreamReq.destroy()
|
|
197
188
|
})
|
|
198
|
-
|
|
199
|
-
res,
|
|
200
|
-
'end',
|
|
201
|
-
function (chunk?: unknown, arg1?: unknown, arg2?: unknown) {
|
|
202
|
-
const callback =
|
|
203
|
-
typeof chunk === 'function'
|
|
204
|
-
? chunk
|
|
205
|
-
: typeof arg1 === 'function'
|
|
206
|
-
? arg1
|
|
207
|
-
: typeof arg2 === 'function'
|
|
208
|
-
? arg2
|
|
209
|
-
: undefined
|
|
210
|
-
const finish = () => {
|
|
211
|
-
flushHead()
|
|
212
|
-
if (typeof callback === 'function') {
|
|
213
|
-
return origEnd(() => {
|
|
214
|
-
Reflect.apply(callback, res, [])
|
|
215
|
-
})
|
|
216
|
-
}
|
|
217
|
-
return origEnd()
|
|
218
|
-
}
|
|
219
|
-
const buf = toBuffer(chunk, arg1)
|
|
220
|
-
if (buf) chunks.push(buf)
|
|
221
|
-
if (chunks.length === 0 || (res.statusCode && res.statusCode !== 200)) {
|
|
222
|
-
if (!res.headersSent) res.removeHeader(ROLLDOWN_INVENTORY_HEADER)
|
|
223
|
-
flushHead()
|
|
224
|
-
for (const queued of chunks) origWrite(queued)
|
|
225
|
-
return finish()
|
|
226
|
-
}
|
|
227
|
-
const payload = Buffer.concat(chunks).toString('utf8')
|
|
228
|
-
const contentType = String(res.getHeader('content-type') ?? '')
|
|
229
|
-
void getCliRuntime()
|
|
230
|
-
.rolldown_bundle_inventory.attachRolldownBundleHttpPayload(
|
|
231
|
-
payload,
|
|
232
|
-
contentType,
|
|
233
|
-
)
|
|
234
|
-
.then((annotated) => {
|
|
235
|
-
if (!res.headersSent) res.removeHeader('content-length')
|
|
236
|
-
flushHead()
|
|
237
|
-
origWrite(Buffer.from(annotated, 'utf8'))
|
|
238
|
-
finish()
|
|
239
|
-
})
|
|
240
|
-
.catch((error: unknown) => {
|
|
241
|
-
console.error('[peach] failed to attach rolldown bundle inventory', error)
|
|
242
|
-
if (!res.headersSent) {
|
|
243
|
-
res.removeHeader('content-length')
|
|
244
|
-
res.removeHeader(ROLLDOWN_INVENTORY_HEADER)
|
|
245
|
-
}
|
|
246
|
-
flushHead()
|
|
247
|
-
origWrite(Buffer.from(payload, 'utf8'))
|
|
248
|
-
finish()
|
|
249
|
-
})
|
|
250
|
-
return res
|
|
251
|
-
},
|
|
252
|
-
)
|
|
253
|
-
next()
|
|
189
|
+
upstreamReq.end()
|
|
254
190
|
})
|
|
255
191
|
const bundleLayer = server.middlewares.stack.pop()
|
|
256
192
|
if (bundleLayer) server.middlewares.stack.unshift(bundleLayer)
|
|
@@ -370,8 +306,11 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
370
306
|
loadKotlinHost()
|
|
371
307
|
.then(async (host) => {
|
|
372
308
|
if (!kotlinModuleRoot) {
|
|
373
|
-
|
|
374
|
-
|
|
309
|
+
const root = host.peachKotlinModuleRoot()
|
|
310
|
+
kotlinModuleRoot = root
|
|
311
|
+
server.watcher.add(
|
|
312
|
+
['sdk.tar.gz', 'toolchain.json'].map((file) => path.join(root, file)),
|
|
313
|
+
)
|
|
375
314
|
}
|
|
376
315
|
const served = await host.serveKotlinRequest(pathname, res, {
|
|
377
316
|
root: server.config.root,
|
|
@@ -8,12 +8,12 @@ const require = createRequire(import.meta.url)
|
|
|
8
8
|
const systemRuntime = fs.readFileSync(require.resolve('systemjs/dist/s.min.js'), 'utf8')
|
|
9
9
|
const minifierModule = require.resolve('rolldown/utils')
|
|
10
10
|
const rollupModule = require.resolve('rollup')
|
|
11
|
-
type MinifiedWorkerChunk = { code: string; map: string }
|
|
11
|
+
type MinifiedWorkerChunk = { code: string; map: string; loweredCode?: string }
|
|
12
12
|
const minifierWorker = `
|
|
13
13
|
const { parentPort, workerData } = require('node:worker_threads');
|
|
14
14
|
const minifier = import(workerData.module);
|
|
15
15
|
const lowering = import(workerData.rollup);
|
|
16
|
-
parentPort.on('message', async ({ code, isEntry, keepNames, measurement, inputMap, entryImports }) => {
|
|
16
|
+
parentPort.on('message', async ({ code, isEntry, keepNames, measurement, inputMap, entryImports, captureStages }) => {
|
|
17
17
|
try {
|
|
18
18
|
const { rollup } = await lowering;
|
|
19
19
|
const entry = 'peach-worker-chunk.js';
|
|
@@ -55,7 +55,7 @@ parentPort.on('message', async ({ code, isEntry, keepNames, measurement, inputMa
|
|
|
55
55
|
inputMap: JSON.parse(loweredMap),
|
|
56
56
|
});
|
|
57
57
|
if (result.errors.length) throw new Error(result.errors.map(error => error.message).join('; '));
|
|
58
|
-
parentPort.postMessage({ code: result.code, map: result.map && JSON.stringify(result.map) });
|
|
58
|
+
parentPort.postMessage({ code: result.code, map: result.map && JSON.stringify(result.map), ...(captureStages ? { loweredCode } : {}) });
|
|
59
59
|
} catch (error) {
|
|
60
60
|
parentPort.postMessage({ error: error instanceof Error ? error.message : String(error) });
|
|
61
61
|
}
|
|
@@ -67,6 +67,7 @@ type MinifierJob = {
|
|
|
67
67
|
keepNames: boolean
|
|
68
68
|
inputMap: string | undefined
|
|
69
69
|
entryImports: readonly string[]
|
|
70
|
+
captureStages: boolean
|
|
70
71
|
resolve: (result: MinifiedWorkerChunk) => void
|
|
71
72
|
reject: (error: Error) => void
|
|
72
73
|
}
|
|
@@ -119,7 +120,13 @@ function runMinifiers() {
|
|
|
119
120
|
message.code &&
|
|
120
121
|
typeof message.map === 'string'
|
|
121
122
|
) {
|
|
122
|
-
result = {
|
|
123
|
+
result = {
|
|
124
|
+
code: message.code,
|
|
125
|
+
map: message.map,
|
|
126
|
+
...(job?.captureStages && typeof message.loweredCode === 'string'
|
|
127
|
+
? { loweredCode: message.loweredCode }
|
|
128
|
+
: {}),
|
|
129
|
+
}
|
|
123
130
|
} else {
|
|
124
131
|
created.failure = new Error(
|
|
125
132
|
'worker minification produced no code or source map',
|
|
@@ -167,6 +174,7 @@ function runMinifiers() {
|
|
|
167
174
|
keepNames: job.keepNames,
|
|
168
175
|
inputMap: job.inputMap,
|
|
169
176
|
entryImports: job.entryImports,
|
|
177
|
+
captureStages: job.captureStages,
|
|
170
178
|
measurement: process.env.PEACH_ENGINE_PROFILE === '1',
|
|
171
179
|
})
|
|
172
180
|
} catch (error) {
|
|
@@ -294,6 +302,7 @@ export function renderWorkerSystemChunk(
|
|
|
294
302
|
keepNames = false,
|
|
295
303
|
inputMap?: string,
|
|
296
304
|
entryImports: readonly string[] = [],
|
|
305
|
+
captureStages = false,
|
|
297
306
|
) {
|
|
298
307
|
return new Promise<MinifiedWorkerChunk>((resolve, reject) => {
|
|
299
308
|
pendingMinifiers.push({
|
|
@@ -302,6 +311,7 @@ export function renderWorkerSystemChunk(
|
|
|
302
311
|
keepNames,
|
|
303
312
|
inputMap,
|
|
304
313
|
entryImports,
|
|
314
|
+
captureStages,
|
|
305
315
|
resolve,
|
|
306
316
|
reject,
|
|
307
317
|
})
|