peachsim 0.1.2583 → 0.1.2584

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.
Files changed (131) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +207 -22
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-KJDUWXKA.mjs → acorn-ZVZ3OCQ5.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-BCVOLC6I.mjs → chunk-3FPE4AWV.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-RQINUPIV.mjs → chunk-5RPUNG6E.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-P7QX5AZ7.mjs → chunk-6HF6IVRZ.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-6BX5JWHW.mjs → chunk-6LCGYQ3Z.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-JDRDX7GD.mjs → chunk-CVDY4GSP.mjs} +5 -5
  32. package/dist-lib/esm-chunks/{chunk-QHE754TD.mjs → chunk-CXTYIQH4.mjs} +5 -5
  33. package/dist-lib/esm-chunks/{chunk-GDJ7IR2Z.mjs → chunk-DXUEAJB5.mjs} +3 -3
  34. package/dist-lib/esm-chunks/{chunk-WUPWE3GM.mjs → chunk-ENXDCDUJ.mjs} +2 -2
  35. package/dist-lib/esm-chunks/{chunk-HDIGMVW3.mjs → chunk-GOQIYGJD.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-5EZQ2X47.mjs → chunk-HEG3RAXL.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-H5QCGXIM.mjs → chunk-HHYIRDUH.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-CTZKF4CT.mjs → chunk-IDKMFS7W.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-E63AEEFF.mjs → chunk-JJ3AI5Y2.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-VUQU4RHT.mjs → chunk-KG72KS7D.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-WN7CGW3X.mjs → chunk-N6PTRYT5.mjs} +4 -4
  42. package/dist-lib/esm-chunks/{chunk-VB7YMHIV.mjs → chunk-NMYRZ4GT.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-KHPJUBZM.mjs → chunk-PMAEKUDN.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-75MU3BRS.mjs → chunk-RJNIFR5Q.mjs} +12 -12
  45. package/dist-lib/esm-chunks/{chunk-OSJLWFBW.mjs → chunk-RYY3XHOE.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-KAKBXXG7.mjs → chunk-VIUKS7O4.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-XNODUYM2.mjs → chunk-W5SRJG3R.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-U3YP4LGG.mjs → chunk-WWYAWBD7.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-KVLGK3C5.mjs → metro-layout-parser-VG2C6B5W.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-ZLDAPPOL.mjs → swift-package-prebuilt-7W4NG7RW.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-5LMMG244.mjs → swift-sdk-app-module-PUXEFZD4.mjs} +14 -14
  52. package/dist-lib/esm-chunks/{swift-sdk-image-OFU6JW3D.mjs → swift-sdk-image-GGYEV75P.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-76YATE4I.mjs → swift-sdk-image-producer-EWBJ4A2A.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +206 -21
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +207 -22
  59. package/dist-lib/host/fetch-proxy-handler.cjs +26 -15
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +1 -1
  73. package/dist-lib/native-app-identity-project.mjs +16 -16
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +79 -74
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +207 -22
  93. package/dist-lib/swift-compile.cjs +1 -1
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +1 -1
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/kotlin/sdk.tar.gz +0 -0
  126. package/package.json +1 -1
  127. package/src/genrule-archives.ts +1 -1
  128. package/src/genrule-library-builds.ts +1 -1
  129. package/src/swift-objc-compile.ts +2 -2
  130. package/src/{swift-wasm64-source-header.ts → swift-wasm64-native-source.ts} +53 -5
  131. package/src/swift-wasm64-wamr.ts +171 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
 
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __commonJS = (cb, mod) => function __require() {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
 
4
4
  // ../../node_modules/valibot/dist/index.cjs
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,12 +1,12 @@
1
- /*! peach v0.1.2583 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2584 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  parse
4
- } from "./esm-chunks/chunk-U3YP4LGG.mjs";
4
+ } from "./esm-chunks/chunk-WWYAWBD7.mjs";
5
5
  import {
6
6
  __privateAdd,
7
7
  __privateGet,
8
8
  __publicField
9
- } from "./esm-chunks/chunk-P7QX5AZ7.mjs";
9
+ } from "./esm-chunks/chunk-6HF6IVRZ.mjs";
10
10
 
11
11
  // src/worklet-kernel.ts
12
12
  var Unsupported = class extends Error {
package/kotlin/sdk.tar.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.2583",
3
+ "version": "0.1.2584",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -14,7 +14,7 @@ import { tryAcquireNumberedLock } from './numbered-lock.ts'
14
14
  import { swiftDistributionAt, swiftSdkPaths } from './swift-compile.ts'
15
15
  import { swiftModuleToolchain } from './swift-distribution.ts'
16
16
  import { swiftFileChecksum, swiftUpstreamRelease } from './swift-toolchain.ts'
17
- import { deriveWasm64Header } from './swift-wasm64-source-header.ts'
17
+ import { deriveWasm64Header } from './swift-wasm64-native-source.ts'
18
18
  import {
19
19
  SWIFT_FRAMEWORK_PRODUCT_FILE,
20
20
  swiftFrameworkProductSchema,
@@ -1,7 +1,7 @@
1
1
  import { execFileSync } from 'node:child_process'
2
2
  import fs from 'node:fs'
3
3
  import path from 'node:path'
4
- import { deriveWasm64Header } from './swift-wasm64-source-header.ts'
4
+ import { deriveWasm64Header } from './swift-wasm64-native-source.ts'
5
5
  import {
6
6
  SWIFT_WASM_TRIPLE,
7
7
  WASI_LIBC_TRIPLE,
@@ -33,7 +33,7 @@ import { readPackageFile, relativeInside, replaceRoot } from './swift-source-fil
33
33
  import { STANDIN_SOURCE_DIGEST } from './swift-standin-digest'
34
34
  import { binaryHeaderSearchPaths, isBinaryLibraryFile } from './swift-standins'
35
35
  import { swiftEnvironment } from './swift-toolchain'
36
- import { deriveWasm64Header } from './swift-wasm64-source-header'
36
+ import { deriveWasm64NativeSource } from './swift-wasm64-native-source'
37
37
  import { SWIFT_WASM_TRIPLE, wasmThreadFlags } from './swiftTargetContract.ts'
38
38
  import { writeXcodeHeaderSearch } from './xcode-header-search'
39
39
  import type {
@@ -360,7 +360,7 @@ function* xcodeObjCInputSteps(
360
360
  resolved,
361
361
  Infinity,
362
362
  )
363
- const derived = deriveWasm64Header(file, bytes)
363
+ const derived = deriveWasm64NativeSource(file, bytes)
364
364
  sources.set(file, derived?.bytes ?? bytes)
365
365
  if (derived) {
366
366
  derivations[file] = {
@@ -1,12 +1,20 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import path from 'node:path'
3
3
  import { DOUBLE_CONVERSION_WASM64_BACKPORT } from './nitro-dependencies'
4
+ import { deriveWamrWasm64Runtime, deriveWamrWasm64Wasi } from './swift-wasm64-wamr'
4
5
  import { swiftWasm64PlatformGates } from './swiftWasm64ConfigContract'
5
6
 
6
7
  const webrtcUnknownArchitecture =
7
8
  '#else\n#error Please add support for your architecture in rtc_base/system/arch.h'
8
9
  const boringsslWordSize = swiftWasm64PlatformGates['swift-nio-ssl/wasm64-word-size']
9
- const derivations = new Map([
10
+ const wamrCommit = '25bd7eb63e828e4bd242cc9b38d260b4b31c6605'
11
+ type SourceDerivation = {
12
+ upstreamCommit: string
13
+ originalSha256: string
14
+ derivedSha256: string
15
+ } & ({ before: string; after: string } | { rewrite: (source: string) => string })
16
+
17
+ const headerDerivations = new Map<string, SourceDerivation>([
10
18
  ['utils.h', DOUBLE_CONVERSION_WASM64_BACKPORT],
11
19
  [
12
20
  'target.h',
@@ -36,22 +44,62 @@ const derivations = new Map([
36
44
  ],
37
45
  ])
38
46
 
39
- export function deriveWasm64Header(file: string, bytes: Buffer) {
40
- const backport = derivations.get(path.basename(file))
47
+ const sourceDerivations = new Map<string, SourceDerivation>([
48
+ [
49
+ 'wasm_runtime_common.c',
50
+ {
51
+ upstreamCommit: wamrCommit,
52
+ originalSha256: 'd2f8ce6f2a826e0bf8c733309e61f62597b446d33f66d8eab04d67625719e4e7',
53
+ derivedSha256: 'a4ac5cecff71f1fc3db347189a9afea2bab22b0240262969d40f4fe7cdd14309',
54
+ rewrite: deriveWamrWasm64Runtime,
55
+ },
56
+ ],
57
+ [
58
+ 'libc_wasi_wrapper.c',
59
+ {
60
+ upstreamCommit: wamrCommit,
61
+ originalSha256: 'bbfb6df14a2928d9b023701002473ecbf8437d42cd68a725faa736ddf88067ac',
62
+ derivedSha256: '3df712348b50a065f465304dc7027ffbdfe8e633ba9ed535803592c3ace7f5f5',
63
+ rewrite: deriveWamrWasm64Wasi,
64
+ },
65
+ ],
66
+ ])
67
+
68
+ function deriveSource(
69
+ file: string,
70
+ bytes: Buffer,
71
+ backport: SourceDerivation | undefined,
72
+ ) {
41
73
  if (
42
74
  !backport ||
43
75
  createHash('sha256').update(bytes).digest('hex') !== backport.originalSha256
44
76
  )
45
77
  return null
46
78
 
79
+ const source = bytes.toString('utf8')
47
80
  const derived = Buffer.from(
48
- bytes.toString('utf8').replace(backport.before, backport.after),
81
+ 'rewrite' in backport
82
+ ? backport.rewrite(source)
83
+ : source.replace(backport.before, backport.after),
49
84
  )
50
85
  if (createHash('sha256').update(derived).digest('hex') !== backport.derivedSha256)
51
- throw new Error(`Native header derivation differs: ${file}`)
86
+ throw new Error(`Native source derivation differs: ${file}`)
52
87
  return {
53
88
  bytes: derived,
54
89
  upstreamCommit: backport.upstreamCommit,
55
90
  originalSha256: backport.originalSha256,
56
91
  }
57
92
  }
93
+
94
+ export function deriveWasm64Header(file: string, bytes: Buffer) {
95
+ return deriveSource(file, bytes, headerDerivations.get(path.basename(file)))
96
+ }
97
+
98
+ export function deriveWasm64NativeSource(file: string, bytes: Buffer) {
99
+ const name = path.basename(file)
100
+ return deriveSource(
101
+ file,
102
+ bytes,
103
+ sourceDerivations.get(name) ?? headerDerivations.get(name),
104
+ )
105
+ }
@@ -0,0 +1,171 @@
1
+ // wamr 2.4.5 interpreter host calls used by the wasi table and buffer callbacks.
2
+ const wasm64NativeSignatures = [
3
+ '(**)i',
4
+ '(i*)i',
5
+ '(iI*)i',
6
+ '(i*~)i',
7
+ '(i*i)i',
8
+ '(i)i',
9
+ '(i*iI*)i',
10
+ '(i*~I*)i',
11
+ '(i*i*)i',
12
+ '(ii)i',
13
+ '(iIi*)i',
14
+ '(iII)i',
15
+ '(iIIi)i',
16
+ '(ii*~i*~)i',
17
+ '(ii*~iIIi*)i',
18
+ '(i*~*~*)i',
19
+ '(i*~i*~)i',
20
+ '(iI)i',
21
+ '(ii*~*)i',
22
+ '(ii*~IIi)i',
23
+ '(*~i*~)i',
24
+ '(**i*)i',
25
+ '(i)',
26
+ '(*~)i',
27
+ '(ii*)i',
28
+ '($$**i*)i',
29
+ '(i**)i',
30
+ '(iii*)i',
31
+ '(i*ii**)i',
32
+ '(i*ii*)i',
33
+ '(iii)i',
34
+ '()i',
35
+ '(*~)',
36
+ '(*~*~)i',
37
+ ]
38
+
39
+ const nativeArgumentTypes = new Map([
40
+ ['i', 'uint32'],
41
+ ['~', 'uint32'],
42
+ ['I', 'uint64'],
43
+ ['*', 'uintptr_t'],
44
+ ['$', 'uintptr_t'],
45
+ ])
46
+
47
+ const wasm64Interpreter =
48
+ 'defined(__wasm64__) && defined(BUILD_TARGET_AARCH64) && ' +
49
+ 'WASM_ENABLE_INTERP != 0 && WASM_ENABLE_AOT == 0 && ' +
50
+ 'WASM_ENABLE_JIT == 0 && WASM_ENABLE_FAST_JIT == 0'
51
+
52
+ function wasm64NativeDispatch() {
53
+ const groups = new Map<
54
+ string,
55
+ { signatures: string[]; params: string[]; result: string }
56
+ >()
57
+ for (const signature of wasm64NativeSignatures) {
58
+ const end = signature.indexOf(')')
59
+ const params = [...signature.slice(1, end)].map((marker) => {
60
+ const type = nativeArgumentTypes.get(marker)
61
+ if (!type) throw new Error(`Unknown WAMR argument marker: ${marker}`)
62
+ return type
63
+ })
64
+ const result = signature.endsWith('i') ? 'uint32' : 'void'
65
+ const key = [result, ...params].join(' ')
66
+ const group = groups.get(key) ?? { signatures: [], params, result }
67
+ group.signatures.push(signature)
68
+ groups.set(key, group)
69
+ }
70
+ const cases = [...groups.values()]
71
+ .map(({ signatures, params, result }) => {
72
+ const condition = signatures
73
+ .map((signature) => `strcmp(signature, "${signature}") == 0`)
74
+ .join(' ||\n ')
75
+ const types = ['WASMExecEnv *', ...params].join(', ')
76
+ const inputs = [
77
+ 'exec_env',
78
+ ...params.map((type, index) => `(${type})args[${index}]`),
79
+ ].join(', ')
80
+ const assign = result === 'void' ? '' : 'args[0] = '
81
+ return ` if (${condition}) {
82
+ typedef ${result} (*TypedFunction)(${types});
83
+ ${assign}((TypedFunction)func_ptr)(${inputs});
84
+ return true;
85
+ }`
86
+ })
87
+ .join('\n')
88
+ return `#if ${wasm64Interpreter}
89
+ static bool
90
+ invoke_wasm64_native(WASMExecEnv *exec_env, void *func_ptr,
91
+ const char *signature, uint64 *args)
92
+ {
93
+ if (!signature)
94
+ return false;
95
+ ${cases}
96
+ return false;
97
+ }
98
+ #endif
99
+
100
+ `
101
+ }
102
+
103
+ // dispatch uses the existing raw path's argument slots and pointer validation.
104
+ // wasm call_indirect checks its lowered type, so native assembly stubs cannot
105
+ // alias a single entry point across return and parameter types.
106
+ export function deriveWamrWasm64Runtime(source: string) {
107
+ const dispatchStart = '/**\n * Implementation of wasm_runtime_invoke_native()'
108
+ const dispatchEnd =
109
+ '|| defined(BUILD_TARGET_RISCV64_LP64) */\n\nbool\nwasm_runtime_call_indirect('
110
+ const entryPoint = (name: string, raw: boolean) => `bool
111
+ ${name}(WASMExecEnv *exec_env, void *func_ptr,
112
+ const WASMFuncType *func_type, const char *signature,
113
+ void *attachment, uint32 *argv, uint32 argc, uint32 *argv_ret)
114
+ {
115
+ return invoke_checked_native(exec_env, func_ptr, func_type, signature,
116
+ attachment, argv, argc, argv_ret, ${raw});
117
+ }
118
+ `
119
+ return source
120
+ .replace(
121
+ `bool
122
+ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
123
+ const WASMFuncType *func_type,
124
+ const char *signature, void *attachment,
125
+ uint32 *argv, uint32 argc, uint32 *argv_ret)
126
+ `,
127
+ () => `${wasm64NativeDispatch()}static bool
128
+ invoke_checked_native(WASMExecEnv *exec_env, void *func_ptr,
129
+ const WASMFuncType *func_type, const char *signature,
130
+ void *attachment, uint32 *argv, uint32 argc,
131
+ uint32 *argv_ret, bool raw)
132
+ `,
133
+ )
134
+ .replace(
135
+ ' exec_env->attachment = attachment;\n invoke_native_raw(exec_env, argv1);\n exec_env->attachment = NULL;\n',
136
+ ` exec_env->attachment = attachment;
137
+ #if ${wasm64Interpreter}
138
+ if (!raw) {
139
+ if (!invoke_wasm64_native(exec_env, func_ptr, signature, argv1)) {
140
+ exec_env->attachment = NULL;
141
+ wasm_runtime_set_exception(module, "unsupported Wasm64 native signature");
142
+ goto fail;
143
+ }
144
+ }
145
+ else
146
+ #endif
147
+ invoke_native_raw(exec_env, argv1);
148
+ exec_env->attachment = NULL;
149
+ `,
150
+ )
151
+ .replace(
152
+ dispatchStart,
153
+ () =>
154
+ entryPoint('wasm_runtime_invoke_native_raw', true) +
155
+ `\n#if ${wasm64Interpreter}\n` +
156
+ entryPoint('wasm_runtime_invoke_native', false) +
157
+ '#else\n' +
158
+ dispatchStart,
159
+ )
160
+ .replace(
161
+ dispatchEnd,
162
+ '|| defined(BUILD_TARGET_RISCV64_LP64) */\n#endif\n\nbool\nwasm_runtime_call_indirect(',
163
+ )
164
+ }
165
+
166
+ export function deriveWamrWasm64Wasi(source: string) {
167
+ return source.replace(
168
+ /^(wasi_sock_set_(?:recv|send)_buf_size\(wasm_exec_env_t exec_env, wasi_fd_t fd, )size_t size\)$/gm,
169
+ '$1uint32 size)',
170
+ )
171
+ }