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.
Files changed (158) hide show
  1. package/README.md +4 -0
  2. package/bin/cli.js +673 -0
  3. package/dist/component.d.ts +1 -1
  4. package/dist/context.d.ts +4 -3
  5. package/dist/index.client.d.ts +11 -0
  6. package/dist/index.d.ts +9 -89
  7. package/dist/index.js +396 -67
  8. package/dist/index.js.map +1 -0
  9. package/dist/index.mjs +392 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/dist/jsx-runtime/jsx-runtime.d.ts +0 -1
  12. package/dist/jsx-runtime.d.ts +1 -1
  13. package/dist/renderer.d.ts +0 -10
  14. package/dist/server-renderer.d.ts +0 -3
  15. package/dist/server-types.d.ts +42 -0
  16. package/package.json +69 -41
  17. package/templates/basic-app/index.html +6 -6
  18. package/templates/basic-app/package.json +18 -7
  19. package/templates/basic-app/postcss.config.js +0 -1
  20. package/templates/basic-app/src/main.tsx +1 -10
  21. package/templates/basic-app/tailwind.config.js +2 -23
  22. package/templates/basic-app/tsconfig.json +4 -17
  23. package/templates/basic-app/vite.config.ts +3 -54
  24. package/templates/fullstack-app/api/hello.ts +18 -0
  25. package/templates/fullstack-app/api/users/[id].ts +73 -0
  26. package/templates/fullstack-app/api/users/index.ts +32 -0
  27. package/templates/fullstack-app/package.json +31 -0
  28. package/templates/fullstack-app/server.ts +46 -0
  29. package/templates/fullstack-app/src/pages/index.tsx +59 -0
  30. package/templates/ssr-template/vite.config.ts +1 -11
  31. package/bin/cli.cjs +0 -16
  32. package/bin/cli.mjs +0 -237
  33. package/dist/backend/api-utils.d.ts +0 -38
  34. package/dist/backend/api-utils.js +0 -135
  35. package/dist/backend/auth.d.ts +0 -134
  36. package/dist/backend/auth.js +0 -387
  37. package/dist/backend/database.d.ts +0 -27
  38. package/dist/backend/database.js +0 -91
  39. package/dist/backend/model.d.ts +0 -43
  40. package/dist/backend/model.js +0 -178
  41. package/dist/backend/router.d.ts +0 -27
  42. package/dist/backend/router.js +0 -137
  43. package/dist/backend/server.d.ts +0 -19
  44. package/dist/backend/server.js +0 -268
  45. package/dist/backend/types.d.ts +0 -217
  46. package/dist/backend/types.js +0 -1
  47. package/dist/batch.js +0 -22
  48. package/dist/cli/index.d.ts +0 -2
  49. package/dist/cli/index.js +0 -215
  50. package/dist/component.js +0 -84
  51. package/dist/components/Counter.js +0 -2
  52. package/dist/context.js +0 -18
  53. package/dist/frontend-hamroun.es.js +0 -1378
  54. package/dist/frontend-hamroun.umd.js +0 -66
  55. package/dist/hooks.js +0 -164
  56. package/dist/jsx-runtime/index.d.ts +0 -11
  57. package/dist/jsx-runtime/index.js +0 -19
  58. package/dist/jsx-runtime/jsx-dev-runtime.js +0 -1
  59. package/dist/jsx-runtime/jsx-runtime.js +0 -95
  60. package/dist/jsx-runtime.js +0 -192
  61. package/dist/renderer.js +0 -51
  62. package/dist/server-renderer.js +0 -102
  63. package/dist/types.js +0 -1
  64. package/dist/vdom.js +0 -27
  65. package/scripts/build-cli.js +0 -1199
  66. package/scripts/generate.js +0 -134
  67. package/src/backend/api-utils.ts +0 -178
  68. package/src/backend/auth.ts +0 -544
  69. package/src/backend/database.ts +0 -104
  70. package/src/backend/model.ts +0 -198
  71. package/src/backend/router.ts +0 -176
  72. package/src/backend/server.ts +0 -330
  73. package/src/backend/types.ts +0 -257
  74. package/src/batch.ts +0 -24
  75. package/src/cli/index.js +0 -554
  76. package/src/cli/index.ts +0 -257
  77. package/src/component.ts +0 -98
  78. package/src/components/Counter.tsx +0 -4
  79. package/src/context.ts +0 -29
  80. package/src/hooks.ts +0 -211
  81. package/src/index.ts +0 -144
  82. package/src/jsx-runtime/index.ts +0 -27
  83. package/src/jsx-runtime/jsx-dev-runtime.ts +0 -0
  84. package/src/jsx-runtime/jsx-runtime.ts +0 -104
  85. package/src/jsx-runtime.ts +0 -226
  86. package/src/renderer.ts +0 -55
  87. package/src/server-renderer.ts +0 -114
  88. package/src/shims.d.ts +0 -20
  89. package/src/types/bcrypt.d.ts +0 -30
  90. package/src/types/jsonwebtoken.d.ts +0 -55
  91. package/src/types.d.ts +0 -26
  92. package/src/types.ts +0 -21
  93. package/src/vdom.ts +0 -34
  94. package/templates/basic/.eslintignore +0 -5
  95. package/templates/basic/.eslintrc.json +0 -25
  96. package/templates/basic/docs/rapport_pfe.aux +0 -27
  97. package/templates/basic/docs/rapport_pfe.log +0 -399
  98. package/templates/basic/docs/rapport_pfe.out +0 -10
  99. package/templates/basic/docs/rapport_pfe.pdf +0 -0
  100. package/templates/basic/docs/rapport_pfe.tex +0 -68
  101. package/templates/basic/docs/rapport_pfe.toc +0 -14
  102. package/templates/basic/index.html +0 -12
  103. package/templates/basic/jsconfig.json +0 -14
  104. package/templates/basic/package.json +0 -18
  105. package/templates/basic/postcss.config.js +0 -7
  106. package/templates/basic/src/App.js +0 -105
  107. package/templates/basic/src/App.tsx +0 -65
  108. package/templates/basic/src/api.ts +0 -58
  109. package/templates/basic/src/components/Counter.tsx +0 -26
  110. package/templates/basic/src/components/Header.tsx +0 -9
  111. package/templates/basic/src/components/TodoList.tsx +0 -90
  112. package/templates/basic/src/main.css +0 -3
  113. package/templates/basic/src/main.js +0 -11
  114. package/templates/basic/src/main.ts +0 -20
  115. package/templates/basic/src/main.tsx +0 -144
  116. package/templates/basic/src/server.ts +0 -99
  117. package/templates/basic/tailwind.config.js +0 -32
  118. package/templates/basic/tsconfig.json +0 -20
  119. package/templates/basic/tsconfig.node.json +0 -10
  120. package/templates/basic/vite.config.js +0 -18
  121. package/templates/basic/vite.config.ts +0 -86
  122. package/templates/basic-app/src/App.js +0 -105
  123. package/templates/basic-app/src/App.tsx +0 -143
  124. package/templates/basic-app/src/api.ts +0 -58
  125. package/templates/basic-app/src/components/Counter.tsx +0 -26
  126. package/templates/basic-app/src/components/Header.tsx +0 -9
  127. package/templates/basic-app/src/components/TodoList.tsx +0 -90
  128. package/templates/basic-app/src/main.js +0 -10
  129. package/templates/basic-app/src/main.ts +0 -21
  130. package/templates/basic-app/src/react/index.ts +0 -35
  131. package/templates/basic-app/src/react/jsx-dev-runtime.ts +0 -13
  132. package/templates/basic-app/src/react/jsx-runtime.ts +0 -12
  133. package/templates/basic-app/src/server.ts +0 -99
  134. package/templates/basic-app/src/shims.ts +0 -9
  135. package/templates/basic-app/tsconfig.node.json +0 -10
  136. package/templates/basic-app/vite.config.js +0 -22
  137. package/templates/full-stack/.env.example +0 -11
  138. package/templates/full-stack/README.md +0 -51
  139. package/templates/full-stack/index.html +0 -12
  140. package/templates/full-stack/jsconfig.json +0 -14
  141. package/templates/full-stack/package.json +0 -21
  142. package/templates/full-stack/src/App.js +0 -105
  143. package/templates/full-stack/src/client/App.tsx +0 -50
  144. package/templates/full-stack/src/client/components/Header.tsx +0 -42
  145. package/templates/full-stack/src/client/components/UserList.tsx +0 -29
  146. package/templates/full-stack/src/client/main.tsx +0 -5
  147. package/templates/full-stack/src/main.css +0 -3
  148. package/templates/full-stack/src/main.js +0 -11
  149. package/templates/full-stack/src/main.ts +0 -20
  150. package/templates/full-stack/src/server/index.ts +0 -99
  151. package/templates/full-stack/src/server/routes/auth.ts +0 -39
  152. package/templates/full-stack/src/server/routes/users.ts +0 -48
  153. package/templates/full-stack/src/shims.ts +0 -9
  154. package/templates/full-stack/tsconfig.json +0 -20
  155. package/templates/full-stack/tsconfig.node.json +0 -10
  156. package/templates/full-stack/tsconfig.server.json +0 -15
  157. package/templates/full-stack/vite.config.js +0 -18
  158. 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
- }
@@ -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, '&amp;')
90
- .replace(/</g, '&lt;')
91
- .replace(/>/g, '&gt;')
92
- .replace(/"/g, '&quot;')
93
- .replace(/'/g, '&#39;');
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
- }