@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
@@ -0,0 +1,114 @@
1
+ // src/api.ts
2
+ import { readdirSync, statSync } from "node:fs";
3
+ import { resolve as resolvePath, relative as relativePath, join } from "node:path";
4
+ var API_VMOD = "virtual:fluixi-api";
5
+ var METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
6
+ function derivePattern(rel, prefix = "/api") {
7
+ const segs = rel.split("/").filter(Boolean);
8
+ if (segs[segs.length - 1] === "index") segs.pop();
9
+ const keys = [];
10
+ let rank = 0;
11
+ const parts = segs.map((seg) => {
12
+ const catchAll = seg.match(/^\[\.\.\.(.+)\]$/);
13
+ if (catchAll) {
14
+ keys.push(catchAll[1]);
15
+ return "(.+)";
16
+ }
17
+ const param = seg.match(/^\[(.+)\]$/);
18
+ if (param) {
19
+ keys.push(param[1]);
20
+ rank += 1;
21
+ return "([^/]+)";
22
+ }
23
+ rank += 10;
24
+ return seg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
25
+ });
26
+ return { source: `^${prefix}${parts.length ? "/" + parts.join("/") : ""}/?$`, keys, rank };
27
+ }
28
+ function isApiPath(pathname, prefix = "/api") {
29
+ return pathname === prefix || pathname.startsWith(prefix + "/");
30
+ }
31
+ function matchApiRoutes(routes, pathname) {
32
+ for (const r of [...routes].sort((a, b) => b.rank - a.rank)) {
33
+ const m = new RegExp(r.source).exec(pathname);
34
+ if (!m) continue;
35
+ const params = {};
36
+ r.keys.forEach((k, i) => params[k] = decodeURIComponent(m[i + 1] ?? ""));
37
+ return { mod: r.mod, params };
38
+ }
39
+ return null;
40
+ }
41
+ async function handleApi(routes, request, prefix = "/api") {
42
+ const pathname = new URL(request.url).pathname;
43
+ const match = matchApiRoutes(routes, pathname);
44
+ if (!match) return new Response("Not Found", { status: 404 });
45
+ const fn = match.mod[request.method];
46
+ if (typeof fn !== "function") {
47
+ const allow = METHODS.filter((m) => typeof match.mod[m] === "function").join(", ");
48
+ return new Response("Method Not Allowed", { status: 405, headers: allow ? { allow } : void 0 });
49
+ }
50
+ const out = await fn(request, { params: match.params });
51
+ if (out instanceof Response) return out;
52
+ return new Response(JSON.stringify(out ?? null), { headers: { "content-type": "application/json; charset=utf-8" } });
53
+ }
54
+ function scanFiles(dir, base = dir) {
55
+ let out = [];
56
+ let entries = [];
57
+ try {
58
+ entries = readdirSync(dir);
59
+ } catch {
60
+ return out;
61
+ }
62
+ for (const name of entries) {
63
+ const full = join(dir, name);
64
+ if (statSync(full).isDirectory()) out = out.concat(scanFiles(full, base));
65
+ else if (/\.(ts|tsx|js|mjs)$/.test(name) && !/\.(spec|test)\./.test(name)) out.push(full);
66
+ }
67
+ return out;
68
+ }
69
+ function apiRoutesVitePlugin(opts) {
70
+ let root = process.cwd();
71
+ const prefix = opts.prefix ?? "/api";
72
+ const id = "\0" + API_VMOD;
73
+ return {
74
+ name: "fluixi-api",
75
+ // Must beat node resolution: '@fluixi/start/api-routes' is a real file in this package,
76
+ // so without `pre` Vite resolves the typed stub and the generated table never loads ,
77
+ // the app builds and every API route 404s.
78
+ enforce: "pre",
79
+ configResolved(config) {
80
+ root = config.root || root;
81
+ },
82
+ resolveId(source) {
83
+ return source === API_VMOD || source === "@fluixi/start/api-routes" ? id : null;
84
+ },
85
+ load(source) {
86
+ if (source !== id) return null;
87
+ const dir = resolvePath(root, opts.dir);
88
+ const files = scanFiles(dir);
89
+ const imports = [];
90
+ const entries = [];
91
+ files.forEach((file, i) => {
92
+ const rel = relativePath(dir, file).replace(/\.(ts|tsx|js|mjs)$/, "").split(/[\\/]/).join("/");
93
+ const { source: src, keys, rank } = derivePattern(rel, prefix);
94
+ imports.push(`import * as _${i} from ${JSON.stringify(file)};`);
95
+ entries.push(`{ source: ${JSON.stringify(src)}, keys: ${JSON.stringify(keys)}, rank: ${rank}, mod: _${i} }`);
96
+ });
97
+ return `import { isApiPath, handleApi } from '@fluixi/start/api';
98
+ ${imports.join("\n")}
99
+ const routes = [${entries.join(",")}];
100
+ export const isApiRequest = (request) => isApiPath(new URL(request.url).pathname, ${JSON.stringify(prefix)});
101
+ export const handleApiRequest = (request) => handleApi(routes, request, ${JSON.stringify(prefix)});
102
+ `;
103
+ }
104
+ };
105
+ }
106
+ var API_VIRTUAL_MODULE = API_VMOD;
107
+ export {
108
+ API_VIRTUAL_MODULE,
109
+ apiRoutesVitePlugin,
110
+ derivePattern,
111
+ handleApi,
112
+ isApiPath,
113
+ matchApiRoutes
114
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ API_VIRTUAL_MODULE,
3
+ apiRoutesVitePlugin,
4
+ derivePattern,
5
+ handleApi,
6
+ isApiPath,
7
+ matchApiRoutes
8
+ } from "./chunk-MTM6M3TC.mjs";
9
+ export {
10
+ API_VIRTUAL_MODULE,
11
+ apiRoutesVitePlugin,
12
+ derivePattern,
13
+ handleApi,
14
+ isApiPath,
15
+ matchApiRoutes
16
+ };
@@ -0,0 +1,17 @@
1
+ /*! @fluixi/start v0.1.0-alpha.75 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ import {
3
+ API_VIRTUAL_MODULE,
4
+ apiRoutesVitePlugin,
5
+ derivePattern,
6
+ handleApi,
7
+ isApiPath,
8
+ matchApiRoutes
9
+ } from "./chunk-GFQ4MUIC.mjs";
10
+ export {
11
+ API_VIRTUAL_MODULE,
12
+ apiRoutesVitePlugin,
13
+ derivePattern,
14
+ handleApi,
15
+ isApiPath,
16
+ matchApiRoutes
17
+ };