peachsim 0.1.2591 → 0.1.2593
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 +5684 -5254
- 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-EMX4WZ72.mjs → acorn-DLENU3SM.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-VYZ5DC3M.mjs → chunk-23D4W2EY.mjs} +1015 -703
- package/dist-lib/esm-chunks/{chunk-MC6NMYWY.mjs → chunk-2MWUVSRW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UIVXVMS5.mjs → chunk-2UERF2EN.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-VRVXRZI4.mjs → chunk-4YJJKKKF.mjs} +112 -58
- package/dist-lib/esm-chunks/{chunk-AKKHSVJ4.mjs → chunk-6O2M4J2Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EGKH2L6J.mjs → chunk-BMKI4WBL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4QHHRGO4.mjs → chunk-DLSPHUHQ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UYJXLDCG.mjs → chunk-E6OGMX3T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VF5WVB3D.mjs → chunk-GFMQ5PNX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-JHXDM3YU.mjs → chunk-IT4CC3HU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-J676B57D.mjs → chunk-JPNUGMLE.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-RKQZGWX2.mjs → chunk-KWMJUJJS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QBMFX3J2.mjs → chunk-LK3KQ4X3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZL5N6ENT.mjs → chunk-LN7ZTBNS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Q4NA6PUR.mjs → chunk-NIYJBFXV.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-7627LKJK.mjs → chunk-OIHSBING.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YR6DNV76.mjs → chunk-P3A4MQHR.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VD27WNCT.mjs → chunk-TXBZEHNH.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-TFG4LZ5T.mjs → chunk-UM4DCXPA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ILWFGZWW.mjs → chunk-UZPLSN2V.mjs} +107 -6
- package/dist-lib/esm-chunks/{chunk-SOAYP72T.mjs → chunk-XFFPOSW2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NX23AMX4.mjs → chunk-ZT5ZXQC2.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-ANKZARNW.mjs → metro-layout-parser-DHGC2DVE.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-4N5CXBOZ.mjs → swift-package-prebuilt-ROIDLGLU.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-5IUSRXYA.mjs → swift-sdk-app-module-5VU63S56.mjs} +30 -20
- package/dist-lib/esm-chunks/{swift-sdk-image-7T2LMQS5.mjs → swift-sdk-image-SNFZVUQ3.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-7QJ3BF6E.mjs → swift-sdk-image-producer-5RQDIX53.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +3561 -3134
- 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 +6082 -5142
- package/dist-lib/host/fetch-proxy-handler.cjs +314 -301
- 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 +1 -1
- 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 +241 -226
- package/dist-lib/native-app-identity-project.mjs +17 -17
- 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 +81 -81
- package/dist-lib/public-origins-lib.json +75 -73
- 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 +8 -8
- package/dist-lib/skills.cjs +6704 -5764
- package/dist-lib/swift-compile.cjs +1333 -922
- 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 +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +12 -6
- 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/engine/native-node-queries.d.ts +1 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/binaryen.lock.json +3 -3
- package/src/native-bundles.ts +2 -0
- package/src/one-native-controls-package.ts +235 -40
- package/src/one-sdk/source.ts +2 -1
- package/src/one-sdk-preparation.ts +40 -2
- package/src/oneSdkContract.ts +13 -2
- package/src/swift-compile.ts +301 -48
- package/src/swift-guest-compile.ts +11 -2
- package/src/swift-guest-projection-storage.ts +45 -26
- package/src/swift-guest-runtime-plan.ts +1 -1
- package/src/swift-host.ts +88 -16
- package/src/swift-reproducible.ts +16 -2
- package/src/swift-root-lock.ts +77 -5
- package/src/swift-sdk-app-module.ts +15 -6
- package/src/swift-sdk-image-wasm.ts +5 -2
- package/src/swift-sdk-image.ts +122 -59
- package/src/swift-startup-split.ts +65 -27
- package/src/swift-toolchain.ts +16 -5
- package/src/swift-wasm-prune.ts +51 -34
- package/src/wasm-lazy-split.ts +46 -40
- package/src/wasm-optimize.ts +146 -140
|
@@ -6,6 +6,7 @@ import { createRequire } from 'node:module'
|
|
|
6
6
|
import path from 'node:path'
|
|
7
7
|
import { fileURLToPath } from 'node:url'
|
|
8
8
|
import { swiftGuestControls } from '../../peach-globals/build/one-swift-control-source'
|
|
9
|
+
import { oneSDKHost, oneSDKModule, oneSDKTransport } from './one-sdk/source'
|
|
9
10
|
import {
|
|
10
11
|
ONE_NATIVE_CONTROLS_CONTRACT,
|
|
11
12
|
ONE_NATIVE_CONTROLS_NAVIGATION_SPLIT_VIEW,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
ONE_NATIVE_CONTROLS_PACKAGE,
|
|
14
15
|
} from './oneNativeControlsContract'
|
|
15
16
|
import { swiftCodeMask, syncSwiftTree } from './swift-compile'
|
|
16
|
-
import { swiftPackageAssets, swiftPackageMetadata } from './swift-host'
|
|
17
|
+
import { projectFor, swiftPackageAssets, swiftPackageMetadata } from './swift-host'
|
|
17
18
|
import { collectSwiftSourceClosure } from './swift-source-closure'
|
|
18
19
|
import { SWIFT_HMR_PATH, SWIFT_PACKAGE_PATH } from './swift-submit'
|
|
19
20
|
import { privateSwiftDistributionRoot, swiftCacheDir } from './swift-toolchain'
|
|
@@ -142,11 +143,55 @@ private func normalizeStyle(_ raw: Spec?) -> Spec {
|
|
|
142
143
|
return style
|
|
143
144
|
}
|
|
144
145
|
|
|
146
|
+
protocol OneGuestIncrementalContainer: AnyObject {
|
|
147
|
+
func insertChild(_ child: UIView, at index: Int)
|
|
148
|
+
func removeChild(_ child: UIView)
|
|
149
|
+
func reset()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private final class DeferredControl {
|
|
153
|
+
private let composition = ControlComposition()
|
|
154
|
+
private var node: Spec
|
|
155
|
+
private lazy var realized = OneNativeDeferredRow(
|
|
156
|
+
createView: { [weak self] in self?.render() },
|
|
157
|
+
releaseView: { [weak self] _ in self?.composition.prune(keeping: []) }
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
init(node: Spec, owner: ControlComposition) {
|
|
161
|
+
self.node = node
|
|
162
|
+
composition.emit = { [weak owner] name, fields in owner?.emit?(name, fields) }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
func update(_ node: Spec, content: Spec) -> OneNativeDeferredRow {
|
|
166
|
+
self.node = node
|
|
167
|
+
realized.configureListRowModifiers(
|
|
168
|
+
styleModifiers(node),
|
|
169
|
+
contentModifiers: styleModifiers(content)
|
|
170
|
+
)
|
|
171
|
+
if !composition.views.isEmpty { _ = render() }
|
|
172
|
+
return realized
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private func styleModifiers(_ node: Spec) -> String? {
|
|
176
|
+
let spec = node["spec"] as? Spec
|
|
177
|
+
let style = spec?["swiftStyle"] as? Spec
|
|
178
|
+
return style?["sdkModifiers"] as? String
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private func render() -> UIView {
|
|
182
|
+
var visited = Set<String>()
|
|
183
|
+
let view = composition.render(node, visited: &visited)
|
|
184
|
+
composition.prune(keeping: visited)
|
|
185
|
+
return view
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
145
189
|
private class ControlComposition {
|
|
146
190
|
private static let reconciledContainers: Set<String> = [
|
|
147
191
|
"OneNativeLazyVStack", "OneNativeLazyHStack", "OneNativeLazyVGrid", "OneNativeLazyHGrid",
|
|
148
192
|
"OneNativeList", "OneNativeSection", "OneNativeForm",
|
|
149
193
|
]
|
|
194
|
+
private var deferredRows: [String: DeferredControl] = [:]
|
|
150
195
|
var views: [String: UIView] = [:]
|
|
151
196
|
var specs: [String: Spec] = [:]
|
|
152
197
|
var children: [String: [UIView]] = [:]
|
|
@@ -182,6 +227,7 @@ private class ControlComposition {
|
|
|
182
227
|
}
|
|
183
228
|
let view: UIView
|
|
184
229
|
visited.insert(id)
|
|
230
|
+
deferredRows.removeValue(forKey: id)
|
|
185
231
|
switch control {
|
|
186
232
|
case "OneNativeToolbar":
|
|
187
233
|
view = views[id] ?? OneNativeToolbarView()
|
|
@@ -226,25 +272,63 @@ private class ControlComposition {
|
|
|
226
272
|
if let container = view as? OneNativeContainerView {
|
|
227
273
|
container.configureSwiftStyle(style)
|
|
228
274
|
container.onSwiftStyleEvent = visit
|
|
229
|
-
let
|
|
275
|
+
let nodes = node["children"] as? [Spec] ?? []
|
|
230
276
|
if Self.reconciledContainers.contains(control) {
|
|
277
|
+
let nested = nodes.map { child -> NSObject in
|
|
278
|
+
if control == "OneNativeSection", let content = deferredContent(child) {
|
|
279
|
+
let childID = child["id"] as! String
|
|
280
|
+
visited.insert(childID)
|
|
281
|
+
let deferred = deferredRows[childID] ?? DeferredControl(node: child, owner: self)
|
|
282
|
+
deferredRows[childID] = deferred
|
|
283
|
+
if let previous = views.removeValue(forKey: childID) {
|
|
284
|
+
(previous as? OneNativeContainerView)?.reset()
|
|
285
|
+
specs.removeValue(forKey: childID)
|
|
286
|
+
children.removeValue(forKey: childID)
|
|
287
|
+
}
|
|
288
|
+
return deferred.update(child, content: content)
|
|
289
|
+
}
|
|
290
|
+
return render(child, visited: &visited)
|
|
291
|
+
}
|
|
231
292
|
container.reconcileComposedChildren(nested)
|
|
232
293
|
} else {
|
|
233
|
-
|
|
234
|
-
nested,
|
|
235
|
-
previous: children[id] ?? [],
|
|
236
|
-
remove: container.removeChild,
|
|
237
|
-
insert: container.insertChild
|
|
238
|
-
)
|
|
294
|
+
placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
|
|
239
295
|
}
|
|
240
|
-
|
|
296
|
+
} else if let container = view as? OneGuestIncrementalContainer {
|
|
297
|
+
placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
|
|
241
298
|
}
|
|
242
299
|
return view
|
|
243
300
|
}
|
|
244
301
|
|
|
302
|
+
private func deferredContent(_ node: Spec) -> Spec? {
|
|
303
|
+
guard (node["spec"] as? Spec)?["control"] as? String == "OneNativeSwipeActions" else { return nil }
|
|
304
|
+
let content = (node["children"] as? [Spec] ?? []).filter {
|
|
305
|
+
($0["spec"] as? Spec)?["control"] as? String != "OneNativeSwipeActionsActions"
|
|
306
|
+
}
|
|
307
|
+
guard content.count == 1, (content[0]["spec"] as? Spec)?["control"] as? String == "OneNativeButton" else {
|
|
308
|
+
return nil
|
|
309
|
+
}
|
|
310
|
+
return content[0]
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private func placeIncrementally(
|
|
314
|
+
_ node: Spec,
|
|
315
|
+
id: String,
|
|
316
|
+
visited: inout Set<String>,
|
|
317
|
+
remove: (UIView) -> Void,
|
|
318
|
+
insert: (UIView, Int) -> Void
|
|
319
|
+
) {
|
|
320
|
+
let nested = (node["children"] as? [Spec] ?? []).map { render($0, visited: &visited) }
|
|
321
|
+
reconcile(nested, previous: children[id] ?? [], remove: remove, insert: insert)
|
|
322
|
+
children[id] = nested
|
|
323
|
+
}
|
|
324
|
+
|
|
245
325
|
func prune(keeping visited: Set<String>) {
|
|
326
|
+
for id in deferredRows.keys where !visited.contains(id) {
|
|
327
|
+
deferredRows.removeValue(forKey: id)
|
|
328
|
+
}
|
|
246
329
|
for (id, view) in views where !visited.contains(id) {
|
|
247
330
|
if let container = view as? OneNativeContainerView { container.reset() }
|
|
331
|
+
if let container = view as? OneGuestIncrementalContainer { container.reset() }
|
|
248
332
|
views.removeValue(forKey: id)
|
|
249
333
|
specs.removeValue(forKey: id)
|
|
250
334
|
children.removeValue(forKey: id)
|
|
@@ -555,8 +639,10 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
|
|
|
555
639
|
default:
|
|
556
640
|
let root = spec["root"] as! Spec
|
|
557
641
|
precondition((root["spec"] as? Spec)?["control"] as? String == view)
|
|
558
|
-
|
|
559
|
-
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
642
|
+
let bridge = ControlBridge(root: root, emit: emit)
|
|
643
|
+
.frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity)
|
|
644
|
+
let height = (spec["height"] as? Double).map { CGFloat($0) }
|
|
645
|
+
return AnyView(bridge.frame(height: height))
|
|
560
646
|
}
|
|
561
647
|
}
|
|
562
648
|
}
|
|
@@ -642,7 +728,19 @@ private let startupProfileSpec: [String: Any] = [
|
|
|
642
728
|
|
|
643
729
|
@main
|
|
644
730
|
struct OneNativeControlsGuest: PeachPackage {
|
|
645
|
-
func view(props: JSON) -> some View {
|
|
731
|
+
@ViewBuilder func view(props: JSON) -> some View {
|
|
732
|
+
#if PEACH_ONE_SDK
|
|
733
|
+
if props["oneSDKHost"] != nil {
|
|
734
|
+
OneSDKUIKitHost(props: props)
|
|
735
|
+
} else {
|
|
736
|
+
startupProfile
|
|
737
|
+
}
|
|
738
|
+
#else
|
|
739
|
+
startupProfile
|
|
740
|
+
#endif
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
private var startupProfile: some View {
|
|
646
744
|
NavigationStackBridge(spec: startupProfileSpec, emit: { _, _ in })
|
|
647
745
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
648
746
|
}
|
|
@@ -695,9 +793,25 @@ function defaultSwiftModuleRoot(): string | undefined {
|
|
|
695
793
|
return fs.existsSync(path.join(root, 'toolchain.json')) ? root : undefined
|
|
696
794
|
}
|
|
697
795
|
|
|
796
|
+
const ONE_SDK_RUNTIME_SOURCES = [
|
|
797
|
+
'SDK/OneSDKRuntime.swift',
|
|
798
|
+
'OneNativeUIKitHostView.swift',
|
|
799
|
+
'OneNativeContent.swift',
|
|
800
|
+
'OneNativeAccessibility.swift',
|
|
801
|
+
'SDKViews/OneNativeViewsTable.swift',
|
|
802
|
+
] as const
|
|
803
|
+
|
|
804
|
+
export interface OneNativeControlsSDKInput {
|
|
805
|
+
files: ReadonlyMap<string, string>
|
|
806
|
+
modules: readonly string[]
|
|
807
|
+
defines?: readonly string[]
|
|
808
|
+
reemitForWasi?: (diagnostic: string) => Promise<ReadonlyMap<string, string> | undefined>
|
|
809
|
+
}
|
|
810
|
+
|
|
698
811
|
export interface OneNativeControlsPackage {
|
|
699
812
|
packagePath: string
|
|
700
813
|
watched: string[]
|
|
814
|
+
oneSDKModules?: string[]
|
|
701
815
|
}
|
|
702
816
|
|
|
703
817
|
function excludedGroupSource(source: string, defines: ReadonlySet<string>): boolean {
|
|
@@ -718,6 +832,7 @@ function excludedGroupSource(source: string, defines: ReadonlySet<string>): bool
|
|
|
718
832
|
export async function oneNativeControlsPackage(
|
|
719
833
|
appRoot?: string,
|
|
720
834
|
linkedGroups?: readonly string[],
|
|
835
|
+
sdk?: OneNativeControlsSDKInput | null,
|
|
721
836
|
): Promise<OneNativeControlsPackage> {
|
|
722
837
|
const iosDir = resolveOneNativeAppleIosDir(appRoot)
|
|
723
838
|
const generated = swiftGuestControls(
|
|
@@ -728,10 +843,13 @@ export async function oneNativeControlsPackage(
|
|
|
728
843
|
const sources: Record<string, string> = {}
|
|
729
844
|
const paths = new Map<string, string>()
|
|
730
845
|
const defines = new Set([...ONE_SDK_DEFINES, ...generated.defines])
|
|
846
|
+
const bindings = sdk && sdk.files.size && sdk.modules.length ? sdk : undefined
|
|
847
|
+
const sdkSources = new Set(ONE_SDK_RUNTIME_SOURCES.map((file) => path.basename(file)))
|
|
731
848
|
for (const folder of ['', 'Generated', 'SDK']) {
|
|
732
849
|
for (const name of fs.readdirSync(path.join(iosDir, folder)).sort()) {
|
|
733
850
|
// the guest SDK supplies PeachPackage and its JSON type.
|
|
734
851
|
if (!name.endsWith('.swift') || name === 'OneSwiftPackage.swift') continue
|
|
852
|
+
if (bindings && sdkSources.has(name)) continue
|
|
735
853
|
if (paths.has(name))
|
|
736
854
|
throw new Error(`duplicate Swift filename ${name} in OneNativeControls`)
|
|
737
855
|
const full = path.join(iosDir, folder, name)
|
|
@@ -743,7 +861,7 @@ export async function oneNativeControlsPackage(
|
|
|
743
861
|
}
|
|
744
862
|
sources['OneNativeGuestControls.swift'] = generated.source
|
|
745
863
|
sources['OneNativeControlsBridge.swift'] = BRIDGE_SWIFT
|
|
746
|
-
const
|
|
864
|
+
const controls = new Map(
|
|
747
865
|
Object.entries(
|
|
748
866
|
collectSwiftSourceClosure(
|
|
749
867
|
sources,
|
|
@@ -754,28 +872,76 @@ export async function oneNativeControlsPackage(
|
|
|
754
872
|
),
|
|
755
873
|
)
|
|
756
874
|
const watched = new Set(generated.watched)
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
875
|
+
const files = new Map<string, string>()
|
|
876
|
+
const prefix = bindings ? 'Sources/Controls/' : ''
|
|
877
|
+
for (const [name, source] of controls) {
|
|
878
|
+
files.set(prefix + name, source)
|
|
761
879
|
const full = paths.get(name)
|
|
762
880
|
if (full) watched.add(full)
|
|
763
|
-
digest.update(name).update('\0').update(source).update('\0')
|
|
764
881
|
}
|
|
765
882
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
883
|
+
if (bindings) {
|
|
884
|
+
files.set('Sources/One/One.swift', oneSDKModule)
|
|
885
|
+
for (const relative of ONE_SDK_RUNTIME_SOURCES) {
|
|
886
|
+
const full = path.join(iosDir, relative)
|
|
887
|
+
files.set('Sources/One/' + path.basename(relative), fs.readFileSync(full, 'utf8'))
|
|
888
|
+
watched.add(full)
|
|
889
|
+
}
|
|
890
|
+
for (const [name, content] of [...bindings.files].sort(([a], [b]) =>
|
|
891
|
+
a.localeCompare(b),
|
|
892
|
+
)) {
|
|
893
|
+
const relative = 'Sources/OneSDKBindings/' + path.basename(name)
|
|
894
|
+
if (files.has(relative))
|
|
895
|
+
throw new Error('duplicate Swift filename in OneSDKBindings: ' + relative)
|
|
896
|
+
files.set(relative, content)
|
|
897
|
+
}
|
|
898
|
+
files.set('Sources/Controls/OneSDKHost.swift', oneSDKHost)
|
|
899
|
+
files.set('Sources/Controls/OneSDKTransport.swift', oneSDKTransport)
|
|
900
|
+
defines.add('PEACH_ONE_SDK')
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
const swiftDefines = (flags: Iterable<string>) =>
|
|
904
|
+
Array.from(flags, (flag) => '.define(' + JSON.stringify(flag) + ')')
|
|
905
|
+
const bindingSettings = [
|
|
906
|
+
...swiftDefines(bindings?.defines ?? []),
|
|
907
|
+
'.unsafeFlags(["-suppress-warnings"])',
|
|
908
|
+
]
|
|
909
|
+
const controlSettings = [
|
|
910
|
+
'.swiftLanguageMode(.v5)',
|
|
911
|
+
...swiftDefines(defines),
|
|
912
|
+
...(bindings
|
|
913
|
+
? ['.unsafeFlags(["-Xfrontend", "-import-module", "-Xfrontend", "One"])']
|
|
914
|
+
: []),
|
|
915
|
+
]
|
|
916
|
+
|
|
917
|
+
let manifest: string
|
|
918
|
+
if (bindings) {
|
|
919
|
+
manifest = [
|
|
770
920
|
'// swift-tools-version: 6.2',
|
|
771
|
-
`// OneNativeControls ${key}`,
|
|
772
921
|
'import PackageDescription',
|
|
773
922
|
`let package = Package(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", platforms: [.iOS(.v17)], targets: [`,
|
|
774
|
-
|
|
923
|
+
' .target(name: "One", path: "Sources/One"),',
|
|
924
|
+
` .target(name: "OneSDKBindings", dependencies: ["One"], path: "Sources/OneSDKBindings", swiftSettings: [${bindingSettings.join(', ')}]),`,
|
|
925
|
+
` .executableTarget(name: "Controls", dependencies: ["One", "OneSDKBindings"], path: "Sources/Controls", swiftSettings: [${controlSettings.join(', ')}]),`,
|
|
775
926
|
'])',
|
|
776
927
|
'',
|
|
777
|
-
].join('\n')
|
|
778
|
-
|
|
928
|
+
].join('\n')
|
|
929
|
+
} else {
|
|
930
|
+
manifest = [
|
|
931
|
+
'// swift-tools-version: 6.2',
|
|
932
|
+
'import PackageDescription',
|
|
933
|
+
`let package = Package(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", platforms: [.iOS(.v17)], targets: [`,
|
|
934
|
+
` .executableTarget(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", path: ".", swiftSettings: [${controlSettings.join(', ')}]),`,
|
|
935
|
+
'])',
|
|
936
|
+
'',
|
|
937
|
+
].join('\n')
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const digest = createHash('sha256').update(manifest)
|
|
941
|
+
for (const [name, source] of files)
|
|
942
|
+
digest.update(name).update('\0').update(source).update('\0')
|
|
943
|
+
const key = digest.digest('hex').slice(0, 16)
|
|
944
|
+
files.set('Package.swift', manifest)
|
|
779
945
|
|
|
780
946
|
const packagePath = path.join(
|
|
781
947
|
swiftCacheDir(),
|
|
@@ -788,30 +954,59 @@ export async function oneNativeControlsPackage(
|
|
|
788
954
|
packagePath,
|
|
789
955
|
new Map([...files].map(([file, text]) => [path.join(packagePath, file), text])),
|
|
790
956
|
)
|
|
791
|
-
return {
|
|
957
|
+
return {
|
|
958
|
+
packagePath,
|
|
959
|
+
watched: [...watched],
|
|
960
|
+
oneSDKModules: bindings && [...bindings.modules],
|
|
961
|
+
}
|
|
792
962
|
}
|
|
793
963
|
|
|
794
964
|
export async function stageOneNativeControlsRelease(
|
|
795
965
|
appRoot?: string,
|
|
796
|
-
options?: {
|
|
966
|
+
options?: {
|
|
967
|
+
moduleRoot?: string
|
|
968
|
+
startupRuntimeUrl?: URL
|
|
969
|
+
sdk?: OneNativeControlsSDKInput | null
|
|
970
|
+
},
|
|
797
971
|
linkedGroups?: readonly string[],
|
|
798
972
|
): Promise<{
|
|
799
973
|
metadataPath: string
|
|
800
974
|
metadata: SwiftEntryModuleArgs
|
|
801
975
|
files: Map<string, Blob>
|
|
976
|
+
oneSDKModules?: string[]
|
|
802
977
|
}> {
|
|
803
|
-
const { packagePath } = await oneNativeControlsPackage(appRoot, linkedGroups)
|
|
804
978
|
const moduleRoot = options?.moduleRoot ?? defaultSwiftModuleRoot()
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
979
|
+
let sdk = options?.sdk
|
|
980
|
+
const compile = async () => {
|
|
981
|
+
for (;;) {
|
|
982
|
+
const { packagePath, oneSDKModules } = await oneNativeControlsPackage(
|
|
983
|
+
appRoot,
|
|
984
|
+
linkedGroups,
|
|
985
|
+
sdk,
|
|
986
|
+
)
|
|
987
|
+
if (oneSDKModules?.length)
|
|
988
|
+
projectFor(fs.realpathSync(packagePath)).oneModule = false
|
|
989
|
+
try {
|
|
990
|
+
const metadata = await swiftPackageMetadata(
|
|
991
|
+
packagePath,
|
|
992
|
+
ONE_NATIVE_CONTROLS_PACKAGE,
|
|
993
|
+
moduleRoot,
|
|
994
|
+
'',
|
|
995
|
+
undefined,
|
|
996
|
+
undefined,
|
|
997
|
+
[],
|
|
998
|
+
options?.startupRuntimeUrl,
|
|
999
|
+
)
|
|
1000
|
+
return { packagePath, oneSDKModules, metadata }
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
if (!sdk?.reemitForWasi || !(error instanceof Error)) throw error
|
|
1003
|
+
const files = await sdk.reemitForWasi(error.message)
|
|
1004
|
+
if (!files) throw error
|
|
1005
|
+
sdk = { ...sdk, files }
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
const { packagePath, oneSDKModules, metadata } = await compile()
|
|
815
1010
|
const assets = await swiftPackageAssets(packagePath, metadata)
|
|
816
1011
|
const files = new Map<string, Blob>()
|
|
817
1012
|
const metadataPath = `${SWIFT_PACKAGE_PATH}${ONE_NATIVE_CONTROLS_PACKAGE}`
|
|
@@ -824,5 +1019,5 @@ export async function stageOneNativeControlsRelease(
|
|
|
824
1019
|
for (const [assetPath, { bytes, contentType }] of assets) {
|
|
825
1020
|
files.set(assetPath, new Blob([new Uint8Array(bytes)], { type: contentType }))
|
|
826
1021
|
}
|
|
827
|
-
return { metadataPath, metadata, files }
|
|
1022
|
+
return { metadataPath, metadata, files, oneSDKModules }
|
|
828
1023
|
}
|
package/src/one-sdk/source.ts
CHANGED
|
@@ -155,7 +155,8 @@ private enum SDKTransport {
|
|
|
155
155
|
|
|
156
156
|
static func failure(_ error: Error, _ context: String? = nil) -> [String: Any] {
|
|
157
157
|
let native = error as NSError
|
|
158
|
-
let
|
|
158
|
+
let detail = (error as? OneSDKError)?.description ?? native.localizedDescription
|
|
159
|
+
let message = context.map { "E_SDK: \($0): \(detail)" } ?? detail
|
|
159
160
|
return envelope(["$error": ["message": message, "code": "E_SDK", "domain": native.domain, "nativeCode": Double(native.code)]])
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
readOneSDKSourceManifest,
|
|
13
13
|
type OneSDKSourceManifest,
|
|
14
14
|
} from './oneSdkContract'
|
|
15
|
+
import { swiftCacheDir } from './swift-toolchain'
|
|
15
16
|
|
|
16
17
|
interface SDKGenerator {
|
|
17
18
|
importedFrameworks(root: string): string[]
|
|
@@ -95,7 +96,9 @@ export async function selectOneSDK(appRoot: string) {
|
|
|
95
96
|
const imports = new Set<string>()
|
|
96
97
|
const skipped = new Set(['node_modules', 'ios', 'android', 'dist', 'build', 'types'])
|
|
97
98
|
async function scan(directory: string): Promise<void> {
|
|
99
|
+
if (imports.has('one')) return
|
|
98
100
|
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
101
|
+
if (imports.has('one')) return
|
|
99
102
|
if (entry.name.startsWith('.') || skipped.has(entry.name)) continue
|
|
100
103
|
const file = path.join(directory, entry.name)
|
|
101
104
|
if (entry.isDirectory()) await scan(file)
|
|
@@ -109,8 +112,10 @@ export async function selectOneSDK(appRoot: string) {
|
|
|
109
112
|
})
|
|
110
113
|
for (const match of code.matchAll(
|
|
111
114
|
/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](one(?:\/ios\/[A-Za-z_][A-Za-z0-9_]*)?)(?:\/[^'"]*)?['"]/g,
|
|
112
|
-
))
|
|
115
|
+
)) {
|
|
113
116
|
imports.add(match[1])
|
|
117
|
+
if (match[1] === 'one') return
|
|
118
|
+
}
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
}
|
|
@@ -199,6 +204,27 @@ export async function prepareOneSDKSources(appRoot: string, output?: string) {
|
|
|
199
204
|
fs.copyFileSync(path.join(published, name), path.join(directory, name))
|
|
200
205
|
return
|
|
201
206
|
}
|
|
207
|
+
const localCache = path.join(swiftCacheDir(), 'one-sdk-sources', entry.key)
|
|
208
|
+
const localManifestPath = path.join(localCache, 'manifest.json')
|
|
209
|
+
if (fs.existsSync(localManifestPath)) {
|
|
210
|
+
const manifest = readOneSDKSourceManifest(
|
|
211
|
+
JSON.parse(fs.readFileSync(localManifestPath, 'utf8')),
|
|
212
|
+
)
|
|
213
|
+
if (
|
|
214
|
+
manifest.generation === generation &&
|
|
215
|
+
JSON.stringify(manifest.frameworks) === JSON.stringify(selected.frameworks) &&
|
|
216
|
+
selected.frameworks.every(
|
|
217
|
+
(name) => manifest.selection[name] === selected.selection[name],
|
|
218
|
+
) &&
|
|
219
|
+
manifest.files.every((name) => fs.existsSync(path.join(localCache, name)))
|
|
220
|
+
) {
|
|
221
|
+
fs.rmSync(directory, { recursive: true, force: true })
|
|
222
|
+
fs.mkdirSync(directory, { recursive: true })
|
|
223
|
+
for (const name of [...manifest.files, 'manifest.json'])
|
|
224
|
+
fs.copyFileSync(path.join(localCache, name), path.join(directory, name))
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
}
|
|
202
228
|
const generated = await generateAppSdkInChild(
|
|
203
229
|
path.join(selected.one, 'dist/sdk/app.mjs'),
|
|
204
230
|
selected.frameworks,
|
|
@@ -216,5 +242,17 @@ export async function prepareOneSDKSources(appRoot: string, output?: string) {
|
|
|
216
242
|
selection: selected.selection,
|
|
217
243
|
files: [...generated.files.keys()],
|
|
218
244
|
}
|
|
219
|
-
|
|
245
|
+
const manifestJson = JSON.stringify(manifest)
|
|
246
|
+
fs.writeFileSync(path.join(directory, 'manifest.json'), manifestJson)
|
|
247
|
+
fs.mkdirSync(path.dirname(localCache), { recursive: true })
|
|
248
|
+
const staging = fs.mkdtempSync(`${localCache}.tmp-`)
|
|
249
|
+
try {
|
|
250
|
+
for (const [name, from] of generated.files)
|
|
251
|
+
fs.copyFileSync(from, path.join(staging, name))
|
|
252
|
+
fs.writeFileSync(path.join(staging, 'manifest.json'), manifestJson)
|
|
253
|
+
fs.renameSync(staging, localCache)
|
|
254
|
+
} catch (error) {
|
|
255
|
+
fs.rmSync(staging, { recursive: true, force: true })
|
|
256
|
+
if (!fs.existsSync(localManifestPath)) throw error
|
|
257
|
+
}
|
|
220
258
|
}
|
package/src/oneSdkContract.ts
CHANGED
|
@@ -19,12 +19,14 @@ export interface OneSDKCompilation extends SwiftEntryOptions {
|
|
|
19
19
|
export function readOneSDKMetadata(value: unknown): OneSDKCompilation | null {
|
|
20
20
|
if (value == null) return null
|
|
21
21
|
if (!isRecord(value)) throw new Error('invalid One SDK compilation metadata')
|
|
22
|
-
const { url, hash, rootId, icuUrl, modules, bundleFiles } = value
|
|
22
|
+
const { url, hash, rootId, icuUrl, sdkUrl, sdkBindingUrl, modules, bundleFiles } = value
|
|
23
23
|
if (
|
|
24
24
|
typeof url !== 'string' ||
|
|
25
25
|
typeof hash !== 'string' ||
|
|
26
26
|
typeof rootId !== 'string' ||
|
|
27
27
|
typeof icuUrl !== 'string' ||
|
|
28
|
+
(sdkUrl !== undefined && typeof sdkUrl !== 'string') ||
|
|
29
|
+
(sdkBindingUrl !== undefined && typeof sdkBindingUrl !== 'string') ||
|
|
28
30
|
!Array.isArray(modules) ||
|
|
29
31
|
!modules.every((name) => typeof name === 'string') ||
|
|
30
32
|
!isRecord(bundleFiles)
|
|
@@ -41,7 +43,16 @@ export function readOneSDKMetadata(value: unknown): OneSDKCompilation | null {
|
|
|
41
43
|
return [name, bytes] satisfies [string, string]
|
|
42
44
|
}),
|
|
43
45
|
)
|
|
44
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
url,
|
|
48
|
+
hash,
|
|
49
|
+
rootId,
|
|
50
|
+
icuUrl,
|
|
51
|
+
...(sdkUrl !== undefined ? { sdkUrl } : {}),
|
|
52
|
+
...(sdkBindingUrl !== undefined ? { sdkBindingUrl } : {}),
|
|
53
|
+
modules,
|
|
54
|
+
bundleFiles: files,
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
export const readOneSDKFooter = (source: string) =>
|