@vibecodeapp/sdk 0.2.0 → 0.2.1
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/dist/dev/VibeDevWrapper.d.ts +9 -0
- package/dist/dev/VibeDevWrapper.d.ts.map +1 -0
- package/dist/dev/VibeDevWrapper.js +6 -0
- package/dist/dev/VibeDevWrapper.js.map +1 -0
- package/dist/dev/safe-insets.d.ts +9 -0
- package/dist/dev/safe-insets.d.ts.map +1 -0
- package/dist/dev/safe-insets.js +5 -0
- package/dist/dev/safe-insets.js.map +1 -0
- package/dist/dev/safe-insets.web.d.ts +9 -0
- package/dist/dev/safe-insets.web.d.ts.map +1 -0
- package/dist/dev/safe-insets.web.js +40 -0
- package/dist/dev/safe-insets.web.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/polyfills/alert.web.d.ts +1 -1
- package/dist/polyfills/alert.web.d.ts.map +1 -1
- package/dist/polyfills/alert.web.js +1 -1
- package/dist/polyfills/alert.web.js.map +1 -1
- package/dist/polyfills/fetch.web.d.ts +14 -0
- package/dist/polyfills/fetch.web.d.ts.map +1 -0
- package/dist/polyfills/fetch.web.js +160 -0
- package/dist/polyfills/fetch.web.js.map +1 -0
- package/dist/polyfills/haptics.web.d.ts.map +1 -1
- package/dist/polyfills/haptics.web.js +3 -3
- package/dist/polyfills/haptics.web.js.map +1 -1
- package/dist/polyfills/maps.web.d.ts +1 -1
- package/dist/polyfills/maps.web.d.ts.map +1 -1
- package/dist/polyfills/maps.web.js +4 -4
- package/dist/polyfills/maps.web.js.map +1 -1
- package/dist/polyfills/refresh-control-component.d.ts +1 -1
- package/dist/polyfills/refresh-control-component.d.ts.map +1 -1
- package/dist/polyfills/refresh-control-component.js +13 -9
- package/dist/polyfills/refresh-control-component.js.map +1 -1
- package/dist/polyfills/secure-store.web.d.ts.map +1 -1
- package/dist/polyfills/secure-store.web.js +6 -6
- package/dist/polyfills/secure-store.web.js.map +1 -1
- package/metro/index.cjs +121 -108
- package/metro/index.d.ts +18 -18
- package/metro/metro-http-store.cjs +254 -254
- package/metro/transformer.cjs +69 -0
- package/package.json +59 -57
package/metro/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const path = require(
|
|
2
|
-
const os = require(
|
|
3
|
-
const { FileStore } = require(
|
|
4
|
-
const { HttpStore } = require(
|
|
1
|
+
const path = require('node:path')
|
|
2
|
+
const os = require('node:os')
|
|
3
|
+
const { FileStore } = require('metro-cache')
|
|
4
|
+
const { HttpStore } = require('./metro-http-store.cjs')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Metro configuration helper for Vibecode
|
|
8
8
|
* Provides web polyfills and HTTP cache store for remote caching.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const distPath = path.resolve(__dirname,
|
|
11
|
+
const distPath = path.resolve(__dirname, '../dist/')
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create cache stores array for Metro config.
|
|
@@ -22,27 +22,28 @@ const distPath = path.resolve(__dirname, "../dist/");
|
|
|
22
22
|
* @returns {Array} Array of cache store instances
|
|
23
23
|
*/
|
|
24
24
|
function createCacheStores(options = {}) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
const cacheDir =
|
|
26
|
+
options.cacheDir ||
|
|
27
|
+
process.env.METRO_CACHE_DIR ||
|
|
28
|
+
path.join(os.homedir(), '.metro-cache')
|
|
29
|
+
|
|
30
|
+
const httpEndpoint =
|
|
31
|
+
options.httpEndpoint || process.env.METRO_CACHE_HTTP_ENDPOINT
|
|
32
|
+
|
|
33
|
+
const stores = [new FileStore({ root: cacheDir })]
|
|
34
|
+
|
|
35
|
+
if (httpEndpoint) {
|
|
36
|
+
stores.push(
|
|
37
|
+
new HttpStore({
|
|
38
|
+
endpoint: httpEndpoint,
|
|
39
|
+
timeout: options.httpTimeout ?? 30000,
|
|
40
|
+
maxConnections: options.httpMaxConnections ?? 64,
|
|
41
|
+
maxConcurrent: options.httpMaxConcurrent ?? 256,
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return stores
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/**
|
|
@@ -65,87 +66,99 @@ function createCacheStores(options = {}) {
|
|
|
65
66
|
* @returns {Object} Enhanced Metro config
|
|
66
67
|
*/
|
|
67
68
|
function withVibecodeMetro(config, options = {}) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
69
|
+
const originalResolveRequest = config.resolver?.resolveRequest
|
|
70
|
+
const enableCache = options.enableCache !== false
|
|
71
|
+
|
|
72
|
+
const result = {
|
|
73
|
+
...config,
|
|
74
|
+
transformer: {
|
|
75
|
+
...config.transformer,
|
|
76
|
+
babelTransformerPath: require.resolve('./transformer.cjs'),
|
|
77
|
+
},
|
|
78
|
+
resolver: {
|
|
79
|
+
...config.resolver,
|
|
80
|
+
extraNodeModules: {
|
|
81
|
+
assert: require.resolve('assert'),
|
|
82
|
+
...config.resolver?.extraNodeModules,
|
|
83
|
+
},
|
|
84
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
85
|
+
// Redirect expo-haptics to our web polyfill on web platform
|
|
86
|
+
if (moduleName === 'expo-haptics' && platform === 'web') {
|
|
87
|
+
return {
|
|
88
|
+
filePath: path.resolve(distPath, 'polyfills/haptics.web.js'),
|
|
89
|
+
type: 'sourceFile',
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (moduleName === 'expo-secure-store' && platform === 'web') {
|
|
94
|
+
return {
|
|
95
|
+
filePath: path.resolve(distPath, 'polyfills/secure-store.web.js'),
|
|
96
|
+
type: 'sourceFile',
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (moduleName === 'react-native-maps' && platform === 'web') {
|
|
101
|
+
return {
|
|
102
|
+
filePath: path.resolve(distPath, 'polyfills/maps.web.js'),
|
|
103
|
+
type: 'sourceFile',
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (
|
|
108
|
+
moduleName === 'react-native-web/dist/exports/RefreshControl' &&
|
|
109
|
+
platform === 'web'
|
|
110
|
+
) {
|
|
111
|
+
return {
|
|
112
|
+
filePath: path.resolve(
|
|
113
|
+
distPath,
|
|
114
|
+
'polyfills/refresh-control-component.js',
|
|
115
|
+
),
|
|
116
|
+
type: 'sourceFile',
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (
|
|
121
|
+
moduleName === 'react-native-web/dist/exports/Alert' &&
|
|
122
|
+
platform === 'web'
|
|
123
|
+
) {
|
|
124
|
+
return {
|
|
125
|
+
filePath: path.resolve(distPath, 'polyfills/alert.web.js'),
|
|
126
|
+
type: 'sourceFile',
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Override expo/fetch on web to use our proxy-enabled fetch
|
|
131
|
+
if (moduleName === 'expo/fetch' && platform === 'web') {
|
|
132
|
+
return {
|
|
133
|
+
filePath: path.resolve(distPath, 'polyfills/fetch.web.js'),
|
|
134
|
+
type: 'sourceFile',
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (originalResolveRequest) {
|
|
139
|
+
return originalResolveRequest(context, moduleName, platform)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return context.resolveRequest(context, moduleName, platform)
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Configure caching if enabled
|
|
148
|
+
if (enableCache) {
|
|
149
|
+
result.cacheStores = createCacheStores({
|
|
150
|
+
cacheDir: options.cacheDir,
|
|
151
|
+
httpEndpoint: options.httpEndpoint,
|
|
152
|
+
httpTimeout: options.httpTimeout,
|
|
153
|
+
httpMaxConnections: options.httpMaxConnections,
|
|
154
|
+
httpMaxConcurrent: options.httpMaxConcurrent,
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
result.cacheVersion =
|
|
158
|
+
options.cacheVersion || process.env.METRO_CACHE_VERSION || '1'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return result
|
|
149
162
|
}
|
|
150
163
|
|
|
151
|
-
module.exports = { withVibecodeMetro }
|
|
164
|
+
module.exports = { withVibecodeMetro }
|
package/metro/index.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { MetroConfig } from
|
|
1
|
+
import type { MetroConfig } from 'metro-config'
|
|
2
2
|
|
|
3
3
|
export interface VibecodeMetroOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
/** Enable cache configuration (default: true) */
|
|
5
|
+
enableCache?: boolean
|
|
6
|
+
/** Local cache directory (default: ~/.metro-cache) */
|
|
7
|
+
cacheDir?: string
|
|
8
|
+
/** Cache version string (default: "1") */
|
|
9
|
+
cacheVersion?: string
|
|
10
|
+
/** HTTP/2 cache server endpoint */
|
|
11
|
+
httpEndpoint?: string
|
|
12
|
+
/** HTTP request timeout in ms (default: 30000) */
|
|
13
|
+
httpTimeout?: number
|
|
14
|
+
/** HTTP/2 connection pool size (default: 64) */
|
|
15
|
+
httpMaxConnections?: number
|
|
16
|
+
/** Max concurrent HTTP requests (default: 256) */
|
|
17
|
+
httpMaxConcurrent?: number
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Wrap a Metro config with Vibecode enhancements.
|
|
22
22
|
*/
|
|
23
23
|
export function withVibecodeMetro(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
): MetroConfig
|
|
24
|
+
config: MetroConfig,
|
|
25
|
+
options?: VibecodeMetroOptions,
|
|
26
|
+
): MetroConfig
|