@flexireact/core 3.0.1 → 3.0.2

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 (55) hide show
  1. package/dist/cli/index.js +1514 -0
  2. package/dist/cli/index.js.map +1 -0
  3. package/dist/core/client/index.js +373 -0
  4. package/dist/core/client/index.js.map +1 -0
  5. package/dist/core/index.js +6415 -0
  6. package/dist/core/index.js.map +1 -0
  7. package/dist/core/server/index.js +3094 -0
  8. package/dist/core/server/index.js.map +1 -0
  9. package/package.json +80 -80
  10. package/bin/flexireact.js +0 -23
  11. package/cli/generators.ts +0 -616
  12. package/cli/index.ts +0 -1182
  13. package/core/actions/index.ts +0 -364
  14. package/core/api.ts +0 -143
  15. package/core/build/index.ts +0 -425
  16. package/core/cli/logger.ts +0 -353
  17. package/core/client/Link.tsx +0 -345
  18. package/core/client/hydration.ts +0 -147
  19. package/core/client/index.ts +0 -12
  20. package/core/client/islands.ts +0 -143
  21. package/core/client/navigation.ts +0 -212
  22. package/core/client/runtime.ts +0 -52
  23. package/core/config.ts +0 -116
  24. package/core/context.ts +0 -83
  25. package/core/dev.ts +0 -47
  26. package/core/devtools/index.ts +0 -644
  27. package/core/edge/cache.ts +0 -344
  28. package/core/edge/fetch-polyfill.ts +0 -247
  29. package/core/edge/handler.ts +0 -248
  30. package/core/edge/index.ts +0 -81
  31. package/core/edge/ppr.ts +0 -264
  32. package/core/edge/runtime.ts +0 -161
  33. package/core/font/index.ts +0 -306
  34. package/core/helpers.ts +0 -494
  35. package/core/image/index.ts +0 -413
  36. package/core/index.ts +0 -218
  37. package/core/islands/index.ts +0 -293
  38. package/core/loader.ts +0 -111
  39. package/core/logger.ts +0 -242
  40. package/core/metadata/index.ts +0 -622
  41. package/core/middleware/index.ts +0 -416
  42. package/core/plugins/index.ts +0 -373
  43. package/core/render/index.ts +0 -1243
  44. package/core/render.ts +0 -136
  45. package/core/router/index.ts +0 -551
  46. package/core/router.ts +0 -141
  47. package/core/rsc/index.ts +0 -199
  48. package/core/server/index.ts +0 -779
  49. package/core/server.ts +0 -203
  50. package/core/ssg/index.ts +0 -346
  51. package/core/start-dev.ts +0 -6
  52. package/core/start-prod.ts +0 -6
  53. package/core/tsconfig.json +0 -30
  54. package/core/types.ts +0 -239
  55. package/core/utils.ts +0 -176
package/core/types.ts DELETED
@@ -1,239 +0,0 @@
1
- /**
2
- * FlexiReact Core Types
3
- */
4
-
5
- import type { IncomingMessage, ServerResponse } from 'http';
6
- import type { ReactNode, ComponentType } from 'react';
7
-
8
- // ============================================================================
9
- // Config Types
10
- // ============================================================================
11
-
12
- export interface FlexiConfig {
13
- /** Stylesheets to include */
14
- styles?: string[];
15
- /** Favicon path */
16
- favicon?: string;
17
- /** Server configuration */
18
- server?: {
19
- port?: number;
20
- host?: string;
21
- };
22
- /** Islands configuration */
23
- islands?: {
24
- enabled?: boolean;
25
- };
26
- /** Routing configuration */
27
- routing?: {
28
- type?: 'flexi' | 'app' | 'pages';
29
- };
30
- /** Pages directory */
31
- pagesDir?: string;
32
- /** Layouts directory */
33
- layoutsDir?: string;
34
- /** Public directory */
35
- publicDir?: string;
36
- }
37
-
38
- // ============================================================================
39
- // Router Types
40
- // ============================================================================
41
-
42
- export type RouteType = 'page' | 'api' | 'layout' | 'loading' | 'error' | 'not-found';
43
-
44
- export interface Route {
45
- type: RouteType;
46
- path: string;
47
- filePath: string;
48
- pattern: RegExp;
49
- segments: string[];
50
- layout?: string | null;
51
- loading?: string | null;
52
- error?: string | null;
53
- notFound?: string | null;
54
- template?: string | null;
55
- isAppRouter?: boolean;
56
- isFlexiRouter?: boolean;
57
- isServerComponent?: boolean;
58
- isClientComponent?: boolean;
59
- isIsland?: boolean;
60
- params?: Record<string, string>;
61
- }
62
-
63
- export interface RouteTree {
64
- pages: Route[];
65
- api: Route[];
66
- layouts: Map<string, string>;
67
- tree: Record<string, unknown>;
68
- appRoutes: Route[];
69
- flexiRoutes: Route[];
70
- rootLayout?: string;
71
- }
72
-
73
- export interface RouteMatch {
74
- route: Route;
75
- params: Record<string, string>;
76
- }
77
-
78
- // ============================================================================
79
- // Server Types
80
- // ============================================================================
81
-
82
- export type Request = IncomingMessage & {
83
- params?: Record<string, string>;
84
- query?: Record<string, string>;
85
- body?: unknown;
86
- json?: () => Promise<unknown>;
87
- };
88
-
89
- export type Response = ServerResponse & {
90
- json?: (data: unknown) => void;
91
- send?: (data: string) => void;
92
- status?: (code: number) => Response;
93
- };
94
-
95
- export type NextFunction = () => void | Promise<void>;
96
-
97
- export type Middleware = (
98
- req: Request,
99
- res: Response,
100
- next: NextFunction
101
- ) => void | Promise<void>;
102
-
103
- export type ApiHandler = (
104
- req: Request,
105
- res: Response
106
- ) => void | Promise<void>;
107
-
108
- // ============================================================================
109
- // Component Types
110
- // ============================================================================
111
-
112
- export interface PageProps {
113
- params?: Record<string, string>;
114
- searchParams?: Record<string, string>;
115
- }
116
-
117
- export interface LayoutProps {
118
- children: ReactNode;
119
- params?: Record<string, string>;
120
- }
121
-
122
- export interface ErrorProps {
123
- error: Error;
124
- reset: () => void;
125
- }
126
-
127
- export interface LoadingProps {}
128
-
129
- export interface NotFoundProps {}
130
-
131
- export type PageComponent = ComponentType<PageProps>;
132
- export type LayoutComponent = ComponentType<LayoutProps>;
133
- export type ErrorComponent = ComponentType<ErrorProps>;
134
- export type LoadingComponent = ComponentType<LoadingProps>;
135
- export type NotFoundComponent = ComponentType<NotFoundProps>;
136
-
137
- // ============================================================================
138
- // Island Types
139
- // ============================================================================
140
-
141
- export interface IslandConfig {
142
- name: string;
143
- component: ComponentType<unknown>;
144
- props?: Record<string, unknown>;
145
- hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'interaction';
146
- media?: string;
147
- }
148
-
149
- export interface IslandManifest {
150
- islands: Map<string, IslandConfig>;
151
- }
152
-
153
- // ============================================================================
154
- // Build Types
155
- // ============================================================================
156
-
157
- export interface BuildOptions {
158
- outDir?: string;
159
- minify?: boolean;
160
- sourcemap?: boolean;
161
- target?: string;
162
- }
163
-
164
- export interface BuildResult {
165
- success: boolean;
166
- errors?: string[];
167
- warnings?: string[];
168
- duration?: number;
169
- }
170
-
171
- // ============================================================================
172
- // SSG Types
173
- // ============================================================================
174
-
175
- export interface StaticPath {
176
- params: Record<string, string>;
177
- }
178
-
179
- export interface StaticProps {
180
- props: Record<string, unknown>;
181
- revalidate?: number | false;
182
- notFound?: boolean;
183
- redirect?: {
184
- destination: string;
185
- permanent?: boolean;
186
- };
187
- }
188
-
189
- export type GetStaticPaths = () => Promise<{
190
- paths: StaticPath[];
191
- fallback: boolean | 'blocking';
192
- }>;
193
-
194
- export type GetStaticProps = (context: {
195
- params?: Record<string, string>;
196
- }) => Promise<StaticProps>;
197
-
198
- // ============================================================================
199
- // Plugin Types
200
- // ============================================================================
201
-
202
- export interface Plugin {
203
- name: string;
204
- setup?: (config: FlexiConfig) => void | Promise<void>;
205
- transform?: (code: string, id: string) => string | null | Promise<string | null>;
206
- buildStart?: () => void | Promise<void>;
207
- buildEnd?: () => void | Promise<void>;
208
- }
209
-
210
- // ============================================================================
211
- // Metadata Types
212
- // ============================================================================
213
-
214
- export interface Metadata {
215
- title?: string;
216
- description?: string;
217
- keywords?: string[];
218
- author?: string;
219
- openGraph?: {
220
- title?: string;
221
- description?: string;
222
- image?: string;
223
- url?: string;
224
- type?: string;
225
- };
226
- twitter?: {
227
- card?: 'summary' | 'summary_large_image' | 'app' | 'player';
228
- title?: string;
229
- description?: string;
230
- image?: string;
231
- };
232
- }
233
-
234
- // ============================================================================
235
- // Re-exports
236
- // ============================================================================
237
-
238
- export type { IncomingMessage, ServerResponse } from 'http';
239
- export type { ReactNode, ComponentType } from 'react';
package/core/utils.ts DELETED
@@ -1,176 +0,0 @@
1
- /**
2
- * FlexiReact Utility Functions
3
- */
4
-
5
- import fs from 'fs';
6
- import path from 'path';
7
- import crypto from 'crypto';
8
-
9
- /**
10
- * Generates a unique hash for cache busting
11
- */
12
- export function generateHash(content) {
13
- return crypto.createHash('md5').update(content).digest('hex').slice(0, 8);
14
- }
15
-
16
- /**
17
- * Escapes HTML special characters
18
- */
19
- export function escapeHtml(str) {
20
- const htmlEntities = {
21
- '&': '&amp;',
22
- '<': '&lt;',
23
- '>': '&gt;',
24
- '"': '&quot;',
25
- "'": '&#39;'
26
- };
27
- return String(str).replace(/[&<>"']/g, char => htmlEntities[char]);
28
- }
29
-
30
- /**
31
- * Recursively finds all files matching a pattern
32
- */
33
- export function findFiles(dir, pattern, files = []) {
34
- if (!fs.existsSync(dir)) return files;
35
-
36
- const entries = fs.readdirSync(dir, { withFileTypes: true });
37
-
38
- for (const entry of entries) {
39
- const fullPath = path.join(dir, entry.name);
40
-
41
- if (entry.isDirectory()) {
42
- findFiles(fullPath, pattern, files);
43
- } else if (pattern.test(entry.name)) {
44
- files.push(fullPath);
45
- }
46
- }
47
-
48
- return files;
49
- }
50
-
51
- /**
52
- * Ensures a directory exists
53
- */
54
- export function ensureDir(dir) {
55
- if (!fs.existsSync(dir)) {
56
- fs.mkdirSync(dir, { recursive: true });
57
- }
58
- }
59
-
60
- /**
61
- * Cleans a directory
62
- */
63
- export function cleanDir(dir) {
64
- if (fs.existsSync(dir)) {
65
- fs.rmSync(dir, { recursive: true, force: true });
66
- }
67
- fs.mkdirSync(dir, { recursive: true });
68
- }
69
-
70
- /**
71
- * Copies a directory recursively
72
- */
73
- export function copyDir(src, dest) {
74
- ensureDir(dest);
75
-
76
- const entries = fs.readdirSync(src, { withFileTypes: true });
77
-
78
- for (const entry of entries) {
79
- const srcPath = path.join(src, entry.name);
80
- const destPath = path.join(dest, entry.name);
81
-
82
- if (entry.isDirectory()) {
83
- copyDir(srcPath, destPath);
84
- } else {
85
- fs.copyFileSync(srcPath, destPath);
86
- }
87
- }
88
- }
89
-
90
- /**
91
- * Debounce function for file watching
92
- */
93
- export function debounce(fn, delay) {
94
- let timeout;
95
- return (...args) => {
96
- clearTimeout(timeout);
97
- timeout = setTimeout(() => fn(...args), delay);
98
- };
99
- }
100
-
101
- /**
102
- * Formats bytes to human readable string
103
- */
104
- export function formatBytes(bytes) {
105
- if (bytes === 0) return '0 B';
106
- const k = 1024;
107
- const sizes = ['B', 'KB', 'MB', 'GB'];
108
- const i = Math.floor(Math.log(bytes) / Math.log(k));
109
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
110
- }
111
-
112
- /**
113
- * Formats milliseconds to human readable string
114
- */
115
- export function formatTime(ms) {
116
- if (ms < 1000) return `${ms}ms`;
117
- return `${(ms / 1000).toFixed(2)}s`;
118
- }
119
-
120
- /**
121
- * Creates a deferred promise
122
- */
123
- export function createDeferred() {
124
- let resolve, reject;
125
- const promise = new Promise((res, rej) => {
126
- resolve = res;
127
- reject = rej;
128
- });
129
- return { promise, resolve, reject };
130
- }
131
-
132
- /**
133
- * Sleep utility
134
- */
135
- export function sleep(ms) {
136
- return new Promise(resolve => setTimeout(resolve, ms));
137
- }
138
-
139
- /**
140
- * Check if a file is a server component (has 'use server' directive)
141
- */
142
- export function isServerComponent(filePath) {
143
- try {
144
- const content = fs.readFileSync(filePath, 'utf-8');
145
- const firstLine = content.split('\n')[0].trim();
146
- return firstLine === "'use server'" || firstLine === '"use server"';
147
- } catch {
148
- return false;
149
- }
150
- }
151
-
152
- /**
153
- * Check if a file is a client component (has 'use client' directive)
154
- */
155
- export function isClientComponent(filePath) {
156
- try {
157
- const content = fs.readFileSync(filePath, 'utf-8');
158
- const firstLine = content.split('\n')[0].trim();
159
- return firstLine === "'use client'" || firstLine === '"use client"';
160
- } catch {
161
- return false;
162
- }
163
- }
164
-
165
- /**
166
- * Check if a component is an island (has 'use island' directive)
167
- */
168
- export function isIsland(filePath) {
169
- try {
170
- const content = fs.readFileSync(filePath, 'utf-8');
171
- const firstLine = content.split('\n')[0].trim();
172
- return firstLine === "'use island'" || firstLine === '"use island"';
173
- } catch {
174
- return false;
175
- }
176
- }