peachsim 0.1.2587 → 0.1.2589
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 +63 -47
- 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 +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-YIT53CUW.mjs → acorn-6FUOY6FX.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-W7KT52XE.mjs → chunk-33SCXU3Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PDSHFDO2.mjs → chunk-3VNUC4DT.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MKUJNT6M.mjs → chunk-464CBA5U.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-7UTPX7DP.mjs → chunk-47K4QPVA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Q7MIJAYP.mjs → chunk-57FFWABF.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-TOK4D3JW.mjs → chunk-5EFD2VBY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WQB3O2KB.mjs → chunk-5QWQDXXD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YQETPIM2.mjs → chunk-BSAAJR25.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TI62KNSX.mjs → chunk-CRIYVOMB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WIS3FIS4.mjs → chunk-EAIFG4MQ.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-VZ2SRV3L.mjs → chunk-FMWEI6OI.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-EINVPQJH.mjs → chunk-FQQ2DMXS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QRBN2H6X.mjs → chunk-I22LAVD5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LBJDNPVZ.mjs → chunk-JLOJZF2Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-33X4F77A.mjs → chunk-KFHCRS5K.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-MHQ3V3HA.mjs → chunk-L3OSVIGA.mjs} +65 -55
- package/dist-lib/esm-chunks/{chunk-KIM7TUG6.mjs → chunk-M4KUWGU3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SES3L2SB.mjs → chunk-MKSOJCRT.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MCQPJCCL.mjs → chunk-PUBH3EXI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BZY37WHL.mjs → chunk-WQ73RKJY.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-DS7BSRKS.mjs → chunk-XTKKROVU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HH6E35Z7.mjs → chunk-Y4PV4HZB.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-IGRR2DCH.mjs → metro-layout-parser-T5QIJTEV.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-B2NMSGIS.mjs → swift-package-prebuilt-AWTZHPDM.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-FYORV7GD.mjs → swift-sdk-app-module-MGTJTVKU.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-BQ4UZV7O.mjs → swift-sdk-image-JABGF3ZR.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-ESIHEVXH.mjs → swift-sdk-image-producer-RJRJ3EFU.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +62 -46
- 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 +233 -130
- package/dist-lib/host/fetch-proxy-handler.cjs +12 -4
- 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 +10 -2
- package/dist-lib/native-app-identity-project.mjs +16 -16
- 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 +82 -81
- package/dist-lib/public-origins-lib.json +76 -69
- 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 +241 -132
- package/dist-lib/swift-compile.cjs +60 -44
- 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 +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +1 -1
- package/package.json +1 -1
- package/src/one-native-controls-package.ts +125 -81
- package/src/swift-compile.ts +2 -44
- package/src/swift-shared-sdk.ts +8 -4
- package/src/swift-source-closure.ts +59 -0
|
@@ -12,43 +12,13 @@ import {
|
|
|
12
12
|
ONE_NATIVE_CONTROLS_NAVIGATION_STACK_VIEW,
|
|
13
13
|
ONE_NATIVE_CONTROLS_PACKAGE,
|
|
14
14
|
} from './oneNativeControlsContract'
|
|
15
|
-
import { syncSwiftTree } from './swift-compile'
|
|
15
|
+
import { swiftCodeMask, syncSwiftTree } from './swift-compile'
|
|
16
16
|
import { swiftPackageAssets, swiftPackageMetadata } from './swift-host'
|
|
17
|
+
import { collectSwiftSourceClosure } from './swift-source-closure'
|
|
17
18
|
import { SWIFT_HMR_PATH, SWIFT_PACKAGE_PATH } from './swift-submit'
|
|
18
19
|
import { privateSwiftDistributionRoot, swiftCacheDir } from './swift-toolchain'
|
|
19
20
|
import type { SwiftEntryModuleArgs } from './swiftContract'
|
|
20
21
|
|
|
21
|
-
// unchanged One SwiftUI sources and their composition dependencies.
|
|
22
|
-
const ONE_CONTROL_SOURCES = [
|
|
23
|
-
'Generated/OneNativeNavigationSplitViewView.swift',
|
|
24
|
-
'Generated/OneNativeNavigationStackView.swift',
|
|
25
|
-
'Generated/OneNativeViewSlots.swift',
|
|
26
|
-
'Generated/OneNativeToolbarView.swift',
|
|
27
|
-
'Generated/OneNativeListView.swift',
|
|
28
|
-
'Generated/OneNativeSectionView.swift',
|
|
29
|
-
'Generated/OneNativeFileImporterView.swift',
|
|
30
|
-
'Generated/OneNativeButtonView.swift',
|
|
31
|
-
'Generated/OneNativeLabelView.swift',
|
|
32
|
-
'Generated/OneNativeTextView.swift',
|
|
33
|
-
'Generated/OneNativeImageView.swift',
|
|
34
|
-
'Generated/OneNativeSwiftUI.swift',
|
|
35
|
-
'Generated/OneNativeAnimationValues.swift',
|
|
36
|
-
'Generated/OneNativeEnvironment.swift',
|
|
37
|
-
'OneNativeContainerSlotView.swift',
|
|
38
|
-
'OneNativeSyncState.swift',
|
|
39
|
-
'OneNativeAnimators.swift',
|
|
40
|
-
'OneNativeDragBinding.swift',
|
|
41
|
-
'OneNativeAccessibility.swift',
|
|
42
|
-
'OneNativeAsyncAction.swift',
|
|
43
|
-
'OneNativeControlled.swift',
|
|
44
|
-
'OneZoomSources.swift',
|
|
45
|
-
'OneNativeComposition.swift',
|
|
46
|
-
'OneNativeHostingController.swift',
|
|
47
|
-
'OneNativeSlot.swift',
|
|
48
|
-
'OneNativeStyle.swift',
|
|
49
|
-
'OneNativeRemoteImage.swift',
|
|
50
|
-
] as const
|
|
51
|
-
|
|
52
22
|
// One.podspec defines a flag for each SDK version up to the installed one, and the
|
|
53
23
|
// native graph reports NATIVE_GRAPH_SDK_VERSION (27.1) to podspecs
|
|
54
24
|
const ONE_SDK_DEFINES = ['ONE_IOS_27_SDK', 'ONE_IOS_27_1_SDK']
|
|
@@ -99,7 +69,7 @@ private func platformColor(named name: String) -> UIColor? {
|
|
|
99
69
|
}
|
|
100
70
|
}
|
|
101
71
|
|
|
102
|
-
|
|
72
|
+
func oneControlColor(_ raw: Any) -> UIColor? {
|
|
103
73
|
if let color = raw as? UIColor { return color }
|
|
104
74
|
if let number = raw as? NSNumber {
|
|
105
75
|
let argb = UInt32(truncatingIfNeeded: number.int64Value)
|
|
@@ -139,8 +109,8 @@ private func parseColor(_ raw: Any) -> UIColor? {
|
|
|
139
109
|
}
|
|
140
110
|
}
|
|
141
111
|
if let dynamic = dict["dynamic"] as? Spec,
|
|
142
|
-
let light = dynamic["light"].flatMap(
|
|
143
|
-
let dark = dynamic["dark"].flatMap(
|
|
112
|
+
let light = dynamic["light"].flatMap(oneControlColor),
|
|
113
|
+
let dark = dynamic["dark"].flatMap(oneControlColor) {
|
|
144
114
|
return UIColor { traits in
|
|
145
115
|
traits.userInterfaceStyle == .dark ? dark : light
|
|
146
116
|
}
|
|
@@ -157,7 +127,7 @@ private func normalizeStyle(_ raw: Spec?) -> Spec {
|
|
|
157
127
|
}
|
|
158
128
|
}
|
|
159
129
|
for key in ["foregroundStyle", "tint", "background", "borderColor", "glassEffectTint"] {
|
|
160
|
-
if let value = style[key], let color =
|
|
130
|
+
if let value = style[key], let color = oneControlColor(value) {
|
|
161
131
|
style[key] = color
|
|
162
132
|
}
|
|
163
133
|
}
|
|
@@ -173,7 +143,12 @@ private func normalizeStyle(_ raw: Spec?) -> Spec {
|
|
|
173
143
|
}
|
|
174
144
|
|
|
175
145
|
private class ControlComposition {
|
|
146
|
+
private static let reconciledContainers: Set<String> = [
|
|
147
|
+
"OneNativeLazyVStack", "OneNativeLazyHStack", "OneNativeLazyVGrid", "OneNativeLazyHGrid",
|
|
148
|
+
"OneNativeList", "OneNativeSection", "OneNativeForm",
|
|
149
|
+
]
|
|
176
150
|
var views: [String: UIView] = [:]
|
|
151
|
+
var specs: [String: Spec] = [:]
|
|
177
152
|
var children: [String: [UIView]] = [:]
|
|
178
153
|
var slots: [String: UIView] = [:]
|
|
179
154
|
var emit: ((String, String) -> Void)?
|
|
@@ -191,7 +166,10 @@ private class ControlComposition {
|
|
|
191
166
|
) {
|
|
192
167
|
let prefix = zip(previous, next).prefix(while: { $0 === $1 }).count
|
|
193
168
|
for child in previous.dropFirst(prefix).reversed() { remove(child) }
|
|
194
|
-
for (index, child) in next.enumerated().dropFirst(prefix) {
|
|
169
|
+
for (index, child) in next.enumerated().dropFirst(prefix) {
|
|
170
|
+
child.removeFromSuperview()
|
|
171
|
+
insert(child, index)
|
|
172
|
+
}
|
|
195
173
|
}
|
|
196
174
|
|
|
197
175
|
func render(_ node: Spec, visited: inout Set<String>) -> UIView {
|
|
@@ -235,22 +213,30 @@ private class ControlComposition {
|
|
|
235
213
|
slot.configure(height: spec["height"] as? Double ?? 0, width: spec["width"] as? Double ?? 0)
|
|
236
214
|
slot.configureSwiftStyle(style)
|
|
237
215
|
slot.onSwiftStyleEvent = visit
|
|
216
|
+
slot.onLayout = { [weak self] frame in
|
|
217
|
+
self?.send(id, "onNativeLayout", ["x": frame.minX, "y": frame.minY, "width": frame.width, "height": frame.height])
|
|
218
|
+
}
|
|
238
219
|
view = slot
|
|
239
220
|
default:
|
|
240
|
-
guard let mount = guestControls[control] else { preconditionFailure("unsupported One
|
|
241
|
-
view = mount(views[id], spec, style) { [weak self] event, fields in self?.send(id, event, fields) }
|
|
221
|
+
guard let mount = guestControls[control] else { preconditionFailure("unsupported One control \\(control)") }
|
|
222
|
+
view = mount(views[id], spec, specs[id], style) { [weak self] event, fields in self?.send(id, event, fields) }
|
|
223
|
+
specs[id] = spec
|
|
242
224
|
}
|
|
243
225
|
views[id] = view
|
|
244
226
|
if let container = view as? OneNativeContainerView {
|
|
245
227
|
container.configureSwiftStyle(style)
|
|
246
228
|
container.onSwiftStyleEvent = visit
|
|
247
229
|
let nested = (node["children"] as? [Spec] ?? []).map { render($0, visited: &visited) }
|
|
248
|
-
|
|
249
|
-
nested
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
230
|
+
if Self.reconciledContainers.contains(control) {
|
|
231
|
+
container.reconcileComposedChildren(nested)
|
|
232
|
+
} else {
|
|
233
|
+
reconcile(
|
|
234
|
+
nested,
|
|
235
|
+
previous: children[id] ?? [],
|
|
236
|
+
remove: container.removeChild,
|
|
237
|
+
insert: container.insertChild
|
|
238
|
+
)
|
|
239
|
+
}
|
|
254
240
|
children[id] = nested
|
|
255
241
|
}
|
|
256
242
|
return view
|
|
@@ -260,12 +246,42 @@ private class ControlComposition {
|
|
|
260
246
|
for (id, view) in views where !visited.contains(id) {
|
|
261
247
|
if let container = view as? OneNativeContainerView { container.reset() }
|
|
262
248
|
views.removeValue(forKey: id)
|
|
249
|
+
specs.removeValue(forKey: id)
|
|
263
250
|
children.removeValue(forKey: id)
|
|
264
251
|
slots.removeValue(forKey: id)
|
|
265
252
|
}
|
|
266
253
|
}
|
|
267
254
|
}
|
|
268
255
|
|
|
256
|
+
private struct ControlBridge: UIViewRepresentable {
|
|
257
|
+
let root: Spec
|
|
258
|
+
let emit: (String, String) -> Void
|
|
259
|
+
|
|
260
|
+
func makeCoordinator() -> ControlComposition { ControlComposition() }
|
|
261
|
+
|
|
262
|
+
func makeUIView(context: Context) -> UIView { UIView(frame: .zero) }
|
|
263
|
+
|
|
264
|
+
func updateUIView(_ host: UIView, context: Context) {
|
|
265
|
+
let state = context.coordinator
|
|
266
|
+
state.emit = emit
|
|
267
|
+
var visited = Set<String>()
|
|
268
|
+
let control = state.render(root, visited: &visited)
|
|
269
|
+
if control.superview !== host {
|
|
270
|
+
host.subviews.forEach { $0.removeFromSuperview() }
|
|
271
|
+
control.frame = host.bounds
|
|
272
|
+
control.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
273
|
+
host.addSubview(control)
|
|
274
|
+
}
|
|
275
|
+
state.prune(keeping: visited)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static func dismantleUIView(_ host: UIView, coordinator: ControlComposition) {
|
|
279
|
+
host.subviews.forEach { $0.removeFromSuperview() }
|
|
280
|
+
coordinator.prune(keeping: [])
|
|
281
|
+
coordinator.emit = nil
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
269
285
|
private struct NavigationDestinationSlot: Identifiable, Equatable {
|
|
270
286
|
let id: String
|
|
271
287
|
let contentHost: String
|
|
@@ -537,7 +553,10 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
|
|
|
537
553
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
538
554
|
.ignoresSafeArea(.container))
|
|
539
555
|
default:
|
|
540
|
-
|
|
556
|
+
let root = spec["root"] as! Spec
|
|
557
|
+
precondition((root["spec"] as? Spec)?["control"] as? String == view)
|
|
558
|
+
return AnyView(ControlBridge(root: root, emit: emit)
|
|
559
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity))
|
|
541
560
|
}
|
|
542
561
|
}
|
|
543
562
|
}
|
|
@@ -681,44 +700,68 @@ export interface OneNativeControlsPackage {
|
|
|
681
700
|
watched: string[]
|
|
682
701
|
}
|
|
683
702
|
|
|
703
|
+
function excludedGroupSource(source: string, defines: ReadonlySet<string>): boolean {
|
|
704
|
+
const code = swiftCodeMask(source).trim()
|
|
705
|
+
const group = /^#if (ONE_GROUP_\w+)[ \t]*\r?\n/.exec(code)?.[1]
|
|
706
|
+
if (!group || defines.has(group)) return false
|
|
707
|
+
let depth = 0
|
|
708
|
+
for (const directive of code.matchAll(/^[ \t]*#(if|elseif|else|endif)\b[^\n]*/gm)) {
|
|
709
|
+
if (directive[1] === 'if') depth++
|
|
710
|
+
else if (directive[1] === 'endif' && --depth === 0)
|
|
711
|
+
return directive.index + directive[0].length === code.length
|
|
712
|
+
else if ((directive[1] === 'else' || directive[1] === 'elseif') && depth === 1)
|
|
713
|
+
return false
|
|
714
|
+
}
|
|
715
|
+
return false
|
|
716
|
+
}
|
|
717
|
+
|
|
684
718
|
export async function oneNativeControlsPackage(
|
|
685
719
|
appRoot?: string,
|
|
720
|
+
linkedGroups?: readonly string[],
|
|
686
721
|
): Promise<OneNativeControlsPackage> {
|
|
687
722
|
const iosDir = resolveOneNativeAppleIosDir(appRoot)
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
const
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
723
|
+
const generated = swiftGuestControls(
|
|
724
|
+
path.dirname(iosDir),
|
|
725
|
+
['OneNativeButton', 'OneNativeLabel', 'OneNativeText', 'OneNativeImage'],
|
|
726
|
+
linkedGroups,
|
|
727
|
+
)
|
|
728
|
+
const sources: Record<string, string> = {}
|
|
729
|
+
const paths = new Map<string, string>()
|
|
730
|
+
const defines = new Set([...ONE_SDK_DEFINES, ...generated.defines])
|
|
731
|
+
for (const folder of ['', 'Generated', 'SDK']) {
|
|
732
|
+
for (const name of fs.readdirSync(path.join(iosDir, folder)).sort()) {
|
|
733
|
+
// the guest SDK supplies PeachPackage and its JSON type.
|
|
734
|
+
if (!name.endsWith('.swift') || name === 'OneSwiftPackage.swift') continue
|
|
735
|
+
if (paths.has(name))
|
|
736
|
+
throw new Error(`duplicate Swift filename ${name} in OneNativeControls`)
|
|
737
|
+
const full = path.join(iosDir, folder, name)
|
|
738
|
+
const source = fs.readFileSync(full, 'utf8')
|
|
739
|
+
if (excludedGroupSource(source, defines)) continue
|
|
740
|
+
paths.set(name, full)
|
|
741
|
+
sources[name] = source
|
|
705
742
|
}
|
|
706
|
-
files.set(flatName, content)
|
|
707
|
-
watched.push(full)
|
|
708
|
-
digest.update(flatName).update('\0').update(content).update('\0')
|
|
709
743
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
744
|
+
sources['OneNativeGuestControls.swift'] = generated.source
|
|
745
|
+
sources['OneNativeControlsBridge.swift'] = BRIDGE_SWIFT
|
|
746
|
+
const files = new Map(
|
|
747
|
+
Object.entries(
|
|
748
|
+
collectSwiftSourceClosure(
|
|
749
|
+
sources,
|
|
750
|
+
['OneNativeControlsGuest'],
|
|
751
|
+
swiftCodeMask,
|
|
752
|
+
new Set(['View']),
|
|
753
|
+
),
|
|
754
|
+
),
|
|
755
|
+
)
|
|
756
|
+
const watched = new Set(generated.watched)
|
|
757
|
+
const digest = createHash('sha256')
|
|
758
|
+
.update([...defines].join('\0'))
|
|
759
|
+
.update('\0')
|
|
760
|
+
for (const [name, source] of files) {
|
|
761
|
+
const full = paths.get(name)
|
|
762
|
+
if (full) watched.add(full)
|
|
763
|
+
digest.update(name).update('\0').update(source).update('\0')
|
|
764
|
+
}
|
|
722
765
|
|
|
723
766
|
const key = digest.digest('hex').slice(0, 16)
|
|
724
767
|
files.set(
|
|
@@ -728,7 +771,7 @@ export async function oneNativeControlsPackage(
|
|
|
728
771
|
`// OneNativeControls ${key}`,
|
|
729
772
|
'import PackageDescription',
|
|
730
773
|
`let package = Package(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", platforms: [.iOS(.v17)], targets: [`,
|
|
731
|
-
` .executableTarget(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", path: ".", swiftSettings: [.swiftLanguageMode(.v5), ${
|
|
774
|
+
` .executableTarget(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", path: ".", swiftSettings: [.swiftLanguageMode(.v5), ${[...defines].map((flag) => `.define("${flag}")`).join(', ')}]),`,
|
|
732
775
|
'])',
|
|
733
776
|
'',
|
|
734
777
|
].join('\n'),
|
|
@@ -745,18 +788,19 @@ export async function oneNativeControlsPackage(
|
|
|
745
788
|
packagePath,
|
|
746
789
|
new Map([...files].map(([file, text]) => [path.join(packagePath, file), text])),
|
|
747
790
|
)
|
|
748
|
-
return { packagePath, watched }
|
|
791
|
+
return { packagePath, watched: [...watched] }
|
|
749
792
|
}
|
|
750
793
|
|
|
751
794
|
export async function stageOneNativeControlsRelease(
|
|
752
795
|
appRoot?: string,
|
|
753
796
|
options?: { moduleRoot?: string; startupRuntimeUrl?: URL },
|
|
797
|
+
linkedGroups?: readonly string[],
|
|
754
798
|
): Promise<{
|
|
755
799
|
metadataPath: string
|
|
756
800
|
metadata: SwiftEntryModuleArgs
|
|
757
801
|
files: Map<string, Blob>
|
|
758
802
|
}> {
|
|
759
|
-
const { packagePath } = await oneNativeControlsPackage(appRoot)
|
|
803
|
+
const { packagePath } = await oneNativeControlsPackage(appRoot, linkedGroups)
|
|
760
804
|
const moduleRoot = options?.moduleRoot ?? defaultSwiftModuleRoot()
|
|
761
805
|
const metadata = await swiftPackageMetadata(
|
|
762
806
|
packagePath,
|
package/src/swift-compile.ts
CHANGED
|
@@ -134,6 +134,7 @@ import {
|
|
|
134
134
|
swiftSharedSdkSourceRoot,
|
|
135
135
|
swiftSharedSdkViewOptions,
|
|
136
136
|
} from './swift-shared-sdk'
|
|
137
|
+
import { collectSwiftSourceClosure } from './swift-source-closure'
|
|
137
138
|
import {
|
|
138
139
|
refreshSwiftCacheHold,
|
|
139
140
|
sourceSwiftCheckout,
|
|
@@ -3894,54 +3895,11 @@ export function swiftSourceAsIOS(
|
|
|
3894
3895
|
return lowerAVAssetURLCluster(out + conditioned.slice(copied))
|
|
3895
3896
|
}
|
|
3896
3897
|
|
|
3897
|
-
// a native module's file closure includes referenced top-level declarations
|
|
3898
|
-
// and extensions. masking uses the compiler's existing Swift lexical scanner.
|
|
3899
3898
|
export function swiftSourceClosure(
|
|
3900
3899
|
files: Record<string, string>,
|
|
3901
3900
|
roots: string[],
|
|
3902
3901
|
): Record<string, string> {
|
|
3903
|
-
|
|
3904
|
-
const owners = new Map<string, Set<string>>()
|
|
3905
|
-
const extensions = new Map<string, Set<string>>()
|
|
3906
|
-
for (const [file, source] of Object.entries(files)) {
|
|
3907
|
-
if (!file.endsWith('.swift')) continue
|
|
3908
|
-
const code = swiftCodeMask(source)
|
|
3909
|
-
const references = new Set(code.match(/[A-Za-z_]\w*/g) ?? [])
|
|
3910
|
-
const pattern =
|
|
3911
|
-
/[{}]|\b(class|struct|enum|protocol|actor|typealias|func|var|let|extension)\s+([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)/g
|
|
3912
|
-
let depth = 0
|
|
3913
|
-
for (const match of code.matchAll(pattern)) {
|
|
3914
|
-
if (match[0] === '{') {
|
|
3915
|
-
depth++
|
|
3916
|
-
continue
|
|
3917
|
-
}
|
|
3918
|
-
if (match[0] === '}') {
|
|
3919
|
-
depth--
|
|
3920
|
-
continue
|
|
3921
|
-
}
|
|
3922
|
-
if (depth !== 0 || !match[2]) continue
|
|
3923
|
-
const name = match[2].split('.').pop()!
|
|
3924
|
-
const index = match[1] === 'extension' ? extensions : owners
|
|
3925
|
-
const set = index.get(name) ?? new Set<string>()
|
|
3926
|
-
set.add(file)
|
|
3927
|
-
index.set(name, set)
|
|
3928
|
-
}
|
|
3929
|
-
sources.set(file, references)
|
|
3930
|
-
}
|
|
3931
|
-
const included = new Set<string>()
|
|
3932
|
-
const pending = [...roots]
|
|
3933
|
-
const seen = new Set<string>()
|
|
3934
|
-
while (pending.length) {
|
|
3935
|
-
const name = pending.pop()!
|
|
3936
|
-
if (seen.has(name)) continue
|
|
3937
|
-
seen.add(name)
|
|
3938
|
-
for (const file of [...(owners.get(name) ?? []), ...(extensions.get(name) ?? [])]) {
|
|
3939
|
-
if (included.has(file)) continue
|
|
3940
|
-
included.add(file)
|
|
3941
|
-
for (const reference of sources.get(file)!) pending.push(reference)
|
|
3942
|
-
}
|
|
3943
|
-
}
|
|
3944
|
-
return Object.fromEntries(Object.entries(files).filter(([file]) => included.has(file)))
|
|
3902
|
+
return collectSwiftSourceClosure(files, roots, swiftCodeMask)
|
|
3945
3903
|
}
|
|
3946
3904
|
|
|
3947
3905
|
/** application entries, excluding comments, strings and inactive branches. */
|
package/src/swift-shared-sdk.ts
CHANGED
|
@@ -243,6 +243,8 @@ function stageOverlaySlot(
|
|
|
243
243
|
const segment = segments[i]!
|
|
244
244
|
for (const entry of readdirSync(real)) {
|
|
245
245
|
if (entry === segment || (i === 0 && entry === SWIFT_CACHE_HOLD_MARKER)) continue
|
|
246
|
+
// swiftpm creates its own configuration directory in each sdk view.
|
|
247
|
+
if (mirror === stagingRoot && entry === 'configuration') continue
|
|
246
248
|
const dest = path.join(mirror, entry)
|
|
247
249
|
if (!fs.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
248
250
|
fs.symlinkSync(path.join(real, entry), dest)
|
|
@@ -294,7 +296,7 @@ export function swiftSharedSdkViewOptions(
|
|
|
294
296
|
const stdint = path.join(overlay, 'include/stdint.h')
|
|
295
297
|
const key = JSON.stringify([
|
|
296
298
|
// bump the recipe when the transformation changes; bundling changes function text.
|
|
297
|
-
'
|
|
299
|
+
'v39',
|
|
298
300
|
[...WEAKEN_FOUNDATION_SYMS],
|
|
299
301
|
toolchainBin,
|
|
300
302
|
sdk,
|
|
@@ -349,9 +351,11 @@ export function swiftSharedSdkViewOptions(
|
|
|
349
351
|
const manifest = path.join(view, path.basename(bundle), 'info.json')
|
|
350
352
|
// a view whose header links point at files that have since gone is rebuilt.
|
|
351
353
|
const intact = () =>
|
|
352
|
-
!fs
|
|
353
|
-
|
|
354
|
-
|
|
354
|
+
!fs
|
|
355
|
+
.lstatSync(path.join(view, SWIFT_CACHE_HOLD_MARKER), {
|
|
356
|
+
throwIfNoEntry: false,
|
|
357
|
+
})
|
|
358
|
+
?.isSymbolicLink() &&
|
|
355
359
|
fs.existsSync(manifest) &&
|
|
356
360
|
fs
|
|
357
361
|
.readdirSync(
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// a native module's file closure includes referenced top-level declarations
|
|
2
|
+
// and extensions.
|
|
3
|
+
export function collectSwiftSourceClosure(
|
|
4
|
+
files: Record<string, string>,
|
|
5
|
+
roots: string[],
|
|
6
|
+
swiftCodeMask: (source: string) => string,
|
|
7
|
+
extensionMembersOnly?: ReadonlySet<string>,
|
|
8
|
+
): Record<string, string> {
|
|
9
|
+
const sources = new Map<string, Set<string>>()
|
|
10
|
+
const owners = new Map<string, Set<string>>()
|
|
11
|
+
for (const [file, source] of Object.entries(files)) {
|
|
12
|
+
if (!file.endsWith('.swift')) continue
|
|
13
|
+
const code = swiftCodeMask(source)
|
|
14
|
+
const references = new Set(code.match(/[A-Za-z_]\w*/g) ?? [])
|
|
15
|
+
const pattern =
|
|
16
|
+
/[{}]|\b(class|struct|enum|protocol|actor|typealias|func|var|let|extension)\s+([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)|\b(?:init|subscript)(?=\s*[?(])/g
|
|
17
|
+
let depth = 0
|
|
18
|
+
let memberExtension: string | undefined
|
|
19
|
+
for (const match of code.matchAll(pattern)) {
|
|
20
|
+
if (match[0] === '{') {
|
|
21
|
+
depth++
|
|
22
|
+
continue
|
|
23
|
+
}
|
|
24
|
+
if (match[0] === '}') {
|
|
25
|
+
if (--depth === 0) memberExtension = undefined
|
|
26
|
+
continue
|
|
27
|
+
}
|
|
28
|
+
if (depth !== 0 && !(depth === 1 && memberExtension)) continue
|
|
29
|
+
const name = match[2]?.split('.').pop() ?? memberExtension
|
|
30
|
+
if (!name) continue
|
|
31
|
+
if (
|
|
32
|
+
match[1] === 'extension' &&
|
|
33
|
+
extensionMembersOnly?.has(name) &&
|
|
34
|
+
/^\s*\{/.test(code.slice(match.index + match[0].length))
|
|
35
|
+
) {
|
|
36
|
+
memberExtension = name
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
const set = owners.get(name) ?? new Set<string>()
|
|
40
|
+
set.add(file)
|
|
41
|
+
owners.set(name, set)
|
|
42
|
+
}
|
|
43
|
+
sources.set(file, references)
|
|
44
|
+
}
|
|
45
|
+
const included = new Set<string>()
|
|
46
|
+
const pending = [...roots]
|
|
47
|
+
const seen = new Set<string>()
|
|
48
|
+
while (pending.length) {
|
|
49
|
+
const name = pending.pop()!
|
|
50
|
+
if (seen.has(name)) continue
|
|
51
|
+
seen.add(name)
|
|
52
|
+
for (const file of owners.get(name) ?? []) {
|
|
53
|
+
if (included.has(file)) continue
|
|
54
|
+
included.add(file)
|
|
55
|
+
for (const reference of sources.get(file)!) pending.push(reference)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return Object.fromEntries(Object.entries(files).filter(([file]) => included.has(file)))
|
|
59
|
+
}
|