@vibecodeapp/sdk 0.2.0 → 0.3.0
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 +30 -0
- package/dist/dev/safe-insets.web.js.map +1 -0
- package/dist/index.d.ts +5 -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 +170 -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 +2 -2
- 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 +2 -2
- package/dist/polyfills/refresh-control-component.d.ts.map +1 -1
- package/dist/polyfills/refresh-control-component.js +19 -10
- 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 +137 -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
|
@@ -15,7 +15,7 @@ const KEYCHAIN_CONSTANTS = {
|
|
|
15
15
|
};
|
|
16
16
|
export const { AFTER_FIRST_UNLOCK, AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY, ALWAYS, WHEN_PASSCODE_SET_THIS_DEVICE_ONLY, ALWAYS_THIS_DEVICE_ONLY, WHEN_UNLOCKED, WHEN_UNLOCKED_THIS_DEVICE_ONLY, } = KEYCHAIN_CONSTANTS;
|
|
17
17
|
function isValidValue(value) {
|
|
18
|
-
if (typeof value !==
|
|
18
|
+
if (typeof value !== 'string') {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
if (new Blob([value]).size > VALUE_BYTES_LIMIT) {
|
|
@@ -27,10 +27,10 @@ function getStorageKey(key) {
|
|
|
27
27
|
return `_vibecode_secure_store_${key}`;
|
|
28
28
|
}
|
|
29
29
|
export async function isAvailableAsync() {
|
|
30
|
-
const testKey =
|
|
30
|
+
const testKey = '__SECURE_STORE_AVAILABILITY_TEST_KEY__';
|
|
31
31
|
try {
|
|
32
|
-
localStorage.setItem(testKey,
|
|
33
|
-
if (localStorage.getItem(testKey) !==
|
|
32
|
+
localStorage.setItem(testKey, 'test');
|
|
33
|
+
if (localStorage.getItem(testKey) !== 'test') {
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
localStorage.removeItem(testKey);
|
|
@@ -48,13 +48,13 @@ export async function getItemAsync(key, _options = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
export async function setItemAsync(key, value, _options = {}) {
|
|
50
50
|
if (!isValidValue(value)) {
|
|
51
|
-
throw new Error(
|
|
51
|
+
throw new Error('Invalid value provided to SecureStore. Values must be strings; consider JSON-encoding your values if they are serializable.');
|
|
52
52
|
}
|
|
53
53
|
localStorage.setItem(getStorageKey(key), value);
|
|
54
54
|
}
|
|
55
55
|
export function setItem(key, value, _options = {}) {
|
|
56
56
|
if (!isValidValue(value)) {
|
|
57
|
-
throw new Error(
|
|
57
|
+
throw new Error('Invalid value provided to SecureStore. Values must be strings; consider JSON-encoding your values if they are serializable.');
|
|
58
58
|
}
|
|
59
59
|
localStorage.setItem(getStorageKey(key), value);
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secure-store.web.js","sourceRoot":"","sources":["../../src/polyfills/secure-store.web.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,iBAAiB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"secure-store.web.js","sourceRoot":"","sources":["../../src/polyfills/secure-store.web.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B,MAAM,kBAAkB,GAAG;IAC1B,kBAAkB,EAAE,CAAC;IACrB,mCAAmC,EAAE,CAAC;IACtC,MAAM,EAAE,CAAC;IACT,kCAAkC,EAAE,CAAC;IACrC,uBAAuB,EAAE,CAAC;IAC1B,aAAa,EAAE,CAAC;IAChB,8BAA8B,EAAE,CAAC;CACjC,CAAA;AAID,MAAM,CAAC,MAAM,EACZ,kBAAkB,EAClB,mCAAmC,EACnC,MAAM,EACN,kCAAkC,EAClC,uBAAuB,EACvB,aAAa,EACb,8BAA8B,GAC9B,GAAG,kBAAkB,CAAA;AAStB,SAAS,YAAY,CAAC,KAAa;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAA;IACb,CAAC;IACD,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,iBAAiB,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,CACX,oDAAoD,iBAAiB,+CAA+C,CACpH,CAAA;IACF,CAAC;IACD,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C,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACd,6HAA6H,CAC7H,CAAA;IACF,CAAC;IACD,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,OAAO,CACtB,GAAW,EACX,WAA+B,EAAE;IAEjC,OAAO,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC5C,OAAO,KAAK,CAAA;AACb,CAAC"}
|
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
|
/**
|
|
@@ -64,88 +65,116 @@ function createCacheStores(options = {}) {
|
|
|
64
65
|
* @param {number} [options.httpMaxConcurrent] - Max concurrent requests
|
|
65
66
|
* @returns {Object} Enhanced Metro config
|
|
66
67
|
*/
|
|
68
|
+
// Path to the fetch polyfill that auto-initializes the proxy
|
|
69
|
+
const fetchPolyfillPath = path.resolve(distPath, 'polyfills/fetch.web.js')
|
|
70
|
+
|
|
67
71
|
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
|
-
|
|
72
|
+
const originalResolveRequest = config.resolver?.resolveRequest
|
|
73
|
+
const originalGetModulesRunBeforeMainModule =
|
|
74
|
+
config.serializer?.getModulesRunBeforeMainModule
|
|
75
|
+
const enableCache = options.enableCache !== false
|
|
76
|
+
|
|
77
|
+
const result = {
|
|
78
|
+
...config,
|
|
79
|
+
serializer: {
|
|
80
|
+
...config.serializer,
|
|
81
|
+
// Inject the fetch polyfill to run before the main module on web
|
|
82
|
+
getModulesRunBeforeMainModule: (entryFilePath) => {
|
|
83
|
+
const originalModules = originalGetModulesRunBeforeMainModule
|
|
84
|
+
? originalGetModulesRunBeforeMainModule(entryFilePath)
|
|
85
|
+
: []
|
|
86
|
+
// Add our fetch polyfill to run before the app starts
|
|
87
|
+
return [...originalModules, fetchPolyfillPath]
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
transformer: {
|
|
91
|
+
...config.transformer,
|
|
92
|
+
babelTransformerPath: require.resolve('./transformer.cjs'),
|
|
93
|
+
},
|
|
94
|
+
resolver: {
|
|
95
|
+
...config.resolver,
|
|
96
|
+
extraNodeModules: {
|
|
97
|
+
assert: require.resolve('assert'),
|
|
98
|
+
...config.resolver?.extraNodeModules,
|
|
99
|
+
},
|
|
100
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
101
|
+
// Redirect expo-haptics to our web polyfill on web platform
|
|
102
|
+
if (moduleName === 'expo-haptics' && platform === 'web') {
|
|
103
|
+
return {
|
|
104
|
+
filePath: path.resolve(distPath, 'polyfills/haptics.web.js'),
|
|
105
|
+
type: 'sourceFile',
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (moduleName === 'expo-secure-store' && platform === 'web') {
|
|
110
|
+
return {
|
|
111
|
+
filePath: path.resolve(distPath, 'polyfills/secure-store.web.js'),
|
|
112
|
+
type: 'sourceFile',
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (moduleName === 'react-native-maps' && platform === 'web') {
|
|
117
|
+
return {
|
|
118
|
+
filePath: path.resolve(distPath, 'polyfills/maps.web.js'),
|
|
119
|
+
type: 'sourceFile',
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
moduleName === 'react-native-web/dist/exports/RefreshControl' &&
|
|
125
|
+
platform === 'web'
|
|
126
|
+
) {
|
|
127
|
+
return {
|
|
128
|
+
filePath: path.resolve(
|
|
129
|
+
distPath,
|
|
130
|
+
'polyfills/refresh-control-component.js',
|
|
131
|
+
),
|
|
132
|
+
type: 'sourceFile',
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (
|
|
137
|
+
moduleName === 'react-native-web/dist/exports/Alert' &&
|
|
138
|
+
platform === 'web'
|
|
139
|
+
) {
|
|
140
|
+
return {
|
|
141
|
+
filePath: path.resolve(distPath, 'polyfills/alert.web.js'),
|
|
142
|
+
type: 'sourceFile',
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Override expo/fetch on web to use our proxy-enabled fetch
|
|
147
|
+
if (moduleName === 'expo/fetch' && platform === 'web') {
|
|
148
|
+
return {
|
|
149
|
+
filePath: path.resolve(distPath, 'polyfills/fetch.web.js'),
|
|
150
|
+
type: 'sourceFile',
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (originalResolveRequest) {
|
|
155
|
+
return originalResolveRequest(context, moduleName, platform)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return context.resolveRequest(context, moduleName, platform)
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Configure caching if enabled
|
|
164
|
+
if (enableCache) {
|
|
165
|
+
result.cacheStores = createCacheStores({
|
|
166
|
+
cacheDir: options.cacheDir,
|
|
167
|
+
httpEndpoint: options.httpEndpoint,
|
|
168
|
+
httpTimeout: options.httpTimeout,
|
|
169
|
+
httpMaxConnections: options.httpMaxConnections,
|
|
170
|
+
httpMaxConcurrent: options.httpMaxConcurrent,
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
result.cacheVersion =
|
|
174
|
+
options.cacheVersion || process.env.METRO_CACHE_VERSION || '1'
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return result
|
|
149
178
|
}
|
|
150
179
|
|
|
151
|
-
module.exports = { withVibecodeMetro }
|
|
180
|
+
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
|