crelte 0.5.7 → 0.5.9

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 (182) hide show
  1. package/dist/blocks/Blocks.d.ts +36 -0
  2. package/dist/blocks/Blocks.d.ts.map +1 -1
  3. package/dist/blocks/Blocks.js +42 -0
  4. package/dist/blocks/Blocks.svelte +2 -16
  5. package/dist/blocks/Blocks.svelte.d.ts +20 -37
  6. package/dist/blocks/Blocks.svelte.d.ts.map +1 -1
  7. package/dist/blocks/index.d.ts +2 -2
  8. package/dist/blocks/index.d.ts.map +1 -1
  9. package/dist/blocks/index.js +2 -2
  10. package/dist/cookies/ServerCookies.d.ts +1 -1
  11. package/dist/cookies/ServerCookies.js +1 -1
  12. package/dist/cookies/index.d.ts +1 -1
  13. package/dist/crelte.d.ts +21 -10
  14. package/dist/crelte.d.ts.map +1 -1
  15. package/dist/index.d.ts +19 -14
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +17 -13
  18. package/dist/init/client.d.ts +2 -2
  19. package/dist/init/client.d.ts.map +1 -1
  20. package/dist/init/client.js +3 -2
  21. package/dist/init/server.d.ts +7 -6
  22. package/dist/init/server.d.ts.map +1 -1
  23. package/dist/init/server.js +6 -6
  24. package/dist/loadData/Globals.d.ts +3 -3
  25. package/dist/loadData/Globals.js +3 -3
  26. package/dist/loadData/loadData.d.ts +8 -18
  27. package/dist/loadData/loadData.d.ts.map +1 -1
  28. package/dist/loadData/loadData.js +2 -2
  29. package/dist/node/index.d.ts +5 -0
  30. package/dist/node/index.d.ts.map +1 -1
  31. package/dist/node/index.js +84 -35
  32. package/dist/plugins/Events.d.ts +4 -4
  33. package/dist/plugins/Plugins.d.ts +2 -2
  34. package/dist/plugins/index.d.ts +2 -3
  35. package/dist/plugins/index.d.ts.map +1 -1
  36. package/dist/plugins/index.js +2 -1
  37. package/dist/queries/Queries.d.ts +9 -0
  38. package/dist/queries/Queries.d.ts.map +1 -1
  39. package/dist/queries/Queries.js +29 -17
  40. package/dist/queries/QueryError.d.ts +2 -0
  41. package/dist/queries/QueryError.d.ts.map +1 -1
  42. package/dist/queries/QueryError.js +6 -1
  43. package/dist/queries/gql.d.ts +2 -2
  44. package/dist/queries/gql.js +2 -2
  45. package/dist/queries/index.d.ts +7 -5
  46. package/dist/queries/index.d.ts.map +1 -1
  47. package/dist/queries/vars.d.ts +7 -7
  48. package/dist/queries/vars.d.ts.map +1 -1
  49. package/dist/queries/vars.js +10 -8
  50. package/dist/routing/LoadRunner.d.ts +1 -1
  51. package/dist/routing/LoadRunner.js +1 -1
  52. package/dist/routing/index.d.ts +4 -4
  53. package/dist/routing/index.d.ts.map +1 -1
  54. package/dist/routing/route/BaseRoute.d.ts +25 -25
  55. package/dist/routing/route/BaseRoute.js +24 -24
  56. package/dist/routing/route/Request.d.ts +4 -4
  57. package/dist/routing/route/Request.js +4 -4
  58. package/dist/routing/route/Route.d.ts +2 -2
  59. package/dist/routing/route/Route.js +2 -2
  60. package/dist/routing/router/BaseRouter.d.ts +4 -4
  61. package/dist/routing/router/BaseRouter.js +3 -3
  62. package/dist/routing/router/ClientRouter.d.ts +1 -1
  63. package/dist/routing/router/ClientRouter.js +1 -1
  64. package/dist/routing/router/Router.d.ts +27 -25
  65. package/dist/routing/router/Router.d.ts.map +1 -1
  66. package/dist/routing/router/Router.js +24 -21
  67. package/dist/routing/router/ServerRouter.d.ts +1 -1
  68. package/dist/routing/router/ServerRouter.js +1 -1
  69. package/dist/server/CrelteServer.d.ts +5 -5
  70. package/dist/server/CrelteServer.d.ts.map +1 -1
  71. package/dist/server/CrelteServer.js +4 -4
  72. package/dist/server/Request.d.ts +7 -1
  73. package/dist/server/Request.d.ts.map +1 -1
  74. package/dist/server/Request.js +7 -1
  75. package/dist/server/ServerRouter.d.ts +1 -1
  76. package/dist/server/ServerRouter.d.ts.map +1 -1
  77. package/dist/server/index.d.ts +4 -4
  78. package/dist/server/index.d.ts.map +1 -1
  79. package/dist/server/index.js +1 -1
  80. package/dist/server/queries/queries.d.ts.map +1 -1
  81. package/dist/server/queries/queries.js +14 -1
  82. package/dist/server/queries/routes.d.ts +10 -1
  83. package/dist/server/queries/routes.d.ts.map +1 -1
  84. package/dist/server/queries/routes.js +22 -5
  85. package/dist/server/shared.d.ts +7 -13
  86. package/dist/server/shared.d.ts.map +1 -1
  87. package/dist/server/shared.js +14 -16
  88. package/dist/ssr/SsrCache.d.ts +56 -4
  89. package/dist/ssr/SsrCache.d.ts.map +1 -1
  90. package/dist/ssr/SsrCache.js +94 -20
  91. package/dist/std/index.d.ts +13 -0
  92. package/dist/std/index.d.ts.map +1 -1
  93. package/dist/std/index.js +13 -0
  94. package/dist/std/rand/index.d.ts +34 -0
  95. package/dist/std/rand/index.d.ts.map +1 -0
  96. package/dist/std/rand/index.js +45 -0
  97. package/dist/std/rand/internal.d.ts +8 -0
  98. package/dist/std/rand/internal.d.ts.map +1 -0
  99. package/dist/std/rand/internal.js +15 -0
  100. package/dist/std/stores/Writable.d.ts +1 -1
  101. package/dist/std/stores/Writable.js +1 -1
  102. package/dist/translations/index.d.ts +28 -0
  103. package/dist/translations/index.d.ts.map +1 -0
  104. package/dist/translations/index.js +31 -0
  105. package/dist/translations/loadTranslations.d.ts +23 -0
  106. package/dist/translations/loadTranslations.d.ts.map +1 -0
  107. package/dist/translations/loadTranslations.js +26 -0
  108. package/dist/translations/loader/GlobalLoader.d.ts +34 -0
  109. package/dist/translations/loader/GlobalLoader.d.ts.map +1 -0
  110. package/dist/translations/loader/GlobalLoader.js +45 -0
  111. package/dist/translations/loader/fileLoader/ClientFileLoader.d.ts +10 -0
  112. package/dist/translations/loader/fileLoader/ClientFileLoader.d.ts.map +1 -0
  113. package/dist/translations/loader/fileLoader/ClientFileLoader.js +24 -0
  114. package/dist/translations/loader/fileLoader/NodeFileLoader.d.ts +9 -0
  115. package/dist/translations/loader/fileLoader/NodeFileLoader.d.ts.map +1 -0
  116. package/dist/translations/loader/fileLoader/NodeFileLoader.js +21 -0
  117. package/dist/translations/loader/fileLoader/fileLoader.d.ts +5 -0
  118. package/dist/translations/loader/fileLoader/fileLoader.d.ts.map +1 -0
  119. package/dist/translations/loader/fileLoader/fileLoader.js +16 -0
  120. package/dist/translations/loader/index.d.ts +7 -0
  121. package/dist/translations/loader/index.d.ts.map +1 -0
  122. package/dist/translations/loader/index.js +1 -0
  123. package/dist/translations/translationsPlugin.d.ts +64 -0
  124. package/dist/translations/translationsPlugin.d.ts.map +1 -0
  125. package/dist/translations/translationsPlugin.js +110 -0
  126. package/dist/translations/utils.d.ts +8 -0
  127. package/dist/translations/utils.d.ts.map +1 -0
  128. package/dist/translations/utils.js +15 -0
  129. package/dist/vite/index.d.ts.map +1 -1
  130. package/dist/vite/index.js +30 -38
  131. package/package.json +9 -1
  132. package/src/blocks/Blocks.svelte +4 -63
  133. package/src/blocks/Blocks.ts +53 -0
  134. package/src/blocks/index.ts +2 -2
  135. package/src/cookies/ServerCookies.ts +1 -1
  136. package/src/cookies/index.ts +1 -1
  137. package/src/crelte.ts +21 -10
  138. package/src/index.ts +19 -14
  139. package/src/init/client.ts +3 -2
  140. package/src/init/server.ts +14 -8
  141. package/src/loadData/Globals.ts +3 -3
  142. package/src/loadData/loadData.ts +8 -18
  143. package/src/node/index.ts +100 -39
  144. package/src/plugins/Events.ts +4 -4
  145. package/src/plugins/Plugins.ts +2 -2
  146. package/src/plugins/index.ts +2 -3
  147. package/src/queries/Queries.ts +35 -18
  148. package/src/queries/QueryError.ts +10 -1
  149. package/src/queries/gql.ts +2 -2
  150. package/src/queries/index.ts +7 -4
  151. package/src/queries/vars.ts +12 -8
  152. package/src/routing/LoadRunner.ts +1 -1
  153. package/src/routing/index.ts +13 -3
  154. package/src/routing/route/BaseRoute.ts +25 -25
  155. package/src/routing/route/Request.ts +4 -4
  156. package/src/routing/route/Route.ts +2 -2
  157. package/src/routing/router/BaseRouter.ts +4 -4
  158. package/src/routing/router/ClientRouter.ts +1 -1
  159. package/src/routing/router/Router.ts +28 -25
  160. package/src/routing/router/ServerRouter.ts +1 -1
  161. package/src/server/CrelteServer.ts +5 -5
  162. package/src/server/Request.ts +7 -1
  163. package/src/server/ServerRouter.ts +1 -2
  164. package/src/server/index.ts +17 -3
  165. package/src/server/queries/queries.ts +21 -3
  166. package/src/server/queries/routes.ts +41 -10
  167. package/src/server/shared.ts +28 -33
  168. package/src/ssr/SsrCache.ts +104 -22
  169. package/src/std/index.ts +14 -0
  170. package/src/std/rand/index.ts +55 -0
  171. package/src/std/rand/internal.ts +17 -0
  172. package/src/std/stores/Writable.ts +1 -1
  173. package/src/translations/index.ts +56 -0
  174. package/src/translations/loadTranslations.ts +33 -0
  175. package/src/translations/loader/GlobalLoader.ts +62 -0
  176. package/src/translations/loader/fileLoader/ClientFileLoader.ts +40 -0
  177. package/src/translations/loader/fileLoader/NodeFileLoader.ts +32 -0
  178. package/src/translations/loader/fileLoader/fileLoader.ts +19 -0
  179. package/src/translations/loader/index.ts +8 -0
  180. package/src/translations/translationsPlugin.ts +145 -0
  181. package/src/translations/utils.ts +17 -0
  182. package/src/vite/index.ts +43 -39
@@ -102,6 +102,59 @@ export class BlockModules {
102
102
  }
103
103
  }
104
104
 
105
+ /**
106
+ * Create a BlockModules instance from modules
107
+ *
108
+ * #### Example
109
+ * ```ts
110
+ * const mods = blockModules(
111
+ * import.meta.glob('./contentDetail/*.svelte', { eager: true })
112
+ );
113
+ * ```
114
+ *
115
+ * #### Example with alias
116
+ * ```ts
117
+ * const mods = blockModules(
118
+ * import.meta.glob('./contentDetail/*.svelte'),
119
+ * {
120
+ * alias: {
121
+ * fakename: 'filename',
122
+ * }
123
+ * }
124
+ * );
125
+ * ```
126
+ */
127
+ export function blockModules(
128
+ modules: Record<string, AsyncModule>,
129
+ opts: BlockModulesOptions = {},
130
+ ): BlockModules {
131
+ return new BlockModules(modules, opts);
132
+ }
133
+
134
+ /**
135
+ * Load blocks data
136
+ *
137
+ * #### Example
138
+ * ```ts
139
+ * const mods = blockModules(import.meta.glob('./contentDetail/*.svelte'));
140
+ *
141
+ * export const loadData = {
142
+ * blocks: (cr, entry) => loadBlocksData(cr, entry.blocks, mods)
143
+ * };
144
+ * ```
145
+ */
146
+ export async function loadBlocksData(
147
+ cr: CrelteRequest,
148
+ blocks: any[],
149
+ modules: BlockModules,
150
+ ): Promise<Blocks> {
151
+ const nBlocks = await newBlocks(blocks, modules);
152
+
153
+ await nBlocks.loadData(cr);
154
+
155
+ return nBlocks;
156
+ }
157
+
105
158
  /**
106
159
  * Creates a new Blocks instance
107
160
  *
@@ -1,4 +1,4 @@
1
- import Blocks, { blockModules, loadBlocksData } from './Blocks.svelte';
1
+ import Blocks from './Blocks.svelte';
2
2
  import type {
3
3
  BlockModules,
4
4
  BlockModulesOptions,
@@ -7,7 +7,7 @@ import type {
7
7
  BlockOptions,
8
8
  } from './Blocks.js';
9
9
  import type BlocksInstance from './Blocks.js';
10
- import { newBlocks } from './Blocks.js';
10
+ import { newBlocks, blockModules, loadBlocksData } from './Blocks.js';
11
11
 
12
12
  export type {
13
13
  BlocksInstance,
@@ -2,7 +2,7 @@ import { Cookies, RemoveOptions, SetOptions } from './index.js';
2
2
  import { parseCookies, type SetCookie, setCookieToString } from './utils.js';
3
3
 
4
4
  /**
5
- * ## Warning
5
+ * #### Warning
6
6
  * This is not stable and should only be used internally by crelte
7
7
  */
8
8
  export default class ServerCookies implements Cookies {
@@ -17,7 +17,7 @@ export interface Cookies {
17
17
  /**
18
18
  * sets the value of the cookie
19
19
  *
20
- * ## Note
20
+ * #### Note
21
21
  * path defaults to '/'
22
22
  */
23
23
  set(name: string, value: string, opts?: SetOptions): void;
package/src/crelte.ts CHANGED
@@ -10,6 +10,7 @@ import { Readable } from './std/stores/index.js';
10
10
  import { Entry } from './loadData/index.js';
11
11
  import { urlWithPath } from './utils.js';
12
12
 
13
+ /** The type for the app.config object */
13
14
  export type Config = {
14
15
  /**
15
16
  * Preload pages on mouse over
@@ -67,7 +68,7 @@ export function configWithDefaults(config: Config = {}): Required<Config> {
67
68
  * In svelte contexts for each of these functions and classes there
68
69
  * should be a getter function like `getCrelte()` or `getRouter()`.
69
70
  *
70
- * ## Note
71
+ * #### Note
71
72
  * Plugins and other instances could modify this type, so when extending cloning
72
73
  * or similar use the spread operator instead of naming all "properties".
73
74
  */
@@ -130,7 +131,7 @@ export type Crelte = {
130
131
  /**
131
132
  * returns the frontend url with an optional path
132
133
  *
133
- * ## Note
134
+ * #### Note
134
135
  * On the client this will always be the current origin
135
136
  * and on the server it will be the from the env `FRONTEND_URL` env
136
137
  * variable
@@ -140,7 +141,7 @@ export type Crelte = {
140
141
  /**
141
142
  * returns the backend url with an optional path
142
143
  *
143
- * ## Note
144
+ * #### Note
144
145
  * For the origin the `ENDPOINT_URL` env variable is used
145
146
  */
146
147
  backendUrl(path?: string): URL;
@@ -148,7 +149,7 @@ export type Crelte = {
148
149
  /**
149
150
  * returns a store which contains a globalSet
150
151
  *
151
- * ## Note
152
+ * #### Note
152
153
  * This only works in loadData, in loadGlobalData this will
153
154
  * always return null. In that context you should use
154
155
  * `CrelteRequest.getGlobalAsync`
@@ -159,7 +160,7 @@ export type Crelte = {
159
160
  * returns a new CrelteRequest instance either with the current
160
161
  * route or a provided one
161
162
  *
162
- * ## Note
163
+ * #### Note
163
164
  * This is useful if you want to create a stateful crelte
164
165
  * to use in loadData context
165
166
  */
@@ -186,7 +187,7 @@ export type Crelte = {
186
187
  * In svelte contexts for each of these functions and classes there
187
188
  * should be a getter function like `getCrelte()` or `getRouter()`.
188
189
  *
189
- * ## Note
190
+ * #### Note
190
191
  * Plugins and other instances could modify this type, so when extending cloning
191
192
  * or similar use the spread operator instead of naming all "properties".
192
193
  */
@@ -199,7 +200,7 @@ export type CrelteWithRoute = Crelte & {
199
200
  /**
200
201
  * returns a store which contains a globalSet
201
202
  *
202
- * ## Note
203
+ * #### Note
203
204
  * This only works in loadData, in loadGlobalData this will
204
205
  * always return null. In that context you should use
205
206
  * `CrelteRequest.getGlobalAsync`
@@ -207,6 +208,16 @@ export type CrelteWithRoute = Crelte & {
207
208
  getGlobal<T = any>(name: string): Readable<T> | null;
208
209
  };
209
210
 
211
+ /**
212
+ * This is Crelte a container of useful features and functions.
213
+ *
214
+ * In svelte contexts for each of these functions and classes there
215
+ * should be a getter function like `getCrelte()` or `getRouter()`.
216
+ *
217
+ * #### Note
218
+ * Plugins and other instances could modify this type, so when extending cloning
219
+ * or similar use the spread operator instead of naming all "properties".
220
+ */
210
221
  export type CrelteRequest = Crelte & {
211
222
  /**
212
223
  * The current request
@@ -216,7 +227,7 @@ export type CrelteRequest = Crelte & {
216
227
  /**
217
228
  * Easy access to this.req.site
218
229
  *
219
- * ## Note
230
+ * #### Note
220
231
  * The site might not always match with the current route
221
232
  * but be the site default site or one that matches the
222
233
  * users language.
@@ -226,7 +237,7 @@ export type CrelteRequest = Crelte & {
226
237
  /**
227
238
  * returns a globalSet
228
239
  *
229
- * ## Note
240
+ * #### Note
230
241
  * This only works in loadData, in loadGlobalData this will
231
242
  * always return null. In that context you should use
232
243
  * `.getGlobalAsync`
@@ -236,7 +247,7 @@ export type CrelteRequest = Crelte & {
236
247
  /**
237
248
  * Get a globalSet and wait until it is loaded
238
249
  *
239
- * ## Note
250
+ * #### Note
240
251
  * This is only useful in loadGlobalData in all other cases
241
252
  * you can use `.getGlobal` which does not return a Promise
242
253
  */
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ export {
30
30
  type LoadDataArray,
31
31
  };
32
32
 
33
+ /** The type for the app.init function */
33
34
  export type Init = (crelte: Crelte) => void;
34
35
 
35
36
  function innerGetCrelte(): Crelte {
@@ -39,7 +40,7 @@ function innerGetCrelte(): Crelte {
39
40
  /**
40
41
  * Get Crelte from the current context
41
42
  *
42
- * ## Note
43
+ * #### Note
43
44
  * This only works during component initialisation.
44
45
  */
45
46
  export function getCrelte(): CrelteWithRoute {
@@ -60,7 +61,7 @@ export function getCrelte(): CrelteWithRoute {
60
61
  /**
61
62
  * Get the router from the current context
62
63
  *
63
- * ## Note
64
+ * #### Note
64
65
  * This only works during component initialisation.
65
66
  */
66
67
  export function getRouter(): Router {
@@ -70,7 +71,7 @@ export function getRouter(): Router {
70
71
  /**
71
72
  * Get the SSR cache from the current context
72
73
  *
73
- * ## Note
74
+ * #### Note
74
75
  * This only works during component initialisation.
75
76
  */
76
77
  export function getSsrCache(): SsrCache {
@@ -80,7 +81,7 @@ export function getSsrCache(): SsrCache {
80
81
  /**
81
82
  * Get the Queries from the current context
82
83
  *
83
- * ## Note
84
+ * #### Note
84
85
  * This only works during component initialisation.
85
86
  */
86
87
  export function getQueries(): Queries {
@@ -90,7 +91,7 @@ export function getQueries(): Queries {
90
91
  /**
91
92
  * Get a store with the current route
92
93
  *
93
- * ## Note
94
+ * #### Note
94
95
  * This only works during component initialisation.
95
96
  */
96
97
  export function getRoute(): Readable<Route> {
@@ -100,7 +101,7 @@ export function getRoute(): Readable<Route> {
100
101
  /**
101
102
  * Get a store with the current site
102
103
  *
103
- * ## Note
104
+ * #### Note
104
105
  * This only works during component initialisation.
105
106
  */
106
107
  export function getSite(): Readable<Site> {
@@ -110,7 +111,7 @@ export function getSite(): Readable<Site> {
110
111
  /**
111
112
  * Get a store with the current entry
112
113
  *
113
- * ## Note
114
+ * #### Note
114
115
  * This only works during component initialisation.
115
116
  */
116
117
  export function getEntry(): Readable<Entry> {
@@ -122,7 +123,7 @@ export function getEntry(): Readable<Entry> {
122
123
  * All env variables need to start with VITE_
123
124
  * except ENDPOINT_URL, CRAFT_WEB_URL and FRONTEND_URL
124
125
  *
125
- * ## Note
126
+ * #### Note
126
127
  * This only works during component initialisation.
127
128
  */
128
129
  export function getEnv(name: 'ENDPOINT_URL'): string;
@@ -136,7 +137,7 @@ export function getEnv(name: string): string | null {
136
137
  /**
137
138
  * returns a store which indicates if the a page is loading
138
139
  *
139
- * ## Note
140
+ * #### Note
140
141
  * This only works during component initialisation.
141
142
  */
142
143
  export function getLoading(): Readable<boolean> {
@@ -146,7 +147,7 @@ export function getLoading(): Readable<boolean> {
146
147
  /**
147
148
  * returns a store which indicates the loading progress between 0 and 1
148
149
  *
149
- * ## Note
150
+ * #### Note
150
151
  * This only works during component initialisation.
151
152
  */
152
153
  export function getLoadingProgress(): Readable<number> {
@@ -156,7 +157,7 @@ export function getLoadingProgress(): Readable<number> {
156
157
  /**
157
158
  * returns a store which contains a globalSet
158
159
  *
159
- * ## Note
160
+ * #### Note
160
161
  * This only works during component initialisation.
161
162
  */
162
163
  export function getGlobal<T = any>(name: string): Readable<T> | null {
@@ -166,7 +167,7 @@ export function getGlobal<T = any>(name: string): Readable<T> | null {
166
167
  /**
167
168
  * returns the cookies instance
168
169
  *
169
- * ## Note
170
+ * #### Note
170
171
  * This only works during component initialisation.
171
172
  */
172
173
  export function getCookies(): Cookies {
@@ -176,7 +177,9 @@ export function getCookies(): Cookies {
176
177
  /**
177
178
  * Listen for route changes
178
179
  *
179
- * ## Note
180
+ * route: {@link Route}
181
+ *
182
+ * #### Note
180
183
  * This only works during component initialisation.
181
184
  */
182
185
  export function onRoute(fn: (route: Route) => void) {
@@ -188,7 +191,9 @@ export function onRoute(fn: (route: Route) => void) {
188
191
  /**
189
192
  * Listen for requests
190
193
  *
191
- * ## Note
194
+ * cr: {@link CrelteRequest}
195
+ *
196
+ * #### Note
192
197
  * This only works during component initialisation.
193
198
  */
194
199
  export function onRequest(fn: (cr: CrelteRequest) => void) {
@@ -33,8 +33,8 @@ export type MainData = {
33
33
  /**
34
34
  * The main function to start the client side rendering
35
35
  *
36
- * ## Example
37
- * ```
36
+ * #### Example
37
+ * ```js
38
38
  * import * as app from './App.svelte';
39
39
  * import * as errorPage from './Error.svelte';
40
40
  * import entryQuery from './queries/entry.graphql';
@@ -55,6 +55,7 @@ export async function main(data: MainData) {
55
55
 
56
56
  const config = configWithDefaults(data.app.config ?? {});
57
57
  const ssrCache = new SsrCache();
58
+ ssrCache.z_importFromHead();
58
59
 
59
60
  // since cors could cause an issue we wan't to override the FRONTEND_URL
60
61
  // env variable, since the server will be reachable on any domain
@@ -18,7 +18,13 @@ import Events from '../plugins/Events.js';
18
18
  import Globals from '../loadData/Globals.js';
19
19
  import { Router } from '../routing/index.js';
20
20
  import { Writable } from '../std/stores/index.js';
21
- import { RenderRequest, RenderResponse } from '../server/shared.js';
21
+ import {
22
+ RenderErrorRequest,
23
+ RenderRequest,
24
+ RenderResponse,
25
+ } from '../server/shared.js';
26
+
27
+ export { type RenderRequest, type RenderResponse } from '../server/shared.js';
22
28
 
23
29
  export type ServerData = RenderRequest;
24
30
 
@@ -36,8 +42,8 @@ export type MainData = {
36
42
  /**
37
43
  * The main function to start the server side rendering
38
44
  *
39
- * ## Example
40
- * ```
45
+ * #### Example
46
+ * ```js
41
47
  * import * as app from './App.svelte';
42
48
  * import entryQuery from './queries/entry.graphql';
43
49
  * import globalQuery from './queries/global.graphql';
@@ -140,7 +146,7 @@ export async function main(data: MainData): Promise<RenderResponse> {
140
146
  });
141
147
 
142
148
  head += ssrComponents.toHead(data.serverData.ssrManifest);
143
- head += crelte.ssrCache.exportToHead();
149
+ head += crelte.ssrCache.z_exportToHead();
144
150
 
145
151
  let htmlTemplate = data.serverData.htmlTemplate;
146
152
  htmlTemplate = htmlTemplate.replace(
@@ -178,15 +184,15 @@ export type MainErrorData = {
178
184
  error: Error;
179
185
  errorPage: any;
180
186
 
181
- serverData: ServerData;
187
+ serverData: RenderErrorRequest;
182
188
  };
183
189
 
184
190
  /**
185
191
  * The main function to start the server side rendering
186
192
  * if there was an error
187
193
  *
188
- * ## Example
189
- * ```
194
+ * #### Example
195
+ * ```js
190
196
  * import * as errorPage from './Error.svelte';
191
197
  *
192
198
  * export function renderError(error, serverData) {
@@ -219,7 +225,7 @@ export async function mainError(
219
225
  });
220
226
 
221
227
  head += ssrComponents.toHead(data.serverData.ssrManifest);
222
- head += ssrCache.exportToHead();
228
+ head += ssrCache.z_exportToHead();
223
229
 
224
230
  let htmlTemplate = data.serverData.htmlTemplate;
225
231
  htmlTemplate = htmlTemplate.replace('<!--page-lang-->', 'de');
@@ -44,7 +44,7 @@ export default class Globals {
44
44
  /**
45
45
  * returns a globalValue
46
46
  *
47
- * ## Note
47
+ * #### Note
48
48
  * This only works in loadData, in loadGlobalData this will
49
49
  * throw an error. In that context you should use `.getAsync`
50
50
  */
@@ -62,7 +62,7 @@ export default class Globals {
62
62
  /**
63
63
  * returns a store which contains a globalSet
64
64
  *
65
- * ## Note
65
+ * #### Note
66
66
  * This only works in loadData, in loadGlobalData this will
67
67
  * always return null. In that context you should use
68
68
  * `.getAsync`
@@ -74,7 +74,7 @@ export default class Globals {
74
74
  /**
75
75
  * Get a store which contains a globalSet and wait until it is loaded
76
76
  *
77
- * ## Note
77
+ * #### Note
78
78
  * This is only useful in loadGlobalData in all other cases
79
79
  * you can use `.get` which does not return a Promise
80
80
  */
@@ -20,11 +20,11 @@ export interface LoadDataArray<A1 = any> extends Array<LoadData<A1>> {}
20
20
  *
21
21
  * There are three main ways `loadData` can be defined:
22
22
  *
23
- * ## Object
23
+ * #### Object
24
24
  * This is the most common way loadData will be used.
25
25
  * Each property should be a loadData type, each one is called in parallel.
26
26
  * And will be available to your component with the same name.
27
- * ```
27
+ * ```js
28
28
  * import entriesQuery from '@/queries/entries.graphql';
29
29
  * import { loadData as headerLoadData } from '@/layout/header.svelte';
30
30
  *
@@ -34,30 +34,20 @@ export interface LoadDataArray<A1 = any> extends Array<LoadData<A1>> {}
34
34
  * };
35
35
  * ```
36
36
  *
37
- * ## GraphQl
37
+ * #### GraphQl
38
38
  * You can just export a graphql query as a loadData type.
39
39
  * This will export all queries from the graphql file as properties.
40
- * ```
40
+ * ```js
41
41
  * import blogsQuery from '@/queries/blogs.graphql';
42
42
  *
43
43
  * export const loadData = blogsQuery;
44
- *
45
- * // or another option
46
- * import { gql } from '@craft-svelte/core/graphql';
47
- *
48
- * export const loadData = gql`query {
49
- * blogs: entries(section: "blogs") {
50
- * title
51
- * url
52
- * }
53
- * }`;
54
44
  * ```
55
45
  *
56
- * ## Function
46
+ * #### Function
57
47
  * Using a function gives you the most flexibility but also is the
58
48
  * most cumbersome.
59
49
  *
60
- * ```
50
+ * ```js
61
51
  * import articlesQuery from '@/queries/articles.graphql';
62
52
  *
63
53
  * export async function loadData(cr, entry) {
@@ -135,8 +125,8 @@ export async function callLoadData<A1 = any>(
135
125
  *
136
126
  * Prefer to use the array syntax.
137
127
  *
138
- * ## Example
139
- * ```
128
+ * #### Example
129
+ * ```js
140
130
  * export const loadData = mergeLoadData(
141
131
  * {
142
132
  * filter: (cr) => cr.route.search.get('filter'),