peachsim 0.1.2441 → 0.1.2457

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 (170) hide show
  1. package/README.md +4 -49
  2. package/cli/app-catalog.ts +8 -7
  3. package/cli/app-stubs.ts +98 -70
  4. package/cli/cloud-box-artifact.ts +2 -5
  5. package/cli/cloud-client.ts +12 -1
  6. package/cli/commands/box.ts +41 -2
  7. package/cli/commands/compat.ts +5 -3
  8. package/cli/commands/cpu-profile.ts +11 -14
  9. package/cli/commands/diagnose.ts +5 -18
  10. package/cli/commands/inspect/describe.ts +4 -8
  11. package/cli/commands/maestro-generate.ts +4 -8
  12. package/cli/commands/mode.ts +3 -19
  13. package/cli/commands/perf.ts +3 -19
  14. package/cli/commands/permissions.ts +2 -6
  15. package/cli/commands/platform.ts +22 -14
  16. package/cli/commands/react.ts +7 -21
  17. package/cli/commands/record-three.ts +6 -10
  18. package/cli/commands/record.ts +38 -62
  19. package/cli/commands/screenshot-command.ts +8 -25
  20. package/cli/commands/storage.ts +4 -16
  21. package/cli/commands/three-mode.ts +6 -10
  22. package/cli/outbound-endpoints.ts +4 -5
  23. package/cli/parse-args.ts +45 -0
  24. package/cli/remote-metro.ts +1 -1
  25. package/cli/remote-simulators.ts +5 -1
  26. package/cli/send-to-box.ts +3 -1
  27. package/detox/index.ts +20 -1
  28. package/dist-lib/agent-daemon-client.cjs +2 -2
  29. package/dist-lib/agent-events.cjs +1 -1
  30. package/dist-lib/attached-projects.cjs +1 -1
  31. package/dist-lib/auth/shared-session.cjs +1 -1
  32. package/dist-lib/backend-origin.cjs +1 -1
  33. package/dist-lib/beta.cjs +1 -1
  34. package/dist-lib/beta.mjs +2 -2
  35. package/dist-lib/bridge-constants.cjs +1 -1
  36. package/dist-lib/bridge-contract-input.cjs +1 -1
  37. package/dist-lib/bridge-contract-input.mjs +5 -5
  38. package/dist-lib/bridge-contract.cjs +1 -1
  39. package/dist-lib/bridge-contract.mjs +3 -3
  40. package/dist-lib/bundle-channel.cjs +240 -316
  41. package/dist-lib/capture-contract.cjs +1 -1
  42. package/dist-lib/capture-contract.mjs +3 -3
  43. package/dist-lib/cloud-contract.cjs +14 -1
  44. package/dist-lib/cloud-contract.mjs +5 -3
  45. package/dist-lib/cloud-test-args.cjs +1 -1
  46. package/dist-lib/cloud-test-args.mjs +2 -2
  47. package/dist-lib/cloud.cjs +1 -1
  48. package/dist-lib/cloud.mjs +7 -7
  49. package/dist-lib/config.cjs +1 -6
  50. package/dist-lib/config.mjs +5 -9
  51. package/dist-lib/detox/index.cjs +17 -5
  52. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  53. package/dist-lib/esm-chunks/{acorn-FRQNHKFC.mjs → acorn-73XUBXBT.mjs} +3 -3
  54. package/dist-lib/esm-chunks/{chunk-IRMC5BCX.mjs → chunk-7V2QJGVI.mjs} +1 -1
  55. package/dist-lib/esm-chunks/{chunk-PMGJ7FLI.mjs → chunk-BHQEYJAF.mjs} +1 -1
  56. package/dist-lib/esm-chunks/{chunk-BAYRN7ZL.mjs → chunk-DSPFMVBM.mjs} +1 -1
  57. package/dist-lib/esm-chunks/{chunk-4HEUXQGM.mjs → chunk-GA73RJSG.mjs} +4 -4
  58. package/dist-lib/esm-chunks/{chunk-ABMB3G7I.mjs → chunk-IGBAFWZ3.mjs} +3 -3
  59. package/dist-lib/esm-chunks/{chunk-ZCMAKWHN.mjs → chunk-IKZDUGT6.mjs} +1 -1
  60. package/dist-lib/esm-chunks/{chunk-VAQJQDWI.mjs → chunk-IP5ZV36U.mjs} +1 -1
  61. package/dist-lib/esm-chunks/{chunk-O4EOBXAP.mjs → chunk-KGHQ4GK2.mjs} +1 -1
  62. package/dist-lib/esm-chunks/{chunk-4BZ3Z3IQ.mjs → chunk-KY63O76W.mjs} +2 -2
  63. package/dist-lib/esm-chunks/{chunk-QYYJESMK.mjs → chunk-LJ74MO6Y.mjs} +1 -1
  64. package/dist-lib/esm-chunks/{chunk-DJMWTW2B.mjs → chunk-LJX42YVT.mjs} +1 -1
  65. package/dist-lib/esm-chunks/{chunk-XO5GX4PI.mjs → chunk-O4KAW2JJ.mjs} +1 -1
  66. package/dist-lib/esm-chunks/{chunk-6A6JEVIF.mjs → chunk-OIFM356B.mjs} +1 -1
  67. package/dist-lib/esm-chunks/{chunk-NPLEBOWJ.mjs → chunk-P63DPATT.mjs} +1 -1
  68. package/dist-lib/esm-chunks/{chunk-VCAJFWZD.mjs → chunk-SCCOZKCP.mjs} +1 -1
  69. package/dist-lib/esm-chunks/{chunk-QUBR7LHU.mjs → chunk-TAZL253K.mjs} +41 -15
  70. package/dist-lib/esm-chunks/{chunk-ORYS5CC4.mjs → chunk-UBXCWZL3.mjs} +1 -1
  71. package/dist-lib/esm-chunks/{chunk-4ZRMJ5YO.mjs → chunk-ZQWWO33G.mjs} +14 -2
  72. package/dist-lib/esm-chunks/{metro-layout-parser-AUAVE5VL.mjs → metro-layout-parser-HNQRTPVE.mjs} +3 -3
  73. package/dist-lib/expo-swift-bundle.cjs +197 -336
  74. package/dist-lib/expo-swift-metadata.cjs +1 -1
  75. package/dist-lib/expo-swift-metadata.mjs +7 -7
  76. package/dist-lib/home-paths.cjs +1 -1
  77. package/dist-lib/host/bridge-host.cjs +276 -381
  78. package/dist-lib/host/fetch-proxy-handler.cjs +35 -43
  79. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  80. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  81. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  82. package/dist-lib/host/websocket-proxy.cjs +4 -2
  83. package/dist-lib/index.cjs +2 -105
  84. package/dist-lib/kotlin-host.cjs +6 -4
  85. package/dist-lib/menu.cjs +1 -1
  86. package/dist-lib/menu.mjs +3 -3
  87. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  88. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  89. package/dist-lib/metro-production-bundle.cjs +1 -1
  90. package/dist-lib/metro-production-bundle.mjs +4 -4
  91. package/dist-lib/native-app-identity-project.cjs +2 -2
  92. package/dist-lib/native-app-identity-project.mjs +12 -12
  93. package/dist-lib/native-app-identity.cjs +1 -1
  94. package/dist-lib/native-app-identity.mjs +6 -6
  95. package/dist-lib/native-firebase-metadata.cjs +1 -1
  96. package/dist-lib/native-firebase-metadata.mjs +3 -3
  97. package/dist-lib/pdfium-raster.cjs +1 -1
  98. package/dist-lib/pdfium-raster.mjs +2 -2
  99. package/dist-lib/plist.cjs +1 -1
  100. package/dist-lib/plist.mjs +3 -3
  101. package/dist-lib/profiles.cjs +1 -1
  102. package/dist-lib/public-brand.cjs +1 -1
  103. package/dist-lib/public-origins-lib-esm.json +64 -64
  104. package/dist-lib/public-origins-lib-static.json +1 -1
  105. package/dist-lib/public-origins-lib.json +107 -85
  106. package/dist-lib/react-native-host-modules.cjs +1 -1
  107. package/dist-lib/react-native-host-modules.mjs +2 -2
  108. package/dist-lib/reap-browser.cjs +1 -1
  109. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  110. package/dist-lib/sdk.cjs +1 -1
  111. package/dist-lib/sdk.mjs +7 -7
  112. package/dist-lib/skills.cjs +310 -310
  113. package/dist-lib/swift-compile.cjs +37 -11
  114. package/dist-lib/swift-compile.mjs +8 -8
  115. package/dist-lib/swift-package.cjs +1 -1
  116. package/dist-lib/swift-package.mjs +3 -3
  117. package/dist-lib/swift-submit.cjs +1 -1
  118. package/dist-lib/swift-submit.mjs +5 -5
  119. package/dist-lib/swift-toolchain.cjs +1 -1
  120. package/dist-lib/swift.cjs +1 -1
  121. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  122. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +14770 -0
  123. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +2790 -0
  124. package/dist-lib/vendor/acorn.cjs +1 -1
  125. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  126. package/dist-lib/vendor/ignore.cjs +1 -1
  127. package/dist-lib/vendor/magic-string.cjs +1 -1
  128. package/dist-lib/vendor/plist.cjs +1 -1
  129. package/dist-lib/vendor/prism.wasm +0 -0
  130. package/dist-lib/vendor/smol-toml.cjs +1 -1
  131. package/dist-lib/vendor/stream-json.cjs +1 -1
  132. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  133. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  134. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  135. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  136. package/dist-lib/vendor/sucrase.cjs +1 -1
  137. package/dist-lib/vendor/terser.cjs +1 -1
  138. package/dist-lib/vendor/valibot.cjs +1 -1
  139. package/dist-lib/vendor/ws.cjs +3710 -0
  140. package/dist-lib/vendor/zod.cjs +1 -1
  141. package/dist-lib/worklet-executable.cjs +1 -1
  142. package/dist-lib/worklet-executable.mjs +3 -3
  143. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +0 -3
  144. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  145. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
  146. package/dist-types/packages/peach-engine/src/engine/text-line-break.d.ts +3 -1
  147. package/dist-types/packages/peach-engine/src/engine/text-paint.d.ts +1 -0
  148. package/dist-types/packages/peach-engine/src/engine/text-runs.d.ts +6 -1
  149. package/kotlin/sdk.tar.gz +0 -0
  150. package/package.json +22 -14
  151. package/skills/peach-setup/references/native-config.md +3 -3
  152. package/src/app-config.ts +7 -15
  153. package/src/cloud-contract.ts +35 -0
  154. package/src/config.ts +2 -6
  155. package/src/estree-walk.ts +13 -0
  156. package/src/host/network-policy.ts +4 -1
  157. package/src/index.ts +0 -1
  158. package/src/one-native-app-config.ts +14 -15
  159. package/src/podspec-prism.ts +7 -1
  160. package/src/process-group.ts +4 -1
  161. package/src/process-table.ts +6 -1
  162. package/src/swift-compile.ts +38 -8
  163. package/src/swift-host.ts +10 -4
  164. package/cli/commands/box/bundle-plane.ts +0 -154
  165. package/dist-lib/jump-to-source-babel.cjs +0 -131
  166. package/dist-lib/jump-to-source-native.cjs +0 -235
  167. package/src/java-static-imports.ts +0 -68
  168. package/src/jump-to-source-babel.ts +0 -143
  169. package/src/jump-to-source-native.ts +0 -200
  170. package/src/kotlin-jvm-sources.ts +0 -35
@@ -1,143 +0,0 @@
1
- import type { PluginObj, types } from '@babel/core'
2
-
3
- export interface SootsimJumpToSourceBabelOptions {
4
- enabled?: boolean
5
- attrName?: string
6
- include?: readonly SourcePathMatcher[]
7
- exclude?: readonly SourcePathMatcher[]
8
- }
9
-
10
- type SourcePathMatcher = string | RegExp
11
-
12
- function normalizeSourcePath(path: string): string {
13
- const queryStart = path.indexOf('?')
14
- const clean = queryStart >= 0 ? path.slice(0, queryStart) : path
15
- return clean.replace(/\\/g, '/')
16
- }
17
-
18
- function matchesPath(path: string, matcher: SourcePathMatcher): boolean {
19
- return typeof matcher === 'string' ? path.includes(matcher) : matcher.test(path)
20
- }
21
-
22
- function shouldStampFile(
23
- filename: string,
24
- options: SootsimJumpToSourceBabelOptions,
25
- ): boolean {
26
- const normalized = normalizeSourcePath(filename)
27
- if (normalized.includes('/node_modules/')) return false
28
- if (normalized.includes('/dist/') || normalized.includes('/build/')) return false
29
- if (options.exclude?.some((matcher) => matchesPath(normalized, matcher))) return false
30
- if (options.include?.length) {
31
- return options.include.some((matcher) => matchesPath(normalized, matcher))
32
- }
33
- return true
34
- }
35
-
36
- export default function sootsimJumpToSourceBabelPlugin(
37
- api: { types: typeof types },
38
- options: SootsimJumpToSourceBabelOptions = {},
39
- ): PluginObj {
40
- const t = api.types
41
- const attrName = options.attrName || 'srcloc'
42
- const stamped = new WeakSet<types.JSXElement>()
43
-
44
- return {
45
- name: 'sootsim-jump-to-source',
46
- visitor: {
47
- JSXElement: {
48
- exit(path, state) {
49
- if (options.enabled === false) return
50
- const filename = state.filename
51
- if (!filename || !shouldStampFile(filename, options)) return
52
-
53
- const node = path.node
54
- if (stamped.has(node)) return
55
- stamped.add(node)
56
- const opening = node.openingElement
57
- const name = opening.name
58
- if (t.isJSXNamespacedName(name)) return
59
- if (
60
- opening.attributes.some(
61
- (attr) =>
62
- t.isJSXAttribute(attr) &&
63
- t.isJSXIdentifier(attr.name, { name: attrName }),
64
- )
65
- )
66
- return
67
- const loc = opening.loc?.start
68
- if (!loc) return
69
- const source = `${normalizeSourcePath(filename)}:${loc.line}:${loc.column + 1}`
70
- if (t.isJSXIdentifier(name) && /^[a-z]/.test(name.name)) {
71
- opening.attributes.push(
72
- t.jsxAttribute(t.jsxIdentifier(attrName), t.stringLiteral(source)),
73
- )
74
- return
75
- }
76
-
77
- // capture the type once, before props and children. names and member
78
- // getters can resolve to fragment at runtime; no symbol accepts srcloc.
79
- const fn = path.getFunctionParent()
80
- const parameterDefault = Boolean(
81
- fn &&
82
- opening.start != null &&
83
- fn.node.body.start != null &&
84
- opening.start < fn.node.body.start,
85
- )
86
- const type = path.scope.generateUidIdentifier('PeachSourceType')
87
- if (!parameterDefault) path.scope.push({ id: type })
88
- // jsx member names have the same object/property shape as expressions.
89
- function expression(
90
- tag: types.JSXIdentifier | types.JSXMemberExpression,
91
- ): types.Expression {
92
- return t.isJSXIdentifier(tag)
93
- ? t.identifier(tag.name)
94
- : t.memberExpression(
95
- expression(tag.object),
96
- t.identifier(tag.property.name),
97
- )
98
- }
99
- const originalType = expression(name)
100
- const alias = t.jsxIdentifier(type.name)
101
- opening.name = alias
102
- if (node.closingElement) node.closingElement.name = alias
103
- opening.attributes.push(
104
- t.jsxSpreadAttribute(
105
- t.conditionalExpression(
106
- t.binaryExpression(
107
- '===',
108
- t.unaryExpression('typeof', type),
109
- t.stringLiteral('symbol'),
110
- ),
111
- t.nullLiteral(),
112
- t.objectExpression([
113
- t.objectProperty(t.stringLiteral(attrName), t.stringLiteral(source)),
114
- ]),
115
- ),
116
- ),
117
- )
118
- // defaults execute outside the function body. their own parameter
119
- // binding preserves lexical this and arguments without a shared temp.
120
- // the always-truthy capture avoids sequence expressions inside jsx.
121
- const replacement = parameterDefault
122
- ? t.callExpression(t.arrowFunctionExpression([type], node), [originalType])
123
- : t.logicalExpression(
124
- '&&',
125
- t.logicalExpression(
126
- '||',
127
- t.assignmentExpression('=', type, originalType),
128
- t.booleanLiteral(true),
129
- ),
130
- node,
131
- )
132
- if (path.parentPath.isJSXElement() || path.parentPath.isJSXFragment()) {
133
- path.replaceWith(t.jsxExpressionContainer(replacement))
134
- } else {
135
- path.replaceWith(replacement)
136
- }
137
- },
138
- },
139
- },
140
- }
141
- }
142
-
143
- export { sootsimJumpToSourceBabelPlugin }
@@ -1,200 +0,0 @@
1
- import MagicString from 'magic-string'
2
- import {
3
- parseSync,
4
- type Program,
5
- type BlockStatement,
6
- type Expression,
7
- type JSXElement,
8
- type JSXFragment,
9
- } from 'oxc-parser'
10
- import { visitParsedProgram } from './visit-parsed-program'
11
- import type { SootsimJumpToSourceBabelOptions } from './jump-to-source-babel.ts'
12
-
13
- export type JumpToSourceNativeOptions = SootsimJumpToSourceBabelOptions
14
-
15
- function matchesPath(path: string, matcher: string | RegExp): boolean {
16
- return typeof matcher === 'string' ? path.includes(matcher) : matcher.test(path)
17
- }
18
-
19
- // stamp the same one-based source locations as the babel plugin before native
20
- // jsx compilation, without running babel in the native bundle pipeline.
21
- export function stampJsxSourceLocations(
22
- code: string,
23
- filename: string,
24
- options: JumpToSourceNativeOptions = {},
25
- ): string | null {
26
- if (options.enabled === false || !filename || !code.includes('<')) return null
27
- const source = filename.split('?')[0].replace(/\\/g, '/')
28
- if (
29
- source.includes('/node_modules/') ||
30
- source.includes('/dist/') ||
31
- source.includes('/build/')
32
- )
33
- return null
34
- if (options.exclude?.some((matcher) => matchesPath(source, matcher))) return null
35
- if (
36
- options.include?.length &&
37
- !options.include.some((matcher) => matchesPath(source, matcher))
38
- )
39
- return null
40
-
41
- const { program, errors } = parseSync(source, code, {
42
- lang: source.endsWith('.tsx') ? 'tsx' : source.endsWith('.ts') ? 'ts' : 'jsx',
43
- })
44
- if (errors.length) return null
45
-
46
- const attrName = options.attrName || 'srcloc'
47
- const lineStarts = [0]
48
- for (let i = 0; i < code.length; i++) {
49
- if (code.charCodeAt(i) === 10) lineStarts.push(i + 1)
50
- }
51
- const magic = new MagicString(code)
52
- let stamped = false
53
- let nextType = 0
54
- const usedTypeNames = new Set(code.match(/\b_PeachSourceType\d+\b/g) ?? [])
55
- type Scope = { body: Program | BlockStatement | Expression; names: string[] }
56
- const scopes: Scope[] = [{ body: program, names: [] }]
57
- const allScopes = [...scopes]
58
- const elements: (JSXElement | JSXFragment)[] = []
59
- const childElements = new WeakSet<JSXElement>()
60
- const enterElement = (node: JSXElement | JSXFragment) => {
61
- elements.push(node)
62
- for (const child of node.children) {
63
- if (child.type === 'JSXElement') childElements.add(child)
64
- }
65
- }
66
- const enterFunction = (node: { body?: BlockStatement | Expression | null }) => {
67
- const scope: Scope = { body: node.body ?? program, names: [] }
68
- scopes.push(scope)
69
- allScopes.push(scope)
70
- }
71
- const exitFunction = () => {
72
- scopes.pop()
73
- }
74
- visitParsedProgram(program, {
75
- FunctionDeclaration: enterFunction,
76
- 'FunctionDeclaration:exit': exitFunction,
77
- FunctionExpression: enterFunction,
78
- 'FunctionExpression:exit': exitFunction,
79
- ArrowFunctionExpression: enterFunction,
80
- 'ArrowFunctionExpression:exit': exitFunction,
81
- JSXElement: enterElement,
82
- 'JSXElement:exit'() {
83
- elements.pop()
84
- },
85
- JSXFragment: enterElement,
86
- 'JSXFragment:exit'() {
87
- elements.pop()
88
- },
89
- JSXOpeningElement(node) {
90
- const name = node.name
91
- if (name.type === 'JSXNamespacedName') return
92
- if (
93
- node.attributes.some(
94
- (attr) =>
95
- attr.type === 'JSXAttribute' &&
96
- attr.name.type === 'JSXIdentifier' &&
97
- attr.name.name === attrName,
98
- )
99
- )
100
- return
101
-
102
- // binary search keeps location lookup logarithmic for large source files.
103
- let lo = 0
104
- let hi = lineStarts.length - 1
105
- while (lo < hi) {
106
- const mid = (lo + hi + 1) >> 1
107
- if (lineStarts[mid] <= node.start) lo = mid
108
- else hi = mid - 1
109
- }
110
- const location = `${source}:${lo + 1}:${node.start - lineStarts[lo] + 1}`
111
- if (name.type === 'JSXIdentifier' && /^[a-z]/.test(name.name)) {
112
- magic.appendLeft(
113
- node.end - (node.selfClosing ? 2 : 1),
114
- ` ${attrName}={${JSON.stringify(location)}}`,
115
- )
116
- } else {
117
- const scope = scopes[scopes.length - 1]
118
- // parameter defaults have their own environment outside the body.
119
- const parameterDefault =
120
- node.start < scope.body.start || node.end > scope.body.end
121
- const element = elements[elements.length - 1]
122
- if (element.type !== 'JSXElement') return
123
- const isChild = childElements.has(element)
124
- let type: string
125
- do {
126
- type = `_PeachSourceType${nextType++}`
127
- } while (usedTypeNames.has(type))
128
- if (!parameterDefault) scope.names.push(type)
129
- const originalType = code.slice(name.start, name.end)
130
- // keep the capture before props without a sequence inside jsx children.
131
- magic.appendLeft(
132
- element.start,
133
- `${isChild ? '{' : ''}${parameterDefault ? `((${type}) => ` : `(((${type} = ${originalType}) || true) && `}`,
134
- )
135
- magic.appendLeft(
136
- element.end,
137
- `${parameterDefault ? `)(${originalType})` : ')'}${isChild ? '}' : ''}`,
138
- )
139
- magic.overwrite(name.start, name.end, type)
140
- if (element.closingElement) {
141
- const closing = element.closingElement.name
142
- magic.overwrite(closing.start, closing.end, type)
143
- }
144
- magic.appendLeft(
145
- node.end - (node.selfClosing ? 2 : 1),
146
- ` {...(typeof ${type} === "symbol" ? null : {${JSON.stringify(attrName)}: ${JSON.stringify(location)}})}`,
147
- )
148
- }
149
- stamped = true
150
- },
151
- })
152
- for (const { body, names } of allScopes) {
153
- if (!names.length) continue
154
- const declaration = `var ${names.join(', ')};`
155
- if (body.type === 'Program' || body.type === 'BlockStatement') {
156
- let start =
157
- body.type === 'Program'
158
- ? program.hashbang
159
- ? code.indexOf('\n', program.hashbang.end) + 1
160
- : 0
161
- : body.start + 1
162
- for (const statement of body.body) {
163
- if (
164
- statement.type !== 'ExpressionStatement' ||
165
- statement.expression.type !== 'Literal' ||
166
- typeof statement.expression.value !== 'string'
167
- )
168
- break
169
- start = statement.end
170
- }
171
- magic.prependLeft(start, declaration)
172
- } else {
173
- magic.prependLeft(body.start, `{${declaration} return (`)
174
- magic.appendLeft(body.end, ');}')
175
- }
176
- }
177
- return stamped ? magic.toString() : null
178
- }
179
-
180
- // metro's nativeTransformModules accepts module ids; consumers can export an
181
- // instance of this transform from a module to supply their include filters.
182
- export function createJumpToSourceNativeTransform(
183
- options: JumpToSourceNativeOptions = {},
184
- ) {
185
- return function jumpToSourceNativeTransform(code: string, ctx: { filename: string }) {
186
- return stampJsxSourceLocations(code, ctx.filename, options)
187
- }
188
- }
189
-
190
- export function jumpToSourceNativePlugin(options: JumpToSourceNativeOptions = {}) {
191
- return {
192
- name: 'sootsim-jump-to-source',
193
- transform(code: string, id: string) {
194
- const stamped = stampJsxSourceLocations(code, id, options)
195
- return stamped == null ? null : { code: stamped, map: null }
196
- },
197
- }
198
- }
199
-
200
- export default createJumpToSourceNativeTransform()
@@ -1,35 +0,0 @@
1
- // Kotlin/JVM's kotlin.collections classes that are typealiases of java.util's,
2
- // so a Kotlin/JVM source naming one means the Java class
3
- const JVM_COLLECTION_ALIASES = [
4
- 'ArrayList',
5
- 'HashMap',
6
- 'HashSet',
7
- 'LinkedHashMap',
8
- 'LinkedHashSet',
9
- ]
10
-
11
- export function importJvmCollectionAliases(source: string): string {
12
- const names = JVM_COLLECTION_ALIASES.filter(
13
- (name) =>
14
- new RegExp(`(?<![\\w.])${name}\\b`).test(source.replace(/^\s*import\s.*$/gm, '')) &&
15
- !new RegExp(
16
- `^\\s*import\\s+[\\w.]+(\\.${name}|\\s+as\\s+${name})\\s*$|\\b(class|typealias|interface)\\s+${name}\\b`,
17
- 'm',
18
- ).test(source),
19
- )
20
- if (!names.length) return source
21
- const imports = names.map((name) => `import java.util.${name}`).join('\n')
22
- const header = /^package\s.*$/m.exec(source)
23
- if (!header) return `${imports}\n${source}`
24
- const end = header.index + header[0].length
25
- return `${source.slice(0, end)}\n${imports}${source.slice(end)}`
26
- }
27
-
28
- // Kotlin/JVM alone takes a class literal with type arguments, for an array:
29
- // the Java class of that array
30
- export function arrayClassLiterals(source: string): string {
31
- return source.replace(
32
- /(?<![\w.])Array<([\w.]+)>::class\.java\b/g,
33
- (_, component) => `${component}::class.java.arrayType()`,
34
- )
35
- }