@fluixi/start 0.1.0-alpha.72 → 0.1.0-alpha.74

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 (64) hide show
  1. package/dist/adapter.cjs +748 -0
  2. package/dist/adapter.mjs +717 -0
  3. package/dist/adapters/entry.cjs +122 -0
  4. package/dist/adapters/entry.mjs +95 -0
  5. package/dist/adapters/platforms.cjs +311 -0
  6. package/dist/adapters/platforms.mjs +284 -0
  7. package/dist/api-RH6E5UTH.mjs +114 -0
  8. package/dist/api.cjs +145 -0
  9. package/dist/api.mjs +116 -0
  10. package/dist/commands/api-23MJFSYL.mjs +17 -0
  11. package/dist/commands/api-4IYNQRKG.mjs +16 -0
  12. package/dist/commands/api-RH6E5UTH.mjs +114 -0
  13. package/dist/commands/build.cjs +870 -0
  14. package/dist/commands/build.mjs +710 -0
  15. package/dist/commands/chunk-NS5GR2GX.mjs +115 -0
  16. package/dist/commands/chunk-OCPCK4ZJ.mjs +117 -0
  17. package/dist/commands/dev.cjs +663 -0
  18. package/dist/commands/dev.mjs +505 -0
  19. package/dist/commands/index.cjs +1138 -0
  20. package/dist/commands/index.mjs +975 -0
  21. package/dist/commands/prerender.cjs +402 -0
  22. package/dist/commands/prerender.mjs +375 -0
  23. package/dist/commands/start.cjs +461 -0
  24. package/dist/commands/start.mjs +426 -0
  25. package/dist/config.cjs +144 -0
  26. package/dist/config.mjs +108 -0
  27. package/dist/di.cjs +200 -0
  28. package/dist/di.mjs +169 -0
  29. package/dist/document.cjs +115 -0
  30. package/dist/document.mjs +86 -0
  31. package/dist/generated-api.cjs +43 -0
  32. package/dist/generated-api.mjs +18 -0
  33. package/dist/generated-server-fns.cjs +43 -0
  34. package/dist/generated-server-fns.mjs +18 -0
  35. package/dist/handler-core.cjs +211 -0
  36. package/dist/handler-core.mjs +185 -0
  37. package/dist/handler.cjs +181 -0
  38. package/dist/handler.mjs +150 -0
  39. package/dist/head.cjs +25 -0
  40. package/dist/head.mjs +4 -0
  41. package/dist/image.cjs +146 -0
  42. package/dist/image.mjs +120 -0
  43. package/dist/index.cjs +1036 -0
  44. package/dist/index.mjs +968 -0
  45. package/dist/interceptors.cjs +71 -0
  46. package/dist/interceptors.mjs +42 -0
  47. package/dist/internal.cjs +388 -0
  48. package/dist/internal.d.ts.map +1 -1
  49. package/dist/internal.js +6 -2
  50. package/dist/internal.mjs +218 -0
  51. package/dist/middleware.cjs +58 -0
  52. package/dist/middleware.mjs +31 -0
  53. package/dist/preload.cjs +42 -0
  54. package/dist/preload.mjs +18 -0
  55. package/dist/router.cjs +25 -0
  56. package/dist/router.mjs +4 -0
  57. package/dist/server-fn-setup.cjs +46 -0
  58. package/dist/server-fn-setup.mjs +22 -0
  59. package/dist/server-fn.cjs +109 -0
  60. package/dist/server-fn.mjs +79 -0
  61. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  62. package/dist/ui.cjs +123 -0
  63. package/dist/ui.mjs +93 -0
  64. package/package.json +45 -25
package/dist/di.cjs ADDED
@@ -0,0 +1,200 @@
1
+ /*! @fluixi/start v0.1.0-alpha.74 | (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 __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
24
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
26
+
27
+ // src/di.ts
28
+ var di_exports = {};
29
+ __export(di_exports, {
30
+ Injector: () => Injector,
31
+ createInjector: () => createInjector,
32
+ getInjector: () => getInjector,
33
+ inject: () => inject,
34
+ injectionToken: () => injectionToken,
35
+ provide: () => provide,
36
+ provideRoot: () => provideRoot,
37
+ runInInjectionContext: () => runInInjectionContext
38
+ });
39
+ module.exports = __toCommonJS(di_exports);
40
+ var import_core = require("@fluixi/core");
41
+ var import_dom = require("@fluixi/dom");
42
+ function injectionToken(name, options) {
43
+ return { id: Symbol(name), name, factory: options?.factory };
44
+ }
45
+ var _Injector_instances, build_fn, fromFactory_fn;
46
+ var Injector = class {
47
+ constructor(parent = null) {
48
+ this.parent = parent;
49
+ __privateAdd(this, _Injector_instances);
50
+ this.records = /* @__PURE__ */ new Map();
51
+ }
52
+ register(providers) {
53
+ for (const p of providers) {
54
+ this.records.set(p.provide.id, { provider: p, built: false, building: false, value: void 0 });
55
+ }
56
+ return this;
57
+ }
58
+ /** Resolve a token from this injector, walking up the parent chain, then the token's factory. */
59
+ get(token) {
60
+ var _a, _b;
61
+ let inj = this;
62
+ while (inj) {
63
+ const rec = inj.records.get(token.id);
64
+ if (rec) return __privateMethod(_a = inj, _Injector_instances, build_fn).call(_a, token, rec);
65
+ inj = inj.parent;
66
+ }
67
+ if (token.factory) return __privateMethod(_b = rootOf(this), _Injector_instances, fromFactory_fn).call(_b, token);
68
+ throw new Error(
69
+ `[fluixi/di] No provider for "${token.name}". Register it with provide()/provideRoot(), or give the token a { factory } to self-provide.`
70
+ );
71
+ }
72
+ /** Run every built service's `onDestroy()`. Owner-scoped injectors call this on cleanup. */
73
+ dispose() {
74
+ for (const rec of this.records.values()) {
75
+ const v = rec.value;
76
+ if (rec.built && v && typeof v.onDestroy === "function") {
77
+ try {
78
+ v.onDestroy();
79
+ } catch (e) {
80
+ console.error("[fluixi/di] onDestroy threw —", e);
81
+ }
82
+ }
83
+ }
84
+ this.records.clear();
85
+ }
86
+ };
87
+ _Injector_instances = new WeakSet();
88
+ build_fn = function(token, rec) {
89
+ if (rec.built) return rec.value;
90
+ if (rec.building) throw new Error(`[fluixi/di] Circular dependency while resolving "${token.name}".`);
91
+ rec.building = true;
92
+ const p = rec.provider;
93
+ try {
94
+ if ("useValue" in p) rec.value = p.useValue;
95
+ else if ("useExisting" in p) rec.value = this.get(p.useExisting);
96
+ else {
97
+ const deps = (p.deps ?? []).map((d) => this.get(d));
98
+ rec.value = "useClass" in p ? new p.useClass(...deps) : p.useFactory(...deps);
99
+ }
100
+ } finally {
101
+ rec.building = false;
102
+ }
103
+ rec.built = true;
104
+ return rec.value;
105
+ };
106
+ fromFactory_fn = function(token) {
107
+ let rec = this.records.get(token.id);
108
+ if (!rec) {
109
+ rec = { provider: { provide: token, useFactory: token.factory }, built: false, building: false, value: void 0 };
110
+ this.records.set(token.id, rec);
111
+ }
112
+ return __privateMethod(this, _Injector_instances, build_fn).call(this, token, rec);
113
+ };
114
+ function rootOf(inj) {
115
+ let i = inj;
116
+ while (i.parent) i = i.parent;
117
+ return i;
118
+ }
119
+ var _rootProviders = [];
120
+ var _reqInjectors = /* @__PURE__ */ new WeakMap();
121
+ var _ownerInjectors = /* @__PURE__ */ new WeakMap();
122
+ var _clientRoot = null;
123
+ var _explicit = null;
124
+ function rootInjector() {
125
+ const ctx = (0, import_dom.getRequestContext)();
126
+ if (ctx) {
127
+ let inj = _reqInjectors.get(ctx);
128
+ if (!inj) _reqInjectors.set(ctx, inj = new Injector(null).register(_rootProviders));
129
+ return inj;
130
+ }
131
+ return _clientRoot ??= new Injector(null).register(_rootProviders);
132
+ }
133
+ function parentInjectorOf(owner) {
134
+ let o = owner?.parent;
135
+ while (o) {
136
+ const inj = _ownerInjectors.get(o);
137
+ if (inj) return inj;
138
+ o = o.parent;
139
+ }
140
+ return rootInjector();
141
+ }
142
+ function currentInjector() {
143
+ if (_explicit) return _explicit;
144
+ let o = (0, import_core.getOwner)();
145
+ while (o) {
146
+ const inj = _ownerInjectors.get(o);
147
+ if (inj) return inj;
148
+ o = o.parent;
149
+ }
150
+ return rootInjector();
151
+ }
152
+ function inject(token) {
153
+ return currentInjector().get(token);
154
+ }
155
+ function provide(providers) {
156
+ const owner = (0, import_core.getOwner)();
157
+ if (!owner) {
158
+ throw new Error("[fluixi/di] provide() must run inside a component/owner scope. Use provideRoot() for app-wide services.");
159
+ }
160
+ let inj = _ownerInjectors.get(owner);
161
+ if (!inj) {
162
+ inj = new Injector(parentInjectorOf(owner));
163
+ _ownerInjectors.set(owner, inj);
164
+ (0, import_core.onCleanup)(() => inj.dispose());
165
+ }
166
+ inj.register(providers);
167
+ return inj;
168
+ }
169
+ function provideRoot(providers) {
170
+ _rootProviders.push(...providers);
171
+ _clientRoot?.register(providers);
172
+ const ctx = (0, import_dom.getRequestContext)();
173
+ if (ctx) _reqInjectors.get(ctx)?.register(providers);
174
+ }
175
+ function runInInjectionContext(injector, fn) {
176
+ const prev = _explicit;
177
+ _explicit = injector;
178
+ try {
179
+ return fn();
180
+ } finally {
181
+ _explicit = prev;
182
+ }
183
+ }
184
+ function getInjector() {
185
+ return currentInjector();
186
+ }
187
+ function createInjector(providers, parent) {
188
+ return new Injector(parent === void 0 ? rootInjector() : parent).register(providers);
189
+ }
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ Injector,
193
+ createInjector,
194
+ getInjector,
195
+ inject,
196
+ injectionToken,
197
+ provide,
198
+ provideRoot,
199
+ runInInjectionContext
200
+ });
package/dist/di.mjs ADDED
@@ -0,0 +1,169 @@
1
+ /*! @fluixi/start v0.1.0-alpha.74 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
8
+
9
+ // src/di.ts
10
+ import { getOwner, onCleanup } from "@fluixi/core";
11
+ import { getRequestContext } from "@fluixi/dom";
12
+ function injectionToken(name, options) {
13
+ return { id: Symbol(name), name, factory: options?.factory };
14
+ }
15
+ var _Injector_instances, build_fn, fromFactory_fn;
16
+ var Injector = class {
17
+ constructor(parent = null) {
18
+ this.parent = parent;
19
+ __privateAdd(this, _Injector_instances);
20
+ this.records = /* @__PURE__ */ new Map();
21
+ }
22
+ register(providers) {
23
+ for (const p of providers) {
24
+ this.records.set(p.provide.id, { provider: p, built: false, building: false, value: void 0 });
25
+ }
26
+ return this;
27
+ }
28
+ /** Resolve a token from this injector, walking up the parent chain, then the token's factory. */
29
+ get(token) {
30
+ var _a, _b;
31
+ let inj = this;
32
+ while (inj) {
33
+ const rec = inj.records.get(token.id);
34
+ if (rec) return __privateMethod(_a = inj, _Injector_instances, build_fn).call(_a, token, rec);
35
+ inj = inj.parent;
36
+ }
37
+ if (token.factory) return __privateMethod(_b = rootOf(this), _Injector_instances, fromFactory_fn).call(_b, token);
38
+ throw new Error(
39
+ `[fluixi/di] No provider for "${token.name}". Register it with provide()/provideRoot(), or give the token a { factory } to self-provide.`
40
+ );
41
+ }
42
+ /** Run every built service's `onDestroy()`. Owner-scoped injectors call this on cleanup. */
43
+ dispose() {
44
+ for (const rec of this.records.values()) {
45
+ const v = rec.value;
46
+ if (rec.built && v && typeof v.onDestroy === "function") {
47
+ try {
48
+ v.onDestroy();
49
+ } catch (e) {
50
+ console.error("[fluixi/di] onDestroy threw —", e);
51
+ }
52
+ }
53
+ }
54
+ this.records.clear();
55
+ }
56
+ };
57
+ _Injector_instances = new WeakSet();
58
+ build_fn = function(token, rec) {
59
+ if (rec.built) return rec.value;
60
+ if (rec.building) throw new Error(`[fluixi/di] Circular dependency while resolving "${token.name}".`);
61
+ rec.building = true;
62
+ const p = rec.provider;
63
+ try {
64
+ if ("useValue" in p) rec.value = p.useValue;
65
+ else if ("useExisting" in p) rec.value = this.get(p.useExisting);
66
+ else {
67
+ const deps = (p.deps ?? []).map((d) => this.get(d));
68
+ rec.value = "useClass" in p ? new p.useClass(...deps) : p.useFactory(...deps);
69
+ }
70
+ } finally {
71
+ rec.building = false;
72
+ }
73
+ rec.built = true;
74
+ return rec.value;
75
+ };
76
+ fromFactory_fn = function(token) {
77
+ let rec = this.records.get(token.id);
78
+ if (!rec) {
79
+ rec = { provider: { provide: token, useFactory: token.factory }, built: false, building: false, value: void 0 };
80
+ this.records.set(token.id, rec);
81
+ }
82
+ return __privateMethod(this, _Injector_instances, build_fn).call(this, token, rec);
83
+ };
84
+ function rootOf(inj) {
85
+ let i = inj;
86
+ while (i.parent) i = i.parent;
87
+ return i;
88
+ }
89
+ var _rootProviders = [];
90
+ var _reqInjectors = /* @__PURE__ */ new WeakMap();
91
+ var _ownerInjectors = /* @__PURE__ */ new WeakMap();
92
+ var _clientRoot = null;
93
+ var _explicit = null;
94
+ function rootInjector() {
95
+ const ctx = getRequestContext();
96
+ if (ctx) {
97
+ let inj = _reqInjectors.get(ctx);
98
+ if (!inj) _reqInjectors.set(ctx, inj = new Injector(null).register(_rootProviders));
99
+ return inj;
100
+ }
101
+ return _clientRoot ??= new Injector(null).register(_rootProviders);
102
+ }
103
+ function parentInjectorOf(owner) {
104
+ let o = owner?.parent;
105
+ while (o) {
106
+ const inj = _ownerInjectors.get(o);
107
+ if (inj) return inj;
108
+ o = o.parent;
109
+ }
110
+ return rootInjector();
111
+ }
112
+ function currentInjector() {
113
+ if (_explicit) return _explicit;
114
+ let o = getOwner();
115
+ while (o) {
116
+ const inj = _ownerInjectors.get(o);
117
+ if (inj) return inj;
118
+ o = o.parent;
119
+ }
120
+ return rootInjector();
121
+ }
122
+ function inject(token) {
123
+ return currentInjector().get(token);
124
+ }
125
+ function provide(providers) {
126
+ const owner = getOwner();
127
+ if (!owner) {
128
+ throw new Error("[fluixi/di] provide() must run inside a component/owner scope. Use provideRoot() for app-wide services.");
129
+ }
130
+ let inj = _ownerInjectors.get(owner);
131
+ if (!inj) {
132
+ inj = new Injector(parentInjectorOf(owner));
133
+ _ownerInjectors.set(owner, inj);
134
+ onCleanup(() => inj.dispose());
135
+ }
136
+ inj.register(providers);
137
+ return inj;
138
+ }
139
+ function provideRoot(providers) {
140
+ _rootProviders.push(...providers);
141
+ _clientRoot?.register(providers);
142
+ const ctx = getRequestContext();
143
+ if (ctx) _reqInjectors.get(ctx)?.register(providers);
144
+ }
145
+ function runInInjectionContext(injector, fn) {
146
+ const prev = _explicit;
147
+ _explicit = injector;
148
+ try {
149
+ return fn();
150
+ } finally {
151
+ _explicit = prev;
152
+ }
153
+ }
154
+ function getInjector() {
155
+ return currentInjector();
156
+ }
157
+ function createInjector(providers, parent) {
158
+ return new Injector(parent === void 0 ? rootInjector() : parent).register(providers);
159
+ }
160
+ export {
161
+ Injector,
162
+ createInjector,
163
+ getInjector,
164
+ inject,
165
+ injectionToken,
166
+ provide,
167
+ provideRoot,
168
+ runInInjectionContext
169
+ };
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/document.ts
21
+ var document_exports = {};
22
+ __export(document_exports, {
23
+ guardHandler: () => guardHandler,
24
+ injectApp: () => injectApp,
25
+ injectAppAndHead: () => injectAppAndHead,
26
+ injectPreload: () => injectPreload,
27
+ splitTemplate: () => splitTemplate
28
+ });
29
+ module.exports = __toCommonJS(document_exports);
30
+ var import_head = require("@fluixi/head");
31
+ function injectApp(template, appHtml, mountId = "root") {
32
+ const mount = new RegExp(`<div id=["']${mountId}["']\\s*>\\s*</div>`);
33
+ if (mount.test(template)) {
34
+ return template.replace(mount, `<div id="${mountId}">${appHtml}</div>`);
35
+ }
36
+ if (template.includes("<!--ssr-outlet-->")) {
37
+ return template.replace("<!--ssr-outlet-->", appHtml);
38
+ }
39
+ return template.replace("</body>", `<div id="${mountId}">${appHtml}</div></body>`);
40
+ }
41
+ function splitTemplate(template, mountId = "root") {
42
+ const mount = new RegExp(`<div id=["']${mountId}["']\\s*>\\s*</div>`);
43
+ const m = template.match(mount);
44
+ if (m && m.index !== void 0) {
45
+ return {
46
+ head: template.slice(0, m.index) + `<div id="${mountId}">`,
47
+ tail: `</div>` + template.slice(m.index + m[0].length)
48
+ };
49
+ }
50
+ const outlet = template.indexOf("<!--ssr-outlet-->");
51
+ if (outlet !== -1) {
52
+ return {
53
+ head: template.slice(0, outlet),
54
+ tail: template.slice(outlet + "<!--ssr-outlet-->".length)
55
+ };
56
+ }
57
+ const body = template.indexOf("</body>");
58
+ if (body !== -1) {
59
+ return {
60
+ head: template.slice(0, body) + `<div id="${mountId}">`,
61
+ tail: `</div>` + template.slice(body)
62
+ };
63
+ }
64
+ return { head: template, tail: "" };
65
+ }
66
+ function injectPreload(template, files) {
67
+ const tags = files.filter((file) => !template.includes(file)).map(
68
+ (file) => file.endsWith(".css") ? `<link rel="stylesheet" href="${file}">` : (
69
+ // `modulepreload` also fetches the chunk's own static imports.
70
+ `<link rel="modulepreload" href="${file}">`
71
+ )
72
+ );
73
+ if (tags.length === 0) return template;
74
+ const head = template.indexOf("</head>");
75
+ if (head === -1) return template;
76
+ return template.slice(0, head) + tags.join("") + template.slice(head);
77
+ }
78
+ function setHtmlAttr(html, name, value) {
79
+ const existing = new RegExp(`(<html\\b[^>]*?)\\s${name}="[^"]*"`, "i");
80
+ if (existing.test(html)) return html.replace(existing, `$1 ${name}="${value}"`);
81
+ return html.replace(/<html\b/i, `<html ${name}="${value}"`);
82
+ }
83
+ function injectAppAndHead(template, rendered, mountId = "root") {
84
+ const { head, body } = (0, import_head.extractHeadMarker)(rendered);
85
+ let html = injectApp(template, body, mountId);
86
+ if (head) {
87
+ if (head.headHtml) {
88
+ if (/<title[\s>]/i.test(head.headHtml)) html = html.replace(/<title>[\s\S]*?<\/title>/i, "");
89
+ html = html.replace("</head>", `${head.headHtml}</head>`);
90
+ }
91
+ for (const [k, v] of Object.entries(head.htmlAttrs)) html = setHtmlAttr(html, k, v);
92
+ }
93
+ return html;
94
+ }
95
+ function guardHandler(handler, onError) {
96
+ return async (request) => {
97
+ try {
98
+ return await handler(request);
99
+ } catch (e) {
100
+ onError?.(e);
101
+ return new Response(String(e?.stack || e), {
102
+ status: 500,
103
+ headers: { "content-type": "text/plain; charset=utf-8" }
104
+ });
105
+ }
106
+ };
107
+ }
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ guardHandler,
111
+ injectApp,
112
+ injectAppAndHead,
113
+ injectPreload,
114
+ splitTemplate
115
+ });
@@ -0,0 +1,86 @@
1
+ // src/document.ts
2
+ import { extractHeadMarker } from "@fluixi/head";
3
+ function injectApp(template, appHtml, mountId = "root") {
4
+ const mount = new RegExp(`<div id=["']${mountId}["']\\s*>\\s*</div>`);
5
+ if (mount.test(template)) {
6
+ return template.replace(mount, `<div id="${mountId}">${appHtml}</div>`);
7
+ }
8
+ if (template.includes("<!--ssr-outlet-->")) {
9
+ return template.replace("<!--ssr-outlet-->", appHtml);
10
+ }
11
+ return template.replace("</body>", `<div id="${mountId}">${appHtml}</div></body>`);
12
+ }
13
+ function splitTemplate(template, mountId = "root") {
14
+ const mount = new RegExp(`<div id=["']${mountId}["']\\s*>\\s*</div>`);
15
+ const m = template.match(mount);
16
+ if (m && m.index !== void 0) {
17
+ return {
18
+ head: template.slice(0, m.index) + `<div id="${mountId}">`,
19
+ tail: `</div>` + template.slice(m.index + m[0].length)
20
+ };
21
+ }
22
+ const outlet = template.indexOf("<!--ssr-outlet-->");
23
+ if (outlet !== -1) {
24
+ return {
25
+ head: template.slice(0, outlet),
26
+ tail: template.slice(outlet + "<!--ssr-outlet-->".length)
27
+ };
28
+ }
29
+ const body = template.indexOf("</body>");
30
+ if (body !== -1) {
31
+ return {
32
+ head: template.slice(0, body) + `<div id="${mountId}">`,
33
+ tail: `</div>` + template.slice(body)
34
+ };
35
+ }
36
+ return { head: template, tail: "" };
37
+ }
38
+ function injectPreload(template, files) {
39
+ const tags = files.filter((file) => !template.includes(file)).map(
40
+ (file) => file.endsWith(".css") ? `<link rel="stylesheet" href="${file}">` : (
41
+ // `modulepreload` also fetches the chunk's own static imports.
42
+ `<link rel="modulepreload" href="${file}">`
43
+ )
44
+ );
45
+ if (tags.length === 0) return template;
46
+ const head = template.indexOf("</head>");
47
+ if (head === -1) return template;
48
+ return template.slice(0, head) + tags.join("") + template.slice(head);
49
+ }
50
+ function setHtmlAttr(html, name, value) {
51
+ const existing = new RegExp(`(<html\\b[^>]*?)\\s${name}="[^"]*"`, "i");
52
+ if (existing.test(html)) return html.replace(existing, `$1 ${name}="${value}"`);
53
+ return html.replace(/<html\b/i, `<html ${name}="${value}"`);
54
+ }
55
+ function injectAppAndHead(template, rendered, mountId = "root") {
56
+ const { head, body } = extractHeadMarker(rendered);
57
+ let html = injectApp(template, body, mountId);
58
+ if (head) {
59
+ if (head.headHtml) {
60
+ if (/<title[\s>]/i.test(head.headHtml)) html = html.replace(/<title>[\s\S]*?<\/title>/i, "");
61
+ html = html.replace("</head>", `${head.headHtml}</head>`);
62
+ }
63
+ for (const [k, v] of Object.entries(head.htmlAttrs)) html = setHtmlAttr(html, k, v);
64
+ }
65
+ return html;
66
+ }
67
+ function guardHandler(handler, onError) {
68
+ return async (request) => {
69
+ try {
70
+ return await handler(request);
71
+ } catch (e) {
72
+ onError?.(e);
73
+ return new Response(String(e?.stack || e), {
74
+ status: 500,
75
+ headers: { "content-type": "text/plain; charset=utf-8" }
76
+ });
77
+ }
78
+ };
79
+ }
80
+ export {
81
+ guardHandler,
82
+ injectApp,
83
+ injectAppAndHead,
84
+ injectPreload,
85
+ splitTemplate
86
+ };
@@ -0,0 +1,43 @@
1
+ /*! @fluixi/start v0.1.0-alpha.74 | (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/generated-api.ts
22
+ var generated_api_exports = {};
23
+ __export(generated_api_exports, {
24
+ handleApiRequest: () => handleApiRequest,
25
+ isApiRequest: () => isApiRequest
26
+ });
27
+ module.exports = __toCommonJS(generated_api_exports);
28
+ function missingPlugin() {
29
+ throw new Error(
30
+ "[fluixi] '@fluixi/start/api-routes' was imported but the API scan plugin did not replace it. Build with `fluixi build`/`fluixi dev`, or add the @fluixi/start plugins to your Vite config."
31
+ );
32
+ }
33
+ function isApiRequest(_request) {
34
+ missingPlugin();
35
+ }
36
+ function handleApiRequest(_request) {
37
+ missingPlugin();
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ handleApiRequest,
42
+ isApiRequest
43
+ });
@@ -0,0 +1,18 @@
1
+ /*! @fluixi/start v0.1.0-alpha.74 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+
3
+ // src/generated-api.ts
4
+ function missingPlugin() {
5
+ throw new Error(
6
+ "[fluixi] '@fluixi/start/api-routes' was imported but the API scan plugin did not replace it. Build with `fluixi build`/`fluixi dev`, or add the @fluixi/start plugins to your Vite config."
7
+ );
8
+ }
9
+ function isApiRequest(_request) {
10
+ missingPlugin();
11
+ }
12
+ function handleApiRequest(_request) {
13
+ missingPlugin();
14
+ }
15
+ export {
16
+ handleApiRequest,
17
+ isApiRequest
18
+ };
@@ -0,0 +1,43 @@
1
+ /*! @fluixi/start v0.1.0-alpha.74 | (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/generated-server-fns.ts
22
+ var generated_server_fns_exports = {};
23
+ __export(generated_server_fns_exports, {
24
+ handleServerFn: () => handleServerFn,
25
+ isServerFnRequest: () => isServerFnRequest
26
+ });
27
+ module.exports = __toCommonJS(generated_server_fns_exports);
28
+ function missingPlugin() {
29
+ throw new Error(
30
+ "[fluixi] '@fluixi/start/server-fns' was imported but the server-function plugin did not replace it. Build with `fluixi build`/`fluixi dev`, or add the @fluixi/start plugins to your Vite config."
31
+ );
32
+ }
33
+ function isServerFnRequest(_request) {
34
+ missingPlugin();
35
+ }
36
+ function handleServerFn(_request) {
37
+ missingPlugin();
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ handleServerFn,
42
+ isServerFnRequest
43
+ });
@@ -0,0 +1,18 @@
1
+ /*! @fluixi/start v0.1.0-alpha.74 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+
3
+ // src/generated-server-fns.ts
4
+ function missingPlugin() {
5
+ throw new Error(
6
+ "[fluixi] '@fluixi/start/server-fns' was imported but the server-function plugin did not replace it. Build with `fluixi build`/`fluixi dev`, or add the @fluixi/start plugins to your Vite config."
7
+ );
8
+ }
9
+ function isServerFnRequest(_request) {
10
+ missingPlugin();
11
+ }
12
+ function handleServerFn(_request) {
13
+ missingPlugin();
14
+ }
15
+ export {
16
+ handleServerFn,
17
+ isServerFnRequest
18
+ };