frontend-hamroun 1.2.16 → 1.2.17
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 +4 -0
- package/bin/cli.js +673 -0
- package/dist/component.d.ts +1 -1
- package/dist/context.d.ts +4 -3
- package/dist/index.client.d.ts +11 -0
- package/dist/index.d.ts +9 -89
- package/dist/index.js +396 -67
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +392 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts +0 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/renderer.d.ts +0 -10
- package/dist/server-renderer.d.ts +0 -3
- package/dist/server-types.d.ts +42 -0
- package/package.json +69 -41
- package/templates/basic-app/index.html +6 -6
- package/templates/basic-app/package.json +18 -7
- package/templates/basic-app/postcss.config.js +0 -1
- package/templates/basic-app/src/main.tsx +1 -10
- package/templates/basic-app/tailwind.config.js +2 -23
- package/templates/basic-app/tsconfig.json +4 -17
- package/templates/basic-app/vite.config.ts +3 -54
- package/templates/fullstack-app/api/hello.ts +18 -0
- package/templates/fullstack-app/api/users/[id].ts +73 -0
- package/templates/fullstack-app/api/users/index.ts +32 -0
- package/templates/fullstack-app/package.json +31 -0
- package/templates/fullstack-app/server.ts +46 -0
- package/templates/fullstack-app/src/pages/index.tsx +59 -0
- package/templates/ssr-template/vite.config.ts +1 -11
- package/bin/cli.cjs +0 -16
- package/bin/cli.mjs +0 -237
- package/dist/backend/api-utils.d.ts +0 -38
- package/dist/backend/api-utils.js +0 -135
- package/dist/backend/auth.d.ts +0 -134
- package/dist/backend/auth.js +0 -387
- package/dist/backend/database.d.ts +0 -27
- package/dist/backend/database.js +0 -91
- package/dist/backend/model.d.ts +0 -43
- package/dist/backend/model.js +0 -178
- package/dist/backend/router.d.ts +0 -27
- package/dist/backend/router.js +0 -137
- package/dist/backend/server.d.ts +0 -19
- package/dist/backend/server.js +0 -268
- package/dist/backend/types.d.ts +0 -217
- package/dist/backend/types.js +0 -1
- package/dist/batch.js +0 -22
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -215
- package/dist/component.js +0 -84
- package/dist/components/Counter.js +0 -2
- package/dist/context.js +0 -18
- package/dist/frontend-hamroun.es.js +0 -1378
- package/dist/frontend-hamroun.umd.js +0 -66
- package/dist/hooks.js +0 -164
- package/dist/jsx-runtime/index.d.ts +0 -11
- package/dist/jsx-runtime/index.js +0 -19
- package/dist/jsx-runtime/jsx-dev-runtime.js +0 -1
- package/dist/jsx-runtime/jsx-runtime.js +0 -95
- package/dist/jsx-runtime.js +0 -192
- package/dist/renderer.js +0 -51
- package/dist/server-renderer.js +0 -102
- package/dist/types.js +0 -1
- package/dist/vdom.js +0 -27
- package/scripts/build-cli.js +0 -1199
- package/scripts/generate.js +0 -134
- package/src/backend/api-utils.ts +0 -178
- package/src/backend/auth.ts +0 -544
- package/src/backend/database.ts +0 -104
- package/src/backend/model.ts +0 -198
- package/src/backend/router.ts +0 -176
- package/src/backend/server.ts +0 -330
- package/src/backend/types.ts +0 -257
- package/src/batch.ts +0 -24
- package/src/cli/index.js +0 -554
- package/src/cli/index.ts +0 -257
- package/src/component.ts +0 -98
- package/src/components/Counter.tsx +0 -4
- package/src/context.ts +0 -29
- package/src/hooks.ts +0 -211
- package/src/index.ts +0 -144
- package/src/jsx-runtime/index.ts +0 -27
- package/src/jsx-runtime/jsx-dev-runtime.ts +0 -0
- package/src/jsx-runtime/jsx-runtime.ts +0 -104
- package/src/jsx-runtime.ts +0 -226
- package/src/renderer.ts +0 -55
- package/src/server-renderer.ts +0 -114
- package/src/shims.d.ts +0 -20
- package/src/types/bcrypt.d.ts +0 -30
- package/src/types/jsonwebtoken.d.ts +0 -55
- package/src/types.d.ts +0 -26
- package/src/types.ts +0 -21
- package/src/vdom.ts +0 -34
- package/templates/basic/.eslintignore +0 -5
- package/templates/basic/.eslintrc.json +0 -25
- package/templates/basic/docs/rapport_pfe.aux +0 -27
- package/templates/basic/docs/rapport_pfe.log +0 -399
- package/templates/basic/docs/rapport_pfe.out +0 -10
- package/templates/basic/docs/rapport_pfe.pdf +0 -0
- package/templates/basic/docs/rapport_pfe.tex +0 -68
- package/templates/basic/docs/rapport_pfe.toc +0 -14
- package/templates/basic/index.html +0 -12
- package/templates/basic/jsconfig.json +0 -14
- package/templates/basic/package.json +0 -18
- package/templates/basic/postcss.config.js +0 -7
- package/templates/basic/src/App.js +0 -105
- package/templates/basic/src/App.tsx +0 -65
- package/templates/basic/src/api.ts +0 -58
- package/templates/basic/src/components/Counter.tsx +0 -26
- package/templates/basic/src/components/Header.tsx +0 -9
- package/templates/basic/src/components/TodoList.tsx +0 -90
- package/templates/basic/src/main.css +0 -3
- package/templates/basic/src/main.js +0 -11
- package/templates/basic/src/main.ts +0 -20
- package/templates/basic/src/main.tsx +0 -144
- package/templates/basic/src/server.ts +0 -99
- package/templates/basic/tailwind.config.js +0 -32
- package/templates/basic/tsconfig.json +0 -20
- package/templates/basic/tsconfig.node.json +0 -10
- package/templates/basic/vite.config.js +0 -18
- package/templates/basic/vite.config.ts +0 -86
- package/templates/basic-app/src/App.js +0 -105
- package/templates/basic-app/src/App.tsx +0 -143
- package/templates/basic-app/src/api.ts +0 -58
- package/templates/basic-app/src/components/Counter.tsx +0 -26
- package/templates/basic-app/src/components/Header.tsx +0 -9
- package/templates/basic-app/src/components/TodoList.tsx +0 -90
- package/templates/basic-app/src/main.js +0 -10
- package/templates/basic-app/src/main.ts +0 -21
- package/templates/basic-app/src/react/index.ts +0 -35
- package/templates/basic-app/src/react/jsx-dev-runtime.ts +0 -13
- package/templates/basic-app/src/react/jsx-runtime.ts +0 -12
- package/templates/basic-app/src/server.ts +0 -99
- package/templates/basic-app/src/shims.ts +0 -9
- package/templates/basic-app/tsconfig.node.json +0 -10
- package/templates/basic-app/vite.config.js +0 -22
- package/templates/full-stack/.env.example +0 -11
- package/templates/full-stack/README.md +0 -51
- package/templates/full-stack/index.html +0 -12
- package/templates/full-stack/jsconfig.json +0 -14
- package/templates/full-stack/package.json +0 -21
- package/templates/full-stack/src/App.js +0 -105
- package/templates/full-stack/src/client/App.tsx +0 -50
- package/templates/full-stack/src/client/components/Header.tsx +0 -42
- package/templates/full-stack/src/client/components/UserList.tsx +0 -29
- package/templates/full-stack/src/client/main.tsx +0 -5
- package/templates/full-stack/src/main.css +0 -3
- package/templates/full-stack/src/main.js +0 -11
- package/templates/full-stack/src/main.ts +0 -20
- package/templates/full-stack/src/server/index.ts +0 -99
- package/templates/full-stack/src/server/routes/auth.ts +0 -39
- package/templates/full-stack/src/server/routes/users.ts +0 -48
- package/templates/full-stack/src/shims.ts +0 -9
- package/templates/full-stack/tsconfig.json +0 -20
- package/templates/full-stack/tsconfig.node.json +0 -10
- package/templates/full-stack/tsconfig.server.json +0 -15
- package/templates/full-stack/vite.config.js +0 -18
- package/templates/full-stack/vite.config.ts +0 -85
package/dist/renderer.js
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
import { createElement } from './jsx-runtime';
|
2
|
-
import { prepareRender, finishRender, setRenderCallback } from './hooks';
|
3
|
-
import { batchUpdates } from './batch';
|
4
|
-
// Track hydration state
|
5
|
-
let isHydrating = false;
|
6
|
-
/**
|
7
|
-
* Hydrates a server-rendered component
|
8
|
-
* @param element The element to hydrate
|
9
|
-
* @param container The container element that contains server-rendered HTML
|
10
|
-
*/
|
11
|
-
export async function hydrate(element, container) {
|
12
|
-
isHydrating = true;
|
13
|
-
try {
|
14
|
-
await render(element, container);
|
15
|
-
}
|
16
|
-
finally {
|
17
|
-
isHydrating = false;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
/**
|
21
|
-
* Renders a component to the DOM
|
22
|
-
* @param element The element to render
|
23
|
-
* @param container The container to render into
|
24
|
-
*/
|
25
|
-
export async function render(element, container) {
|
26
|
-
console.log('Rendering to:', container.id || 'unnamed-container');
|
27
|
-
batchUpdates(async () => {
|
28
|
-
const rendererId = prepareRender();
|
29
|
-
try {
|
30
|
-
setRenderCallback(render, element, container);
|
31
|
-
const domNode = await createElement(element);
|
32
|
-
// Don't clear container if we're hydrating
|
33
|
-
if (!isHydrating) {
|
34
|
-
container.innerHTML = '';
|
35
|
-
}
|
36
|
-
// When hydrating, we should match and update existing nodes
|
37
|
-
// rather than appending new ones
|
38
|
-
if (isHydrating && container.firstChild) {
|
39
|
-
// During hydration, we assume the structure matches
|
40
|
-
// and just attach event handlers without replacing DOM
|
41
|
-
console.log('Hydrating existing DOM');
|
42
|
-
}
|
43
|
-
else {
|
44
|
-
container.appendChild(domNode);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
finally {
|
48
|
-
finishRender();
|
49
|
-
}
|
50
|
-
});
|
51
|
-
}
|
package/dist/server-renderer.js
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
import { prepareRender, finishRender, setRenderCallback } from './hooks';
|
2
|
-
/**
|
3
|
-
* Renders a component to a string
|
4
|
-
*/
|
5
|
-
export async function renderToString(element) {
|
6
|
-
// Setup render context
|
7
|
-
const rendererId = prepareRender();
|
8
|
-
setRenderCallback(() => { }, element, null);
|
9
|
-
try {
|
10
|
-
if (element == null)
|
11
|
-
return '';
|
12
|
-
if (typeof element === 'boolean')
|
13
|
-
return '';
|
14
|
-
if (typeof element === 'number' || typeof element === 'string') {
|
15
|
-
return escapeHtml(String(element));
|
16
|
-
}
|
17
|
-
if (Array.isArray(element)) {
|
18
|
-
const children = await Promise.all(element.map(renderToString));
|
19
|
-
return children.join('');
|
20
|
-
}
|
21
|
-
if ('type' in element && element.props !== undefined) {
|
22
|
-
const { type, props } = element;
|
23
|
-
// Handle function components
|
24
|
-
if (typeof type === 'function') {
|
25
|
-
try {
|
26
|
-
// Prepare new render context for the component
|
27
|
-
prepareRender();
|
28
|
-
const result = await type(props || {});
|
29
|
-
const html = await renderToString(result);
|
30
|
-
finishRender();
|
31
|
-
return html;
|
32
|
-
}
|
33
|
-
catch (error) {
|
34
|
-
console.error('Error rendering component:', error);
|
35
|
-
return '';
|
36
|
-
}
|
37
|
-
}
|
38
|
-
// Handle Fragment special case
|
39
|
-
if (type === Symbol.for('react.fragment') || type.name === 'Fragment') {
|
40
|
-
if (props.children) {
|
41
|
-
const children = Array.isArray(props.children) ? props.children : [props.children];
|
42
|
-
const renderedChildren = await Promise.all(children.map(renderToString));
|
43
|
-
return renderedChildren.join('');
|
44
|
-
}
|
45
|
-
return '';
|
46
|
-
}
|
47
|
-
// Handle regular elements
|
48
|
-
let html = `<${type}`;
|
49
|
-
// Add attributes, skipping internal ones like 'key'
|
50
|
-
for (const [key, value] of Object.entries(props || {})) {
|
51
|
-
if (key === 'children' || key === 'key')
|
52
|
-
continue;
|
53
|
-
if (key === 'className') {
|
54
|
-
html += ` class="${escapeHtml(String(value))}"`;
|
55
|
-
}
|
56
|
-
else if (key === 'style' && typeof value === 'object') {
|
57
|
-
html += ` style="${stringifyStyle(value || {})}"`;
|
58
|
-
}
|
59
|
-
else if (!key.startsWith('on')) {
|
60
|
-
html += ` ${key}="${escapeHtml(String(value))}"`;
|
61
|
-
}
|
62
|
-
}
|
63
|
-
// Handle self-closing tags
|
64
|
-
const voidElements = new Set([
|
65
|
-
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
66
|
-
'link', 'meta', 'param', 'source', 'track', 'wbr'
|
67
|
-
]);
|
68
|
-
if (voidElements.has(type)) {
|
69
|
-
return html + '/>';
|
70
|
-
}
|
71
|
-
html += '>';
|
72
|
-
// Add children
|
73
|
-
if (props?.children) {
|
74
|
-
const children = Array.isArray(props.children) ? props.children : [props.children];
|
75
|
-
for (const child of children) {
|
76
|
-
html += await renderToString(child);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
return html + `</${type}>`;
|
80
|
-
}
|
81
|
-
return escapeHtml(String(element));
|
82
|
-
}
|
83
|
-
finally {
|
84
|
-
finishRender();
|
85
|
-
}
|
86
|
-
}
|
87
|
-
function escapeHtml(str) {
|
88
|
-
return str
|
89
|
-
.replace(/&/g, '&')
|
90
|
-
.replace(/</g, '<')
|
91
|
-
.replace(/>/g, '>')
|
92
|
-
.replace(/"/g, '"')
|
93
|
-
.replace(/'/g, ''');
|
94
|
-
}
|
95
|
-
function stringifyStyle(style) {
|
96
|
-
return Object.entries(style)
|
97
|
-
.map(([key, value]) => `${hyphenate(key)}:${value}`)
|
98
|
-
.join(';');
|
99
|
-
}
|
100
|
-
function hyphenate(str) {
|
101
|
-
return str.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
102
|
-
}
|
package/dist/types.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/vdom.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
function arePropsEqual(oldProps, newProps) {
|
2
|
-
// Handle null/undefined props
|
3
|
-
oldProps = oldProps || {};
|
4
|
-
newProps = newProps || {};
|
5
|
-
const oldKeys = Object.keys(oldProps).filter(k => k !== 'children');
|
6
|
-
const newKeys = Object.keys(newProps).filter(k => k !== 'children');
|
7
|
-
if (oldKeys.length !== newKeys.length)
|
8
|
-
return false;
|
9
|
-
return oldKeys.every(key => oldProps[key] === newProps[key]);
|
10
|
-
}
|
11
|
-
export function diff(oldNode, newNode) {
|
12
|
-
if (oldNode == null || newNode == null)
|
13
|
-
return oldNode !== newNode;
|
14
|
-
if (typeof oldNode !== typeof newNode)
|
15
|
-
return true;
|
16
|
-
if (typeof newNode === 'string' || typeof newNode === 'number')
|
17
|
-
return oldNode !== newNode;
|
18
|
-
// Handle primitive values that are not objects
|
19
|
-
if (!oldNode.type || !newNode.type)
|
20
|
-
return oldNode !== newNode;
|
21
|
-
if (newNode.type !== oldNode.type)
|
22
|
-
return true;
|
23
|
-
return !arePropsEqual(oldNode.props, newNode.props);
|
24
|
-
}
|
25
|
-
export function shouldComponentUpdate(oldProps, newProps) {
|
26
|
-
return !arePropsEqual(oldProps, newProps);
|
27
|
-
}
|