@flexireact/core 3.0.0 → 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.
- package/README.md +204 -52
- package/dist/cli/index.js +1514 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/client/index.js +373 -0
- package/dist/core/client/index.js.map +1 -0
- package/dist/core/index.js +6415 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/server/index.js +3094 -0
- package/dist/core/server/index.js.map +1 -0
- package/package.json +80 -80
- package/bin/flexireact.js +0 -23
- package/cli/generators.ts +0 -616
- package/cli/index.ts +0 -1182
- package/core/actions/index.ts +0 -364
- package/core/api.ts +0 -143
- package/core/build/index.ts +0 -425
- package/core/cli/logger.ts +0 -353
- package/core/client/Link.tsx +0 -345
- package/core/client/hydration.ts +0 -147
- package/core/client/index.ts +0 -12
- package/core/client/islands.ts +0 -143
- package/core/client/navigation.ts +0 -212
- package/core/client/runtime.ts +0 -52
- package/core/config.ts +0 -116
- package/core/context.ts +0 -83
- package/core/dev.ts +0 -47
- package/core/devtools/index.ts +0 -644
- package/core/edge/cache.ts +0 -344
- package/core/edge/fetch-polyfill.ts +0 -247
- package/core/edge/handler.ts +0 -248
- package/core/edge/index.ts +0 -81
- package/core/edge/ppr.ts +0 -264
- package/core/edge/runtime.ts +0 -161
- package/core/font/index.ts +0 -306
- package/core/helpers.ts +0 -494
- package/core/image/index.ts +0 -413
- package/core/index.ts +0 -218
- package/core/islands/index.ts +0 -293
- package/core/loader.ts +0 -111
- package/core/logger.ts +0 -242
- package/core/metadata/index.ts +0 -622
- package/core/middleware/index.ts +0 -416
- package/core/plugins/index.ts +0 -373
- package/core/render/index.ts +0 -1243
- package/core/render.ts +0 -136
- package/core/router/index.ts +0 -551
- package/core/router.ts +0 -141
- package/core/rsc/index.ts +0 -199
- package/core/server/index.ts +0 -779
- package/core/server.ts +0 -203
- package/core/ssg/index.ts +0 -346
- package/core/start-dev.ts +0 -6
- package/core/start-prod.ts +0 -6
- package/core/tsconfig.json +0 -30
- package/core/types.ts +0 -239
- package/core/utils.ts +0 -176
package/core/context.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FlexiReact Context System
|
|
3
|
-
* Provides request context and shared state for SSR/RSC
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
// Server-side request context
|
|
9
|
-
export const RequestContext = React.createContext(null);
|
|
10
|
-
|
|
11
|
-
// Route context for nested routes
|
|
12
|
-
export const RouteContext = React.createContext(null);
|
|
13
|
-
|
|
14
|
-
// Layout context
|
|
15
|
-
export const LayoutContext = React.createContext(null);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates a request context value
|
|
19
|
-
*/
|
|
20
|
-
export function createRequestContext(req, res, params = {}, query = {}) {
|
|
21
|
-
return {
|
|
22
|
-
req,
|
|
23
|
-
res,
|
|
24
|
-
params,
|
|
25
|
-
query,
|
|
26
|
-
url: req.url,
|
|
27
|
-
method: req.method,
|
|
28
|
-
headers: req.headers,
|
|
29
|
-
cookies: parseCookies(req.headers.cookie || '')
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Parse cookies from header string
|
|
35
|
-
*/
|
|
36
|
-
function parseCookies(cookieHeader) {
|
|
37
|
-
const cookies = {};
|
|
38
|
-
if (!cookieHeader) return cookies;
|
|
39
|
-
|
|
40
|
-
cookieHeader.split(';').forEach(cookie => {
|
|
41
|
-
const [name, ...rest] = cookie.split('=');
|
|
42
|
-
if (name) {
|
|
43
|
-
cookies[name.trim()] = rest.join('=').trim();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return cookies;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Hook to access request context (server-side only)
|
|
52
|
-
*/
|
|
53
|
-
export function useRequest() {
|
|
54
|
-
const context = React.useContext(RequestContext);
|
|
55
|
-
if (!context) {
|
|
56
|
-
throw new Error('useRequest must be used within a RequestContext provider');
|
|
57
|
-
}
|
|
58
|
-
return context;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Hook to access route params
|
|
63
|
-
*/
|
|
64
|
-
export function useParams() {
|
|
65
|
-
const context = React.useContext(RouteContext);
|
|
66
|
-
return context?.params || {};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Hook to access query parameters
|
|
71
|
-
*/
|
|
72
|
-
export function useQuery() {
|
|
73
|
-
const context = React.useContext(RouteContext);
|
|
74
|
-
return context?.query || {};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Hook to access current pathname
|
|
79
|
-
*/
|
|
80
|
-
export function usePathname() {
|
|
81
|
-
const context = React.useContext(RouteContext);
|
|
82
|
-
return context?.pathname || '/';
|
|
83
|
-
}
|
package/core/dev.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* FlexiReact Dev Server Launcher
|
|
5
|
-
* This script starts the server with the JSX loader enabled
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { spawn } from 'child_process';
|
|
9
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = path.dirname(__filename);
|
|
14
|
-
|
|
15
|
-
const serverPath = path.join(__dirname, 'server.js');
|
|
16
|
-
const loaderPath = path.join(__dirname, 'loader.js');
|
|
17
|
-
|
|
18
|
-
// Convert to file:// URLs for Windows compatibility
|
|
19
|
-
const loaderUrl = pathToFileURL(loaderPath).href;
|
|
20
|
-
|
|
21
|
-
// Start Node.js with the custom loader
|
|
22
|
-
const child = spawn(
|
|
23
|
-
process.execPath,
|
|
24
|
-
[
|
|
25
|
-
'--import',
|
|
26
|
-
`data:text/javascript,import { register } from 'node:module'; register('${loaderUrl.replace(/\\/g, '/')}', import.meta.url);`,
|
|
27
|
-
serverPath
|
|
28
|
-
],
|
|
29
|
-
{
|
|
30
|
-
stdio: 'inherit',
|
|
31
|
-
cwd: process.cwd(),
|
|
32
|
-
env: process.env
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
child.on('error', (error) => {
|
|
37
|
-
console.error('Failed to start server:', error);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
child.on('exit', (code) => {
|
|
42
|
-
process.exit(code || 0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Forward signals to child process
|
|
46
|
-
process.on('SIGINT', () => child.kill('SIGINT'));
|
|
47
|
-
process.on('SIGTERM', () => child.kill('SIGTERM'));
|