peachsim 0.1.795 → 0.1.797
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/cloud-test-tunnel.ts +1 -1
- package/cli/outbound-endpoints.ts +6 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.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 +383 -355
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +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/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +357 -336
- 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 +680 -575
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +401 -178
- 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 +1 -1
- 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 +1 -1
- 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/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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +85 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +976 -851
- package/dist-lib/swift-compile.cjs +18 -4
- package/dist-lib/swift-compile.mjs +18 -4
- 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 +416 -368
- package/dist-lib/vite.cjs +240 -15
- package/package.json +1 -1
- package/scripts/dev-server-scanner.ts +16 -5
- package/src/expo-swift-host.ts +8 -4
- package/src/one-widget-discovery.ts +17 -0
- package/src/one-widget-metadata.ts +208 -0
- package/src/one-widget-package.ts +11 -165
- package/src/oneWidgetContract.ts +122 -0
- package/src/swift-compile.ts +21 -3
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-host.ts +2 -48
- package/src/swift-source-file.ts +48 -0
- package/src/vite-plugin-one.ts +18 -1
|
@@ -1,181 +1,27 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { execFile } from 'node:child_process'
|
|
1
|
+
// prebuild owns the source bytes; projection and compilation are placement-only.
|
|
3
2
|
import { createHash } from 'node:crypto'
|
|
4
3
|
import fs from 'node:fs'
|
|
5
|
-
import { createRequire } from 'node:module'
|
|
6
4
|
import os from 'node:os'
|
|
7
5
|
import path from 'node:path'
|
|
8
|
-
import {
|
|
9
|
-
import { RNX_FORKED_SCRIPT_ENV } from '../cli/internal-child'
|
|
10
|
-
import { isRecord } from './is-record'
|
|
6
|
+
import { readOneWidgetSources, ONE_WIDGET_PACKAGE } from './one-widget-metadata'
|
|
11
7
|
import { syncSwiftTree } from './swift-compile'
|
|
12
|
-
import {
|
|
13
|
-
import { MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
|
|
14
|
-
import type { OneWidgetMetadata, OneWidgetPackage } from './oneWidgetContract'
|
|
8
|
+
import type { OneWidgetPackage } from './oneWidgetContract'
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
export const ONE_WIDGET_PACKAGE = 'OneWidgets'
|
|
18
|
-
|
|
19
|
-
type WidgetConfig = Omit<OneWidgetMetadata, 'sources'>
|
|
20
|
-
|
|
21
|
-
interface ConfigRead {
|
|
22
|
-
widget: WidgetConfig | null
|
|
23
|
-
watched: string[]
|
|
24
|
-
stamp: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const configs = new Map<string, ConfigRead>()
|
|
28
|
-
const reads = new Map<string, Promise<ConfigRead>>()
|
|
29
|
-
const CONFIG_CHILD = `
|
|
30
|
-
import fs from 'node:fs';
|
|
31
|
-
import { loadUserOneOptions } from 'one/vite';
|
|
32
|
-
const { config, oneOptions } = await loadUserOneOptions('serve', true);
|
|
33
|
-
const app = oneOptions.native?.app;
|
|
34
|
-
const widgets = app?.ios?.widgets;
|
|
35
|
-
fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
36
|
-
widget: widgets ? { appName: app.name, bundleId: app.ios.bundleId,
|
|
37
|
-
suite: widgets.appGroup, kind: widgets.kind, displayName: widgets.displayName,
|
|
38
|
-
description: widgets.description } : null,
|
|
39
|
-
watched: [config.path, ...config.dependencies]
|
|
40
|
-
}));
|
|
41
|
-
`
|
|
42
|
-
|
|
43
|
-
function configStamp(files: string[]): string {
|
|
44
|
-
return JSON.stringify(
|
|
45
|
-
files.map((file) => {
|
|
46
|
-
if (!fs.existsSync(file)) return [file, null]
|
|
47
|
-
const stat = fs.statSync(file)
|
|
48
|
-
return [file, stat.mtimeMs, stat.ctimeMs, stat.size]
|
|
49
|
-
}),
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function readConfig(root: string): Promise<ConfigRead> {
|
|
54
|
-
const cached = configs.get(root)
|
|
55
|
-
if (cached && cached.stamp === configStamp(cached.watched)) return cached
|
|
56
|
-
const reading = reads.get(root)
|
|
57
|
-
if (reading) return reading
|
|
58
|
-
const promise = (async () => {
|
|
59
|
-
// resolve before launching: an app without One is not a configured One app.
|
|
60
|
-
createRequire(path.join(root, 'package.json')).resolve('one/vite')
|
|
61
|
-
const cache = path.join(root, 'node_modules/.cache/peach-widget-config')
|
|
62
|
-
fs.mkdirSync(cache, { recursive: true })
|
|
63
|
-
const directory = fs.mkdtempSync(path.join(cache, 'read-'))
|
|
64
|
-
const script = path.join(directory, 'read.mjs')
|
|
65
|
-
const result = path.join(directory, 'result.json')
|
|
66
|
-
fs.writeFileSync(script, CONFIG_CHILD)
|
|
67
|
-
try {
|
|
68
|
-
await run(process.execPath, [script, result], {
|
|
69
|
-
cwd: root,
|
|
70
|
-
env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: '1' },
|
|
71
|
-
timeout: 30_000,
|
|
72
|
-
maxBuffer: 1024 * 1024,
|
|
73
|
-
})
|
|
74
|
-
const value: unknown = JSON.parse(fs.readFileSync(result, 'utf8'))
|
|
75
|
-
if (
|
|
76
|
-
!isRecord(value) ||
|
|
77
|
-
!Array.isArray(value.watched) ||
|
|
78
|
-
!value.watched.every((file): file is string => typeof file === 'string')
|
|
79
|
-
)
|
|
80
|
-
throw new Error('One config loader returned invalid dependencies')
|
|
81
|
-
let widget: WidgetConfig | null = null
|
|
82
|
-
if (value.widget !== null) {
|
|
83
|
-
const entry = value.widget
|
|
84
|
-
if (
|
|
85
|
-
!isRecord(entry) ||
|
|
86
|
-
typeof entry.appName !== 'string' ||
|
|
87
|
-
!/^[A-Za-z][A-Za-z0-9_]*$/.test(entry.appName) ||
|
|
88
|
-
typeof entry.bundleId !== 'string' ||
|
|
89
|
-
!entry.bundleId ||
|
|
90
|
-
typeof entry.suite !== 'string' ||
|
|
91
|
-
!entry.suite ||
|
|
92
|
-
typeof entry.kind !== 'string' ||
|
|
93
|
-
!entry.kind ||
|
|
94
|
-
typeof entry.displayName !== 'string' ||
|
|
95
|
-
!entry.displayName ||
|
|
96
|
-
typeof entry.description !== 'string' ||
|
|
97
|
-
!entry.description
|
|
98
|
-
)
|
|
99
|
-
throw new Error('One config loader returned invalid native.app.ios.widgets')
|
|
100
|
-
widget = {
|
|
101
|
-
appName: entry.appName,
|
|
102
|
-
bundleId: entry.bundleId,
|
|
103
|
-
suite: entry.suite,
|
|
104
|
-
kind: entry.kind,
|
|
105
|
-
displayName: entry.displayName,
|
|
106
|
-
description: entry.description,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const watched = [
|
|
110
|
-
...new Set([
|
|
111
|
-
path.join(root, 'package.json'),
|
|
112
|
-
...value.watched.map((file) => path.resolve(root, file)),
|
|
113
|
-
]),
|
|
114
|
-
]
|
|
115
|
-
const loaded = { widget, watched, stamp: configStamp(watched) }
|
|
116
|
-
configs.set(root, loaded)
|
|
117
|
-
return loaded
|
|
118
|
-
} finally {
|
|
119
|
-
fs.rmSync(directory, { recursive: true, force: true })
|
|
120
|
-
}
|
|
121
|
-
})()
|
|
122
|
-
reads.set(root, promise)
|
|
123
|
-
try {
|
|
124
|
-
return await promise
|
|
125
|
-
} finally {
|
|
126
|
-
reads.delete(root)
|
|
127
|
-
}
|
|
128
|
-
}
|
|
10
|
+
export { ONE_WIDGET_PACKAGE } from './one-widget-metadata'
|
|
129
11
|
|
|
130
12
|
export async function oneWidgetPackage(
|
|
131
13
|
appRoot: string,
|
|
132
14
|
): Promise<OneWidgetPackage | null> {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const sourceFiles = {
|
|
138
|
-
'OneWidget.swift': path.join(root, 'ios/OneWidgets/OneWidget.swift'),
|
|
139
|
-
'OneWidgetContract.swift': path.join(
|
|
140
|
-
root,
|
|
141
|
-
'ios',
|
|
142
|
-
widget.appName,
|
|
143
|
-
'OneWidgetContract.swift',
|
|
144
|
-
),
|
|
145
|
-
}
|
|
146
|
-
const files = new Map<string, string>()
|
|
147
|
-
const sources: Record<string, string> = {}
|
|
148
|
-
for (const [name, file] of Object.entries(sourceFiles)) {
|
|
149
|
-
if (!fs.existsSync(file))
|
|
150
|
-
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`)
|
|
151
|
-
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
152
|
-
const text = bytes.toString('utf8')
|
|
153
|
-
if (!Buffer.from(text).equals(bytes))
|
|
154
|
-
throw new Error(`One widget prebuild source is not UTF-8: ${file}`)
|
|
155
|
-
files.set(name, text)
|
|
156
|
-
sources[path.relative(root, file).split(path.sep).join('/')] = createHash('sha256')
|
|
157
|
-
.update(bytes)
|
|
158
|
-
.digest('hex')
|
|
159
|
-
}
|
|
160
|
-
const contract = files.get('OneWidgetContract.swift') ?? ''
|
|
161
|
-
const source = files.get('OneWidget.swift') ?? ''
|
|
162
|
-
if (
|
|
163
|
-
!contract.includes(`static let appGroup = ${JSON.stringify(widget.suite)}`) ||
|
|
164
|
-
!contract.includes(`static let kind = ${JSON.stringify(widget.kind)}`) ||
|
|
165
|
-
!source.includes(
|
|
166
|
-
`.configurationDisplayName(${JSON.stringify(widget.displayName)})`,
|
|
167
|
-
) ||
|
|
168
|
-
!source.includes(`.description(${JSON.stringify(widget.description)})`)
|
|
169
|
-
)
|
|
170
|
-
throw new Error(
|
|
171
|
-
'One widget prebuild sources disagree with native.app.ios.widgets; run one prebuild',
|
|
172
|
-
)
|
|
15
|
+
const source = await readOneWidgetSources(appRoot)
|
|
16
|
+
if (!source) return null
|
|
17
|
+
const { root, files, watched, widget } = source
|
|
18
|
+
const { sources: _sources, ...config } = widget
|
|
173
19
|
// configuration participates in the existing package stamp and compile address.
|
|
174
20
|
files.set(
|
|
175
21
|
'Package.swift',
|
|
176
22
|
[
|
|
177
23
|
'// swift-tools-version: 6.2',
|
|
178
|
-
`// One widget config ${JSON.stringify(
|
|
24
|
+
`// One widget config ${JSON.stringify(config)}`,
|
|
179
25
|
'import PackageDescription',
|
|
180
26
|
'let package = Package(name: "OneWidgets", targets: [',
|
|
181
27
|
' .executableTarget(name: "OneWidgets", path: ".", swiftSettings: [.swiftLanguageMode(.v5)]),',
|
|
@@ -196,7 +42,7 @@ export async function oneWidgetPackage(
|
|
|
196
42
|
)
|
|
197
43
|
return {
|
|
198
44
|
packagePath,
|
|
199
|
-
watched
|
|
200
|
-
widget
|
|
45
|
+
watched,
|
|
46
|
+
widget,
|
|
201
47
|
}
|
|
202
48
|
}
|
package/src/oneWidgetContract.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { alignLoopbackBundleUrlWithProbe } from './native-dev-bundle-url'
|
|
2
|
+
|
|
1
3
|
// generated One widget package metadata carried by the Swift serving host.
|
|
2
4
|
export interface OneWidgetMetadata {
|
|
3
5
|
appName: string
|
|
@@ -14,3 +16,123 @@ export interface OneWidgetPackage {
|
|
|
14
16
|
watched: string[]
|
|
15
17
|
widget: OneWidgetMetadata
|
|
16
18
|
}
|
|
19
|
+
|
|
20
|
+
// lightweight discovery identity; packageUrl compiles only when placement requests it.
|
|
21
|
+
export interface ConfiguredOneWidget {
|
|
22
|
+
metadata: OneWidgetMetadata
|
|
23
|
+
projectRoot: string
|
|
24
|
+
appIdentity: string
|
|
25
|
+
bundleUrl: string
|
|
26
|
+
packageUrl: string
|
|
27
|
+
urlSchemes: string[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// a descriptor belongs to the server that answered for this exact bundle path.
|
|
31
|
+
export function configuredWidgetFromScan(
|
|
32
|
+
value: unknown,
|
|
33
|
+
bundleUrl: string,
|
|
34
|
+
): ConfiguredOneWidget | null {
|
|
35
|
+
if (!Array.isArray(value)) return null
|
|
36
|
+
const requested = new URL(bundleUrl)
|
|
37
|
+
for (const entry of value) {
|
|
38
|
+
if (!entry || typeof entry !== 'object') continue
|
|
39
|
+
const widget: unknown = Reflect.get(entry, 'widget')
|
|
40
|
+
if (!widget || typeof widget !== 'object') continue
|
|
41
|
+
const metadata: unknown = Reflect.get(widget, 'metadata')
|
|
42
|
+
const advertisedUrl: unknown = Reflect.get(widget, 'bundleUrl')
|
|
43
|
+
const packageUrl: unknown = Reflect.get(widget, 'packageUrl')
|
|
44
|
+
const projectRoot: unknown = Reflect.get(widget, 'projectRoot')
|
|
45
|
+
const appIdentity: unknown = Reflect.get(widget, 'appIdentity')
|
|
46
|
+
const urlSchemes: unknown = Reflect.get(widget, 'urlSchemes')
|
|
47
|
+
if (
|
|
48
|
+
typeof advertisedUrl !== 'string' ||
|
|
49
|
+
typeof packageUrl !== 'string' ||
|
|
50
|
+
typeof projectRoot !== 'string' ||
|
|
51
|
+
!projectRoot ||
|
|
52
|
+
typeof appIdentity !== 'string' ||
|
|
53
|
+
!/^[a-f0-9]{64}$/.test(appIdentity) ||
|
|
54
|
+
!Array.isArray(urlSchemes) ||
|
|
55
|
+
!urlSchemes.every(
|
|
56
|
+
(scheme): scheme is string =>
|
|
57
|
+
typeof scheme === 'string' && /^[A-Za-z][A-Za-z0-9+.-]*$/.test(scheme),
|
|
58
|
+
) ||
|
|
59
|
+
!metadata ||
|
|
60
|
+
typeof metadata !== 'object'
|
|
61
|
+
)
|
|
62
|
+
continue
|
|
63
|
+
const advertised = new URL(alignLoopbackBundleUrlWithProbe(advertisedUrl, bundleUrl))
|
|
64
|
+
if (
|
|
65
|
+
advertised.protocol !== requested.protocol ||
|
|
66
|
+
advertised.port !== requested.port ||
|
|
67
|
+
advertised.hostname !== requested.hostname ||
|
|
68
|
+
advertised.pathname !== requested.pathname
|
|
69
|
+
)
|
|
70
|
+
continue
|
|
71
|
+
if (
|
|
72
|
+
['rnxProjectId', 'rnxReplacementToken'].some(
|
|
73
|
+
(key) =>
|
|
74
|
+
requested.searchParams.has(key) &&
|
|
75
|
+
requested.searchParams.get(key) !== advertised.searchParams.get(key),
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
continue
|
|
79
|
+
if (
|
|
80
|
+
new URL(packageUrl).origin !== new URL(advertisedUrl).origin ||
|
|
81
|
+
new URL(packageUrl).pathname !== '/__peach/swift-package/OneWidgets'
|
|
82
|
+
)
|
|
83
|
+
continue
|
|
84
|
+
const appName: unknown = Reflect.get(metadata, 'appName')
|
|
85
|
+
const bundleId: unknown = Reflect.get(metadata, 'bundleId')
|
|
86
|
+
const kind: unknown = Reflect.get(metadata, 'kind')
|
|
87
|
+
const suite: unknown = Reflect.get(metadata, 'suite')
|
|
88
|
+
const displayName: unknown = Reflect.get(metadata, 'displayName')
|
|
89
|
+
const description: unknown = Reflect.get(metadata, 'description')
|
|
90
|
+
const sources: unknown = Reflect.get(metadata, 'sources')
|
|
91
|
+
if (
|
|
92
|
+
typeof appName !== 'string' ||
|
|
93
|
+
!/^[A-Za-z][A-Za-z0-9_]*$/.test(appName) ||
|
|
94
|
+
typeof bundleId !== 'string' ||
|
|
95
|
+
!bundleId ||
|
|
96
|
+
typeof kind !== 'string' ||
|
|
97
|
+
!kind ||
|
|
98
|
+
typeof suite !== 'string' ||
|
|
99
|
+
!suite ||
|
|
100
|
+
typeof displayName !== 'string' ||
|
|
101
|
+
!displayName ||
|
|
102
|
+
typeof description !== 'string' ||
|
|
103
|
+
!description ||
|
|
104
|
+
!sources ||
|
|
105
|
+
typeof sources !== 'object' ||
|
|
106
|
+
Array.isArray(sources)
|
|
107
|
+
)
|
|
108
|
+
continue
|
|
109
|
+
const sourceHashes: Record<string, string> = {}
|
|
110
|
+
for (const [file, hash] of Object.entries(sources)) {
|
|
111
|
+
if (typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash)) return null
|
|
112
|
+
sourceHashes[file] = hash
|
|
113
|
+
}
|
|
114
|
+
if (
|
|
115
|
+
Object.keys(sourceHashes).length !== 2 ||
|
|
116
|
+
!sourceHashes['ios/OneWidgets/OneWidget.swift'] ||
|
|
117
|
+
!sourceHashes[`ios/${appName}/OneWidgetContract.swift`]
|
|
118
|
+
)
|
|
119
|
+
continue
|
|
120
|
+
return {
|
|
121
|
+
metadata: {
|
|
122
|
+
appName,
|
|
123
|
+
bundleId,
|
|
124
|
+
kind,
|
|
125
|
+
suite,
|
|
126
|
+
displayName,
|
|
127
|
+
description,
|
|
128
|
+
sources: sourceHashes,
|
|
129
|
+
},
|
|
130
|
+
bundleUrl,
|
|
131
|
+
packageUrl: new URL('/__peach/swift-package/OneWidgets', requested).href,
|
|
132
|
+
projectRoot,
|
|
133
|
+
appIdentity,
|
|
134
|
+
urlSchemes,
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return null
|
|
138
|
+
}
|
package/src/swift-compile.ts
CHANGED
|
@@ -566,7 +566,7 @@ const FOUNDATION_IMPLICIT_FLAGS =
|
|
|
566
566
|
const ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
|
|
567
567
|
|
|
568
568
|
/** bump with any change to the emitted multi-target manifest text. */
|
|
569
|
-
export const MULTI_MANIFEST_VERSION =
|
|
569
|
+
export const MULTI_MANIFEST_VERSION = 12
|
|
570
570
|
|
|
571
571
|
export function swiftArtifactHash(
|
|
572
572
|
input: SwiftCompileInput,
|
|
@@ -650,10 +650,14 @@ export function emitSwiftPackageManifest(args: {
|
|
|
650
650
|
)
|
|
651
651
|
.flatMap((name) => [name, ...(OPTIONAL_FRAMEWORK_DEPENDENCIES[name] ?? [])]),
|
|
652
652
|
)
|
|
653
|
+
if (spriteKit) {
|
|
654
|
+
reachedFrameworks.add('SpriteKit')
|
|
655
|
+
reachedFrameworks.add('PeachBox2D')
|
|
656
|
+
}
|
|
653
657
|
// the distribution builder names each object lib/<target>-<file>.o.
|
|
654
658
|
// preserve link order while leaving unreached optional module objects out.
|
|
655
659
|
const distributionObjects = distribution?.objects.filter((object) =>
|
|
656
|
-
[...OPTIONAL_FRAMEWORKS].every(
|
|
660
|
+
[...OPTIONAL_FRAMEWORKS, 'SpriteKit', 'PeachBox2D'].every(
|
|
657
661
|
(name) => !object.startsWith(`lib/${name}-`) || reachedFrameworks.has(name),
|
|
658
662
|
),
|
|
659
663
|
)
|
|
@@ -2236,7 +2240,21 @@ export function compileSwiftProjectUnit(
|
|
|
2236
2240
|
]),
|
|
2237
2241
|
],
|
|
2238
2242
|
{
|
|
2239
|
-
env:
|
|
2243
|
+
env: {
|
|
2244
|
+
...BUILD_ENV,
|
|
2245
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
2246
|
+
...(process.platform === 'linux'
|
|
2247
|
+
? {
|
|
2248
|
+
LD_LIBRARY_PATH: [
|
|
2249
|
+
path.resolve(options.toolchainBin, '../lib/swift/linux'),
|
|
2250
|
+
path.resolve(options.toolchainBin, '../lib/swift/host'),
|
|
2251
|
+
process.env.LD_LIBRARY_PATH,
|
|
2252
|
+
]
|
|
2253
|
+
.filter(Boolean)
|
|
2254
|
+
.join(':'),
|
|
2255
|
+
}
|
|
2256
|
+
: {}),
|
|
2257
|
+
},
|
|
2240
2258
|
maxBuffer: 64 * 1024 * 1024,
|
|
2241
2259
|
timeout: options.timeoutMs,
|
|
2242
2260
|
},
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "1a431e89764e8cfa",
|
|
3
3
|
"release": "swift-6.3-RELEASE",
|
|
4
|
-
"wasmSdkId": "swift-6.3-RELEASE_wasm-peach-41921598-peach-
|
|
5
|
-
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-
|
|
6
|
-
"wasmSdkChecksum": "
|
|
7
|
-
"source": "
|
|
4
|
+
"wasmSdkId": "swift-6.3-RELEASE_wasm-peach-41921598-peach-f2d7f5d4",
|
|
5
|
+
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-f2d7f5d4.artifactbundle.tar.gz",
|
|
6
|
+
"wasmSdkChecksum": "7471b1c145aba62bb9f696aa4d0cd1657cbd9bc7637811b2e6bda1f650553f8d",
|
|
7
|
+
"source": "90d77cf86a77ba84839e5885e1c354a4976f825f",
|
|
8
8
|
"hosts": {
|
|
9
9
|
"darwin-arm64": {
|
|
10
|
-
"sha256": "
|
|
11
|
-
"size":
|
|
10
|
+
"sha256": "ae344e0c60631747c512785d3232be4bc3066d3edbc2916616d43f2a8ee9d759",
|
|
11
|
+
"size": 36453618
|
|
12
12
|
},
|
|
13
13
|
"linux-x64": {
|
|
14
|
-
"sha256": "
|
|
15
|
-
"size":
|
|
14
|
+
"sha256": "16d8f064eaec39e35ee969719481d1f709e9dd08b7112dd83c7c0b8c0b447922",
|
|
15
|
+
"size": 36458677
|
|
16
16
|
},
|
|
17
17
|
"linux-arm64": {
|
|
18
|
-
"sha256": "
|
|
19
|
-
"size":
|
|
18
|
+
"sha256": "942892104d80b351b2dc9b414ba72695542ed3b066e0fe9e98d8e42ac760c8df",
|
|
19
|
+
"size": 36457909
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
package/src/swift-host.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
1
2
|
// the node host for every Swift preview: package inputs, one compile and
|
|
2
3
|
// immutable artifact addresses. vite and the foreground CLI adapt this host.
|
|
3
|
-
|
|
4
|
-
import { createHash } from 'node:crypto'
|
|
5
4
|
import fs from 'node:fs'
|
|
6
5
|
import os from 'node:os'
|
|
7
6
|
import path from 'node:path'
|
|
@@ -33,6 +32,7 @@ import {
|
|
|
33
32
|
type SwiftPackageGap,
|
|
34
33
|
type SwiftPackages,
|
|
35
34
|
} from './swift-packages'
|
|
35
|
+
import { readPackageFile } from './swift-source-file'
|
|
36
36
|
import {
|
|
37
37
|
standinGenerationInputs,
|
|
38
38
|
swiftStandins,
|
|
@@ -467,52 +467,6 @@ function sourceTreeFiles(dir: string, canonicalRoot: string): string[] {
|
|
|
467
467
|
return found
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
export function readPackageFile(root: string, file: string, maxBytes: number): Buffer {
|
|
471
|
-
const canonicalRoot = fs.realpathSync(root)
|
|
472
|
-
const relative = path.relative(canonicalRoot, fs.realpathSync(file))
|
|
473
|
-
if (
|
|
474
|
-
relative === '..' ||
|
|
475
|
-
relative.startsWith(`..${path.sep}`) ||
|
|
476
|
-
path.isAbsolute(relative)
|
|
477
|
-
) {
|
|
478
|
-
throw new Error(`swift input escapes the selected package: ${file}`)
|
|
479
|
-
}
|
|
480
|
-
let ancestor = path.resolve(file)
|
|
481
|
-
while (ancestor !== canonicalRoot) {
|
|
482
|
-
if (fs.lstatSync(ancestor).isSymbolicLink()) {
|
|
483
|
-
throw new Error(`swift input is a symlink: ${ancestor}`)
|
|
484
|
-
}
|
|
485
|
-
const parent = path.dirname(ancestor)
|
|
486
|
-
if (parent === ancestor)
|
|
487
|
-
throw new Error(`swift input escapes the selected package: ${file}`)
|
|
488
|
-
ancestor = parent
|
|
489
|
-
}
|
|
490
|
-
const expected = fs.statSync(file)
|
|
491
|
-
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW)
|
|
492
|
-
try {
|
|
493
|
-
const stat = fs.fstatSync(fd)
|
|
494
|
-
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
495
|
-
throw new Error(`swift input changed while opening: ${file}`)
|
|
496
|
-
}
|
|
497
|
-
if (!stat.isFile() || stat.size > maxBytes) {
|
|
498
|
-
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`)
|
|
499
|
-
}
|
|
500
|
-
const bytes = Buffer.alloc(stat.size + 1)
|
|
501
|
-
let offset = 0
|
|
502
|
-
while (offset < bytes.length) {
|
|
503
|
-
const count = fs.readSync(fd, bytes, offset, bytes.length - offset, null)
|
|
504
|
-
if (count === 0) break
|
|
505
|
-
offset += count
|
|
506
|
-
}
|
|
507
|
-
if (offset !== stat.size || fs.fstatSync(fd).size !== stat.size) {
|
|
508
|
-
throw new Error(`swift input changed while reading: ${file}`)
|
|
509
|
-
}
|
|
510
|
-
return bytes.subarray(0, offset)
|
|
511
|
-
} finally {
|
|
512
|
-
fs.closeSync(fd)
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
470
|
export function sourceFiles(root: string): string[] {
|
|
517
471
|
return packageFiles(root).filter((file) => file.endsWith('.swift'))
|
|
518
472
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
export function readPackageFile(root: string, file: string, maxBytes: number): Buffer {
|
|
5
|
+
const canonicalRoot = fs.realpathSync(root)
|
|
6
|
+
const relative = path.relative(canonicalRoot, fs.realpathSync(file))
|
|
7
|
+
if (
|
|
8
|
+
relative === '..' ||
|
|
9
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
10
|
+
path.isAbsolute(relative)
|
|
11
|
+
) {
|
|
12
|
+
throw new Error(`swift input escapes the selected package: ${file}`)
|
|
13
|
+
}
|
|
14
|
+
let ancestor = path.resolve(file)
|
|
15
|
+
while (ancestor !== canonicalRoot) {
|
|
16
|
+
if (fs.lstatSync(ancestor).isSymbolicLink()) {
|
|
17
|
+
throw new Error(`swift input is a symlink: ${ancestor}`)
|
|
18
|
+
}
|
|
19
|
+
const parent = path.dirname(ancestor)
|
|
20
|
+
if (parent === ancestor)
|
|
21
|
+
throw new Error(`swift input escapes the selected package: ${file}`)
|
|
22
|
+
ancestor = parent
|
|
23
|
+
}
|
|
24
|
+
const expected = fs.statSync(file)
|
|
25
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW)
|
|
26
|
+
try {
|
|
27
|
+
const stat = fs.fstatSync(fd)
|
|
28
|
+
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
29
|
+
throw new Error(`swift input changed while opening: ${file}`)
|
|
30
|
+
}
|
|
31
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
32
|
+
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`)
|
|
33
|
+
}
|
|
34
|
+
const bytes = Buffer.alloc(stat.size + 1)
|
|
35
|
+
let offset = 0
|
|
36
|
+
while (offset < bytes.length) {
|
|
37
|
+
const count = fs.readSync(fd, bytes, offset, bytes.length - offset, null)
|
|
38
|
+
if (count === 0) break
|
|
39
|
+
offset += count
|
|
40
|
+
}
|
|
41
|
+
if (offset !== stat.size || fs.fstatSync(fd).size !== stat.size) {
|
|
42
|
+
throw new Error(`swift input changed while reading: ${file}`)
|
|
43
|
+
}
|
|
44
|
+
return bytes.subarray(0, offset)
|
|
45
|
+
} finally {
|
|
46
|
+
fs.closeSync(fd)
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/vite-plugin-one.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from './dev-server-open'
|
|
21
21
|
import { isDaemonLockfileFresh, readDaemonLockfile } from './home-paths'
|
|
22
22
|
import { handleReplacementModuleRequest } from './host/replacement-module-handler'
|
|
23
|
+
import { configuredOneWidget } from './one-widget-metadata'
|
|
23
24
|
import {
|
|
24
25
|
isRootRuntimeAssetPath,
|
|
25
26
|
resolveRuntimeFilePath,
|
|
@@ -353,7 +354,7 @@ export function rnxPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
353
354
|
// we describe only this server (the shell drives THIS app) — no localhost-
|
|
354
355
|
// wide scan, so the published plugin pulls in no shell-only scanner
|
|
355
356
|
// internals. shape matches DiscoveredServer enough for the resolver.
|
|
356
|
-
server.middlewares.use((req, res, next) => {
|
|
357
|
+
server.middlewares.use(async (req, res, next) => {
|
|
357
358
|
if ((req.url || '').split('?')[0] !== '/__server-scan') return next()
|
|
358
359
|
const scanPort = listeningPort()
|
|
359
360
|
const pluginBundleUrl = bundleForPort(scanPort)
|
|
@@ -361,12 +362,28 @@ export function rnxPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
361
362
|
? pluginBundleUrl
|
|
362
363
|
: `http://localhost:${scanPort}${pluginBundleUrl}`
|
|
363
364
|
res.setHeader('content-type', 'application/json')
|
|
365
|
+
res.setHeader('access-control-allow-origin', '*')
|
|
366
|
+
res.setHeader('cache-control', 'no-store')
|
|
367
|
+
let widget: Awaited<ReturnType<typeof configuredOneWidget>> = null
|
|
368
|
+
let widgetError: string | undefined
|
|
369
|
+
try {
|
|
370
|
+
widget = await configuredOneWidget(server.config.root, absoluteBundleUrl)
|
|
371
|
+
if (widget && packageMap().has('OneWidgets'))
|
|
372
|
+
throw new Error(
|
|
373
|
+
"swift package OneWidgets conflicts with One's generated widget extension",
|
|
374
|
+
)
|
|
375
|
+
} catch (error) {
|
|
376
|
+
widget = null
|
|
377
|
+
widgetError = String(error)
|
|
378
|
+
}
|
|
364
379
|
res.end(
|
|
365
380
|
JSON.stringify([
|
|
366
381
|
{
|
|
367
382
|
port: scanPort,
|
|
368
383
|
framework: 'one',
|
|
369
384
|
bundleUrl: absoluteBundleUrl,
|
|
385
|
+
widget,
|
|
386
|
+
...(widgetError ? { widgetError } : {}),
|
|
370
387
|
...(appName ? { projectName: appName } : {}),
|
|
371
388
|
lastSeen: Date.now(),
|
|
372
389
|
},
|