peachsim 0.1.2247 → 0.1.2249
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/bin.ts +5 -0
- package/cli/bridge-flow-runner.ts +28 -2
- package/cli/cloud-dispatch.ts +2 -0
- package/cli/commands/control.ts +2 -2
- package/cli/commands/coverage-swift.ts +3 -3
- package/cli/commands/inspect/settling.ts +35 -4
- package/cli/commands/shell-url.ts +6 -0
- package/cli/commands/skills.ts +6 -3
- package/cli/drivers/playwright.ts +2 -0
- package/dist-lib/agent-daemon-client.cjs +1 -29
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -10
- 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 +4300 -4531
- 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 +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +32 -315
- package/dist-lib/dev-bundle-resolution.cjs +1 -12
- package/dist-lib/expo-swift-bundle.cjs +3579 -3864
- 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 +4376 -4682
- package/dist-lib/host/fetch-proxy-handler.cjs +97 -713
- 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 +669 -1116
- 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 +3 -24
- 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 -10
- package/dist-lib/metro-production-bundle.mjs +1 -12
- package/dist-lib/metro.cjs +546 -975
- package/dist-lib/native-app-identity-project.cjs +299 -592
- package/dist-lib/native-app-identity-project.mjs +11 -232
- 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/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.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 +28 -96
- package/dist-lib/public-origins-lib.json +172 -1058
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -34
- package/dist-lib/sdk.cjs +31 -7
- package/dist-lib/sdk.mjs +31 -7
- package/dist-lib/skills.cjs +4960 -5345
- package/dist-lib/swift-compile.cjs +1185 -1107
- package/dist-lib/swift-compile.mjs +137 -54
- 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 +1568 -1672
- package/dist-lib/vite.cjs +173 -763
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/render-worker/webview-capture-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/settings/duo-fold-bus.d.ts +10 -2
- package/dist-types/packages/peach-globals/src/globalsContract.d.ts +5 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/wasm/include/math.h +1 -1
- package/sdk/ios/wasm/include/pthread.h +1 -1
- package/src/assetCatalogContract.ts +6 -0
- package/src/kotlin-module.ts +3 -3
- package/src/sfSymbolMetricsContract.ts +73 -37
- package/src/swift-compile.ts +99 -7
- package/src/swift-coverage/provenance.ts +4 -4
- package/src/swift-guest-image-ledger.ts +10 -5
- package/src/swift-guest-link.ts +20 -14
- package/src/swift-objc-sdk.ts +34 -21
- package/src/swift-objc-standin.ts +7 -7
- package/src/swift-standins.ts +11 -8
- package/src/swift-wasm-prune.ts +30 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -7,6 +7,7 @@ export declare const SCENE_I32_STRIDE = 8;
|
|
|
7
7
|
export declare const SCENE_F64_STRIDE = 100;
|
|
8
8
|
export declare const SCENE_F32_STRIDE = 20;
|
|
9
9
|
export declare const SCENE_MAX_TRANSFORM_OPS = 6;
|
|
10
|
+
export declare function transformListBounded(transform: readonly unknown[]): boolean;
|
|
10
11
|
export declare const AUTO_RETAINED_MAX_LAYOUT_AREA = 400000;
|
|
11
12
|
export declare const SCENE_I_FIRST_CHILD = 4;
|
|
12
13
|
export declare const SCENE_I_NEXT_SIBLING = 5;
|
|
@@ -259,6 +260,7 @@ export interface SceneNativeBinding {
|
|
|
259
260
|
_peach_frame_portals(surface: number, count: number, top: number): number;
|
|
260
261
|
_peach_frame_local_roots(surface: number, count: number): number;
|
|
261
262
|
_peach_portal_end(slot: number): void;
|
|
263
|
+
_peach_frame_hoist_host(slot: number, host: number): void;
|
|
262
264
|
_peach_portal_hosted(host: number, count: number): number;
|
|
263
265
|
_peach_portal_over_app(root: number, count: number, top: number): number;
|
|
264
266
|
_peach_frame_classes(entries: number): number;
|
|
@@ -337,6 +339,7 @@ export declare class SceneTable {
|
|
|
337
339
|
}, shape: number, fillShape: number, topWidth: number, rightWidth: number, bottomWidth: number, leftWidth: number, fill: Float32Array, top: Float32Array, right: Float32Array, bottom: Float32Array, left: Float32Array): void;
|
|
338
340
|
writePropFlags(slot: number, propFlags: number): void;
|
|
339
341
|
writeHoistFlag(slot: number, flag: number, on: boolean): void;
|
|
342
|
+
writeHoistHost(slot: number, hostSlot: number): void;
|
|
340
343
|
presentationStyleBacked(slot: number): boolean;
|
|
341
344
|
resizePaintsOwnInkOnly(slot: number): boolean;
|
|
342
345
|
presentsBox(slot: number): boolean;
|
|
@@ -1243,6 +1243,10 @@ export type CompositorHostToWorker = {
|
|
|
1243
1243
|
} | {
|
|
1244
1244
|
type: 'webViewCaptureStream';
|
|
1245
1245
|
port: MessagePort;
|
|
1246
|
+
} | {
|
|
1247
|
+
type: 'webViewSnapshot';
|
|
1248
|
+
view: import('./webview-capture-protocol.d.ts').WebViewSnapshotTarget;
|
|
1249
|
+
bitmap: ImageBitmap | null;
|
|
1246
1250
|
} | {
|
|
1247
1251
|
type: 'animationClock';
|
|
1248
1252
|
snapshot: AnimationClockSnapshot;
|
|
@@ -6,6 +6,13 @@ import type { SootSimNodeType } from '../engine/types.d.ts';
|
|
|
6
6
|
import type { LayoutAnimationConfig } from '../react-native/layout-animation.d.ts';
|
|
7
7
|
import type { GraphPresentation } from './graph-linked-value.d.ts';
|
|
8
8
|
import type { WireInlineSources } from './shell-tree-inline-sources.d.ts';
|
|
9
|
+
export interface WireCenteredPlacement {
|
|
10
|
+
leading: number;
|
|
11
|
+
trailing: number;
|
|
12
|
+
margin: number;
|
|
13
|
+
width: number;
|
|
14
|
+
gap: number;
|
|
15
|
+
}
|
|
9
16
|
export interface WireElementNode {
|
|
10
17
|
k: 0;
|
|
11
18
|
id: number;
|
|
@@ -13,6 +20,7 @@ export interface WireElementNode {
|
|
|
13
20
|
props: Record<string, unknown>;
|
|
14
21
|
styleRecord: Uint8Array;
|
|
15
22
|
layoutPlacement?: LayoutHookPlacement;
|
|
23
|
+
centeredPlacement?: WireCenteredPlacement;
|
|
16
24
|
animDriven?: readonly AnimatedDrivenStyleLease[];
|
|
17
25
|
animDrivenRetired?: readonly AnimatedDrivenStyleRetirement[];
|
|
18
26
|
text?: string;
|
|
@@ -28,3 +28,4 @@ export declare function isWebViewCaptureRegistration(value: unknown): value is W
|
|
|
28
28
|
export interface WebViewCaptureTarget extends WebViewCaptureRegistration {
|
|
29
29
|
captureGeneration: number;
|
|
30
30
|
}
|
|
31
|
+
export type WebViewSnapshotTarget = Omit<WebViewCaptureRegistration, 'sourceKey'>;
|
|
@@ -30,10 +30,11 @@ export declare function duoSweepTiming(sweep: {
|
|
|
30
30
|
export declare function duoViewerLeg(leaving: DuoFoldRest, to: DuoFoldRest): boolean;
|
|
31
31
|
export declare function duoSweepHinge(leaving: DuoFoldRest, to: DuoFoldRest, travel: number): number;
|
|
32
32
|
export declare function duoRestLandscapeSide(rest: DuoFoldRest): LandscapeSide | undefined;
|
|
33
|
+
export type DuoFoldFace = HTMLCanvasElement | OffscreenCanvas;
|
|
33
34
|
export type DuoFoldPage = {
|
|
34
35
|
origin: 'closed' | 'open';
|
|
35
|
-
image:
|
|
36
|
-
back:
|
|
36
|
+
image: DuoFoldFace;
|
|
37
|
+
back: DuoFoldFace | null;
|
|
37
38
|
keepsLayout: boolean;
|
|
38
39
|
side: LandscapeSide;
|
|
39
40
|
} | null;
|
|
@@ -62,6 +63,9 @@ type DuoFoldState = {
|
|
|
62
63
|
cloak: DuoFoldCloak;
|
|
63
64
|
};
|
|
64
65
|
export type DuoFoldWireState = Pick<DuoFoldState, 'progress' | 'active' | 'ready' | 'rest'>;
|
|
66
|
+
export type DuoFoldMirrorState = Omit<DuoFoldState, 'page' | 'clock'> & {
|
|
67
|
+
now: number;
|
|
68
|
+
};
|
|
65
69
|
export declare function getDuoFoldProgress(): number;
|
|
66
70
|
export type DeviceHingeStatus = 'closed' | 'partiallyOpen' | 'fullyOpen';
|
|
67
71
|
export declare function readDeviceHinge(): {
|
|
@@ -90,4 +94,8 @@ export declare function duoFoldPosture(progress?: number): DuoFoldPosture;
|
|
|
90
94
|
export declare function duoFrameSampleDifference(first: ArrayLike<number>, second: ArrayLike<number>): number;
|
|
91
95
|
export declare function duoFrameSampleCovered(sample: ArrayLike<number>): boolean;
|
|
92
96
|
export declare function snapshotDuoFoldState(): DuoFoldWireState;
|
|
97
|
+
export declare function snapshotDuoFoldMirror(): {
|
|
98
|
+
state: DuoFoldMirrorState;
|
|
99
|
+
page: DuoFoldPage;
|
|
100
|
+
} | null;
|
|
93
101
|
export {};
|
|
@@ -426,6 +426,11 @@ export type SootSimMetroDefine = (factory: (globalObj: typeof globalThis, requir
|
|
|
426
426
|
export interface SootSimDirectGlobals {
|
|
427
427
|
__peachPageServingAuthority: PeachPageServingAuthority | null;
|
|
428
428
|
__peachWebViewHost: (request: SootSimWebViewHostRequest) => Promise<void>;
|
|
429
|
+
__peachWebViewFrame: (instanceId: string) => Promise<{
|
|
430
|
+
width: number;
|
|
431
|
+
height: number;
|
|
432
|
+
rgbaBase64: string;
|
|
433
|
+
} | null>;
|
|
429
434
|
__sootsimAuxCompositorStats: () => SootSimAuxCompositorStats;
|
|
430
435
|
__sootsimDeviceSpec: SootSimDeviceSpec;
|
|
431
436
|
__sootsimDeviceSpecListeners: Set<() => void>;
|
package/kotlin/sdk.tar.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/runtime-companion.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"abi":1,"sha256":"
|
|
1
|
+
{"abi":1,"sha256":"0576baa8f64749f044d1fee413b30d3459d6a2a5caf1435ecc04500a7031bf93","file":"node/cli-0576baa8f64749f044d1fee413b30d3459d6a2a5caf1435ecc04500a7031bf93.cjs"}
|
|
@@ -53,7 +53,7 @@ _Float16 __fmaf16(_Float16, _Float16, _Float16);
|
|
|
53
53
|
#endif
|
|
54
54
|
|
|
55
55
|
#define PEACH_MATH_PREDICATE(name, builtin, suffix, type) \
|
|
56
|
-
static
|
|
56
|
+
static __inline__ int __inline_##name##suffix(type x) { return __builtin_##builtin(x); }
|
|
57
57
|
#define PEACH_MATH_PREDICATES(name, builtin) \
|
|
58
58
|
PEACH_MATH_PREDICATE(name, builtin, f, float) \
|
|
59
59
|
PEACH_MATH_PREDICATE(name, builtin, d, double) \
|
|
@@ -62,7 +62,7 @@ int pthread_key_delete(pthread_key_t) __asm__("__peach_darwin_pthread_key_delete
|
|
|
62
62
|
void * _Nullable pthread_getspecific(pthread_key_t) __asm__("__peach_darwin_pthread_getspecific");
|
|
63
63
|
int pthread_setspecific(pthread_key_t, const void * _Nullable) __asm__("__peach_darwin_pthread_setspecific");
|
|
64
64
|
int sched_yield(void);
|
|
65
|
-
static
|
|
65
|
+
static __inline__ void pthread_yield_np(void) { sched_yield(); }
|
|
66
66
|
__END_DECLS
|
|
67
67
|
|
|
68
68
|
#define pthread_cleanup_push(func, val) \
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
// the asset data exchanged by project hosts and the private renderer.
|
|
2
|
+
export const SF_SYMBOL_METRICS_CATALOG_FILE = 'metrics-dict.bin.gz'
|
|
3
|
+
|
|
4
|
+
export function sfSymbolMetricsFilename(catalogVersion: string): string {
|
|
5
|
+
return `metrics-${catalogVersion}-dict.bin`
|
|
6
|
+
}
|
|
7
|
+
|
|
2
8
|
export interface SwiftImageSource {
|
|
3
9
|
uri: string
|
|
4
10
|
scale: number
|
package/src/kotlin-module.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IS_STANDALONE } from '../cli/standalone'
|
|
|
7
7
|
import { rnxHomeDir } from './home-paths'
|
|
8
8
|
import { isRecord } from './is-record'
|
|
9
9
|
|
|
10
|
-
declare const __PEACH_BUNDLED_KOTLIN__:
|
|
10
|
+
declare const __PEACH_BUNDLED_KOTLIN__: string
|
|
11
11
|
|
|
12
12
|
let installedRoot: string | undefined
|
|
13
13
|
|
|
@@ -16,8 +16,8 @@ export function peachKotlinModuleRoot(): string {
|
|
|
16
16
|
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'kotlin')
|
|
17
17
|
if (installedRoot) return installedRoot
|
|
18
18
|
|
|
19
|
-
const files = __PEACH_BUNDLED_KOTLIN__
|
|
20
|
-
const digest = createHash('sha256').update(
|
|
19
|
+
const files: Record<string, string> = JSON.parse(__PEACH_BUNDLED_KOTLIN__)
|
|
20
|
+
const digest = createHash('sha256').update(__PEACH_BUNDLED_KOTLIN__).digest('hex')
|
|
21
21
|
const parent = path.join(rnxHomeDir(), 'kotlin', 'modules')
|
|
22
22
|
const root = path.join(parent, digest)
|
|
23
23
|
fs.mkdirSync(parent, { recursive: true })
|
|
@@ -106,9 +106,9 @@ function bracket(scale: SfSymbolScale, weight: SfSymbolWeight) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
109
|
+
// little endian: name count, name bytes, unique row count (u32), padded utf-8
|
|
110
|
+
// names, variant constants (f32), name-to-row indices (u32), then unique rows
|
|
111
|
+
// in column order (f32). aliases retain their names and share identical rows.
|
|
112
112
|
export function encodeSfSymbolMetrics(
|
|
113
113
|
rows: ReadonlyMap<string, ReadonlyMap<string, SfSymbolMetricRow>>,
|
|
114
114
|
): Uint8Array {
|
|
@@ -116,22 +116,7 @@ export function encodeSfSymbolMetrics(
|
|
|
116
116
|
names.sort()
|
|
117
117
|
const nameBytes = new TextEncoder().encode(names.join('\n'))
|
|
118
118
|
const namesLength = Math.ceil(nameBytes.length / 4) * 4
|
|
119
|
-
const
|
|
120
|
-
const out = new Uint8Array(
|
|
121
|
-
header +
|
|
122
|
-
4 *
|
|
123
|
-
(VARIANT_COUNT * CONSTANTS.length +
|
|
124
|
-
KNOT_VARIANT_COUNT * COLUMNS.length * names.length),
|
|
125
|
-
)
|
|
126
|
-
const view = new DataView(out.buffer)
|
|
127
|
-
view.setUint32(0, names.length, true)
|
|
128
|
-
view.setUint32(4, nameBytes.length, true)
|
|
129
|
-
out.set(nameBytes, 8)
|
|
130
|
-
let offset = header
|
|
131
|
-
const put = (value: number) => {
|
|
132
|
-
view.setFloat32(offset, value, true)
|
|
133
|
-
offset += 4
|
|
134
|
-
}
|
|
119
|
+
const constants: number[] = []
|
|
135
120
|
for (const scale of SF_SYMBOL_SCALES)
|
|
136
121
|
for (const weight of SF_SYMBOL_WEIGHTS) {
|
|
137
122
|
const variant = rows.get(variantKey(scale, weight))
|
|
@@ -147,13 +132,51 @@ export function encodeSfSymbolMetrics(
|
|
|
147
132
|
`SF Symbol metrics: ${key} varies by name at ${scale}-${weight}`,
|
|
148
133
|
)
|
|
149
134
|
}
|
|
150
|
-
for (const key of CONSTANTS)
|
|
135
|
+
for (const key of CONSTANTS) constants.push(first[key])
|
|
151
136
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
137
|
+
const uniqueRows: Float32Array[] = []
|
|
138
|
+
const rowIds = new Map<string, number>()
|
|
139
|
+
const indices = new Uint32Array(names.length)
|
|
140
|
+
const columnCount = KNOT_VARIANT_COUNT * COLUMNS.length
|
|
141
|
+
for (const [index, name] of names.entries()) {
|
|
142
|
+
const values = new Float32Array(columnCount)
|
|
143
|
+
let column = 0
|
|
144
|
+
for (const scale of SF_SYMBOL_SCALES)
|
|
145
|
+
for (const knot of sfSymbolMetricKnots(scale)) {
|
|
146
|
+
const row = rows.get(variantKey(scale, knot))!.get(name)!
|
|
147
|
+
for (const key of COLUMNS) values[column++] = row[key]
|
|
148
|
+
}
|
|
149
|
+
const key = new Uint32Array(values.buffer).join(',')
|
|
150
|
+
let id = rowIds.get(key)
|
|
151
|
+
if (id === undefined) {
|
|
152
|
+
id = uniqueRows.length
|
|
153
|
+
rowIds.set(key, id)
|
|
154
|
+
uniqueRows.push(values)
|
|
155
|
+
}
|
|
156
|
+
indices[index] = id
|
|
157
|
+
}
|
|
158
|
+
const header = 12 + namesLength
|
|
159
|
+
const out = new Uint8Array(
|
|
160
|
+
header + 4 * (constants.length + indices.length + columnCount * uniqueRows.length),
|
|
161
|
+
)
|
|
162
|
+
const view = new DataView(out.buffer)
|
|
163
|
+
view.setUint32(0, names.length, true)
|
|
164
|
+
view.setUint32(4, nameBytes.length, true)
|
|
165
|
+
view.setUint32(8, uniqueRows.length, true)
|
|
166
|
+
out.set(nameBytes, 12)
|
|
167
|
+
let offset = header
|
|
168
|
+
for (const value of constants) {
|
|
169
|
+
view.setFloat32(offset, value, true)
|
|
170
|
+
offset += 4
|
|
171
|
+
}
|
|
172
|
+
for (const index of indices) {
|
|
173
|
+
view.setUint32(offset, index, true)
|
|
174
|
+
offset += 4
|
|
175
|
+
}
|
|
176
|
+
for (let column = 0; column < columnCount; column++)
|
|
177
|
+
for (const row of uniqueRows) {
|
|
178
|
+
view.setFloat32(offset, row[column]!, true)
|
|
179
|
+
offset += 4
|
|
157
180
|
}
|
|
158
181
|
return out
|
|
159
182
|
}
|
|
@@ -167,24 +190,37 @@ export class SfSymbolMetrics {
|
|
|
167
190
|
private readonly index = new Map<string, number>()
|
|
168
191
|
private readonly constants: Float32Array
|
|
169
192
|
private readonly columns: Float32Array
|
|
193
|
+
private readonly rowCount: number
|
|
170
194
|
|
|
171
195
|
constructor(bytes: Uint8Array) {
|
|
196
|
+
if (bytes.byteLength < 12) throw new Error('SF Symbol metrics: malformed header')
|
|
172
197
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
173
198
|
const count = view.getUint32(0, true)
|
|
174
199
|
const nameLength = view.getUint32(4, true)
|
|
175
|
-
this.
|
|
176
|
-
|
|
177
|
-
throw new Error('SF Symbol metrics: name count mismatch')
|
|
178
|
-
this.names.forEach((name, i) => this.index.set(name, i))
|
|
179
|
-
const header = 8 + Math.ceil(nameLength / 4) * 4
|
|
180
|
-
const floats = bytes.byteLength - header
|
|
181
|
-
if (floats % 4 !== 0) throw new Error('SF Symbol metrics: malformed')
|
|
182
|
-
const all = new Float32Array(bytes.slice(header).buffer)
|
|
200
|
+
this.rowCount = view.getUint32(8, true)
|
|
201
|
+
const header = 12 + Math.ceil(nameLength / 4) * 4
|
|
183
202
|
const constantCount = VARIANT_COUNT * CONSTANTS.length
|
|
184
|
-
|
|
203
|
+
const expected =
|
|
204
|
+
header +
|
|
205
|
+
4 * (constantCount + count + KNOT_VARIANT_COUNT * COLUMNS.length * this.rowCount)
|
|
206
|
+
if (
|
|
207
|
+
!count ||
|
|
208
|
+
!this.rowCount ||
|
|
209
|
+
this.rowCount > count ||
|
|
210
|
+
bytes.byteLength !== expected
|
|
211
|
+
)
|
|
185
212
|
throw new Error('SF Symbol metrics: size mismatch')
|
|
186
|
-
this.
|
|
187
|
-
this.
|
|
213
|
+
this.names = new TextDecoder().decode(bytes.subarray(12, 12 + nameLength)).split('\n')
|
|
214
|
+
if (this.names.length !== count)
|
|
215
|
+
throw new Error('SF Symbol metrics: name count mismatch')
|
|
216
|
+
const indicesOffset = header + constantCount * 4
|
|
217
|
+
this.names.forEach((name, index) => {
|
|
218
|
+
const row = view.getUint32(indicesOffset + index * 4, true)
|
|
219
|
+
if (row >= this.rowCount) throw new Error('SF Symbol metrics: invalid row index')
|
|
220
|
+
this.index.set(name, row)
|
|
221
|
+
})
|
|
222
|
+
this.constants = new Float32Array(bytes.slice(header, indicesOffset).buffer)
|
|
223
|
+
this.columns = new Float32Array(bytes.slice(indicesOffset + count * 4).buffer)
|
|
188
224
|
}
|
|
189
225
|
|
|
190
226
|
has(name: string): boolean {
|
|
@@ -196,7 +232,7 @@ export class SfSymbolMetrics {
|
|
|
196
232
|
const at = this.index.get(name)
|
|
197
233
|
if (at === undefined) return undefined
|
|
198
234
|
const { lowKnot, highKnot, t } = bracket(scale, weight)
|
|
199
|
-
const count = this.
|
|
235
|
+
const count = this.rowCount
|
|
200
236
|
const read = (knot: SfSymbolWeight, column: number) =>
|
|
201
237
|
this.columns[(knotIndex(scale, knot) * COLUMNS.length + column) * count + at]!
|
|
202
238
|
const value = (column: number) => {
|
package/src/swift-compile.ts
CHANGED
|
@@ -437,6 +437,60 @@ const clangInterfaceHeader = (header: string): string =>
|
|
|
437
437
|
.replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, '$1')
|
|
438
438
|
.replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, '')
|
|
439
439
|
|
|
440
|
+
const objcEnumerations = (header: string): string[] =>
|
|
441
|
+
[
|
|
442
|
+
...header.matchAll(
|
|
443
|
+
/^\s*typedef\s+(?:NS|CF|SWIFT)_\w*(?:ENUM|OPTIONS)\w*\s*\(\s*\w+\s*,\s*(\w+)\b/gm,
|
|
444
|
+
),
|
|
445
|
+
].map((match) => match[1]!)
|
|
446
|
+
|
|
447
|
+
/** the @_cdecl functions a generated header declares that one of the native header texts also declares. */
|
|
448
|
+
function nativelyDeclaredFunctions(
|
|
449
|
+
generated: string,
|
|
450
|
+
headers: Iterable<string>,
|
|
451
|
+
): string[] {
|
|
452
|
+
const candidates = [
|
|
453
|
+
...new Set(
|
|
454
|
+
[...generated.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
|
|
455
|
+
(match) => match[1]!,
|
|
456
|
+
),
|
|
457
|
+
),
|
|
458
|
+
]
|
|
459
|
+
if (candidates.length === 0) return []
|
|
460
|
+
const declaration = new RegExp(`^[^\\n#/*]*?\\b(${candidates.join('|')})\\s*\\(`, 'gm')
|
|
461
|
+
const found = new Set<string>()
|
|
462
|
+
for (const header of headers)
|
|
463
|
+
for (const match of header.matchAll(declaration)) found.add(match[1]!)
|
|
464
|
+
return [...found]
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const sdkDeclarationOwners = new Map<string, Map<string, string>>()
|
|
468
|
+
/** the framework whose headers define each Objective-C class, protocol and enumeration in an SDK's frameworks directory. */
|
|
469
|
+
function sdkObjCDeclarationOwners(frameworks: string): Map<string, string> {
|
|
470
|
+
const known = sdkDeclarationOwners.get(frameworks)
|
|
471
|
+
if (known) return known
|
|
472
|
+
const owners = new Map<string, string>()
|
|
473
|
+
for (const framework of readdirSync(frameworks))
|
|
474
|
+
if (framework.endsWith('.framework')) {
|
|
475
|
+
const headers = path.join(frameworks, framework, 'Headers')
|
|
476
|
+
if (existsSync(headers))
|
|
477
|
+
for (const file of readdirSync(headers, { recursive: true, encoding: 'utf8' }))
|
|
478
|
+
if (file.endsWith('.h')) {
|
|
479
|
+
const header = readFileSync(path.join(headers, file), 'utf8')
|
|
480
|
+
for (const name of [
|
|
481
|
+
...swiftInterfaceDeclarations(header),
|
|
482
|
+
...objcEnumerations(header),
|
|
483
|
+
...[
|
|
484
|
+
...header.matchAll(/^[A-Z_]*_(?:EXTERN|EXPORT)\b[^;(\n]*?\b(\w+)\s*\(/gm),
|
|
485
|
+
].map((match) => match[1]!),
|
|
486
|
+
])
|
|
487
|
+
owners.set(name, framework.slice(0, -'.framework'.length))
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
sdkDeclarationOwners.set(frameworks, owners)
|
|
491
|
+
return owners
|
|
492
|
+
}
|
|
493
|
+
|
|
440
494
|
export function swiftHeaderWithSuperclassImports(
|
|
441
495
|
header: string,
|
|
442
496
|
interfaceFor: (
|
|
@@ -502,6 +556,11 @@ export function withoutSwiftDeclarations(
|
|
|
502
556
|
/^\s*(?:[A-Z_]\w*(?:\([^()\n]*\))?\s+)*@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(
|
|
503
557
|
line,
|
|
504
558
|
)?.[1]
|
|
559
|
+
// an @_cdecl function the native headers already declare keeps their prototype
|
|
560
|
+
const external = /^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(.*\)[^;\n]*;\s*$/.exec(
|
|
561
|
+
line,
|
|
562
|
+
)?.[1]
|
|
563
|
+
if (external && declared.has(external)) continue
|
|
505
564
|
const enumeration =
|
|
506
565
|
/^\s*typedef\s+(?:NS_ENUM|NS_OPTIONS|SWIFT_ENUM(?:_NAMED)?)\s*\(\s*\w+\s*,\s*(\w+)\b/.exec(
|
|
507
566
|
line,
|
|
@@ -7497,11 +7556,34 @@ function compileSwiftProjectOnce(
|
|
|
7497
7556
|
readFileSync(path.join(headers, file), 'utf8'),
|
|
7498
7557
|
))
|
|
7499
7558
|
declared.add(name)
|
|
7500
|
-
const
|
|
7559
|
+
const own = withoutSwiftDeclarations(
|
|
7501
7560
|
clangInterfaceHeader(readFileSync(source, 'utf8')),
|
|
7502
7561
|
declared,
|
|
7503
7562
|
`#import <${name}/${name}.h>`,
|
|
7504
7563
|
)
|
|
7564
|
+
// the swift module also implements classes another framework's headers
|
|
7565
|
+
// already define; clang takes those from the owning framework
|
|
7566
|
+
const owners = sdkObjCDeclarationOwners(path.dirname(path.dirname(headers)))
|
|
7567
|
+
const foreign = new Map<string, string>()
|
|
7568
|
+
for (const declaration of [
|
|
7569
|
+
...swiftInterfaceDeclarations(own),
|
|
7570
|
+
...objcEnumerations(own),
|
|
7571
|
+
...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
|
|
7572
|
+
(match) => match[1]!,
|
|
7573
|
+
),
|
|
7574
|
+
]) {
|
|
7575
|
+
const owner = owners.get(declaration)
|
|
7576
|
+
if (owner && owner !== name) foreign.set(declaration, owner)
|
|
7577
|
+
}
|
|
7578
|
+
const header = foreign.size
|
|
7579
|
+
? withoutSwiftDeclarations(
|
|
7580
|
+
own,
|
|
7581
|
+
new Set(foreign.keys()),
|
|
7582
|
+
[...new Set(foreign.values())]
|
|
7583
|
+
.map((owner) => `#import <${owner}/${owner}.h>`)
|
|
7584
|
+
.join('\n'),
|
|
7585
|
+
)
|
|
7586
|
+
: own
|
|
7505
7587
|
const value = {
|
|
7506
7588
|
file: path.join(root, '.build/peach-framework-objc', `${name}-Swift.h`),
|
|
7507
7589
|
header,
|
|
@@ -7550,18 +7632,28 @@ function compileSwiftProjectOnce(
|
|
|
7550
7632
|
const original = preparation.nativeHeaderDeclarations[producer]
|
|
7551
7633
|
? emitted.replace(/-Swift\.h$/, '-Swift.original.h')
|
|
7552
7634
|
: emitted
|
|
7553
|
-
if (existsSync(original))
|
|
7635
|
+
if (existsSync(original)) {
|
|
7636
|
+
const generated = clangInterfaceHeader(readFileSync(original, 'utf8'))
|
|
7554
7637
|
writeBuildFile(
|
|
7555
7638
|
emitted,
|
|
7556
7639
|
withoutSwiftDeclarations(
|
|
7557
|
-
swiftHeaderWithSuperclassImports(
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7640
|
+
swiftHeaderWithSuperclassImports(generated, frameworkInterface),
|
|
7641
|
+
new Set([
|
|
7642
|
+
...(preparation.nativeHeaderDeclarations[producer] ?? []),
|
|
7643
|
+
...nativelyDeclaredFunctions(
|
|
7644
|
+
generated,
|
|
7645
|
+
Object.entries(input.files)
|
|
7646
|
+
.filter(
|
|
7647
|
+
([name]) =>
|
|
7648
|
+
name.endsWith('.h') && !name.endsWith('-Swift.h'),
|
|
7649
|
+
)
|
|
7650
|
+
.map(([, source]) => source),
|
|
7651
|
+
),
|
|
7652
|
+
]),
|
|
7562
7653
|
`#import <${producer}/${producer}.h>`,
|
|
7563
7654
|
),
|
|
7564
7655
|
)
|
|
7656
|
+
}
|
|
7565
7657
|
}
|
|
7566
7658
|
}
|
|
7567
7659
|
// an interrupted swiftpm build rolls back completed object records.
|
|
@@ -41,8 +41,8 @@ export function swiftCoverageSourceDigests(srcDir: string): Record<string, strin
|
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
declare const __SWIFT_COVERAGE_SOURCE_DIGESTS__:
|
|
45
|
-
export const swiftCoverageProvenance =
|
|
46
|
-
typeof __SWIFT_COVERAGE_SOURCE_DIGESTS__ === '
|
|
47
|
-
? __SWIFT_COVERAGE_SOURCE_DIGESTS__
|
|
44
|
+
declare const __SWIFT_COVERAGE_SOURCE_DIGESTS__: string | undefined
|
|
45
|
+
export const swiftCoverageProvenance: Record<string, string> =
|
|
46
|
+
typeof __SWIFT_COVERAGE_SOURCE_DIGESTS__ === 'string'
|
|
47
|
+
? JSON.parse(__SWIFT_COVERAGE_SOURCE_DIGESTS__)
|
|
48
48
|
: swiftCoverageSourceDigests(join(import.meta.dirname, '..'))
|
|
@@ -486,9 +486,13 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
+
const nameBytes = new Map<string, Buffer>()
|
|
490
|
+
for (const definition of definitions)
|
|
491
|
+
if (!nameBytes.has(definition.name))
|
|
492
|
+
nameBytes.set(definition.name, Buffer.from(definition.name))
|
|
489
493
|
definitions.sort(
|
|
490
494
|
(a, b) =>
|
|
491
|
-
Buffer.compare(
|
|
495
|
+
Buffer.compare(nameBytes.get(a.name)!, nameBytes.get(b.name)!) || a.image - b.image,
|
|
492
496
|
)
|
|
493
497
|
const preserveCanonical = new Set<string>()
|
|
494
498
|
const definitionsByName = Map.groupBy(definitions, (definition) => definition.name)
|
|
@@ -537,12 +541,12 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
|
|
|
537
541
|
preserveCanonical.add(name)
|
|
538
542
|
for (const name of input.commandLineSymbols ?? []) preserveCanonical.add(name)
|
|
539
543
|
const bindingsByImage = new Map<number, Map<string, string>>()
|
|
544
|
+
const definitionsByImage = Map.groupBy(definitions, (definition) => definition.image)
|
|
540
545
|
for (const caller of input.callers) {
|
|
541
546
|
const bindings = new Map<string, string>()
|
|
542
547
|
const seen = new Map<string, GuestImageDefinition>()
|
|
543
548
|
for (const image of [caller.image, ...caller.next])
|
|
544
|
-
for (const definition of
|
|
545
|
-
if (definition.image !== image) continue
|
|
549
|
+
for (const definition of definitionsByImage.get(image) ?? []) {
|
|
546
550
|
const previous = seen.get(definition.name)
|
|
547
551
|
// the linker already accepted the image, so duplicate definitions inside
|
|
548
552
|
// it resolve as in a static link: the first binds and a strong one beats a weak one.
|
|
@@ -589,8 +593,9 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
|
|
|
589
593
|
definitionsByAlias.set(definition.alias, definition)
|
|
590
594
|
}
|
|
591
595
|
const objects = units.map(({ image, object, aliases, functionImports }) => {
|
|
592
|
-
const
|
|
593
|
-
|
|
596
|
+
const shared = bindingsByImage.get(image)!
|
|
597
|
+
const own = startup.get(object.path)
|
|
598
|
+
const bindings = own ? new Map([...shared, ...own]) : shared
|
|
594
599
|
for (const [name, type] of functionImports) {
|
|
595
600
|
const alias = bindings.get(name)
|
|
596
601
|
const provider = alias === undefined ? undefined : definitionsByAlias.get(alias)
|
package/src/swift-guest-link.ts
CHANGED
|
@@ -359,6 +359,7 @@ export function linkGuestImages(
|
|
|
359
359
|
)
|
|
360
360
|
}
|
|
361
361
|
const archives = new Map<string, ReturnType<typeof readArMembers>>()
|
|
362
|
+
const memberBytes = new Map<string, Map<string, Uint8Array>>()
|
|
362
363
|
const prepare = (provider: boolean) => {
|
|
363
364
|
const trace = runLink('discovery', [
|
|
364
365
|
...withOutput(args, discovery, true),
|
|
@@ -403,20 +404,23 @@ export function linkGuestImages(
|
|
|
403
404
|
}
|
|
404
405
|
const objectsByImage = new Map<number, GuestImageObject[]>()
|
|
405
406
|
for (const image of plan.images) objectsByImage.set(image.id, [])
|
|
407
|
+
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]))
|
|
406
408
|
for (const item of selected) {
|
|
407
|
-
const artifact =
|
|
408
|
-
(candidate) => candidate.path === item.artifact,
|
|
409
|
-
)!
|
|
409
|
+
const artifact = artifacts.get(item.artifact)!
|
|
410
410
|
const image = selectedGuestInputImage(artifact, item.member)
|
|
411
411
|
let bytes: Uint8Array
|
|
412
412
|
if (item.member === null) bytes = fs.readFileSync(item.artifact)
|
|
413
413
|
else {
|
|
414
|
-
let
|
|
415
|
-
if (!
|
|
416
|
-
members = readArMembers(fs.readFileSync(item.artifact))
|
|
414
|
+
let byName = memberBytes.get(item.artifact)
|
|
415
|
+
if (!byName) {
|
|
416
|
+
const members = readArMembers(fs.readFileSync(item.artifact))
|
|
417
417
|
archives.set(item.artifact, members)
|
|
418
|
+
byName = new Map()
|
|
419
|
+
for (const member of members)
|
|
420
|
+
if (!byName.has(member.name)) byName.set(member.name, member.bytes)
|
|
421
|
+
memberBytes.set(item.artifact, byName)
|
|
418
422
|
}
|
|
419
|
-
bytes =
|
|
423
|
+
bytes = byName.get(item.member)!
|
|
420
424
|
}
|
|
421
425
|
const objects = objectsByImage.get(image)
|
|
422
426
|
if (!objects) throw new Error(`unknown image ${image}`)
|
|
@@ -453,10 +457,11 @@ export function linkGuestImages(
|
|
|
453
457
|
const { selected, ledger } = prepared
|
|
454
458
|
const replacements = new Map<string, string>()
|
|
455
459
|
const linkedOwners = new Map<string, number>()
|
|
460
|
+
const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]))
|
|
456
461
|
for (const [index, artifact] of plan.artifacts.entries()) {
|
|
457
462
|
const prefix = `${artifact.path}(`
|
|
458
463
|
if (artifact.kind === 'object') {
|
|
459
|
-
const object =
|
|
464
|
+
const object = ledgerObjects.get(artifact.path)
|
|
460
465
|
if (!object) continue
|
|
461
466
|
const output = path.join(directory, `object-${index}.o`)
|
|
462
467
|
fs.writeFileSync(output, object.bytes)
|
|
@@ -483,9 +488,7 @@ export function linkGuestImages(
|
|
|
483
488
|
const output = path.join(directory, `archive-${index}.a`)
|
|
484
489
|
const inputs = members.map((member) => {
|
|
485
490
|
const memberOutput = path.join(memberDir, member.name)
|
|
486
|
-
const rewritten =
|
|
487
|
-
(item) => item.path === `${prefix}${member.name})`,
|
|
488
|
-
)
|
|
491
|
+
const rewritten = ledgerObjects.get(`${prefix}${member.name})`)
|
|
489
492
|
fs.writeFileSync(memberOutput, rewritten?.bytes ?? member.bytes)
|
|
490
493
|
if (rewritten) {
|
|
491
494
|
linkedOwners.set(
|
|
@@ -889,7 +892,7 @@ export function selectedGuestSymbolInputs(
|
|
|
889
892
|
readonly definitionObjects: ReadonlyMap<string, ReadonlySet<string>>
|
|
890
893
|
} {
|
|
891
894
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]))
|
|
892
|
-
const archives = new Map<string,
|
|
895
|
+
const archives = new Map<string, Map<string, { bytes: Uint8Array }[]>>()
|
|
893
896
|
const symbols = new Set<string>()
|
|
894
897
|
const hostImports = new Set<string>()
|
|
895
898
|
const tags = new Set<string>()
|
|
@@ -907,10 +910,13 @@ export function selectedGuestSymbolInputs(
|
|
|
907
910
|
else {
|
|
908
911
|
let members = archives.get(item.artifact)
|
|
909
912
|
if (!members) {
|
|
910
|
-
members =
|
|
913
|
+
members = Map.groupBy(
|
|
914
|
+
readArMembers(fs.readFileSync(item.artifact)),
|
|
915
|
+
(member) => member.name,
|
|
916
|
+
)
|
|
911
917
|
archives.set(item.artifact, members)
|
|
912
918
|
}
|
|
913
|
-
const matching = members.
|
|
919
|
+
const matching = members.get(item.member) ?? []
|
|
914
920
|
if (matching.length !== 1)
|
|
915
921
|
throw new Error(
|
|
916
922
|
`ambiguous selected symbol input ${item.artifact}(${item.member})`,
|