@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.
Files changed (43) hide show
  1. package/dist/dev/VibeDevWrapper.d.ts +9 -0
  2. package/dist/dev/VibeDevWrapper.d.ts.map +1 -0
  3. package/dist/dev/VibeDevWrapper.js +6 -0
  4. package/dist/dev/VibeDevWrapper.js.map +1 -0
  5. package/dist/dev/safe-insets.d.ts +9 -0
  6. package/dist/dev/safe-insets.d.ts.map +1 -0
  7. package/dist/dev/safe-insets.js +5 -0
  8. package/dist/dev/safe-insets.js.map +1 -0
  9. package/dist/dev/safe-insets.web.d.ts +9 -0
  10. package/dist/dev/safe-insets.web.d.ts.map +1 -0
  11. package/dist/dev/safe-insets.web.js +40 -0
  12. package/dist/dev/safe-insets.web.js.map +1 -0
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +5 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/polyfills/alert.web.d.ts +1 -1
  18. package/dist/polyfills/alert.web.d.ts.map +1 -1
  19. package/dist/polyfills/alert.web.js +1 -1
  20. package/dist/polyfills/alert.web.js.map +1 -1
  21. package/dist/polyfills/fetch.web.d.ts +14 -0
  22. package/dist/polyfills/fetch.web.d.ts.map +1 -0
  23. package/dist/polyfills/fetch.web.js +160 -0
  24. package/dist/polyfills/fetch.web.js.map +1 -0
  25. package/dist/polyfills/haptics.web.d.ts.map +1 -1
  26. package/dist/polyfills/haptics.web.js +3 -3
  27. package/dist/polyfills/haptics.web.js.map +1 -1
  28. package/dist/polyfills/maps.web.d.ts +1 -1
  29. package/dist/polyfills/maps.web.d.ts.map +1 -1
  30. package/dist/polyfills/maps.web.js +4 -4
  31. package/dist/polyfills/maps.web.js.map +1 -1
  32. package/dist/polyfills/refresh-control-component.d.ts +1 -1
  33. package/dist/polyfills/refresh-control-component.d.ts.map +1 -1
  34. package/dist/polyfills/refresh-control-component.js +13 -9
  35. package/dist/polyfills/refresh-control-component.js.map +1 -1
  36. package/dist/polyfills/secure-store.web.d.ts.map +1 -1
  37. package/dist/polyfills/secure-store.web.js +6 -6
  38. package/dist/polyfills/secure-store.web.js.map +1 -1
  39. package/metro/index.cjs +121 -108
  40. package/metro/index.d.ts +18 -18
  41. package/metro/metro-http-store.cjs +254 -254
  42. package/metro/transformer.cjs +69 -0
  43. package/package.json +59 -57
package/metro/index.cjs CHANGED
@@ -1,14 +1,14 @@
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");
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, "../dist/");
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
- const cacheDir =
26
- options.cacheDir ||
27
- process.env.METRO_CACHE_DIR ||
28
- path.join(os.homedir(), ".metro-cache");
29
-
30
- const httpEndpoint = options.httpEndpoint || process.env.METRO_CACHE_HTTP_ENDPOINT;
31
-
32
- const stores = [new FileStore({ root: cacheDir })];
33
-
34
- if (httpEndpoint) {
35
- stores.push(
36
- new HttpStore({
37
- endpoint: httpEndpoint,
38
- timeout: options.httpTimeout ?? 30000,
39
- maxConnections: options.httpMaxConnections ?? 64,
40
- maxConcurrent: options.httpMaxConcurrent ?? 256,
41
- })
42
- );
43
- }
44
-
45
- return stores;
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
- const originalResolveRequest = config.resolver?.resolveRequest;
69
- const enableCache = options.enableCache !== false;
70
-
71
- const result = {
72
- ...config,
73
- resolver: {
74
- ...config.resolver,
75
- extraNodeModules: {
76
- assert: require.resolve("assert"),
77
- ...config.resolver?.extraNodeModules,
78
- },
79
- resolveRequest: (context, moduleName, platform) => {
80
- // Redirect expo-haptics to our web polyfill on web platform
81
- if (moduleName === "expo-haptics" && platform === "web") {
82
- return {
83
- filePath: path.resolve(distPath, "polyfills/haptics.web.js"),
84
- type: "sourceFile",
85
- };
86
- }
87
-
88
- if (moduleName === "expo-secure-store" && platform === "web") {
89
- return {
90
- filePath: path.resolve(distPath, "polyfills/secure-store.web.js"),
91
- type: "sourceFile",
92
- };
93
- }
94
-
95
- if (moduleName === "react-native-maps" && platform === "web") {
96
- return {
97
- filePath: path.resolve(distPath, "polyfills/maps.web.js"),
98
- type: "sourceFile",
99
- };
100
- }
101
-
102
- if (
103
- moduleName === "react-native-web/dist/exports/RefreshControl" &&
104
- platform === "web"
105
- ) {
106
- return {
107
- filePath: path.resolve(
108
- distPath,
109
- "polyfills/refresh-control-component.js"
110
- ),
111
- type: "sourceFile",
112
- };
113
- }
114
-
115
- if (
116
- moduleName === "react-native-web/dist/exports/Alert" &&
117
- platform === "web"
118
- ) {
119
- return {
120
- filePath: path.resolve(distPath, "polyfills/alert.web.js"),
121
- type: "sourceFile",
122
- };
123
- }
124
-
125
- if (originalResolveRequest) {
126
- return originalResolveRequest(context, moduleName, platform);
127
- }
128
-
129
- return context.resolveRequest(context, moduleName, platform);
130
- },
131
- },
132
- };
133
-
134
- // Configure caching if enabled
135
- if (enableCache) {
136
- result.cacheStores = createCacheStores({
137
- cacheDir: options.cacheDir,
138
- httpEndpoint: options.httpEndpoint,
139
- httpTimeout: options.httpTimeout,
140
- httpMaxConnections: options.httpMaxConnections,
141
- httpMaxConcurrent: options.httpMaxConcurrent,
142
- });
143
-
144
- result.cacheVersion =
145
- options.cacheVersion || process.env.METRO_CACHE_VERSION || "1";
146
- }
147
-
148
- return result;
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 "metro-config";
1
+ import type { MetroConfig } from 'metro-config'
2
2
 
3
3
  export interface VibecodeMetroOptions {
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;
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
- config: MetroConfig,
25
- options?: VibecodeMetroOptions
26
- ): MetroConfig;
24
+ config: MetroConfig,
25
+ options?: VibecodeMetroOptions,
26
+ ): MetroConfig