peachsim 0.1.2173 → 0.1.2176
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/bridge-flow-runner.ts +6 -0
- package/cli/commands/control.ts +5 -0
- package/cli/commands/coverage-swift.ts +1 -1
- package/cli/commands/flow.ts +4 -1
- package/cli/commands/inspect/settling.ts +3 -3
- package/cli/commands/shell-url.ts +12 -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 +40 -20
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +4 -4
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +35 -15
- 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 +40 -20
- package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
- 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 +6 -6
- 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 +3 -3
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- 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 +24 -24
- package/dist-lib/public-origins-lib.json +53 -53
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +4 -4
- package/dist-lib/sdk.mjs +4 -4
- package/dist-lib/skills.cjs +60 -23
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- 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 +3 -3
- package/dist-lib/vite.cjs +3 -3
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-nested.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/engine/text-paint.d.ts +1 -0
- package/package.json +1 -1
- package/src/expo-native-workspace.ts +37 -11
- package/src/nitro-adapter.lock.json +253 -253
- package/src/nitro-superset.lock.json +4 -4
- package/src/swift-coverage/sdk.ts +8 -3
- package/src/swift-coverage/types.ts +1 -1
- package/src/swift-distribution.lock.json +11 -11
- package/src/turbo-runtime.lock.json +23 -23
- package/src/vite-plugin.ts +235 -82
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
},
|
|
9
9
|
"compiler": "swift-6.4.0-RELEASE-custom-11345d60dca47496",
|
|
10
10
|
"sdk": {
|
|
11
|
-
"id": "swift-6.4.0-RELEASE_wasm-peach-
|
|
12
|
-
"checksum": "
|
|
11
|
+
"id": "swift-6.4.0-RELEASE_wasm-peach-3452e5a2",
|
|
12
|
+
"checksum": "fe042506d9418d5b73a3a30d62157931439c23e3bcb869871a0fcb8747223a02"
|
|
13
13
|
},
|
|
14
14
|
"framework": {
|
|
15
|
-
"distribution": "
|
|
15
|
+
"distribution": "2405235872029d30",
|
|
16
16
|
"wireAbi": "246b8412514b644113e6a26252c8ebd6de49ab4156ac5f5c98bb9e4c2ff2568b"
|
|
17
17
|
},
|
|
18
18
|
"archives": [
|
|
@@ -20,71 +20,71 @@
|
|
|
20
20
|
"headers": {
|
|
21
21
|
"reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
|
|
22
22
|
},
|
|
23
|
-
"sha256": "
|
|
24
|
-
"size":
|
|
23
|
+
"sha256": "038855e8522f39ea85557bcafc84eb64ec5d9b155c686dca3cff6fa397de0165",
|
|
24
|
+
"size": 25395
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"headers": {
|
|
28
28
|
"reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
|
|
29
29
|
},
|
|
30
|
-
"sha256": "
|
|
31
|
-
"size":
|
|
30
|
+
"sha256": "b815028eb321b50907658ba883329d13204d29368cc598dab5c39b2a249de88f",
|
|
31
|
+
"size": 26139
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"headers": {
|
|
35
35
|
"reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
|
|
36
36
|
},
|
|
37
|
-
"sha256": "
|
|
38
|
-
"size":
|
|
37
|
+
"sha256": "f8fd89f680b86d8abb42a644db8866eb33ff82b4370a7c373bc054efdec33095",
|
|
38
|
+
"size": 25395
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"headers": {
|
|
42
42
|
"reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
|
|
43
43
|
},
|
|
44
|
-
"sha256": "
|
|
45
|
-
"size":
|
|
44
|
+
"sha256": "9190e3a9f312d8c156aacf727904cf1b9c543b30833f544164daa32e3c005d84",
|
|
45
|
+
"size": 25168
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"headers": {
|
|
49
49
|
"reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
|
|
50
50
|
},
|
|
51
|
-
"sha256": "
|
|
52
|
-
"size":
|
|
51
|
+
"sha256": "89bc0c5214c848b06e50424dcecf1cb0d3b01b058270d606a86c2e799d529c15",
|
|
52
|
+
"size": 25401
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"headers": {
|
|
56
56
|
"reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
|
|
57
57
|
},
|
|
58
|
-
"sha256": "
|
|
59
|
-
"size":
|
|
58
|
+
"sha256": "8c0d4fa4b65b44dc649c7401df0832663c837098bb5794b143751073c800e66b",
|
|
59
|
+
"size": 26139
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"headers": {
|
|
63
63
|
"reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
|
|
64
64
|
},
|
|
65
|
-
"sha256": "
|
|
66
|
-
"size":
|
|
65
|
+
"sha256": "ea3395926d0c9202404ca292fed40561c04537cbc11bb8b49ac8a7d9f983fa60",
|
|
66
|
+
"size": 26138
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"headers": {
|
|
70
70
|
"reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
|
|
71
71
|
},
|
|
72
|
-
"sha256": "
|
|
73
|
-
"size":
|
|
72
|
+
"sha256": "7a17d6b3e143a8cf38d73b18b21e142b40fc2c0076d7a01dfb1837194c977f43",
|
|
73
|
+
"size": 25268
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"headers": {
|
|
77
77
|
"reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
|
|
78
78
|
},
|
|
79
|
-
"sha256": "
|
|
80
|
-
"size":
|
|
79
|
+
"sha256": "96f6b7bb8bd33d20ee9b6249c0f747e2d160d80515efbf74f9a263f57d847667",
|
|
80
|
+
"size": 26142
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
"headers": {
|
|
84
84
|
"reactNativeJsi": "c8270f1315745ecc204c4209a4f50f58ff6f14b4a385ad6820a69800270b53c6"
|
|
85
85
|
},
|
|
86
|
-
"sha256": "
|
|
87
|
-
"size":
|
|
86
|
+
"sha256": "bf587717d6b32d1e7abc630e952f0c70ea964488f87e83c20028b86781317b6f",
|
|
87
|
+
"size": 25104
|
|
88
88
|
}
|
|
89
89
|
]
|
|
90
90
|
}
|
package/src/vite-plugin.ts
CHANGED
|
@@ -654,56 +654,78 @@ function warmManifestJsonPlugin(): Plugin {
|
|
|
654
654
|
// graph and serial requests, since moving bytes into chunks alone is no gain.
|
|
655
655
|
// reanimated and shell-in-worker still evaluate at their original import()
|
|
656
656
|
// boundaries after the worklet runtime installs.
|
|
657
|
+
const WORKER_ROLES = ['shell', 'compositor'] as const
|
|
658
|
+
const WORKER_BACKENDS = ['graphite', 'ganesh'] as const
|
|
659
|
+
type WorkerRole = (typeof WORKER_ROLES)[number]
|
|
660
|
+
type WorkerBackend = (typeof WORKER_BACKENDS)[number]
|
|
661
|
+
|
|
657
662
|
export type WorkerBootClosure = {
|
|
658
663
|
// substring of the worker entry module id this applies to
|
|
659
664
|
entry: string
|
|
660
|
-
//
|
|
661
|
-
//
|
|
662
|
-
|
|
663
|
-
// byte cap on the entry and every chunk it loads eagerly; fix excess boot
|
|
664
|
-
// dependencies and unneeded inclusions rather than raising the cap.
|
|
665
|
+
// byte cap on the entry and every chunk either role loads before Home, each
|
|
666
|
+
// counted once; fix excess boot dependencies and unneeded inclusions rather
|
|
667
|
+
// than raising the cap.
|
|
665
668
|
// a cap failure in a worktree whose node_modules is symlinked from another
|
|
666
669
|
// tree is suspect: workspace modules resolve into the other tree and bundle
|
|
667
670
|
// twice (~1MB rendered here). re-run with a real `bun install` first.
|
|
668
671
|
maxBytes: number
|
|
672
|
+
// per role, the implementation roots loaded before Home and the native glue
|
|
673
|
+
// roots of each backend. only their static dependencies share a chunk; other
|
|
674
|
+
// dynamic roots retain their first-use boundaries.
|
|
675
|
+
roles?: Record<
|
|
676
|
+
WorkerRole,
|
|
677
|
+
{ home: readonly string[]; backends: Record<WorkerBackend, readonly string[]> }
|
|
678
|
+
>
|
|
669
679
|
}
|
|
670
680
|
|
|
671
|
-
const SHELL_WORKER_BOOT_ROOTS = [
|
|
672
|
-
'src/render-worker/shell-worker-canvaskit.ts',
|
|
673
|
-
'src/render-worker/shell-worker.ts',
|
|
674
|
-
'src/render-worker/shell-reanimated-boot.ts',
|
|
675
|
-
'src/render-worker/shell-in-worker.tsx',
|
|
676
|
-
'src/render-worker/aux-roots.tsx',
|
|
677
|
-
'src/ios/HomeTreeRoot.tsx',
|
|
678
|
-
'src/ios/connect-app-icon.ts',
|
|
679
|
-
'src/demo/app-catalog.tsx',
|
|
680
|
-
]
|
|
681
|
-
const COMPOSITOR_WORKER_BOOT_ROOTS = [
|
|
682
|
-
'src/render-worker/compositor-worker-adapter.ts',
|
|
683
|
-
'src/render-worker/compositor-worker.ts',
|
|
684
|
-
'src/render-worker/shell-tree-materializer.ts',
|
|
685
|
-
]
|
|
686
|
-
const WORKER_BACKEND_ROOTS = {
|
|
687
|
-
graphite: [
|
|
688
|
-
'src/render-worker/canvaskit-webgpu.ts',
|
|
689
|
-
'src/render-worker/compositor-gpu-graphite.ts',
|
|
690
|
-
'vendor/canvaskit-graphite.js',
|
|
691
|
-
],
|
|
692
|
-
ganesh: ['src/render-worker/compositor-gpu-ganesh.ts', 'vendor/canvaskit-ganesh.js'],
|
|
693
|
-
}
|
|
694
681
|
const ENGINE_WORKER_BOOT_CLOSURES: WorkerBootClosure[] = [
|
|
695
682
|
// only tenants parse font name tables and forward aliases/metrics to hosts.
|
|
696
|
-
//
|
|
697
|
-
// retain their dynamic boundary, so a worker
|
|
698
|
-
|
|
699
|
-
entry: 'src/render-worker/shell-worker-entry.ts',
|
|
700
|
-
maxBytes: 3_020_000,
|
|
701
|
-
bootRoots: SHELL_WORKER_BOOT_ROOTS,
|
|
702
|
-
},
|
|
683
|
+
// the shell and compositor share one entry so their common modules download
|
|
684
|
+
// once. native backend modules retain their dynamic boundary, so a worker
|
|
685
|
+
// fetches only its admitted glue.
|
|
703
686
|
{
|
|
704
|
-
entry: 'src/render-worker/
|
|
705
|
-
maxBytes:
|
|
706
|
-
|
|
687
|
+
entry: 'src/render-worker/engine-worker-entry.ts',
|
|
688
|
+
maxBytes: 3_850_000,
|
|
689
|
+
roles: {
|
|
690
|
+
shell: {
|
|
691
|
+
home: [
|
|
692
|
+
'src/render-worker/shell-worker-canvaskit.ts',
|
|
693
|
+
'src/render-worker/shell-worker.ts',
|
|
694
|
+
'src/render-worker/shell-reanimated-boot.ts',
|
|
695
|
+
'src/render-worker/shell-in-worker.tsx',
|
|
696
|
+
'src/render-worker/aux-roots.tsx',
|
|
697
|
+
'src/ios/HomeTreeRoot.tsx',
|
|
698
|
+
'src/ios/connect-app-icon.ts',
|
|
699
|
+
'src/demo/app-catalog.tsx',
|
|
700
|
+
],
|
|
701
|
+
backends: {
|
|
702
|
+
graphite: [
|
|
703
|
+
'src/render-worker/canvaskit-webgpu.ts',
|
|
704
|
+
'vendor/canvaskit-graphite.js',
|
|
705
|
+
],
|
|
706
|
+
ganesh: ['vendor/canvaskit-ganesh.js'],
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
compositor: {
|
|
710
|
+
home: [
|
|
711
|
+
'src/render-worker/compositor-worker-adapter.ts',
|
|
712
|
+
'src/render-worker/compositor-worker.ts',
|
|
713
|
+
'src/engine/debug.ts',
|
|
714
|
+
'src/render-worker/shell-tree-materializer.ts',
|
|
715
|
+
],
|
|
716
|
+
backends: {
|
|
717
|
+
graphite: [
|
|
718
|
+
'src/render-worker/canvaskit-webgpu.ts',
|
|
719
|
+
'src/render-worker/compositor-gpu-graphite.ts',
|
|
720
|
+
'vendor/canvaskit-graphite.js',
|
|
721
|
+
],
|
|
722
|
+
ganesh: [
|
|
723
|
+
'src/render-worker/compositor-gpu-ganesh.ts',
|
|
724
|
+
'vendor/canvaskit-ganesh.js',
|
|
725
|
+
],
|
|
726
|
+
},
|
|
727
|
+
},
|
|
728
|
+
},
|
|
707
729
|
},
|
|
708
730
|
]
|
|
709
731
|
|
|
@@ -837,11 +859,38 @@ export function hostBootChunkPlugin(): Plugin {
|
|
|
837
859
|
}
|
|
838
860
|
}
|
|
839
861
|
|
|
862
|
+
// the chunk group a role's boot module rides: shared by both roles or one
|
|
863
|
+
// role's own, and Home or one backend's native glue. a worker fetches the
|
|
864
|
+
// groups naming its role or no role, and Home or its admitted backend
|
|
865
|
+
// (engineManifest.ts reads these names).
|
|
866
|
+
function workerBootGroup(
|
|
867
|
+
roles: ReadonlySet<WorkerRole>,
|
|
868
|
+
backends: ReadonlySet<WorkerBackend>,
|
|
869
|
+
) {
|
|
870
|
+
const role = roles.size === 1 ? `${[...roles][0]}-` : ''
|
|
871
|
+
const kind = backends.size === 1 ? [...backends][0] : 'home'
|
|
872
|
+
return `worker-${role}${kind}`
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function workerBootGroupLoads(group: string, role: WorkerRole, backend: WorkerBackend) {
|
|
876
|
+
const match = /^worker-(?:(shell|compositor)-)?(home|graphite|ganesh)$/.exec(group)
|
|
877
|
+
return (
|
|
878
|
+
match !== null &&
|
|
879
|
+
(match[1] === undefined || match[1] === role) &&
|
|
880
|
+
(match[2] === 'home' || match[2] === backend)
|
|
881
|
+
)
|
|
882
|
+
}
|
|
883
|
+
|
|
840
884
|
export function workerBootChunkPlugin(closures: WorkerBootClosure[]): Plugin {
|
|
841
885
|
let closure: WorkerBootClosure | null = null
|
|
842
886
|
let isWorker = false
|
|
843
|
-
|
|
844
|
-
const
|
|
887
|
+
// the boot modules of each role and backend, and the group each module rides
|
|
888
|
+
const bootModules: {
|
|
889
|
+
role: WorkerRole
|
|
890
|
+
backend: WorkerBackend
|
|
891
|
+
modules: Set<string>
|
|
892
|
+
}[] = []
|
|
893
|
+
const moduleGroups = new Map<string, string>()
|
|
845
894
|
let homeDefinitionsPreloaded = false
|
|
846
895
|
return {
|
|
847
896
|
name: 'sootsim-worker-boot-chunk',
|
|
@@ -872,34 +921,80 @@ export function workerBootChunkPlugin(closures: WorkerBootClosure[]): Plugin {
|
|
|
872
921
|
}
|
|
873
922
|
},
|
|
874
923
|
buildEnd(error) {
|
|
875
|
-
if (!isWorker || error || !closure?.
|
|
876
|
-
bootModules =
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
924
|
+
if (!isWorker || error || !closure?.roles) return
|
|
925
|
+
bootModules.length = 0
|
|
926
|
+
moduleGroups.clear()
|
|
927
|
+
for (const role of WORKER_ROLES) {
|
|
928
|
+
const roots = closure.roles[role]
|
|
929
|
+
const home = collectStaticBootModules(this, roots.home)
|
|
930
|
+
for (const backend of WORKER_BACKENDS)
|
|
931
|
+
bootModules.push({
|
|
932
|
+
role,
|
|
933
|
+
backend,
|
|
934
|
+
modules: new Set([
|
|
935
|
+
...home,
|
|
936
|
+
...collectStaticBootModules(this, roots.backends[backend]),
|
|
937
|
+
]),
|
|
938
|
+
})
|
|
939
|
+
}
|
|
940
|
+
const owners = new Map<
|
|
941
|
+
string,
|
|
942
|
+
{ roles: Set<WorkerRole>; backends: Set<WorkerBackend> }
|
|
943
|
+
>()
|
|
944
|
+
for (const { role, backend, modules } of bootModules) {
|
|
945
|
+
for (const id of modules) {
|
|
946
|
+
let owner = owners.get(id)
|
|
947
|
+
if (!owner) owners.set(id, (owner = { roles: new Set(), backends: new Set() }))
|
|
948
|
+
owner.roles.add(role)
|
|
949
|
+
owner.backends.add(backend)
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
// a boot module the other role can reach at all, eagerly or lazily, is
|
|
953
|
+
// shared: placed with one role it would pull that role's whole Home chunk
|
|
954
|
+
// into the other worker on first use.
|
|
955
|
+
for (const role of WORKER_ROLES) {
|
|
956
|
+
const roots = closure.roles[role]
|
|
957
|
+
const reached = new Set<string>()
|
|
958
|
+
const visit = (id: string) => {
|
|
959
|
+
if (reached.has(id)) return
|
|
960
|
+
reached.add(id)
|
|
961
|
+
const info = this.getModuleInfo(id)
|
|
962
|
+
for (const next of [
|
|
963
|
+
...(info?.importedIds ?? []),
|
|
964
|
+
...(info?.dynamicallyImportedIds ?? []),
|
|
965
|
+
])
|
|
966
|
+
visit(next)
|
|
967
|
+
}
|
|
968
|
+
const starts = [
|
|
969
|
+
roots.home,
|
|
970
|
+
...WORKER_BACKENDS.map((b) => roots.backends[b]),
|
|
971
|
+
].flat()
|
|
972
|
+
for (const id of this.getModuleIds())
|
|
973
|
+
if (starts.some((root) => id.endsWith(`/${root}`))) visit(id)
|
|
974
|
+
for (const [id, owner] of owners) if (reached.has(id)) owner.roles.add(role)
|
|
975
|
+
}
|
|
976
|
+
// a module either backend needs rides Home, so selecting Ganesh cannot
|
|
977
|
+
// pull in a chunk containing Graphite's native glue; one both roles need
|
|
978
|
+
// rides a shared group, downloaded once for both workers.
|
|
979
|
+
for (const [id, owner] of owners)
|
|
980
|
+
moduleGroups.set(id, workerBootGroup(owner.roles, owner.backends))
|
|
883
981
|
},
|
|
884
982
|
outputOptions(options) {
|
|
885
983
|
if (!isWorker) return null
|
|
886
984
|
return {
|
|
887
985
|
...options,
|
|
888
|
-
codeSplitting: closure?.
|
|
986
|
+
codeSplitting: closure?.roles
|
|
889
987
|
? {
|
|
890
|
-
groups
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
test: (id: string) =>
|
|
899
|
-
backendModules.get(backend)!.has(id) && !bootModules.has(id),
|
|
988
|
+
// rolldown reads the groups before buildEnd assigns their modules
|
|
989
|
+
groups: ['', ...WORKER_ROLES.map((role) => `${role}-`)]
|
|
990
|
+
.flatMap((role) =>
|
|
991
|
+
['home', ...WORKER_BACKENDS].map((kind) => `worker-${role}${kind}`),
|
|
992
|
+
)
|
|
993
|
+
.map((name) => ({
|
|
994
|
+
name,
|
|
995
|
+
test: (id: string) => moduleGroups.get(id) === name,
|
|
900
996
|
includeDependenciesRecursively: false,
|
|
901
997
|
})),
|
|
902
|
-
],
|
|
903
998
|
}
|
|
904
999
|
: true,
|
|
905
1000
|
strictExecutionOrder: true,
|
|
@@ -915,20 +1010,24 @@ export function workerBootChunkPlugin(closures: WorkerBootClosure[]): Plugin {
|
|
|
915
1010
|
},
|
|
916
1011
|
renderChunk: {
|
|
917
1012
|
order: 'post',
|
|
918
|
-
async handler(code, chunk, outputOptions) {
|
|
1013
|
+
async handler(code, chunk, outputOptions, meta) {
|
|
919
1014
|
if (!isWorker) return null
|
|
920
1015
|
// lower vite's final module urls into the shared worker chunk protocol.
|
|
921
1016
|
// each chunk retains its own module base rather than the entry's location.
|
|
922
|
-
// fetch
|
|
923
|
-
// generated init wrappers still evaluate each source
|
|
924
|
-
// original import(), after the worklet runtime and
|
|
925
|
-
// retaining a separate chunk also keeps the worker
|
|
926
|
-
|
|
1017
|
+
// fetch the definitions both roles share with the entry's static
|
|
1018
|
+
// dependencies. the generated init wrappers still evaluate each source
|
|
1019
|
+
// module at its original import(), after the worklet runtime and
|
|
1020
|
+
// CanvasKit install. retaining a separate chunk also keeps the worker
|
|
1021
|
+
// entry private.
|
|
1022
|
+
if (chunk.isEntry && closure?.roles) {
|
|
927
1023
|
homeDefinitionsPreloaded = false
|
|
928
|
-
for (const
|
|
929
|
-
if (
|
|
1024
|
+
for (const shared of Object.values(meta.chunks)) {
|
|
1025
|
+
if (shared.name !== 'worker-home') continue
|
|
930
1026
|
homeDefinitionsPreloaded = true
|
|
931
|
-
const relative = path.posix.relative(
|
|
1027
|
+
const relative = path.posix.relative(
|
|
1028
|
+
path.posix.dirname(chunk.fileName),
|
|
1029
|
+
shared.fileName,
|
|
1030
|
+
)
|
|
932
1031
|
code = `import ${JSON.stringify(`./${relative}`)};\n${code}`
|
|
933
1032
|
}
|
|
934
1033
|
}
|
|
@@ -965,27 +1064,81 @@ export function workerBootChunkPlugin(closures: WorkerBootClosure[]): Plugin {
|
|
|
965
1064
|
bootChunk.imports.push(chunk.fileName)
|
|
966
1065
|
}
|
|
967
1066
|
}
|
|
968
|
-
const eager = new Set<string>()
|
|
969
|
-
const pending = [bootChunk.fileName]
|
|
970
1067
|
const byName = new Map(chunks.map((chunk) => [chunk.fileName, chunk]))
|
|
971
|
-
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1068
|
+
const staticClosure = (roots: string[]) => {
|
|
1069
|
+
const reached = new Set<string>()
|
|
1070
|
+
const pending = [...roots]
|
|
1071
|
+
while (pending.length > 0) {
|
|
1072
|
+
const file = pending.pop()!
|
|
1073
|
+
if (reached.has(file)) continue
|
|
1074
|
+
reached.add(file)
|
|
1075
|
+
pending.push(...(byName.get(file)?.imports ?? []))
|
|
1076
|
+
}
|
|
1077
|
+
return reached
|
|
976
1078
|
}
|
|
977
|
-
|
|
1079
|
+
// each role and backend loads the entry with the groups it names; every
|
|
1080
|
+
// boot module must ride one of them, or Home would wait on a lazy fetch.
|
|
1081
|
+
for (const { role, backend, modules } of bootModules) {
|
|
1082
|
+
const loaded = staticClosure([
|
|
1083
|
+
bootChunk.fileName,
|
|
1084
|
+
...chunks
|
|
1085
|
+
.filter((chunk) => workerBootGroupLoads(chunk.name, role, backend))
|
|
1086
|
+
.map((chunk) => chunk.fileName),
|
|
1087
|
+
])
|
|
978
1088
|
for (const chunk of chunks) {
|
|
979
|
-
if (
|
|
980
|
-
const required = chunk.moduleIds.find((id) =>
|
|
1089
|
+
if (loaded.has(chunk.fileName)) continue
|
|
1090
|
+
const required = chunk.moduleIds.find((id) => modules.has(id))
|
|
981
1091
|
if (required)
|
|
982
1092
|
this.error(
|
|
983
|
-
`worker Home dependency remains lazy: ${required} in ${chunk.fileName}`,
|
|
1093
|
+
`worker ${role} Home dependency remains lazy on ${backend}: ${required} in ${chunk.fileName}`,
|
|
1094
|
+
)
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
// a role never links the other role's chunks: one import, eager or lazy,
|
|
1098
|
+
// of a module the other role owns would download and parse its whole
|
|
1099
|
+
// Home. shared chunks serve both roles, so the walk stops at them.
|
|
1100
|
+
const roleOf = (name: string) => /^worker-(shell|compositor)-/.exec(name)?.[1]
|
|
1101
|
+
for (const role of WORKER_ROLES) {
|
|
1102
|
+
const parents = new Map<string, string | null>()
|
|
1103
|
+
const pending: string[] = []
|
|
1104
|
+
for (const chunk of chunks)
|
|
1105
|
+
if (roleOf(chunk.name) === role) {
|
|
1106
|
+
parents.set(chunk.fileName, null)
|
|
1107
|
+
pending.push(chunk.fileName)
|
|
1108
|
+
}
|
|
1109
|
+
while (pending.length > 0) {
|
|
1110
|
+
const file = pending.shift()!
|
|
1111
|
+
const chunk = byName.get(file)
|
|
1112
|
+
if (!chunk) continue
|
|
1113
|
+
const owner = roleOf(chunk.name)
|
|
1114
|
+
if (owner && owner !== role) {
|
|
1115
|
+
const chain: string[] = []
|
|
1116
|
+
for (let at: string | null = file; at; at = parents.get(at) ?? null)
|
|
1117
|
+
chain.unshift(at)
|
|
1118
|
+
this.error(
|
|
1119
|
+
`worker ${role} reaches ${owner} chunk ${file}:\n ${chain.join('\n -> ')}\nadd the module it imports to the ${role} Home roots so both roles share it`,
|
|
984
1120
|
)
|
|
1121
|
+
}
|
|
1122
|
+
if (
|
|
1123
|
+
chunk.name === 'worker-home' ||
|
|
1124
|
+
WORKER_BACKENDS.some((b) => chunk.name === `worker-${b}`)
|
|
1125
|
+
)
|
|
1126
|
+
continue
|
|
1127
|
+
for (const next of [...chunk.imports, ...chunk.dynamicImports]) {
|
|
1128
|
+
if (parents.has(next)) continue
|
|
1129
|
+
parents.set(next, file)
|
|
1130
|
+
pending.push(next)
|
|
1131
|
+
}
|
|
985
1132
|
}
|
|
986
1133
|
}
|
|
987
|
-
// the cap counts every chunk
|
|
988
|
-
// definitions ride their own
|
|
1134
|
+
// the cap counts the entry and every Home chunk of either role once:
|
|
1135
|
+
// once Home's definitions ride their own chunks the entry is a thin loader
|
|
1136
|
+
const eager = staticClosure([
|
|
1137
|
+
bootChunk.fileName,
|
|
1138
|
+
...chunks
|
|
1139
|
+
.filter((chunk) => /^worker-(?:(?:shell|compositor)-)?home$/.test(chunk.name))
|
|
1140
|
+
.map((chunk) => chunk.fileName),
|
|
1141
|
+
])
|
|
989
1142
|
const eagerChunks = chunks.filter((chunk) => eager.has(chunk.fileName))
|
|
990
1143
|
const bytes = eagerChunks.reduce(
|
|
991
1144
|
(sum, chunk) => sum + Buffer.byteLength(chunk.code),
|