peachsim 0.1.2605 → 0.1.2607
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/commands/package.ts +71 -39
- package/cli/commands/perf-native.ts +259 -6
- package/cli/commands/shell-url.ts +1 -0
- 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 +1520 -932
- 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-UNOYFUKI.mjs → acorn-KFWXYMX5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-WSRPZF7M.mjs → chunk-6JPUMAC2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-M4G5YUO7.mjs → chunk-6NDABMDX.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-GT54N3GG.mjs → chunk-7SKDPTZN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FXONOT2L.mjs → chunk-ACAXWH62.mjs} +1 -1
- package/dist-lib/esm-chunks/chunk-ARYRQJUB.mjs +326 -0
- package/dist-lib/esm-chunks/{chunk-WB2EBX5Q.mjs → chunk-BNAXRY5Q.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AST6VA7D.mjs → chunk-CA64UUHF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-B54SPDLA.mjs → chunk-DBW62F4N.mjs} +3 -2
- package/dist-lib/esm-chunks/{chunk-7K33ENH6.mjs → chunk-ESS2CG5G.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-LFN7VAPB.mjs → chunk-IGSLOAPL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RJCM34J7.mjs → chunk-KIIALACX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YO756PYQ.mjs → chunk-LJZ373SO.mjs} +819 -681
- package/dist-lib/esm-chunks/{chunk-VRQPEROV.mjs → chunk-M4ORY3NH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3XUIDCBF.mjs → chunk-MBWWOGI5.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-M3V4F5OV.mjs → chunk-O5BPZVLB.mjs} +5 -5
- package/dist-lib/esm-chunks/chunk-P5Q5QCTP.mjs +32 -0
- package/dist-lib/esm-chunks/{chunk-O55DZ2EL.mjs → chunk-QJUAWJDB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HHS4A7GI.mjs → chunk-RIDXKGBZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LG76KUUO.mjs → chunk-TD2DBEKQ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AYHTHFG4.mjs → chunk-UTSB5CDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UPUOCALX.mjs → chunk-WMWOBH7E.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6TE7WLSF.mjs → chunk-ZNGLVJYL.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-YRBZCLVD.mjs → metro-layout-parser-UY3B6VGU.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-S7KR6TKE.mjs → swift-package-prebuilt-HDHPWS44.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-3JNA7PCB.mjs → swift-sdk-app-module-U6G5RZV2.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-3P4IUP2A.mjs → swift-sdk-image-PVDA2MVM.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-EA2RYBM4.mjs → swift-sdk-image-producer-YHPS3KNR.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +1519 -931
- 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 +1677 -947
- package/dist-lib/host/fetch-proxy-handler.cjs +44 -37
- 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 +540 -247
- package/dist-lib/native-app-identity-project.mjs +218 -1828
- 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 +327 -15
- package/dist-lib/plist.mjs +13 -5
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +82 -129
- package/dist-lib/public-origins-lib.json +69 -140
- 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 +211 -3
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +1693 -963
- package/dist-lib/swift-compile.cjs +812 -673
- 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 +3 -2
- 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/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.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 +38 -2
- package/dist-types/packages/peach-globals/src/canvasAgentContract.d.ts +8 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/package.json +1 -6
- package/src/agent-prompt.ts +5 -1
- package/src/bazel-project.ts +1 -1
- package/src/expo-native-prebuilt.ts +1 -1
- package/src/expo-workspace-exclusion.ts +1 -1
- package/src/gitignore.ts +175 -0
- package/src/intent-definition/plist-reader.ts +22 -168
- package/src/one-native-controls-package.ts +143 -1
- package/src/oneNativeControlsContract.ts +1 -0
- package/src/plist-bytes.ts +144 -2
- package/src/plist.ts +359 -2
- package/src/swift-compile-budget.ts +28 -7
- package/src/swift-compile.ts +972 -809
- package/src/swift-guest-compile.ts +3 -0
- package/src/swift-toolchain.ts +4 -1
- package/src/xcode-project.ts +1 -1
- package/dist-lib/esm-chunks/chunk-OW4VRQKO.mjs +0 -10993
- package/dist-lib/esm-chunks/chunk-ZSHGFGW7.mjs +0 -65
- package/dist-lib/vendor/@xmldom/xmldom.cjs +0 -6481
- package/dist-lib/vendor/bplist-parser.cjs +0 -1589
- package/dist-lib/vendor/ignore.cjs +0 -455
- package/dist-lib/vendor/plist.cjs +0 -10978
package/src/gitignore.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export interface GitignoreTestResult {
|
|
2
|
+
ignored: boolean
|
|
3
|
+
unignored: boolean
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface GitignoreMatcher {
|
|
7
|
+
add(patterns: string | readonly string[]): GitignoreMatcher
|
|
8
|
+
test(relativePath: string): GitignoreTestResult
|
|
9
|
+
ignores(relativePath: string): boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface CompiledRule {
|
|
13
|
+
negative: boolean
|
|
14
|
+
directoryOnly: boolean
|
|
15
|
+
regex: RegExp
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function stripTrailingSpaces(line: string): string {
|
|
19
|
+
let end = line.length
|
|
20
|
+
while (end > 0 && line[end - 1] === ' ') {
|
|
21
|
+
let slashes = 0
|
|
22
|
+
for (let i = end - 2; i >= 0 && line[i] === '\\'; i--) slashes++
|
|
23
|
+
if (slashes % 2 === 1) break
|
|
24
|
+
end--
|
|
25
|
+
}
|
|
26
|
+
return line.slice(0, end)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function globToRegexSource(pattern: string): string {
|
|
30
|
+
let out = ''
|
|
31
|
+
let i = 0
|
|
32
|
+
while (i < pattern.length) {
|
|
33
|
+
const ch = pattern[i]!
|
|
34
|
+
if (ch === '\\' && i + 1 < pattern.length) {
|
|
35
|
+
out += pattern[i + 1]!.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
36
|
+
i += 2
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
if (ch === '*') {
|
|
40
|
+
if (pattern[i + 1] === '*') {
|
|
41
|
+
const prevIsSlashOrStart = i === 0 || pattern[i - 1] === '/'
|
|
42
|
+
const nextIsSlash = pattern[i + 2] === '/'
|
|
43
|
+
const nextIsEnd = i + 2 === pattern.length
|
|
44
|
+
if (prevIsSlashOrStart && nextIsSlash) {
|
|
45
|
+
out += '(?:.+/)?'
|
|
46
|
+
i += 3
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if (prevIsSlashOrStart && nextIsEnd) {
|
|
50
|
+
out += '.*'
|
|
51
|
+
i += 2
|
|
52
|
+
continue
|
|
53
|
+
}
|
|
54
|
+
out += '.*'
|
|
55
|
+
i += 2
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
58
|
+
out += '[^/]*'
|
|
59
|
+
i++
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
if (ch === '?') {
|
|
63
|
+
out += '[^/]'
|
|
64
|
+
i++
|
|
65
|
+
continue
|
|
66
|
+
}
|
|
67
|
+
if (ch === '[') {
|
|
68
|
+
let j = i + 1
|
|
69
|
+
if (j < pattern.length && (pattern[j] === '!' || pattern[j] === '^')) j++
|
|
70
|
+
if (j < pattern.length && pattern[j] === ']') j++
|
|
71
|
+
while (j < pattern.length && pattern[j] !== ']') {
|
|
72
|
+
if (pattern[j] === '\\' && j + 1 < pattern.length) j += 2
|
|
73
|
+
else j++
|
|
74
|
+
}
|
|
75
|
+
if (j < pattern.length) {
|
|
76
|
+
let body = pattern.slice(i + 1, j)
|
|
77
|
+
if (body.startsWith('!')) body = `^${body.slice(1)}`
|
|
78
|
+
out += `[${body}]`
|
|
79
|
+
i = j + 1
|
|
80
|
+
continue
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
out += ch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
84
|
+
i++
|
|
85
|
+
}
|
|
86
|
+
return out
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function compileRule(rawLine: string): CompiledRule | null {
|
|
90
|
+
const withoutCr = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine
|
|
91
|
+
const trimmed = stripTrailingSpaces(withoutCr)
|
|
92
|
+
if (!trimmed || trimmed.startsWith('#')) return null
|
|
93
|
+
|
|
94
|
+
let negative = false
|
|
95
|
+
let pattern = trimmed
|
|
96
|
+
if (pattern.startsWith('!')) {
|
|
97
|
+
negative = true
|
|
98
|
+
pattern = pattern.slice(1)
|
|
99
|
+
}
|
|
100
|
+
if (!pattern) return null
|
|
101
|
+
|
|
102
|
+
const directoryOnly = pattern.endsWith('/')
|
|
103
|
+
if (directoryOnly) {
|
|
104
|
+
pattern = pattern.slice(0, -1)
|
|
105
|
+
if (!pattern) return null
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const anchored = pattern.includes('/')
|
|
109
|
+
if (pattern.startsWith('/')) {
|
|
110
|
+
pattern = pattern.slice(1)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const body = globToRegexSource(pattern)
|
|
114
|
+
const prefix = anchored ? '^' : '(?:^|/)'
|
|
115
|
+
const regex = new RegExp(`${prefix}${body}$`, 'i')
|
|
116
|
+
return { negative, directoryOnly, regex }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function normalizePath(input: string): { path: string; isDirectory: boolean } {
|
|
120
|
+
const isDirectory = input.endsWith('/')
|
|
121
|
+
let normalized = isDirectory ? input.slice(0, -1) : input
|
|
122
|
+
if (normalized.startsWith('./')) normalized = normalized.slice(2)
|
|
123
|
+
return { path: normalized, isDirectory }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function createGitignoreMatcher(): GitignoreMatcher {
|
|
127
|
+
const rules: CompiledRule[] = []
|
|
128
|
+
|
|
129
|
+
const matchSingle = (candidate: string, isDirectory: boolean): GitignoreTestResult => {
|
|
130
|
+
let ignored = false
|
|
131
|
+
let unignored = false
|
|
132
|
+
for (const rule of rules) {
|
|
133
|
+
if (rule.directoryOnly && !isDirectory) continue
|
|
134
|
+
if (!rule.regex.test(candidate)) continue
|
|
135
|
+
if (rule.negative) {
|
|
136
|
+
ignored = false
|
|
137
|
+
unignored = true
|
|
138
|
+
} else {
|
|
139
|
+
ignored = true
|
|
140
|
+
unignored = false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { ignored, unignored }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const matcher: GitignoreMatcher = {
|
|
147
|
+
add(patterns) {
|
|
148
|
+
const list = typeof patterns === 'string' ? patterns.split('\n') : patterns
|
|
149
|
+
for (const entry of list) {
|
|
150
|
+
for (const line of entry.split('\n')) {
|
|
151
|
+
const compiled = compileRule(line)
|
|
152
|
+
if (compiled) rules.push(compiled)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return matcher
|
|
156
|
+
},
|
|
157
|
+
test(relativePath) {
|
|
158
|
+
const { path, isDirectory } = normalizePath(relativePath)
|
|
159
|
+
if (!path) return { ignored: false, unignored: false }
|
|
160
|
+
const parts = path.split('/')
|
|
161
|
+
let prefix = ''
|
|
162
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
163
|
+
prefix = prefix ? `${prefix}/${parts[i]!}` : parts[i]!
|
|
164
|
+
const parent = matchSingle(prefix, true)
|
|
165
|
+
if (parent.ignored) return { ignored: true, unignored: false }
|
|
166
|
+
}
|
|
167
|
+
return matchSingle(path, isDirectory)
|
|
168
|
+
},
|
|
169
|
+
ignores(relativePath) {
|
|
170
|
+
return matcher.test(relativePath).ignored
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return matcher
|
|
175
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert/strict'
|
|
2
|
-
import {
|
|
2
|
+
import { parseXmlPlist } from '../plist'
|
|
3
|
+
import { parseBinaryPlist } from '../plist-bytes'
|
|
3
4
|
import { IntentReal } from './hash-input'
|
|
4
5
|
|
|
5
6
|
function safeNumber(value: bigint): bigint | number {
|
|
@@ -17,178 +18,31 @@ function xmlPlist(bytes: Buffer): unknown {
|
|
|
17
18
|
? 'utf-16be'
|
|
18
19
|
: 'utf-8'
|
|
19
20
|
const text = new TextDecoder(encoding, { fatal: true }).decode(bytes)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
return parseXmlPlist(text, {
|
|
22
|
+
strict: true,
|
|
23
|
+
onInteger(raw) {
|
|
24
|
+
assert(raw.length > 0)
|
|
25
|
+
return safeNumber(BigInt(raw))
|
|
23
26
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case 'dict': {
|
|
33
|
-
const entries = children(element)
|
|
34
|
-
assert(entries.length % 2 === 0)
|
|
35
|
-
const pairs: [string, unknown][] = []
|
|
36
|
-
for (let i = 0; i < entries.length; i += 2) {
|
|
37
|
-
const key = entries[i]!
|
|
38
|
-
assert(key.tagName === 'key')
|
|
39
|
-
pairs.push([contents(key), visit(entries[i + 1]!)])
|
|
40
|
-
}
|
|
41
|
-
return Object.fromEntries(pairs)
|
|
42
|
-
}
|
|
43
|
-
case 'array':
|
|
44
|
-
return children(element).map(visit)
|
|
45
|
-
case 'string':
|
|
46
|
-
return contents(element)
|
|
47
|
-
case 'integer': {
|
|
48
|
-
const value = contents(element).trim()
|
|
49
|
-
assert(value.length > 0)
|
|
50
|
-
return safeNumber(BigInt(value))
|
|
51
|
-
}
|
|
52
|
-
case 'real': {
|
|
53
|
-
const value = contents(element).trim()
|
|
54
|
-
assert(value.length > 0)
|
|
55
|
-
return new IntentReal(
|
|
56
|
-
/^[+-]?inf(?:inity)?$/i.test(value)
|
|
57
|
-
? value.startsWith('-')
|
|
58
|
-
? -Infinity
|
|
59
|
-
: Infinity
|
|
60
|
-
: Number(value),
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
case 'true':
|
|
64
|
-
return true
|
|
65
|
-
case 'false':
|
|
66
|
-
return false
|
|
67
|
-
case 'data':
|
|
68
|
-
return Buffer.from(contents(element), 'base64')
|
|
69
|
-
case 'date':
|
|
70
|
-
return new Date(contents(element))
|
|
71
|
-
default:
|
|
72
|
-
throw new Error(`unsupported plist element ${element.tagName}`)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const plist = document.documentElement
|
|
76
|
-
assert(plist?.tagName === 'plist' && plist.children.length === 1)
|
|
77
|
-
return visit(plist.children[0]!)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function binaryPlist(bytes: Buffer): unknown {
|
|
81
|
-
assert(bytes.length >= 40)
|
|
82
|
-
const trailer = bytes.length - 32
|
|
83
|
-
const offsetWidth = bytes[trailer + 6]
|
|
84
|
-
const refWidth = bytes[trailer + 7]
|
|
85
|
-
assert(offsetWidth > 0 && offsetWidth <= 8 && refWidth > 0 && refWidth <= 8)
|
|
86
|
-
const count = Number(bytes.readBigUInt64BE(trailer + 8))
|
|
87
|
-
const root = Number(bytes.readBigUInt64BE(trailer + 16))
|
|
88
|
-
const table = Number(bytes.readBigUInt64BE(trailer + 24))
|
|
89
|
-
assert(
|
|
90
|
-
table >= 8 &&
|
|
91
|
-
table < trailer &&
|
|
92
|
-
count > 0 &&
|
|
93
|
-
count <= (trailer - table) / offsetWidth,
|
|
94
|
-
)
|
|
95
|
-
const unsigned = (at: number, width: number) => {
|
|
96
|
-
assert(at >= 8 && at + width <= trailer)
|
|
97
|
-
let result = 0n
|
|
98
|
-
for (let i = at; i < at + width; i++) result = result * 256n + BigInt(bytes[i])
|
|
99
|
-
return result
|
|
100
|
-
}
|
|
101
|
-
const cache = new Map<number, unknown>()
|
|
102
|
-
const visiting = new Set<number>()
|
|
103
|
-
const visit = (ref: number): unknown => {
|
|
104
|
-
assert(ref >= 0 && ref < count && !visiting.has(ref))
|
|
105
|
-
if (cache.has(ref)) return cache.get(ref)
|
|
106
|
-
visiting.add(ref)
|
|
107
|
-
const at = Number(unsigned(table + ref * offsetWidth, offsetWidth))
|
|
108
|
-
assert(at >= 8 && at < table)
|
|
109
|
-
const marker = bytes[at]
|
|
110
|
-
const type = marker >> 4
|
|
111
|
-
let length = marker & 15
|
|
112
|
-
let data = at + 1
|
|
113
|
-
if (length === 15 && [4, 5, 6, 7, 10, 13].includes(type)) {
|
|
114
|
-
assert(data < table && bytes[data] >> 4 === 1)
|
|
115
|
-
const width = 2 ** (bytes[data] & 15)
|
|
116
|
-
assert(width <= 8 && data + 1 + width <= table)
|
|
117
|
-
length = Number(unsigned(data + 1, width))
|
|
118
|
-
data += 1 + width
|
|
119
|
-
}
|
|
120
|
-
const end = (size: number) => {
|
|
121
|
-
assert(Number.isSafeInteger(size) && data + size <= table)
|
|
122
|
-
return data + size
|
|
123
|
-
}
|
|
124
|
-
const references = (total: number) => {
|
|
125
|
-
end(total * refWidth)
|
|
126
|
-
return Array.from({ length: total }, (_, i) =>
|
|
127
|
-
visit(Number(unsigned(data + i * refWidth, refWidth))),
|
|
27
|
+
onReal(raw) {
|
|
28
|
+
assert(raw.length > 0)
|
|
29
|
+
return new IntentReal(
|
|
30
|
+
/^[+-]?inf(?:inity)?$/i.test(raw)
|
|
31
|
+
? raw.startsWith('-')
|
|
32
|
+
? -Infinity
|
|
33
|
+
: Infinity
|
|
34
|
+
: Number(raw),
|
|
128
35
|
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
switch (type) {
|
|
132
|
-
case 0:
|
|
133
|
-
assert(marker === 8 || marker === 9)
|
|
134
|
-
value = marker === 9
|
|
135
|
-
break
|
|
136
|
-
case 1: {
|
|
137
|
-
const size = 2 ** length
|
|
138
|
-
assert(size <= 16)
|
|
139
|
-
end(size)
|
|
140
|
-
const integer = unsigned(data, size)
|
|
141
|
-
value = safeNumber(size >= 8 ? BigInt.asIntN(size * 8, integer) : integer)
|
|
142
|
-
break
|
|
143
|
-
}
|
|
144
|
-
case 2:
|
|
145
|
-
assert(length === 2 || length === 3)
|
|
146
|
-
end(2 ** length)
|
|
147
|
-
value = new IntentReal(
|
|
148
|
-
length === 2 ? bytes.readFloatBE(data) : bytes.readDoubleBE(data),
|
|
149
|
-
)
|
|
150
|
-
break
|
|
151
|
-
case 3:
|
|
152
|
-
assert(length === 3)
|
|
153
|
-
end(8)
|
|
154
|
-
value = new Date(Date.UTC(2001, 0, 1) + bytes.readDoubleBE(data) * 1000)
|
|
155
|
-
break
|
|
156
|
-
case 4:
|
|
157
|
-
value = bytes.subarray(data, end(length))
|
|
158
|
-
break
|
|
159
|
-
case 5:
|
|
160
|
-
value = bytes.toString('ascii', data, end(length))
|
|
161
|
-
break
|
|
162
|
-
case 6:
|
|
163
|
-
value = Buffer.from(bytes.subarray(data, end(length * 2)))
|
|
164
|
-
.swap16()
|
|
165
|
-
.toString('utf16le')
|
|
166
|
-
break
|
|
167
|
-
case 7:
|
|
168
|
-
value = bytes.toString('utf8', data, end(length))
|
|
169
|
-
break
|
|
170
|
-
case 10:
|
|
171
|
-
value = references(length)
|
|
172
|
-
break
|
|
173
|
-
case 13: {
|
|
174
|
-
const elements = references(length * 2)
|
|
175
|
-
const keys = elements.slice(0, length)
|
|
176
|
-
assert(keys.every((key) => typeof key === 'string'))
|
|
177
|
-
value = Object.fromEntries(keys.map((key, i) => [key, elements[length + i]]))
|
|
178
|
-
break
|
|
179
|
-
}
|
|
180
|
-
default:
|
|
181
|
-
throw new Error(`unsupported binary plist type ${type}`)
|
|
182
|
-
}
|
|
183
|
-
visiting.delete(ref)
|
|
184
|
-
cache.set(ref, value)
|
|
185
|
-
return value
|
|
186
|
-
}
|
|
187
|
-
return visit(root)
|
|
36
|
+
},
|
|
37
|
+
})
|
|
188
38
|
}
|
|
189
39
|
|
|
190
40
|
export function parseIntentPlist(bytes: Buffer): unknown {
|
|
191
41
|
return bytes.toString('ascii', 0, 8) === 'bplist00'
|
|
192
|
-
?
|
|
42
|
+
? parseBinaryPlist(bytes, {
|
|
43
|
+
strict: true,
|
|
44
|
+
onInteger: safeNumber,
|
|
45
|
+
onReal: (value) => new IntentReal(value),
|
|
46
|
+
})
|
|
193
47
|
: xmlPlist(bytes)
|
|
194
48
|
}
|
|
@@ -9,6 +9,7 @@ import { swiftGuestControls } from '../../peach-globals/build/one-swift-control-
|
|
|
9
9
|
import { oneSDKHost, oneSDKModule, oneSDKTransport } from './one-sdk/source'
|
|
10
10
|
import {
|
|
11
11
|
ONE_NATIVE_CONTROLS_CONTRACT,
|
|
12
|
+
ONE_NATIVE_CONTROLS_TAB_VIEW,
|
|
12
13
|
ONE_NATIVE_CONTROLS_NAVIGATION_SPLIT_VIEW,
|
|
13
14
|
ONE_NATIVE_CONTROLS_NAVIGATION_STACK_VIEW,
|
|
14
15
|
ONE_NATIVE_CONTROLS_PACKAGE,
|
|
@@ -25,12 +26,33 @@ import type { SwiftEntryModuleArgs } from './swiftContract'
|
|
|
25
26
|
// native graph reports NATIVE_GRAPH_SDK_VERSION (27.1) to podspecs
|
|
26
27
|
const ONE_SDK_DEFINES = ['ONE_IOS_26_SDK', 'ONE_IOS_27_SDK', 'ONE_IOS_27_1_SDK']
|
|
27
28
|
|
|
28
|
-
const BRIDGE_SWIFT =
|
|
29
|
+
const BRIDGE_SWIFT = `@_spi(Peach) import SwiftUI
|
|
29
30
|
@_spi(Peach) import UIKit
|
|
30
31
|
import PeachJSON
|
|
31
32
|
|
|
32
33
|
typealias Spec = [String: Any]
|
|
33
34
|
|
|
35
|
+
private final class OneContentHost: UIView, _PeachToolbarTitleMenuProvider {
|
|
36
|
+
var titleMenu: [Spec] = []
|
|
37
|
+
var onTitleMenuAction: ((Int) -> Void)?
|
|
38
|
+
|
|
39
|
+
var _peachToolbarTitleMenuContent: AnyView? {
|
|
40
|
+
guard !titleMenu.isEmpty else { return nil }
|
|
41
|
+
return AnyView(ForEach(Array(titleMenu.enumerated()), id: \\.offset) { index, item in
|
|
42
|
+
let label = item["label"] as! String
|
|
43
|
+
Button(role: item["role"] as? String == "destructive" ? .destructive : nil) { [weak self] in
|
|
44
|
+
self?.onTitleMenuAction?(index)
|
|
45
|
+
} label: {
|
|
46
|
+
if let symbol = item["systemImage"] as? String {
|
|
47
|
+
Label(label, systemImage: symbol)
|
|
48
|
+
} else {
|
|
49
|
+
Text(label)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
34
56
|
private func platformColor(named name: String) -> UIColor? {
|
|
35
57
|
switch name {
|
|
36
58
|
case "label", "-apple-system-label": return UIColor.label
|
|
@@ -647,6 +669,122 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
|
|
|
647
669
|
}
|
|
648
670
|
}
|
|
649
671
|
|
|
672
|
+
private struct TabViewBridge: UIViewRepresentable {
|
|
673
|
+
let spec: Spec
|
|
674
|
+
let emit: (String, String) -> Void
|
|
675
|
+
|
|
676
|
+
final class Coordinator: ControlComposition {
|
|
677
|
+
var pageHosts: [String: OneContentHost] = [:]
|
|
678
|
+
var toolbars: [OneNativeToolbarView] = []
|
|
679
|
+
var tabSelectionSequence = 0
|
|
680
|
+
|
|
681
|
+
func host(_ id: String, name: String?, titleMenu: [Spec]) -> UIView {
|
|
682
|
+
let host = pageHosts[id] ?? OneContentHost(frame: .zero)
|
|
683
|
+
pageHosts[id] = host
|
|
684
|
+
host._peachReactContentHost = name
|
|
685
|
+
host.titleMenu = titleMenu
|
|
686
|
+
host.onTitleMenuAction = { [weak self] index in
|
|
687
|
+
self?.send(id, "onNativeTitleMenuAction", ["index": index])
|
|
688
|
+
}
|
|
689
|
+
return host
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
func makeCoordinator() -> Coordinator { Coordinator() }
|
|
694
|
+
func makeUIView(context: Context) -> OneNativeTabViewView { OneNativeTabViewView(frame: .zero) }
|
|
695
|
+
|
|
696
|
+
func updateUIView(_ tabs: OneNativeTabViewView, context: Context) {
|
|
697
|
+
let state = context.coordinator
|
|
698
|
+
state.emit = emit
|
|
699
|
+
let root = self.spec["root"] as! Spec
|
|
700
|
+
let id = root["id"] as! String
|
|
701
|
+
let spec = root["spec"] as! Spec
|
|
702
|
+
let nodes = root["children"] as? [Spec] ?? []
|
|
703
|
+
var visited = Set<String>()
|
|
704
|
+
tabs.onSelection = { [weak state] selection, count, revision in
|
|
705
|
+
state?.send(id, "onNativeTabViewSelectionChange", ["selection": selection, "eventCount": count, "revision": revision])
|
|
706
|
+
}
|
|
707
|
+
tabs.onAction = { [weak state] tabId in
|
|
708
|
+
state?.send(id, "onNativeTabViewAction", ["tabId": tabId])
|
|
709
|
+
}
|
|
710
|
+
tabs.onCustomization = { [weak state] customization in
|
|
711
|
+
state?.send(id, "onNativeTabViewCustomizationChange", ["customization": customization])
|
|
712
|
+
}
|
|
713
|
+
tabs.onSDKEvent = { [weak state] name, value in
|
|
714
|
+
state?.send(id, "onNativeSDKEvent", ["name": name, "value": value])
|
|
715
|
+
}
|
|
716
|
+
tabs.configureStyle(normalizeStyle(spec["swiftStyle"] as? Spec))
|
|
717
|
+
tabs.configure(
|
|
718
|
+
tabViewStyle: spec["tabViewStyle"] as? String ?? "automatic",
|
|
719
|
+
tabBarVisibility: spec["tabBarVisibility"] as? String ?? "automatic",
|
|
720
|
+
customization: spec["customization"] as? String ?? "",
|
|
721
|
+
customizable: spec["customizable"] as? Bool ?? false,
|
|
722
|
+
bottomAccessoryEnabled: spec["bottomAccessoryEnabled"] as? Bool ?? true
|
|
723
|
+
)
|
|
724
|
+
var pages: [OneNativeTabItem] = []
|
|
725
|
+
var toolbars: [Spec] = []
|
|
726
|
+
for node in nodes {
|
|
727
|
+
let page = node["spec"] as! Spec
|
|
728
|
+
if page["control"] as? String == "OneNativeToolbar" {
|
|
729
|
+
toolbars.append(node)
|
|
730
|
+
continue
|
|
731
|
+
}
|
|
732
|
+
precondition(page["control"] as? String == "OneNativeTab", "Swift.TabView requires Swift.Tab or Swift.Toolbar children")
|
|
733
|
+
let owner = node["id"] as! String
|
|
734
|
+
visited.insert(owner)
|
|
735
|
+
let item = OneNativeTabItem(
|
|
736
|
+
id: page["tabId"] as! String,
|
|
737
|
+
kind: page["kind"] as? String ?? "page",
|
|
738
|
+
title: page["title"] as? String ?? "",
|
|
739
|
+
systemImage: page["systemImage"] as? String ?? "",
|
|
740
|
+
badge: page["badge"] as? String ?? "",
|
|
741
|
+
role: page["tabRole"] as? String ?? "",
|
|
742
|
+
slotHeight: page["slotHeight"] as? Double ?? 0,
|
|
743
|
+
tabModifiers: page["tabModifiers"] as? String ?? "{}",
|
|
744
|
+
view: state.host(owner, name: node["contentHost"] as? String, titleMenu: page["titleMenu"] as? [Spec] ?? []),
|
|
745
|
+
onLayout: { [weak state] frame in state?.send(owner, "onNativeLayout", frameFields(frame)) }
|
|
746
|
+
)
|
|
747
|
+
item.configureStyle(normalizeStyle(page["swiftStyle"] as? Spec))
|
|
748
|
+
item.emit = { [weak state] name, value in
|
|
749
|
+
state?.send(owner, "onNativeSDKEvent", ["name": name, "value": value])
|
|
750
|
+
}
|
|
751
|
+
pages.append(item)
|
|
752
|
+
}
|
|
753
|
+
tabs.setPages(pages)
|
|
754
|
+
let previousSequence = state.tabSelectionSequence
|
|
755
|
+
for commit in spec["__peachTabSelections"] as? [Spec] ?? [] {
|
|
756
|
+
guard let sequence = commit["sequence"] as? Int, sequence > state.tabSelectionSequence else { continue }
|
|
757
|
+
state.tabSelectionSequence = sequence
|
|
758
|
+
if let selection = commit["selection"] as? String, pages.contains(where: { $0.id == selection }) {
|
|
759
|
+
tabs.setSelection(selection, acknowledgedEvent: commit["acknowledgedEvent"] as? Int ?? 0, revision: commit["revision"] as? Int ?? 0)
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
tabs.setSelection(spec["selection"] as? String ?? "", acknowledgedEvent: spec["acknowledgedEvent"] as? Int ?? 0, revision: spec["revision"] as? Int ?? 0)
|
|
763
|
+
if state.tabSelectionSequence > previousSequence {
|
|
764
|
+
state.send(id, "onNativeTabSelectionsApplied", ["sequence": state.tabSelectionSequence])
|
|
765
|
+
}
|
|
766
|
+
let next = toolbars.map { state.render($0, visited: &visited) as! OneNativeToolbarView }
|
|
767
|
+
state.reconcile(next, previous: state.toolbars,
|
|
768
|
+
remove: { tabs.unmountToolbar($0 as! OneNativeToolbarView) },
|
|
769
|
+
insert: { view, _ in tabs.mountToolbar(view as! OneNativeToolbarView) })
|
|
770
|
+
state.toolbars = next
|
|
771
|
+
state.prune(keeping: visited)
|
|
772
|
+
state.pageHosts = state.pageHosts.filter { visited.contains($0.key) }
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
static func dismantleUIView(_ view: OneNativeTabViewView, coordinator: Coordinator) {
|
|
776
|
+
coordinator.emit = nil
|
|
777
|
+
view.reset()
|
|
778
|
+
coordinator.prune(keeping: [])
|
|
779
|
+
coordinator.pageHosts.removeAll()
|
|
780
|
+
coordinator.toolbars.removeAll()
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
private func frameFields(_ frame: CGRect) -> Spec {
|
|
785
|
+
["x": frame.minX, "y": frame.minY, "width": frame.width, "height": frame.height]
|
|
786
|
+
}
|
|
787
|
+
|
|
650
788
|
@_expose(wasm, "peach_register_views")
|
|
651
789
|
@_cdecl("peach_register_views")
|
|
652
790
|
@MainActor public func peach_register_views() {
|
|
@@ -664,6 +802,10 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
|
|
|
664
802
|
return AnyView(NavigationSplitViewBridge(spec: spec, emit: emit)
|
|
665
803
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
666
804
|
.ignoresSafeArea(.container))
|
|
805
|
+
case "${ONE_NATIVE_CONTROLS_TAB_VIEW}":
|
|
806
|
+
return AnyView(TabViewBridge(spec: spec, emit: emit)
|
|
807
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
808
|
+
.ignoresSafeArea(.container, edges: .horizontal))
|
|
667
809
|
default:
|
|
668
810
|
let root = spec["root"] as! Spec
|
|
669
811
|
precondition((root["spec"] as? Spec)?["control"] as? String == view)
|