peachsim 0.1.2411 → 0.1.2421
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/README.md +1 -1
- package/cli/catalog/content.ts +6 -3
- package/cli/catalog/meta.ts +63 -17
- package/cli/catalog/routes.ts +4 -0
- package/cli/cloud-box-artifact.ts +45 -24
- package/cli/cloud-client.ts +6 -2
- package/cli/command-registry.ts +3 -1
- package/cli/commands/control.ts +74 -55
- package/cli/commands/desktop.ts +3 -3
- package/cli/commands/electron.ts +7 -5
- package/cli/commands/kotlin.ts +8 -1
- package/cli/commands/platform.ts +5 -7
- package/cli/commands/profile.ts +2 -2
- package/cli/commands/settings.ts +90 -0
- package/cli/commands/shell-url.ts +18 -10
- package/cli/commands/swift.ts +3 -1
- package/cli/main.ts +6 -0
- package/cli/outbound-endpoints.ts +17 -15
- package/cli/settings-flags.ts +115 -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 +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 +3706 -1818
- 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 +3 -7
- package/dist-lib/config.mjs +3 -7
- package/dist-lib/detox/index.cjs +4 -4
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +17144 -15295
- 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 +63288 -62269
- package/dist-lib/host/fetch-proxy-handler.cjs +1598 -211
- 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 +3007 -1512
- 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 +972 -246
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1742 -247
- package/dist-lib/native-app-identity-project.cjs +40 -204
- package/dist-lib/native-app-identity-project.mjs +40 -204
- 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 +26 -24
- package/dist-lib/public-origins-lib.json +198 -117
- 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 +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +21765 -20511
- package/dist-lib/swift-compile.cjs +48 -228
- package/dist-lib/swift-compile.mjs +48 -228
- 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 -199
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +227 -251
- package/dist-lib/vite.cjs +5240 -3788
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +1 -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-widgetContract.d.ts +5 -0
- package/kotlin/README.md +4 -3
- package/kotlin/sdk.tar.gz +0 -0
- package/kotlin/toolchain.json +3 -6
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h +1 -43
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayerContents.h +55 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +3 -3
- package/sdk/ios/usr/include/ObjectiveC.apinotes +0 -24
- package/sdk/ios/usr/include/grp.h +93 -0
- package/sdk/ios/usr/include/netinet/tcp.h +299 -0
- package/sdk/ios/wasm/include/netinet/tcp.h +6 -0
- package/sdk/ios/wasm/include/stdlib.h +1 -0
- package/sdk/ios/wasm/include/unistd.h +2 -0
- package/skills/contrast/SKILL.md +1 -0
- package/skills/peach-setup/SKILL.md +11 -1
- package/src/android-bridge-dependencies.ts +1 -1
- package/src/app-config.ts +7 -0
- package/src/binaryen.lock.json +21 -0
- package/src/cocoapods-trunk.ts +52 -0
- package/src/config.ts +21 -31
- package/src/expo-native-workspace.ts +4 -0
- package/src/kotlin-host.ts +1 -1
- package/src/kotlin-sdk.ts +7 -7
- package/src/kotlin-toolchain.ts +28 -24
- package/src/kotlinSdkContract.ts +2 -2
- package/src/native-bundles.ts +5 -2
- package/src/native-static-libraries.ts +38 -5
- package/src/podfile-cocoapods.ts +1473 -0
- package/src/podspec-cocoapods.ts +331 -106
- package/src/podspec-ruby-stdlib.ts +134 -19
- package/src/podspec-ruby.ts +199 -46
- package/src/settingsContract.ts +74 -0
- package/src/swift-compile.ts +1 -1
- package/src/swift-compiler-digest.ts +1 -0
- package/src/swift-host.ts +107 -15
- package/src/swift-objc-compile.ts +5 -0
- package/src/swift-packages.ts +75 -0
- package/src/swift-shared-sdk.ts +19 -0
- package/src/swift-toolchain.ts +2 -201
- package/src/turbo-source.ts +7 -37
- package/src/wasm-optimize.ts +4 -27
- package/src/xcode-project.ts +22 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// the slice of Ruby's core and standard library podspecs and React Native's
|
|
2
2
|
// pod helpers read: files, directories, JSON, ENV, Pathname, versions. it reads
|
|
3
3
|
// the disk and never writes it.
|
|
4
|
+
import { spawnSync } from 'node:child_process'
|
|
4
5
|
import { createHash } from 'node:crypto'
|
|
5
6
|
import fs from 'node:fs'
|
|
6
7
|
import os from 'node:os'
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
type Call,
|
|
10
11
|
type Interpreter,
|
|
11
12
|
type Value,
|
|
13
|
+
childEnv,
|
|
12
14
|
equal,
|
|
13
15
|
hashKey,
|
|
14
16
|
RFloat,
|
|
@@ -250,7 +252,11 @@ export function makeVersion(interp: Interpreter, cls: RModule, value: Value): RO
|
|
|
250
252
|
value instanceof RObject && value.data instanceof RubyVersion
|
|
251
253
|
? value.data.text
|
|
252
254
|
: interp.toS(value)
|
|
253
|
-
|
|
255
|
+
const pod = interp.ancestors(cls).some((m) => m.name === 'Pod::Version')
|
|
256
|
+
version.data = new RubyVersion(
|
|
257
|
+
pod ? raw.trim() : raw.trim().replace(/-/g, '.pre.'),
|
|
258
|
+
pod,
|
|
259
|
+
)
|
|
254
260
|
return version
|
|
255
261
|
}
|
|
256
262
|
|
|
@@ -263,20 +269,24 @@ export function defineVersionClass(interp: Interpreter, cls: RModule) {
|
|
|
263
269
|
}
|
|
264
270
|
const other = (c: Call) => {
|
|
265
271
|
const v = c.args[0] ?? null
|
|
266
|
-
|
|
267
|
-
if (v instanceof
|
|
272
|
+
const pod = data(c).pod
|
|
273
|
+
if (v instanceof RObject && v.data instanceof RubyVersion)
|
|
274
|
+
return v.data.pod === pod ? v.data : new RubyVersion(v.data.text, pod)
|
|
275
|
+
if (v instanceof RString) return new RubyVersion(v.s, pod)
|
|
268
276
|
return null
|
|
269
277
|
}
|
|
278
|
+
const receiver = (c: Call) => (c.self instanceof RModule ? c.self : cls)
|
|
270
279
|
interp.defineNative(
|
|
271
280
|
cls,
|
|
272
281
|
'new',
|
|
273
|
-
(c) => makeVersion(interp,
|
|
282
|
+
(c) => makeVersion(interp, receiver(c), c.args[0] ?? null),
|
|
274
283
|
true,
|
|
275
284
|
)
|
|
276
285
|
interp.defineNative(
|
|
277
286
|
cls,
|
|
278
287
|
'create',
|
|
279
|
-
(c) =>
|
|
288
|
+
(c) =>
|
|
289
|
+
c.args[0] === null ? null : makeVersion(interp, receiver(c), c.args[0] ?? null),
|
|
280
290
|
true,
|
|
281
291
|
)
|
|
282
292
|
interp.defineNative(
|
|
@@ -297,9 +307,7 @@ export function defineVersionClass(interp: Interpreter, cls: RModule) {
|
|
|
297
307
|
interp.defineNative(cls, 'major', (c) => segment(data(c).segments[0] ?? 0))
|
|
298
308
|
interp.defineNative(cls, 'minor', (c) => segment(data(c).segments[1] ?? 0))
|
|
299
309
|
interp.defineNative(cls, 'patch', (c) => segment(data(c).segments[2] ?? 0))
|
|
300
|
-
interp.defineNative(cls, 'prerelease?', (c) =>
|
|
301
|
-
data(c).segments.some((s) => typeof s === 'string'),
|
|
302
|
-
)
|
|
310
|
+
interp.defineNative(cls, 'prerelease?', (c) => data(c).prerelease)
|
|
303
311
|
interp.defineNative(cls, 'release', (c) => {
|
|
304
312
|
const segments = data(c).segments
|
|
305
313
|
const end = segments.findIndex((s) => typeof s === 'string')
|
|
@@ -309,6 +317,18 @@ export function defineVersionClass(interp: Interpreter, cls: RModule) {
|
|
|
309
317
|
str((end < 0 ? segments : segments.slice(0, end)).join('.')),
|
|
310
318
|
)
|
|
311
319
|
})
|
|
320
|
+
// Gem::Version#bump: the release with its last kept segment incremented, for ~>
|
|
321
|
+
interp.defineNative(cls, 'bump', (c) => {
|
|
322
|
+
const segments = data(c).segments.filter((s): s is number => typeof s === 'number')
|
|
323
|
+
const end = data(c).segments.findIndex((s) => typeof s === 'string')
|
|
324
|
+
const release = end < 0 ? segments : segments.slice(0, end)
|
|
325
|
+
const kept = release.length > 1 ? release.slice(0, -1) : release
|
|
326
|
+
return makeVersion(
|
|
327
|
+
interp,
|
|
328
|
+
cls,
|
|
329
|
+
str([...kept.slice(0, -1), (kept.at(-1) ?? 0) + 1].join('.')),
|
|
330
|
+
)
|
|
331
|
+
})
|
|
312
332
|
interp.defineNative(cls, 'hash', (c) =>
|
|
313
333
|
Number.parseInt(
|
|
314
334
|
createHash('sha1').update(data(c).text).digest('hex').slice(0, 12),
|
|
@@ -325,7 +345,7 @@ export function defineVersionClass(interp: Interpreter, cls: RModule) {
|
|
|
325
345
|
})
|
|
326
346
|
interp.defineNative(cls, '<=>', (c) => {
|
|
327
347
|
const o = other(c)
|
|
328
|
-
return o ? data(c).
|
|
348
|
+
return o ? data(c).order(o) : null
|
|
329
349
|
})
|
|
330
350
|
for (const op of ['<', '<=', '>', '>=', '==', '!='] as const)
|
|
331
351
|
interp.defineNative(cls, op, (c) => {
|
|
@@ -338,7 +358,8 @@ export function defineVersionClass(interp: Interpreter, cls: RModule) {
|
|
|
338
358
|
`comparison of ${cls.name} with ${toInspect(interp, c.args[0] ?? null)} failed`,
|
|
339
359
|
)
|
|
340
360
|
}
|
|
341
|
-
|
|
361
|
+
// Pod::Version's < and > go through <=>, which breaks ties by text
|
|
362
|
+
const r = op === '<' || op === '>' ? data(c).order(o) : data(c).compare(o)
|
|
342
363
|
return op === '<'
|
|
343
364
|
? r < 0
|
|
344
365
|
: op === '<='
|
|
@@ -393,6 +414,7 @@ export function installStdlib(interp: Interpreter) {
|
|
|
393
414
|
const file = interp.defineModule('File', object, true, interp.classes.IO ?? object)
|
|
394
415
|
file.consts.set('SEPARATOR', new RString('/', true))
|
|
395
416
|
file.consts.set('ALT_SEPARATOR', null)
|
|
417
|
+
file.consts.set('PATH_SEPARATOR', new RString(':', true))
|
|
396
418
|
file.consts.set('FNM_PATHNAME', 2)
|
|
397
419
|
file.consts.set('FNM_DOTMATCH', 4)
|
|
398
420
|
file.consts.set('FNM_EXTGLOB', 16)
|
|
@@ -671,19 +693,59 @@ export function installStdlib(interp: Interpreter) {
|
|
|
671
693
|
}
|
|
672
694
|
return c.args[0] ?? null
|
|
673
695
|
})
|
|
696
|
+
// an argv command runs without a shell; evaluation runs only node
|
|
697
|
+
const runArgv = (argv: string[]) => {
|
|
698
|
+
if (argv[0] !== 'node')
|
|
699
|
+
throw new UnsupportedRuby(`command ${argv.map((a) => JSON.stringify(a)).join(' ')}`)
|
|
700
|
+
const result = spawnSync('node', argv.slice(1), {
|
|
701
|
+
cwd: host.cwd,
|
|
702
|
+
env: childEnv(host.env),
|
|
703
|
+
encoding: 'utf8',
|
|
704
|
+
})
|
|
705
|
+
return {
|
|
706
|
+
stdout: result.stdout ?? '',
|
|
707
|
+
stderr: result.stderr ?? '',
|
|
708
|
+
status: result.status ?? 1,
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const processStatus = (code: number) => {
|
|
712
|
+
const status = new RObject(interp.classes.ProcessStatus!)
|
|
713
|
+
status.data = code
|
|
714
|
+
interp.globals.set('$?', status)
|
|
715
|
+
return status
|
|
716
|
+
}
|
|
674
717
|
const open3 = interp.defineModule('Open3', object)
|
|
675
718
|
for (const name of ['capture2', 'capture2e', 'capture3'])
|
|
676
719
|
def(open3, name, (c) => {
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
720
|
+
const args = c.args.filter((a) => !(a instanceof RHash)).map((a) => text(interp, a))
|
|
721
|
+
const result =
|
|
722
|
+
args.length === 1
|
|
723
|
+
? { ...host.shell(args[0]!, host.cwd), stderr: '' }
|
|
724
|
+
: runArgv(args)
|
|
725
|
+
const status = processStatus(result.status)
|
|
726
|
+
return name === 'capture3'
|
|
727
|
+
? [str(result.stdout), str(result.stderr), status]
|
|
728
|
+
: name === 'capture2e'
|
|
729
|
+
? [str(result.stdout + result.stderr), status]
|
|
730
|
+
: [str(result.stdout), status]
|
|
686
731
|
})
|
|
732
|
+
def(interp.classes.IO!, 'popen', (c) => {
|
|
733
|
+
const command = c.args[0]
|
|
734
|
+
const result = Array.isArray(command)
|
|
735
|
+
? runArgv(command.map((a) => text(interp, a)))
|
|
736
|
+
: host.shell(text(interp, command ?? null), host.cwd)
|
|
737
|
+
processStatus(result.status)
|
|
738
|
+
const io = interp.callMethod(
|
|
739
|
+
interp.object.consts.get('StringIO') ?? null,
|
|
740
|
+
'new',
|
|
741
|
+
[str(result.stdout)],
|
|
742
|
+
null,
|
|
743
|
+
null,
|
|
744
|
+
null,
|
|
745
|
+
null,
|
|
746
|
+
)
|
|
747
|
+
return c.block ? interp.callProc(c.block, [io]) : io
|
|
748
|
+
})
|
|
687
749
|
|
|
688
750
|
// JSON
|
|
689
751
|
const json = interp.defineModule('JSON', object)
|
|
@@ -1054,6 +1116,59 @@ export function installStdlib(interp: Interpreter) {
|
|
|
1054
1116
|
[str('ruby_version'), str('3.3.0')],
|
|
1055
1117
|
]),
|
|
1056
1118
|
)
|
|
1119
|
+
interp.evalString(
|
|
1120
|
+
String.raw`
|
|
1121
|
+
class StringIO
|
|
1122
|
+
attr_accessor :string, :pos
|
|
1123
|
+
def initialize(string = '')
|
|
1124
|
+
@string = string
|
|
1125
|
+
@pos = 0
|
|
1126
|
+
end
|
|
1127
|
+
def gets
|
|
1128
|
+
return nil if @pos >= @string.length
|
|
1129
|
+
index = @string.index("\n", @pos)
|
|
1130
|
+
stop = index ? index + 1 : @string.length
|
|
1131
|
+
line = @string[@pos...stop]
|
|
1132
|
+
@pos = stop
|
|
1133
|
+
line
|
|
1134
|
+
end
|
|
1135
|
+
def read
|
|
1136
|
+
rest = @string[@pos..] || ''
|
|
1137
|
+
@pos = @string.length
|
|
1138
|
+
rest
|
|
1139
|
+
end
|
|
1140
|
+
def each_line
|
|
1141
|
+
while (line = gets)
|
|
1142
|
+
yield line
|
|
1143
|
+
end
|
|
1144
|
+
end
|
|
1145
|
+
def eof?
|
|
1146
|
+
@pos >= @string.length
|
|
1147
|
+
end
|
|
1148
|
+
def close; end
|
|
1149
|
+
def puts(*lines)
|
|
1150
|
+
lines.each { |line| @string += line.to_s.end_with?("\n") ? line.to_s : "#{line}\n" }
|
|
1151
|
+
nil
|
|
1152
|
+
end
|
|
1153
|
+
def write(text)
|
|
1154
|
+
@string += text.to_s
|
|
1155
|
+
text.to_s.length
|
|
1156
|
+
end
|
|
1157
|
+
end
|
|
1158
|
+
|
|
1159
|
+
module Singleton
|
|
1160
|
+
def self.included(base)
|
|
1161
|
+
base.extend(SingletonClassMethods)
|
|
1162
|
+
end
|
|
1163
|
+
module SingletonClassMethods
|
|
1164
|
+
def instance
|
|
1165
|
+
@singleton__instance__ ||= new
|
|
1166
|
+
end
|
|
1167
|
+
end
|
|
1168
|
+
end
|
|
1169
|
+
`,
|
|
1170
|
+
'ruby-stdlib',
|
|
1171
|
+
)
|
|
1057
1172
|
}
|
|
1058
1173
|
|
|
1059
1174
|
class FileHandle {
|
package/src/podspec-ruby.ts
CHANGED
|
@@ -263,10 +263,28 @@ export const sym = (s: string) => RSymbol.of(s)
|
|
|
263
263
|
export const truthy = (value: Value) => value !== null && value !== false
|
|
264
264
|
|
|
265
265
|
/** Gem::Version's segment comparison. */
|
|
266
|
+
const POD_VERSION_METADATA = /\+[0-9a-zA-Z.-]+$/
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Gem::Version, or with `pod` cocoapods-core's Pod::Version, which keeps its
|
|
270
|
+
* text, splits semantic versions on the hyphen and orders a prerelease below
|
|
271
|
+
* its release.
|
|
272
|
+
*/
|
|
266
273
|
export class RubyVersion {
|
|
267
274
|
readonly segments: (number | string)[]
|
|
268
|
-
constructor(
|
|
275
|
+
constructor(
|
|
276
|
+
readonly text: string,
|
|
277
|
+
readonly pod = false,
|
|
278
|
+
) {
|
|
269
279
|
const trimmed = text.trim()
|
|
280
|
+
if (pod) {
|
|
281
|
+
if (!/^(?:[0-9]+(?:\.[0-9a-zA-Z-]+)*(?:\+[0-9a-zA-Z.-]+)?)?$/.test(trimmed))
|
|
282
|
+
throw new UnsupportedRuby(`Malformed version number string ${text}`)
|
|
283
|
+
this.segments = (
|
|
284
|
+
trimmed.replace(POD_VERSION_METADATA, '').match(/[0-9]+|[a-z]+/gi) ?? []
|
|
285
|
+
).map((part) => (/^\d+$/.test(part) ? Number(part) : part))
|
|
286
|
+
return
|
|
287
|
+
}
|
|
270
288
|
if (
|
|
271
289
|
!/^[0-9]+(?:\.[0-9a-zA-Z]+)*(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(
|
|
272
290
|
trimmed,
|
|
@@ -279,7 +297,50 @@ export class RubyVersion {
|
|
|
279
297
|
.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)|\./)
|
|
280
298
|
.map((part) => (/^\d+$/.test(part) ? Number(part) : part))
|
|
281
299
|
}
|
|
300
|
+
get prerelease(): boolean {
|
|
301
|
+
return this.pod
|
|
302
|
+
? /[a-zA-Z-]/.test(this.text.trim().replace(POD_VERSION_METADATA, ''))
|
|
303
|
+
: this.segments.some((s) => typeof s === 'string')
|
|
304
|
+
}
|
|
305
|
+
/** Pod::Version#compare_segments: the numeric part without trailing zeros, then the prerelease part, where none ranks above any. */
|
|
306
|
+
private comparePod(other: RubyVersion): number {
|
|
307
|
+
if (this.text.trim() === other.text.trim()) return 0
|
|
308
|
+
const numeric = (v: RubyVersion) => {
|
|
309
|
+
const end = v.segments.findIndex((s) => typeof s !== 'number')
|
|
310
|
+
const copy = end < 0 ? [...v.segments] : v.segments.slice(0, end)
|
|
311
|
+
while (copy.at(-1) === 0) copy.pop()
|
|
312
|
+
return copy
|
|
313
|
+
}
|
|
314
|
+
const prerelease = (v: RubyVersion) => {
|
|
315
|
+
const start = v.segments.findIndex((s) => typeof s !== 'number')
|
|
316
|
+
return start < 0 ? [] : v.segments.slice(start)
|
|
317
|
+
}
|
|
318
|
+
const compare = (a: (number | string)[], b: (number | string)[], pre: boolean) => {
|
|
319
|
+
for (let i = 0; i <= Math.max(a.length, b.length); i++) {
|
|
320
|
+
const x = a[i]
|
|
321
|
+
const y = b[i]
|
|
322
|
+
if (x === y) continue
|
|
323
|
+
if (x === undefined) return pre && i === 0 ? 1 : -1
|
|
324
|
+
if (y === undefined) return pre && i === 0 ? -1 : 1
|
|
325
|
+
if (typeof x === typeof y) return x < y ? -1 : 1
|
|
326
|
+
return typeof x === 'number' ? -1 : 1
|
|
327
|
+
}
|
|
328
|
+
return 0
|
|
329
|
+
}
|
|
330
|
+
return (
|
|
331
|
+
compare(numeric(this), numeric(other), false) ||
|
|
332
|
+
compare(prerelease(this), prerelease(other), true)
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
/** `<=>`: Pod::Version breaks a segment tie by its text. */
|
|
336
|
+
order(other: RubyVersion): number {
|
|
337
|
+
const c = this.compare(other)
|
|
338
|
+
if (c !== 0 || !this.pod) return c
|
|
339
|
+
const [a, b] = [this.text.trim(), other.text.trim()]
|
|
340
|
+
return a === b ? 0 : a < b ? -1 : 1
|
|
341
|
+
}
|
|
282
342
|
compare(other: RubyVersion): number {
|
|
343
|
+
if (this.pod) return this.comparePod(other)
|
|
283
344
|
const trim = (segments: (number | string)[]) => {
|
|
284
345
|
const copy = [...segments]
|
|
285
346
|
while (copy.length > 1 && copy[copy.length - 1] === 0) copy.pop()
|
|
@@ -398,6 +459,7 @@ export class Interpreter {
|
|
|
398
459
|
'Proc',
|
|
399
460
|
'Time',
|
|
400
461
|
'Method',
|
|
462
|
+
'UnboundMethod',
|
|
401
463
|
'Exception',
|
|
402
464
|
'IO',
|
|
403
465
|
'ProcessStatus',
|
|
@@ -1167,7 +1229,9 @@ export class Interpreter {
|
|
|
1167
1229
|
if (value instanceof RObject && value.data instanceof BoundMethod) {
|
|
1168
1230
|
const bound = value.data
|
|
1169
1231
|
return new RProc(null, null, new Scope(null), this.topFrame, true, (args, block) =>
|
|
1170
|
-
|
|
1232
|
+
bound.body
|
|
1233
|
+
? this.invoke(bound.body, bound.receiver, args, null, block, env, node)
|
|
1234
|
+
: this.callMethod(bound.receiver, bound.name, args, null, block, env, node),
|
|
1171
1235
|
)
|
|
1172
1236
|
}
|
|
1173
1237
|
this.unsupported(
|
|
@@ -2121,9 +2185,15 @@ export class BoundMethod {
|
|
|
2121
2185
|
constructor(
|
|
2122
2186
|
readonly receiver: Value,
|
|
2123
2187
|
readonly name: string,
|
|
2188
|
+
// a method taken with instance_method and bound keeps that body after redefinition
|
|
2189
|
+
readonly body: MethodBody | null = null,
|
|
2124
2190
|
) {}
|
|
2125
2191
|
}
|
|
2126
2192
|
|
|
2193
|
+
class UnboundMethod {
|
|
2194
|
+
constructor(readonly body: MethodBody) {}
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2127
2197
|
function sourceOfRegexpPart(part: N.StringNode): string {
|
|
2128
2198
|
return part.unescaped.value
|
|
2129
2199
|
}
|
|
@@ -3092,13 +3162,8 @@ function enumerableMethod(
|
|
|
3092
3162
|
case 'each_with_index_map':
|
|
3093
3163
|
return NOT_FOUND
|
|
3094
3164
|
case 'uniq': {
|
|
3095
|
-
const seen = new
|
|
3096
|
-
return items.filter((item) =>
|
|
3097
|
-
const key = hashKey(block ? yields(item) : item)
|
|
3098
|
-
if (seen.has(key)) return false
|
|
3099
|
-
seen.add(key)
|
|
3100
|
-
return true
|
|
3101
|
-
})
|
|
3165
|
+
const seen = new RubyKeys(interp)
|
|
3166
|
+
return items.filter((item) => seen.add(block ? yields(item) : item))
|
|
3102
3167
|
}
|
|
3103
3168
|
case 'zip':
|
|
3104
3169
|
return items.map((item, i) => [
|
|
@@ -3148,6 +3213,48 @@ function flatten(values: Value[], depth: number): Value[] {
|
|
|
3148
3213
|
)
|
|
3149
3214
|
}
|
|
3150
3215
|
|
|
3216
|
+
/** Ruby's element identity for uniq and the set operators: #hash, then #eql?,
|
|
3217
|
+
* either of which a class may define for its objects. */
|
|
3218
|
+
class RubyKeys {
|
|
3219
|
+
private buckets = new Map<string, Value[]>()
|
|
3220
|
+
constructor(private interp: Interpreter) {}
|
|
3221
|
+
|
|
3222
|
+
private defined(value: Value, name: string) {
|
|
3223
|
+
if (!(value instanceof RObject)) return null
|
|
3224
|
+
const method = this.interp.findMethod(this.interp.dispatchClass(value), name)
|
|
3225
|
+
return method?.kind === 'ruby' ? method : null
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
private bucket(value: Value): string {
|
|
3229
|
+
const hash = this.defined(value, 'hash')
|
|
3230
|
+
return hash
|
|
3231
|
+
? `u${hashKey(this.interp.invoke(hash, value, [], null, null, null, null))}`
|
|
3232
|
+
: hashKey(value)
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
private eql(a: Value, b: Value): boolean {
|
|
3236
|
+
const eql = this.defined(a, 'eql?')
|
|
3237
|
+
return eql
|
|
3238
|
+
? truthy(this.interp.invoke(eql, a, [b], null, null, null, null))
|
|
3239
|
+
: hashKey(a) === hashKey(b)
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
has(value: Value): boolean {
|
|
3243
|
+
return (this.buckets.get(this.bucket(value)) ?? []).some((kept) =>
|
|
3244
|
+
this.eql(kept, value),
|
|
3245
|
+
)
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
/** adds `value`, answering whether no eql? value was there. */
|
|
3249
|
+
add(value: Value): boolean {
|
|
3250
|
+
const key = this.bucket(value)
|
|
3251
|
+
const kept = this.buckets.get(key) ?? []
|
|
3252
|
+
if (kept.some((other) => this.eql(other, value))) return false
|
|
3253
|
+
this.buckets.set(key, [...kept, value])
|
|
3254
|
+
return true
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3151
3258
|
function arrayMethod(
|
|
3152
3259
|
interp: Interpreter,
|
|
3153
3260
|
self: Value[],
|
|
@@ -3272,29 +3379,21 @@ function arrayMethod(
|
|
|
3272
3379
|
return [...self, ...a]
|
|
3273
3380
|
case '-': {
|
|
3274
3381
|
if (!Array.isArray(a)) return NOT_FOUND
|
|
3275
|
-
const remove = new
|
|
3276
|
-
|
|
3382
|
+
const remove = new RubyKeys(interp)
|
|
3383
|
+
for (const v of a) remove.add(v)
|
|
3384
|
+
return self.filter((v) => !remove.has(v))
|
|
3277
3385
|
}
|
|
3278
3386
|
case '&': {
|
|
3279
3387
|
if (!Array.isArray(a)) return NOT_FOUND
|
|
3280
|
-
const keep = new
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
if (!keep.has(k) || seen.has(k)) return false
|
|
3285
|
-
seen.add(k)
|
|
3286
|
-
return true
|
|
3287
|
-
})
|
|
3388
|
+
const keep = new RubyKeys(interp)
|
|
3389
|
+
for (const v of a) keep.add(v)
|
|
3390
|
+
const seen = new RubyKeys(interp)
|
|
3391
|
+
return self.filter((v) => keep.has(v) && seen.add(v))
|
|
3288
3392
|
}
|
|
3289
3393
|
case '|': {
|
|
3290
3394
|
if (!Array.isArray(a)) return NOT_FOUND
|
|
3291
|
-
const seen = new
|
|
3292
|
-
return [...self, ...a].filter((v) =>
|
|
3293
|
-
const k = hashKey(v)
|
|
3294
|
-
if (seen.has(k)) return false
|
|
3295
|
-
seen.add(k)
|
|
3296
|
-
return true
|
|
3297
|
-
})
|
|
3395
|
+
const seen = new RubyKeys(interp)
|
|
3396
|
+
return [...self, ...a].filter((v) => seen.add(v))
|
|
3298
3397
|
}
|
|
3299
3398
|
case '*':
|
|
3300
3399
|
if (a instanceof RString) return str(self.map((v) => interp.toS(v)).join(a.s))
|
|
@@ -3703,6 +3802,14 @@ function numberMethod(
|
|
|
3703
3802
|
case '%':
|
|
3704
3803
|
case '**':
|
|
3705
3804
|
return arith(interp, call.name, self, a ?? null)
|
|
3805
|
+
case '^':
|
|
3806
|
+
case '&':
|
|
3807
|
+
case '|': {
|
|
3808
|
+
if (typeof self !== 'number' || typeof a !== 'number')
|
|
3809
|
+
throw new UnsupportedRuby(`${call.name} on ${toInspect(interp, self)}`)
|
|
3810
|
+
const [x, y] = [BigInt(self), BigInt(a)]
|
|
3811
|
+
return Number(call.name === '^' ? x ^ y : call.name === '&' ? x & y : x | y)
|
|
3812
|
+
}
|
|
3706
3813
|
case '-@':
|
|
3707
3814
|
return typeof self === 'number' ? -self : new RFloat(-v)
|
|
3708
3815
|
case '==':
|
|
@@ -4536,13 +4643,11 @@ function moduleMethod(
|
|
|
4536
4643
|
if (call.name === 'module_function') {
|
|
4537
4644
|
const found = interp.findMethod(self, name)
|
|
4538
4645
|
if (found)
|
|
4539
|
-
interp
|
|
4540
|
-
|
|
4541
|
-
.
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
visibility: 'public',
|
|
4545
|
-
})
|
|
4646
|
+
interp.metaOf(self).methods.set(name, {
|
|
4647
|
+
...found,
|
|
4648
|
+
owner: interp.metaOf(self),
|
|
4649
|
+
visibility: 'public',
|
|
4650
|
+
})
|
|
4546
4651
|
continue
|
|
4547
4652
|
}
|
|
4548
4653
|
if (method) holder.methods.set(name, { ...method, visibility })
|
|
@@ -4609,8 +4714,18 @@ function moduleMethod(
|
|
|
4609
4714
|
)
|
|
4610
4715
|
return found !== null && found.visibility === 'private'
|
|
4611
4716
|
}
|
|
4612
|
-
case 'instance_method':
|
|
4613
|
-
|
|
4717
|
+
case 'instance_method': {
|
|
4718
|
+
const name = a instanceof RSymbol ? a.name : strArg(interp, a)
|
|
4719
|
+
const body = interp.findMethod(self, name)
|
|
4720
|
+
if (!body)
|
|
4721
|
+
return interp.raise(
|
|
4722
|
+
'NameError',
|
|
4723
|
+
`undefined method '${name}' for class '${self.name}'`,
|
|
4724
|
+
)
|
|
4725
|
+
const unbound = new RObject(interp.classes.UnboundMethod!)
|
|
4726
|
+
unbound.data = new UnboundMethod(body)
|
|
4727
|
+
return unbound
|
|
4728
|
+
}
|
|
4614
4729
|
case 'class_eval':
|
|
4615
4730
|
case 'module_eval':
|
|
4616
4731
|
case 'class_exec':
|
|
@@ -4813,17 +4928,45 @@ export function builtin(
|
|
|
4813
4928
|
) {
|
|
4814
4929
|
const bound = self.data
|
|
4815
4930
|
result =
|
|
4816
|
-
name
|
|
4817
|
-
? interp.
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4931
|
+
name !== 'call'
|
|
4932
|
+
? interp.toProc(self, env, call.node)
|
|
4933
|
+
: bound.body
|
|
4934
|
+
? interp.invoke(
|
|
4935
|
+
bound.body,
|
|
4936
|
+
bound.receiver,
|
|
4937
|
+
call.args,
|
|
4938
|
+
null,
|
|
4939
|
+
call.block,
|
|
4940
|
+
env,
|
|
4941
|
+
call.node,
|
|
4942
|
+
)
|
|
4943
|
+
: interp.callMethod(
|
|
4944
|
+
bound.receiver,
|
|
4945
|
+
bound.name,
|
|
4946
|
+
call.args,
|
|
4947
|
+
null,
|
|
4948
|
+
call.block,
|
|
4949
|
+
env,
|
|
4950
|
+
call.node,
|
|
4951
|
+
)
|
|
4952
|
+
} else if (self instanceof RObject && self.data instanceof UnboundMethod) {
|
|
4953
|
+
const { body } = self.data
|
|
4954
|
+
if (name === 'bind') {
|
|
4955
|
+
const bound = new RObject(interp.classes.Method!)
|
|
4956
|
+
bound.data = new BoundMethod(call.args[0] ?? null, body.name, body)
|
|
4957
|
+
result = bound
|
|
4958
|
+
} else if (name === 'bind_call')
|
|
4959
|
+
result = interp.invoke(
|
|
4960
|
+
body,
|
|
4961
|
+
call.args[0] ?? null,
|
|
4962
|
+
call.args.slice(1),
|
|
4963
|
+
null,
|
|
4964
|
+
call.block,
|
|
4965
|
+
env,
|
|
4966
|
+
call.node,
|
|
4967
|
+
)
|
|
4968
|
+
else if (name === 'name') result = sym(body.name)
|
|
4969
|
+
else if (name === 'owner') result = body.owner
|
|
4827
4970
|
} else if (self instanceof RObject && self.data instanceof EnumeratorData) {
|
|
4828
4971
|
if (name === 'with_index' || name === 'each_with_index') {
|
|
4829
4972
|
const values = self.data.values
|
|
@@ -5159,7 +5302,17 @@ export function nodeShell(
|
|
|
5159
5302
|
command: string,
|
|
5160
5303
|
cwd: string,
|
|
5161
5304
|
env: Map<string, string>,
|
|
5305
|
+
writable: readonly string[],
|
|
5162
5306
|
): { stdout: string; status: number } {
|
|
5307
|
+
// react native's pod helpers write the Xcode env files with a literal echo
|
|
5308
|
+
const echo = /^echo '([^'\\]*)' > (\S+)$/.exec(command.trim())
|
|
5309
|
+
if (echo) {
|
|
5310
|
+
const target = path.resolve(cwd, echo[2]!)
|
|
5311
|
+
if (!writable.some((root) => target === root || target.startsWith(`${root}/`)))
|
|
5312
|
+
throw new UnsupportedRuby(`shell command \`${command}\` writes outside the package`)
|
|
5313
|
+
fs.writeFileSync(target, `${echo[1]}\n`)
|
|
5314
|
+
return { stdout: '', status: 0 }
|
|
5315
|
+
}
|
|
5163
5316
|
const steps = command.split(/&&|;/).map((step) => step.trim().split(/\s+/)[0])
|
|
5164
5317
|
if (!steps.every((program) => program === 'node' || program === 'cd'))
|
|
5165
5318
|
throw new UnsupportedRuby(`shell command \`${command}\``)
|
package/src/settingsContract.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IOS_DYNAMIC_TYPE_SCALES } from '@peach/globals/dynamic-type-scales'
|
|
1
2
|
import {
|
|
2
3
|
DEFAULT_PROFILER_CATEGORIES,
|
|
3
4
|
formatProfilerCategories,
|
|
@@ -633,6 +634,79 @@ export function isSettingKey(key: string): key is SettingKey {
|
|
|
633
634
|
return Object.hasOwn(settingsSchema, key)
|
|
634
635
|
}
|
|
635
636
|
|
|
637
|
+
// the device settings a peach.config.ts profile, a `peach open` flag or
|
|
638
|
+
// `peach settings` sets: the simulated device's own settings and its locale
|
|
639
|
+
export const PROFILE_SETTING_KEYS = [
|
|
640
|
+
...SIMULATED_DEVICE_SETTING_KEYS,
|
|
641
|
+
'language',
|
|
642
|
+
'region',
|
|
643
|
+
'preferredLanguages',
|
|
644
|
+
] as const satisfies readonly SettingKey[]
|
|
645
|
+
|
|
646
|
+
export type ProfileSettingKey = (typeof PROFILE_SETTING_KEYS)[number]
|
|
647
|
+
|
|
648
|
+
export type SettingsProfile = Partial<Pick<SettingsValues, ProfileSettingKey>>
|
|
649
|
+
|
|
650
|
+
export function isProfileSettingKey(key: string): key is ProfileSettingKey {
|
|
651
|
+
return PROFILE_SETTING_KEYS.some((profileKey) => profileKey === key)
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// one text form for every setting, shared by launch url params and cli flags:
|
|
655
|
+
// booleans are on|off (1|0 and true|false too), lists are comma separated
|
|
656
|
+
export function parseSettingText(key: SettingKey, text: string): unknown {
|
|
657
|
+
const def = settingsSchema[key]
|
|
658
|
+
if (def.type === 'boolean') {
|
|
659
|
+
if (['1', 'true', 'on'].includes(text)) return true
|
|
660
|
+
if (['0', 'false', 'off'].includes(text)) return false
|
|
661
|
+
return undefined
|
|
662
|
+
}
|
|
663
|
+
if (def.type === 'number') return text.trim() ? Number(text) : undefined
|
|
664
|
+
if (def.type === 'string-array') return text ? text.split(',') : []
|
|
665
|
+
return text
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// a profile names an iOS Dynamic Type size, the only font sizes iOS offers
|
|
669
|
+
export function isValidProfileValue(key: ProfileSettingKey, value: unknown): boolean {
|
|
670
|
+
if (!isValidSettingValue(key, value)) return false
|
|
671
|
+
return key !== 'fontSize' || IOS_DYNAMIC_TYPE_SCALES.some((scale) => scale === value)
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
export function formatSettingText(value: unknown): string {
|
|
675
|
+
if (typeof value === 'boolean') return value ? '1' : '0'
|
|
676
|
+
if (Array.isArray(value)) return value.join(',')
|
|
677
|
+
return String(value)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export function describeSettingValues(key: SettingKey): string {
|
|
681
|
+
if (key === 'fontSize')
|
|
682
|
+
return `a Dynamic Type size (${IOS_DYNAMIC_TYPE_SCALES.join(', ')})`
|
|
683
|
+
const def = settingsSchema[key]
|
|
684
|
+
if (def.type === 'boolean') return 'on or off'
|
|
685
|
+
if (def.options) return def.options.join(', ')
|
|
686
|
+
if (def.type === 'string-array') return 'a comma separated list'
|
|
687
|
+
if (def.type === 'number') return def.validate ? 'a number in its range' : 'a number'
|
|
688
|
+
return 'text'
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// a profile from peach.config.ts or flags, every value checked against the schema
|
|
692
|
+
export function readSettingsProfile(value: unknown, label: string): SettingsProfile {
|
|
693
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
694
|
+
throw new Error(`${label} must be an object of settings`)
|
|
695
|
+
const profile: Record<string, unknown> = {}
|
|
696
|
+
for (const [key, setting] of Object.entries(value)) {
|
|
697
|
+
if (!isProfileSettingKey(key))
|
|
698
|
+
throw new Error(
|
|
699
|
+
`${label}: unknown setting "${key}". profiles set ${PROFILE_SETTING_KEYS.join(', ')}`,
|
|
700
|
+
)
|
|
701
|
+
if (!isValidProfileValue(key, setting))
|
|
702
|
+
throw new Error(
|
|
703
|
+
`${label}: ${key} must be ${describeSettingValues(key)}, got ${JSON.stringify(setting)}`,
|
|
704
|
+
)
|
|
705
|
+
profile[key] = setting
|
|
706
|
+
}
|
|
707
|
+
return profile
|
|
708
|
+
}
|
|
709
|
+
|
|
636
710
|
export function getSettingsByGroup(group: SettingGroup): [SettingKey, SettingDef][] {
|
|
637
711
|
return Object.entries(settingsSchema).filter(
|
|
638
712
|
(entry): entry is [SettingKey, SettingDef] =>
|
package/src/swift-compile.ts
CHANGED
|
@@ -1748,7 +1748,7 @@ const PRECONCURRENCY_FOUNDATION_IMPORT =
|
|
|
1748
1748
|
/^[ \t]*@preconcurrency[ \t]+(?:(?:public|package|internal|fileprivate|private)[ \t]+)?import[ \t]+(?:Foundation|UIKit|SwiftUI)[ \t]*(?:\/\/.*)?$/m
|
|
1749
1749
|
export function withPreconcurrencyFoundationModules(source: string): string {
|
|
1750
1750
|
if (!PRECONCURRENCY_FOUNDATION_IMPORT.test(source)) return source
|
|
1751
|
-
return `${source}${source.endsWith('\n') ? '' : '\n'}#if canImport(PeachObjC)\n${['ObjectiveC', ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}\n`).join('')}#endif\n`
|
|
1751
|
+
return `${source}${source.endsWith('\n') ? '' : '\n'}#if canImport(PeachObjC)\n${['CoreFoundation', 'ObjectiveC', ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}\n`).join('')}#endif\n`
|
|
1752
1752
|
}
|
|
1753
1753
|
const FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
1754
1754
|
(module) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module}"`,
|