@flexireact/core 2.3.0 → 2.5.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/cli/generators.ts +616 -0
- package/cli/index.ts +27 -8
- package/core/devtools/index.ts +644 -0
- package/core/edge/cache.ts +344 -0
- package/core/edge/fetch-polyfill.ts +247 -0
- package/core/edge/handler.ts +248 -0
- package/core/edge/index.ts +81 -0
- package/core/edge/ppr.ts +264 -0
- package/core/edge/runtime.ts +161 -0
- package/core/index.ts +57 -1
- package/package.json +1 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlexiReact Universal Edge Runtime
|
|
3
|
+
*
|
|
4
|
+
* Works on:
|
|
5
|
+
* - Node.js
|
|
6
|
+
* - Bun
|
|
7
|
+
* - Deno
|
|
8
|
+
* - Cloudflare Workers
|
|
9
|
+
* - Vercel Edge
|
|
10
|
+
* - Any Web-standard runtime
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Detect runtime environment
|
|
14
|
+
export type RuntimeEnvironment =
|
|
15
|
+
| 'node'
|
|
16
|
+
| 'bun'
|
|
17
|
+
| 'deno'
|
|
18
|
+
| 'cloudflare'
|
|
19
|
+
| 'vercel-edge'
|
|
20
|
+
| 'netlify-edge'
|
|
21
|
+
| 'fastly'
|
|
22
|
+
| 'unknown';
|
|
23
|
+
|
|
24
|
+
export function detectRuntime(): RuntimeEnvironment {
|
|
25
|
+
// Bun
|
|
26
|
+
if (typeof globalThis.Bun !== 'undefined') {
|
|
27
|
+
return 'bun';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Deno
|
|
31
|
+
if (typeof globalThis.Deno !== 'undefined') {
|
|
32
|
+
return 'deno';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Cloudflare Workers
|
|
36
|
+
if (typeof globalThis.caches !== 'undefined' && typeof (globalThis as any).WebSocketPair !== 'undefined') {
|
|
37
|
+
return 'cloudflare';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Vercel Edge
|
|
41
|
+
if (typeof process !== 'undefined' && process.env?.VERCEL_EDGE === '1') {
|
|
42
|
+
return 'vercel-edge';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Netlify Edge
|
|
46
|
+
if (typeof globalThis.Netlify !== 'undefined') {
|
|
47
|
+
return 'netlify-edge';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Node.js
|
|
51
|
+
if (typeof process !== 'undefined' && process.versions?.node) {
|
|
52
|
+
return 'node';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return 'unknown';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Runtime capabilities
|
|
59
|
+
export interface RuntimeCapabilities {
|
|
60
|
+
hasFileSystem: boolean;
|
|
61
|
+
hasWebCrypto: boolean;
|
|
62
|
+
hasWebStreams: boolean;
|
|
63
|
+
hasFetch: boolean;
|
|
64
|
+
hasWebSocket: boolean;
|
|
65
|
+
hasKV: boolean;
|
|
66
|
+
hasCache: boolean;
|
|
67
|
+
maxExecutionTime: number; // ms, 0 = unlimited
|
|
68
|
+
maxMemory: number; // bytes, 0 = unlimited
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getRuntimeCapabilities(): RuntimeCapabilities {
|
|
72
|
+
const runtime = detectRuntime();
|
|
73
|
+
|
|
74
|
+
switch (runtime) {
|
|
75
|
+
case 'cloudflare':
|
|
76
|
+
return {
|
|
77
|
+
hasFileSystem: false,
|
|
78
|
+
hasWebCrypto: true,
|
|
79
|
+
hasWebStreams: true,
|
|
80
|
+
hasFetch: true,
|
|
81
|
+
hasWebSocket: true,
|
|
82
|
+
hasKV: true,
|
|
83
|
+
hasCache: true,
|
|
84
|
+
maxExecutionTime: 30000, // 30s for paid, 10ms for free
|
|
85
|
+
maxMemory: 128 * 1024 * 1024 // 128MB
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
case 'vercel-edge':
|
|
89
|
+
return {
|
|
90
|
+
hasFileSystem: false,
|
|
91
|
+
hasWebCrypto: true,
|
|
92
|
+
hasWebStreams: true,
|
|
93
|
+
hasFetch: true,
|
|
94
|
+
hasWebSocket: false,
|
|
95
|
+
hasKV: true, // Vercel KV
|
|
96
|
+
hasCache: true,
|
|
97
|
+
maxExecutionTime: 30000,
|
|
98
|
+
maxMemory: 128 * 1024 * 1024
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
case 'deno':
|
|
102
|
+
return {
|
|
103
|
+
hasFileSystem: true,
|
|
104
|
+
hasWebCrypto: true,
|
|
105
|
+
hasWebStreams: true,
|
|
106
|
+
hasFetch: true,
|
|
107
|
+
hasWebSocket: true,
|
|
108
|
+
hasKV: true, // Deno KV
|
|
109
|
+
hasCache: true,
|
|
110
|
+
maxExecutionTime: 0,
|
|
111
|
+
maxMemory: 0
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
case 'bun':
|
|
115
|
+
return {
|
|
116
|
+
hasFileSystem: true,
|
|
117
|
+
hasWebCrypto: true,
|
|
118
|
+
hasWebStreams: true,
|
|
119
|
+
hasFetch: true,
|
|
120
|
+
hasWebSocket: true,
|
|
121
|
+
hasKV: false,
|
|
122
|
+
hasCache: false,
|
|
123
|
+
maxExecutionTime: 0,
|
|
124
|
+
maxMemory: 0
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
case 'node':
|
|
128
|
+
default:
|
|
129
|
+
return {
|
|
130
|
+
hasFileSystem: true,
|
|
131
|
+
hasWebCrypto: true,
|
|
132
|
+
hasWebStreams: true,
|
|
133
|
+
hasFetch: true,
|
|
134
|
+
hasWebSocket: true,
|
|
135
|
+
hasKV: false,
|
|
136
|
+
hasCache: false,
|
|
137
|
+
maxExecutionTime: 0,
|
|
138
|
+
maxMemory: 0
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Runtime info
|
|
144
|
+
export const runtime = {
|
|
145
|
+
name: detectRuntime(),
|
|
146
|
+
capabilities: getRuntimeCapabilities(),
|
|
147
|
+
|
|
148
|
+
get isEdge(): boolean {
|
|
149
|
+
return ['cloudflare', 'vercel-edge', 'netlify-edge', 'fastly'].includes(this.name);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
get isServer(): boolean {
|
|
153
|
+
return ['node', 'bun', 'deno'].includes(this.name);
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
get supportsStreaming(): boolean {
|
|
157
|
+
return this.capabilities.hasWebStreams;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export default runtime;
|
package/core/index.ts
CHANGED
|
@@ -70,6 +70,54 @@ export {
|
|
|
70
70
|
builtinPlugins
|
|
71
71
|
} from './plugins/index.js';
|
|
72
72
|
|
|
73
|
+
// Edge Runtime
|
|
74
|
+
export {
|
|
75
|
+
// Runtime
|
|
76
|
+
detectRuntime,
|
|
77
|
+
getRuntimeCapabilities,
|
|
78
|
+
edgeRuntimeInfo,
|
|
79
|
+
// Fetch
|
|
80
|
+
FlexiRequest,
|
|
81
|
+
FlexiResponse,
|
|
82
|
+
FlexiHeaders,
|
|
83
|
+
// Handler
|
|
84
|
+
createEdgeApp,
|
|
85
|
+
// Cache
|
|
86
|
+
smartCache,
|
|
87
|
+
initCache,
|
|
88
|
+
cacheFunction,
|
|
89
|
+
unstable_cache,
|
|
90
|
+
revalidateTag,
|
|
91
|
+
revalidatePath,
|
|
92
|
+
reactCache,
|
|
93
|
+
// PPR
|
|
94
|
+
dynamic,
|
|
95
|
+
staticComponent,
|
|
96
|
+
PPRBoundary,
|
|
97
|
+
PPRShell,
|
|
98
|
+
prerenderWithPPR,
|
|
99
|
+
streamPPR,
|
|
100
|
+
pprFetch,
|
|
101
|
+
PPRLoading,
|
|
102
|
+
experimental_ppr,
|
|
103
|
+
// Default exports
|
|
104
|
+
createApp
|
|
105
|
+
} from './edge/index.js';
|
|
106
|
+
export type {
|
|
107
|
+
RuntimeEnvironment,
|
|
108
|
+
RuntimeCapabilities,
|
|
109
|
+
EdgeContext,
|
|
110
|
+
EdgeHandler,
|
|
111
|
+
EdgeMiddleware,
|
|
112
|
+
EdgeAppConfig,
|
|
113
|
+
CacheEntry,
|
|
114
|
+
CacheOptions,
|
|
115
|
+
PPRConfig,
|
|
116
|
+
PPRRenderResult,
|
|
117
|
+
PPRPageConfig,
|
|
118
|
+
GenerateStaticParams
|
|
119
|
+
} from './edge/index.js';
|
|
120
|
+
|
|
73
121
|
// Font Optimization
|
|
74
122
|
export {
|
|
75
123
|
createFont,
|
|
@@ -152,8 +200,16 @@ export {
|
|
|
152
200
|
} from './helpers.js';
|
|
153
201
|
export type { CookieOptions } from './helpers.js';
|
|
154
202
|
|
|
203
|
+
// DevTools
|
|
204
|
+
export {
|
|
205
|
+
devtools,
|
|
206
|
+
DevToolsOverlay,
|
|
207
|
+
initPerformanceMonitoring,
|
|
208
|
+
initNetworkInterceptor
|
|
209
|
+
} from './devtools/index.js';
|
|
210
|
+
|
|
155
211
|
// Version
|
|
156
|
-
export const VERSION = '2.
|
|
212
|
+
export const VERSION = '2.5.0';
|
|
157
213
|
|
|
158
214
|
// Default export
|
|
159
215
|
export default {
|