@fluixi/start 0.1.0-alpha.73 → 0.1.0-alpha.75

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 (123) hide show
  1. package/dist/adapter.cjs +750 -0
  2. package/dist/adapter.d.ts +9 -9
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js +10 -10
  5. package/dist/adapter.mjs +719 -0
  6. package/dist/adapters/entry.cjs +122 -0
  7. package/dist/adapters/entry.js +1 -1
  8. package/dist/adapters/entry.mjs +95 -0
  9. package/dist/adapters/platforms.cjs +311 -0
  10. package/dist/adapters/platforms.d.ts +2 -2
  11. package/dist/adapters/platforms.js +8 -8
  12. package/dist/adapters/platforms.mjs +284 -0
  13. package/dist/api-HD7KU3BS.mjs +114 -0
  14. package/dist/api.cjs +145 -0
  15. package/dist/api.js +1 -1
  16. package/dist/api.mjs +116 -0
  17. package/dist/commands/api-HD7KU3BS.mjs +114 -0
  18. package/dist/commands/api-PBT4QZ34.mjs +16 -0
  19. package/dist/commands/api-PJL37LV3.mjs +17 -0
  20. package/dist/commands/build.cjs +877 -0
  21. package/dist/commands/build.js +6 -6
  22. package/dist/commands/build.mjs +717 -0
  23. package/dist/commands/chunk-GFQ4MUIC.mjs +117 -0
  24. package/dist/commands/chunk-MTM6M3TC.mjs +115 -0
  25. package/dist/commands/dev.cjs +670 -0
  26. package/dist/commands/dev.js +3 -3
  27. package/dist/commands/dev.mjs +512 -0
  28. package/dist/commands/index.cjs +1145 -0
  29. package/dist/commands/index.d.ts +1 -1
  30. package/dist/commands/index.js +1 -1
  31. package/dist/commands/index.mjs +982 -0
  32. package/dist/commands/prerender.cjs +404 -0
  33. package/dist/commands/prerender.d.ts +1 -1
  34. package/dist/commands/prerender.js +2 -2
  35. package/dist/commands/prerender.mjs +377 -0
  36. package/dist/commands/start.cjs +463 -0
  37. package/dist/commands/start.d.ts +1 -1
  38. package/dist/commands/start.js +2 -2
  39. package/dist/commands/start.mjs +428 -0
  40. package/dist/config.cjs +150 -0
  41. package/dist/config.d.ts +24 -7
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +8 -6
  44. package/dist/config.mjs +114 -0
  45. package/dist/define-config.cjs +32 -0
  46. package/dist/define-config.d.ts +12 -0
  47. package/dist/define-config.d.ts.map +1 -0
  48. package/dist/define-config.js +3 -0
  49. package/dist/define-config.mjs +7 -0
  50. package/dist/di.cjs +200 -0
  51. package/dist/di.d.ts +4 -4
  52. package/dist/di.d.ts.map +1 -1
  53. package/dist/di.js +9 -9
  54. package/dist/di.mjs +169 -0
  55. package/dist/document.cjs +115 -0
  56. package/dist/document.d.ts +1 -1
  57. package/dist/document.js +1 -1
  58. package/dist/document.mjs +86 -0
  59. package/dist/generated-api.cjs +43 -0
  60. package/dist/generated-api.js +1 -1
  61. package/dist/generated-api.mjs +18 -0
  62. package/dist/generated-server-fns.cjs +43 -0
  63. package/dist/generated-server-fns.mjs +18 -0
  64. package/dist/handler-core.cjs +211 -0
  65. package/dist/handler-core.d.ts +2 -2
  66. package/dist/handler-core.js +2 -2
  67. package/dist/handler-core.mjs +185 -0
  68. package/dist/handler.cjs +182 -0
  69. package/dist/handler.d.ts +3 -3
  70. package/dist/handler.js +3 -3
  71. package/dist/handler.mjs +152 -0
  72. package/dist/head.cjs +25 -0
  73. package/dist/head.d.ts +1 -1
  74. package/dist/head.js +1 -1
  75. package/dist/head.mjs +4 -0
  76. package/dist/image-loader.cjs +37 -0
  77. package/dist/image-loader.d.ts +25 -0
  78. package/dist/image-loader.d.ts.map +1 -0
  79. package/dist/image-loader.js +18 -0
  80. package/dist/image-loader.mjs +12 -0
  81. package/dist/image.cjs +151 -0
  82. package/dist/image.d.ts +2 -19
  83. package/dist/image.d.ts.map +1 -1
  84. package/dist/image.js +5 -21
  85. package/dist/image.mjs +126 -0
  86. package/dist/index.cjs +303 -0
  87. package/dist/index.d.ts +28 -8
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +33 -17
  90. package/dist/index.mjs +262 -0
  91. package/dist/interceptors.cjs +72 -0
  92. package/dist/interceptors.js +1 -1
  93. package/dist/interceptors.mjs +44 -0
  94. package/dist/internal.cjs +393 -0
  95. package/dist/internal.d.ts +6 -6
  96. package/dist/internal.d.ts.map +1 -1
  97. package/dist/internal.js +23 -15
  98. package/dist/internal.mjs +223 -0
  99. package/dist/middleware.cjs +58 -0
  100. package/dist/middleware.d.ts +3 -3
  101. package/dist/middleware.d.ts.map +1 -1
  102. package/dist/middleware.js +1 -1
  103. package/dist/middleware.mjs +31 -0
  104. package/dist/preload.cjs +42 -0
  105. package/dist/preload.js +1 -1
  106. package/dist/preload.mjs +18 -0
  107. package/dist/router.cjs +25 -0
  108. package/dist/router.d.ts +3 -3
  109. package/dist/router.js +3 -3
  110. package/dist/router.mjs +4 -0
  111. package/dist/server-fn-setup.cjs +46 -0
  112. package/dist/server-fn-setup.d.ts +1 -1
  113. package/dist/server-fn-setup.js +2 -2
  114. package/dist/server-fn-setup.mjs +22 -0
  115. package/dist/server-fn.cjs +109 -0
  116. package/dist/server-fn.d.ts +2 -2
  117. package/dist/server-fn.js +2 -2
  118. package/dist/server-fn.mjs +79 -0
  119. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  120. package/dist/ui.cjs +123 -0
  121. package/dist/ui.js +1 -1
  122. package/dist/ui.mjs +93 -0
  123. package/package.json +63 -25
package/dist/index.cjs ADDED
@@ -0,0 +1,303 @@
1
+ /*! @fluixi/start v0.1.0-alpha.75 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ addInterceptor: () => addInterceptor,
25
+ clearInterceptors: () => clearInterceptors,
26
+ composeMiddleware: () => composeMiddleware,
27
+ createHandlerFrom: () => createHandlerFrom,
28
+ defineConfig: () => defineConfig,
29
+ defineMiddleware: () => defineMiddleware,
30
+ fetchWithInterceptors: () => fetchWithInterceptors,
31
+ getLocals: () => import_server.getLocals,
32
+ getRequestLocals: () => import_server.getRequestLocals,
33
+ html: () => import_core.html,
34
+ imageLoader: () => imageLoader,
35
+ injectApp: () => injectApp,
36
+ injectAppAndHead: () => injectAppAndHead,
37
+ normalizeMiddleware: () => normalizeMiddleware,
38
+ splitTemplate: () => splitTemplate,
39
+ svg: () => import_core.svg
40
+ });
41
+ module.exports = __toCommonJS(index_exports);
42
+
43
+ // src/define-config.ts
44
+ function defineConfig(config) {
45
+ return config;
46
+ }
47
+
48
+ // src/index.ts
49
+ var import_core = require("@fluixi/core");
50
+
51
+ // src/document.ts
52
+ var import_head = require("@fluixi/head");
53
+ function injectApp(template, appHtml, mountId = "root") {
54
+ const mount = new RegExp(`<div id=["']${mountId}["']\\s*>\\s*</div>`);
55
+ if (mount.test(template)) {
56
+ return template.replace(mount, `<div id="${mountId}">${appHtml}</div>`);
57
+ }
58
+ if (template.includes("<!--ssr-outlet-->")) {
59
+ return template.replace("<!--ssr-outlet-->", appHtml);
60
+ }
61
+ return template.replace("</body>", `<div id="${mountId}">${appHtml}</div></body>`);
62
+ }
63
+ function splitTemplate(template, mountId = "root") {
64
+ const mount = new RegExp(`<div id=["']${mountId}["']\\s*>\\s*</div>`);
65
+ const m = template.match(mount);
66
+ if (m && m.index !== void 0) {
67
+ return {
68
+ head: template.slice(0, m.index) + `<div id="${mountId}">`,
69
+ tail: `</div>` + template.slice(m.index + m[0].length)
70
+ };
71
+ }
72
+ const outlet = template.indexOf("<!--ssr-outlet-->");
73
+ if (outlet !== -1) {
74
+ return {
75
+ head: template.slice(0, outlet),
76
+ tail: template.slice(outlet + "<!--ssr-outlet-->".length)
77
+ };
78
+ }
79
+ const body = template.indexOf("</body>");
80
+ if (body !== -1) {
81
+ return {
82
+ head: template.slice(0, body) + `<div id="${mountId}">`,
83
+ tail: `</div>` + template.slice(body)
84
+ };
85
+ }
86
+ return { head: template, tail: "" };
87
+ }
88
+ function injectPreload(template, files) {
89
+ const tags = files.filter((file) => !template.includes(file)).map(
90
+ (file) => file.endsWith(".css") ? `<link rel="stylesheet" href="${file}">` : (
91
+ // `modulepreload` also fetches the chunk's own static imports.
92
+ `<link rel="modulepreload" href="${file}">`
93
+ )
94
+ );
95
+ if (tags.length === 0) return template;
96
+ const head = template.indexOf("</head>");
97
+ if (head === -1) return template;
98
+ return template.slice(0, head) + tags.join("") + template.slice(head);
99
+ }
100
+ function setHtmlAttr(html2, name, value) {
101
+ const existing = new RegExp(`(<html\\b[^>]*?)\\s${name}="[^"]*"`, "i");
102
+ if (existing.test(html2)) return html2.replace(existing, `$1 ${name}="${value}"`);
103
+ return html2.replace(/<html\b/i, `<html ${name}="${value}"`);
104
+ }
105
+ function injectAppAndHead(template, rendered, mountId = "root") {
106
+ const { head, body } = (0, import_head.extractHeadMarker)(rendered);
107
+ let html2 = injectApp(template, body, mountId);
108
+ if (head) {
109
+ if (head.headHtml) {
110
+ if (/<title[\s>]/i.test(head.headHtml)) html2 = html2.replace(/<title>[\s\S]*?<\/title>/i, "");
111
+ html2 = html2.replace("</head>", `${head.headHtml}</head>`);
112
+ }
113
+ for (const [k, v] of Object.entries(head.htmlAttrs)) html2 = setHtmlAttr(html2, k, v);
114
+ }
115
+ return html2;
116
+ }
117
+ function guardHandler(handler, onError) {
118
+ return async (request) => {
119
+ try {
120
+ return await handler(request);
121
+ } catch (e) {
122
+ onError?.(e);
123
+ return new Response(String(e?.stack || e), {
124
+ status: 500,
125
+ headers: { "content-type": "text/plain; charset=utf-8" }
126
+ });
127
+ }
128
+ };
129
+ }
130
+
131
+ // src/handler.ts
132
+ function streamDocument(head, body, tail) {
133
+ const enc = new TextEncoder();
134
+ const stream = new ReadableStream({
135
+ async start(controller) {
136
+ try {
137
+ controller.enqueue(enc.encode(head));
138
+ const reader = body.getReader();
139
+ for (; ; ) {
140
+ const { done, value } = await reader.read();
141
+ if (done) break;
142
+ controller.enqueue(value);
143
+ }
144
+ controller.enqueue(enc.encode(tail));
145
+ controller.close();
146
+ } catch (err) {
147
+ controller.error(err);
148
+ }
149
+ }
150
+ });
151
+ return new Response(stream, {
152
+ status: 200,
153
+ headers: { "content-type": "text/html; charset=utf-8" }
154
+ });
155
+ }
156
+ function createRequestHandler(render) {
157
+ return async (request) => {
158
+ const url = new URL(request.url);
159
+ try {
160
+ const html2 = await render(url.pathname + url.search, request);
161
+ return new Response(html2, {
162
+ status: 200,
163
+ headers: { "content-type": "text/html; charset=utf-8" }
164
+ });
165
+ } catch (e) {
166
+ return new Response(String(e?.stack || e), {
167
+ status: 500,
168
+ headers: { "content-type": "text/plain; charset=utf-8" }
169
+ });
170
+ }
171
+ };
172
+ }
173
+
174
+ // src/middleware.ts
175
+ function defineMiddleware(mw) {
176
+ return Array.isArray(mw) ? mw.slice() : [mw];
177
+ }
178
+ function normalizeMiddleware(mod) {
179
+ const def = mod?.default ?? mod;
180
+ if (def == null) return [];
181
+ if (Array.isArray(def)) return def.filter((m) => typeof m === "function");
182
+ return typeof def === "function" ? [def] : [];
183
+ }
184
+ function composeMiddleware(middlewares, core) {
185
+ if (middlewares.length === 0) return core;
186
+ return (request) => {
187
+ let lastCalled = -1;
188
+ const dispatch = (i) => {
189
+ if (i <= lastCalled) {
190
+ return Promise.reject(new Error("middleware called next() more than once"));
191
+ }
192
+ lastCalled = i;
193
+ const mw = middlewares[i];
194
+ if (!mw) return Promise.resolve(core(request));
195
+ return Promise.resolve(mw(request, () => dispatch(i + 1)));
196
+ };
197
+ return dispatch(0);
198
+ };
199
+ }
200
+
201
+ // src/handler-core.ts
202
+ function createHandlerFrom({ template, mod, cfg, middleware, preload }) {
203
+ const withPreload = (html2, pathname) => preload ? injectPreload(html2, preload(pathname)) : html2;
204
+ let core;
205
+ if (!cfg.ssr) {
206
+ core = createRequestHandler(async (url) => withPreload(template, url.split("?")[0]));
207
+ } else if (typeof mod.renderStream === "function") {
208
+ core = async (request) => {
209
+ const url = new URL(request.url);
210
+ const { head, tail } = splitTemplate(withPreload(template, url.pathname), cfg.mountId);
211
+ const body = await mod.renderStream(url.pathname + url.search, request);
212
+ return streamDocument(head, body, tail);
213
+ };
214
+ } else {
215
+ const render = mod.render ?? mod.default;
216
+ core = createRequestHandler(
217
+ async (url, request) => (
218
+ // `url` here is `pathname + search`; matching only ever wants the path.
219
+ injectAppAndHead(withPreload(template, url.split("?")[0]), await render(url, request), cfg.mountId)
220
+ )
221
+ );
222
+ }
223
+ if (typeof mod.handleServerFn === "function" && typeof mod.isServerFnRequest === "function") {
224
+ const render = core;
225
+ core = async (request) => mod.isServerFnRequest(request) ? mod.handleServerFn(request) : render(request);
226
+ }
227
+ if (typeof mod.handleApiRequest === "function" && typeof mod.isApiRequest === "function") {
228
+ const next = core;
229
+ core = async (request) => mod.isApiRequest(request) ? mod.handleApiRequest(request) : next(request);
230
+ }
231
+ if (!middleware) return guardHandler(core);
232
+ return guardHandler(composeMiddleware(normalizeMiddleware(middleware), core));
233
+ }
234
+
235
+ // src/server-fn.ts
236
+ var _fetch = (...a) => fetch(...a);
237
+ function setServerFnFetch(f) {
238
+ _fetch = f;
239
+ }
240
+
241
+ // src/interceptors.ts
242
+ var interceptors = [];
243
+ function addInterceptor(interceptor) {
244
+ if (interceptors.length === 0) setServerFnFetch(fetchWithInterceptors);
245
+ interceptors.push(interceptor);
246
+ return () => {
247
+ const i = interceptors.indexOf(interceptor);
248
+ if (i >= 0) interceptors.splice(i, 1);
249
+ };
250
+ }
251
+ function clearInterceptors() {
252
+ interceptors.length = 0;
253
+ setServerFnFetch(((...a) => fetch(...a)));
254
+ }
255
+ async function fetchWithInterceptors(input, init) {
256
+ let request = input instanceof Request && !init ? input : new Request(input, init);
257
+ for (const i of interceptors) if (i.request) request = await i.request(request);
258
+ let response;
259
+ try {
260
+ response = await fetch(request);
261
+ } catch (error) {
262
+ for (const i of interceptors) {
263
+ if (!i.error) continue;
264
+ const recovered = await i.error(error, request);
265
+ if (recovered) return recovered;
266
+ }
267
+ throw error;
268
+ }
269
+ for (const i of interceptors) if (i.response) response = await i.response(response, request);
270
+ return response;
271
+ }
272
+
273
+ // src/image-loader.ts
274
+ function imageLoader(options = {}) {
275
+ const path = options.path ?? "/api/image";
276
+ return ({ src, width, quality }) => {
277
+ const params = new URLSearchParams({ url: src, w: String(width) });
278
+ if (quality != null) params.set("q", String(quality));
279
+ return `${path}?${params.toString()}`;
280
+ };
281
+ }
282
+
283
+ // src/index.ts
284
+ var import_server = require("@fluixi/server");
285
+ // Annotate the CommonJS export names for ESM import in node:
286
+ 0 && (module.exports = {
287
+ addInterceptor,
288
+ clearInterceptors,
289
+ composeMiddleware,
290
+ createHandlerFrom,
291
+ defineConfig,
292
+ defineMiddleware,
293
+ fetchWithInterceptors,
294
+ getLocals,
295
+ getRequestLocals,
296
+ html,
297
+ imageLoader,
298
+ injectApp,
299
+ injectAppAndHead,
300
+ normalizeMiddleware,
301
+ splitTemplate,
302
+ svg
303
+ });
package/dist/index.d.ts CHANGED
@@ -1,25 +1,45 @@
1
1
  /**
2
- * @fluixi/start the Fluixi meta-framework.
2
+ * @fluixi/start: the Fluixi meta-framework.
3
3
  *
4
4
  * Packages the dev server, build, and production SSR server over @fluixi/server +
5
5
  * Vite, so apps stop hand-rolling server.mjs. Use the `fluixi` CLI (dev/build/start)
6
6
  * or call the commands programmatically.
7
+ *
8
+ * **This entry is safe to import from a browser bundle.** Everything that reads the
9
+ * filesystem, starts a server, or runs the bundler lives behind a subpath instead, and
10
+ * that is a rule rather than an accident: an app's client entry legitimately wants
11
+ * `addInterceptor`, and a root export that also carried the dev server put `node:fs`,
12
+ * `node:http` and esbuild into the page. Vite reports that as
13
+ * `"resolve" is not exported by "__vite-browser-external"`, from a line nobody wrote.
14
+ *
15
+ * What moved, and where it is now:
16
+ *
17
+ * loadConfig, resolveConfig `@fluixi/start/config`
18
+ * serveNode, createRequestHandler, and the
19
+ * rest of the request layer `@fluixi/start/handler`
20
+ * nodeAdapter, webAdapter, cloudflareAdapter,
21
+ * netlifyAdapter, vercelAdapter,
22
+ * createProdHandler, ssrBuildOptions `@fluixi/start/adapter`
23
+ * createImageHandler `@fluixi/start/image`
24
+ * the dev/build/start commands `@fluixi/start/commands`
25
+ *
26
+ * `defineConfig` stays here, because a config file is the first thing an app writes and
27
+ * it is only a type-level helper.
7
28
  */
8
- export { defineConfig, resolveConfig, loadConfig } from './config.js';
29
+ export { defineConfig } from './define-config.js';
9
30
  export type { FluixiConfig, ResolvedConfig } from './config.js';
10
31
  export { html, svg } from '@fluixi/core';
11
32
  export { injectApp, injectAppAndHead, splitTemplate } from './document.js';
12
- export { createRequestHandler, toNodeHandler, nodeToRequest, sendResponse, serveNode, streamDocument, withStaticFiles, } from './handler.js';
13
- export type { FetchHandler, RenderFn, StreamRenderFn, ServeNodeOptions } from './handler.js';
14
- export { createProdHandler, nodeAdapter, webAdapter, cloudflareAdapter, netlifyAdapter, vercelAdapter, ssrBuildOptions, } from './adapter.js';
15
- export type { Adapter, AdapterContext, AdapterBuildContext } from './adapter.js';
16
33
  export { createHandlerFrom } from './handler-core.js';
17
34
  export type { HandlerParts, ServerModule } from './handler-core.js';
18
35
  export { defineMiddleware, composeMiddleware, normalizeMiddleware } from './middleware.js';
19
36
  export type { Middleware, MiddlewareNext } from './middleware.js';
20
37
  export { addInterceptor, clearInterceptors, fetchWithInterceptors } from './interceptors.js';
21
38
  export type { Interceptor } from './interceptors.js';
22
- export { createImageHandler, imageLoader } from './image.js';
23
- export type { ImageHandlerOptions, ImageLoaderOptions, ImageTransform, ImageTransformArgs } from './image.js';
39
+ export { imageLoader } from './image-loader.js';
40
+ export type { ImageLoaderOptions } from './image-loader.js';
41
+ export type { ImageHandlerOptions, ImageTransform, ImageTransformArgs } from './image.js';
24
42
  export { getRequestLocals, getLocals, type RequestLocals } from '@fluixi/server';
43
+ export type { Adapter, AdapterContext, AdapterBuildContext } from './adapter.js';
44
+ export type { FetchHandler, RenderFn, StreamRenderFn, ServeNodeOptions, } from './handler.js';
25
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAI9G,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIhE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIlE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAK1F,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGjF,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACjF,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,32 +1,48 @@
1
1
  /**
2
- * @fluixi/start the Fluixi meta-framework.
2
+ * @fluixi/start: the Fluixi meta-framework.
3
3
  *
4
4
  * Packages the dev server, build, and production SSR server over @fluixi/server +
5
5
  * Vite, so apps stop hand-rolling server.mjs. Use the `fluixi` CLI (dev/build/start)
6
6
  * or call the commands programmatically.
7
+ *
8
+ * **This entry is safe to import from a browser bundle.** Everything that reads the
9
+ * filesystem, starts a server, or runs the bundler lives behind a subpath instead, and
10
+ * that is a rule rather than an accident: an app's client entry legitimately wants
11
+ * `addInterceptor`, and a root export that also carried the dev server put `node:fs`,
12
+ * `node:http` and esbuild into the page. Vite reports that as
13
+ * `"resolve" is not exported by "__vite-browser-external"`, from a line nobody wrote.
14
+ *
15
+ * What moved, and where it is now:
16
+ *
17
+ * loadConfig, resolveConfig `@fluixi/start/config`
18
+ * serveNode, createRequestHandler, and the
19
+ * rest of the request layer `@fluixi/start/handler`
20
+ * nodeAdapter, webAdapter, cloudflareAdapter,
21
+ * netlifyAdapter, vercelAdapter,
22
+ * createProdHandler, ssrBuildOptions `@fluixi/start/adapter`
23
+ * createImageHandler `@fluixi/start/image`
24
+ * the dev/build/start commands `@fluixi/start/commands`
25
+ *
26
+ * `defineConfig` stays here, because a config file is the first thing an app writes and
27
+ * it is only a type-level helper.
7
28
  */
8
- export { defineConfig, resolveConfig, loadConfig } from './config.js';
9
- // The html``/svg`` template tags — so a meta-framework app can author without JSX:
29
+ // Config authoring. The loader is not here: it resolves and reads a file.
30
+ export { defineConfig } from './define-config.js';
31
+ // The html``/svg`` template tags, so a meta-framework app can author without JSX:
10
32
  // `import { html } from '@fluixi/start'`. Inert markers; the compiler lowers them.
11
33
  export { html, svg } from '@fluixi/core';
12
- // The commands live at `@fluixi/start/commands`. Re-exporting them here would put
13
- // the dev server and the bundler behind every runtime import of this package —
14
- // and a deploy adapter, which inlines everything its entry can reach, would carry
15
- // vite into a worker.
16
- // From the leaf, not internal.js: that one reaches the dev server's env loader,
17
- // and with it vite, which has no business in a runtime import of this package.
34
+ // Document assembly: string work over a template, with nothing to read from disk.
18
35
  export { injectApp, injectAppAndHead, splitTemplate } from './document.js';
19
- // The runtime-neutral request layer the seam adapters (edge/worker/Bun/Deno) build on.
20
- export { createRequestHandler, toNodeHandler, nodeToRequest, sendResponse, serveNode, streamDocument, withStaticFiles, } from './handler.js';
21
- // Deploy adapters: the portable prod handler + the node/web reference adapters.
22
- export { createProdHandler, nodeAdapter, webAdapter, cloudflareAdapter, netlifyAdapter, vercelAdapter, ssrBuildOptions, } from './adapter.js';
36
+ // The handler's runtime-neutral core. The node/http half is behind `/handler`.
23
37
  export { createHandlerFrom } from './handler-core.js';
24
- // Request middleware a `(request, next) => Response` chain run before render.
38
+ // Request middleware: a `(request, next) => Response` chain run before render.
25
39
  export { defineMiddleware, composeMiddleware, normalizeMiddleware } from './middleware.js';
26
- // HTTP interceptors request/response/error pipeline around fetch (server-fn RPC + app fetch).
40
+ // HTTP interceptors: request/response/error pipeline around fetch (server-fn RPC + app
41
+ // fetch). Client-side by nature, and the reason this entry has to stay importable.
27
42
  export { addInterceptor, clearInterceptors, fetchWithInterceptors } from './interceptors.js';
28
- export { createImageHandler, imageLoader } from './image.js';
43
+ // Builds an image URL. The handler that serves it reads files, so it is behind `/image`.
44
+ export { imageLoader } from './image-loader.js';
29
45
  // Middleware→render locals bridge: write `getRequestLocals(request).x = …` in middleware;
30
46
  // read it back in loaders/server-fns/render via getLocals() (the app entry forwards
31
- // `request` on the render event `renderRequestAsync(App, { url, request })`).
47
+ // `request` on the render event: `renderRequestAsync(App, { url, request })`).
32
48
  export { getRequestLocals, getLocals } from '@fluixi/server';