dinou 4.0.5 → 4.0.6

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [4.0.6]
9
+
10
+ ### Fixed
11
+
12
+ - Execute page_functions on not_found page too in getJSX.
13
+
8
14
  ## [4.0.5]
9
15
 
10
16
  ### Fixed
@@ -11,7 +11,7 @@ async function getJSX(
11
11
  reqPath,
12
12
  query,
13
13
  isNotFound = null,
14
- isDevelopment = false
14
+ isDevelopment = false,
15
15
  ) {
16
16
  const srcFolder = path.resolve(process.cwd(), "src");
17
17
  const reqSegments = reqPath.split("/").filter(Boolean);
@@ -43,7 +43,7 @@ async function getJSX(
43
43
  const [filePath, dParams] = getFilePathAndDynamicParams(
44
44
  reqSegments,
45
45
  query,
46
- srcFolder
46
+ srcFolder,
47
47
  );
48
48
  pagePath = filePath;
49
49
  dynamicParams = dParams ?? {};
@@ -60,26 +60,43 @@ async function getJSX(
60
60
  srcFolder,
61
61
  "not_found",
62
62
  true,
63
- false
63
+ false,
64
64
  );
65
65
  if (!notFoundPath) {
66
66
  jsx = React.createElement(
67
67
  "div",
68
68
  null,
69
- `Page not found: no "page" file found for "${reqPath}"`
69
+ `Page not found: no "page" file found for "${reqPath}"`,
70
70
  );
71
71
  } else {
72
72
  const pageModule = await importModule(notFoundPath);
73
73
  const Page = pageModule.default ?? pageModule;
74
- jsx = React.createElement(Page, {
74
+ let props = {
75
75
  params: dParams ?? {},
76
- // searchParams: query,
77
- });
78
-
76
+ };
79
77
  const notFoundDir = path.dirname(notFoundPath);
78
+
79
+ const [pageFunctionsPath] = getFilePathAndDynamicParams(
80
+ reqSegments,
81
+ query,
82
+ notFoundDir,
83
+ "page_functions",
84
+ true,
85
+ true,
86
+ undefined,
87
+ reqSegments.length,
88
+ );
89
+ if (pageFunctionsPath) {
90
+ const pageFunctionsModule = await importModule(pageFunctionsPath);
91
+ const getProps = pageFunctionsModule.getProps;
92
+ pageFunctionsProps = await getProps?.(dParams ?? {});
93
+ props = { ...props, ...(pageFunctionsProps?.page ?? {}) };
94
+ }
95
+
96
+ jsx = React.createElement(Page, props);
80
97
  const noLayoutNotFoundPath = path.join(
81
98
  notFoundDir,
82
- `no_layout_not_found`
99
+ `no_layout_not_found`,
83
100
  );
84
101
  if (existsSync(noLayoutNotFoundPath)) {
85
102
  return jsx;
@@ -104,7 +121,7 @@ async function getJSX(
104
121
  true,
105
122
  true,
106
123
  undefined,
107
- reqSegments.length
124
+ reqSegments.length,
108
125
  );
109
126
  if (pageFunctionsPath) {
110
127
  const pageFunctionsModule = await importModule(pageFunctionsPath);
@@ -122,7 +139,7 @@ async function getJSX(
122
139
  query,
123
140
  srcFolder,
124
141
  "no_layout",
125
- false
142
+ false,
126
143
  )[0]
127
144
  ) {
128
145
  return jsx;
@@ -138,7 +155,7 @@ async function getJSX(
138
155
  undefined,
139
156
  0,
140
157
  {},
141
- true
158
+ true,
142
159
  );
143
160
 
144
161
  if (layouts && Array.isArray(layouts)) {
@@ -151,7 +168,7 @@ async function getJSX(
151
168
  {},
152
169
  layoutFolderPath,
153
170
  "reset_layout",
154
- false
171
+ false,
155
172
  )[0];
156
173
  const Layout = layoutModule.default ?? layoutModule;
157
174
  const updatedSlots = {};
@@ -175,7 +192,7 @@ async function getJSX(
175
192
  true, // withExtension
176
193
  true, // finalDestination
177
194
  undefined, // lastFound
178
- reqSegments.length
195
+ reqSegments.length,
179
196
  );
180
197
 
181
198
  if (slotErrorPath) {
@@ -196,13 +213,13 @@ async function getJSX(
196
213
  });
197
214
  } else {
198
215
  console.warn(
199
- `[Dinou] Slot @${slotName} failed and does not have error.tsx`
216
+ `[Dinou] Slot @${slotName} failed and does not have error.tsx`,
200
217
  );
201
218
  updatedSlotElement = null;
202
219
  }
203
220
  } else {
204
221
  console.error(
205
- `[Dinou] Could not locate the path of the slot @${slotName}`
222
+ `[Dinou] Could not locate the path of the slot @${slotName}`,
206
223
  );
207
224
  updatedSlotElement = null;
208
225
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou-ejected",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "main": "index.js",
5
5
  "private": true,
6
6
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "description": "Full-Stack React 19 framework with React Server Components, Server Functions, and Streaming SSR.",
5
5
  "main": "index.js",
6
6
  "bin": {