flamefront 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Alec Larson
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Flamefront
2
+
3
+ Flamefront brings routing, server rendering, and static pages to Octane.
4
+ One route list connects your pages to the server, browser router, and build.
5
+
6
+ ## Why try it?
7
+
8
+ - **Render each page where it makes sense.** On the server, at build time, or
9
+ in the browser.
10
+ - **React Router-style loaders.** Load data beside your page component and read
11
+ it with `useLoaderData`.
12
+ - **Shared layouts.** Keep navigation and shared UI in place as pages change.
13
+ - **Persistent shell state.** Keep players running, uploads progressing, and
14
+ other shared UI state intact between pages without making the whole app
15
+ client-rendered.
16
+ - **Control interactivity.** Activate a page immediately, when it becomes
17
+ visible, or when someone interacts with it.
18
+ - **Markdown routes.** Use Markdown and MDX files as pages.
19
+
20
+ ## One route list
21
+
22
+ ```ts
23
+ import { clientRoute, defineApp, serverRoute, staticRoute } from "flamefront"
24
+
25
+ export const app = defineApp({
26
+ shell: "/src/AppShell.tsrx",
27
+ routes: [
28
+ serverRoute("/", "/src/HomePage.tsrx"),
29
+ staticRoute("/docs", "/src/DocsPage.tsrx"),
30
+ clientRoute("/settings", "/src/SettingsPage.tsrx"),
31
+ ],
32
+ })
33
+ ```
34
+
35
+ The shell holds shared UI. Each route pairs a URL with an Octane page component
36
+ and chooses how it renders.
37
+
38
+ ## Quickstart
39
+
40
+ [Try the included app](./docs/getting-started.md): build a static page, inspect
41
+ its generated HTML, and serve it locally. Then [create your own app](./docs/create-app.md).
42
+
43
+ ## Before you try it
44
+
45
+ Flamefront is an early alpha and requires Node.js 26+. Expect changes before
46
+ 1.0. Follow the setup guide for matching packages.
47
+
48
+ There is no built-in form action or mutation API yet. If your current framework
49
+ already covers your needs, there's no need to switch.
50
+
51
+ Licensed under [FSL-1.1-MIT](./LICENSE.md).
52
+
53
+ ## Learn more
54
+
55
+ - [How Flamefront fits](./docs/index.md)
56
+ - [Route rendering and data](./docs/routes.md)
57
+ - [Build and deployment](./docs/deployment.md)
58
+ - [Migrating an existing app](./docs/brownfield-migration.md)
@@ -0,0 +1,18 @@
1
+ import { readFile } from "node:fs/promises"
2
+ import { stripTypeScriptTypes } from "node:module"
3
+
4
+ const extensions = [".cts", ".mts", ".ts", ".tsx"]
5
+
6
+ export async function load(url, context, nextLoad) {
7
+ if (!extensions.some((extension) => url.endsWith(extension))) {
8
+ return nextLoad(url, context)
9
+ }
10
+
11
+ const source = await readFile(new URL(url), "utf8")
12
+
13
+ return {
14
+ format: "module",
15
+ shortCircuit: true,
16
+ source: stripTypeScriptTypes(source, { mode: "strip" }),
17
+ }
18
+ }
package/bin/ff.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { register } from "node:module"
4
+
5
+ register("./ff-loader.mjs", import.meta.url)
6
+ await import("../src/cli.ts")
package/package.json CHANGED
@@ -1,13 +1,89 @@
1
1
  {
2
2
  "name": "flamefront",
3
- "version": "0.0.0",
4
- "description": "",
5
- "main": "index.js",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Typed centralized route manifests for Octane.",
6
+ "license": "FSL-1.1-MIT",
7
+ "repository": "https://github.com/aleclarson/flamefront",
8
+ "files": [
9
+ "bin",
10
+ "src"
11
+ ],
12
+ "engines": {
13
+ "node": ">=26.0.0"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "bin": {
19
+ "ff": "./bin/ff.js"
20
+ },
21
+ "type": "module",
22
+ "exports": {
23
+ ".": "./src/index.ts",
24
+ "./entry": "./src/entry.ts",
25
+ "./fetch": "./src/fetch.ts",
26
+ "./fragment": "./src/fragment.tsx",
27
+ "./octane": "./src/octane.tsx",
28
+ "./octane/client": "./src/octane-client.ts",
29
+ "./octane/router-document": "./src/octane-router-document.ts",
30
+ "./remix-router": "./src/remix-router.ts",
31
+ "./remix-router/data": "./src/remix-route-data.ts",
32
+ "./server": "./src/server.ts",
33
+ "./output": "./src/output.ts",
34
+ "./srvx": "./src/srvx.ts",
35
+ "./vite": "./src/vite.ts"
36
+ },
6
37
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
38
+ "dev": "pnpm --filter flamefront-playground dev",
39
+ "build": "pnpm --filter flamefront-playground build",
40
+ "preview": "pnpm --filter flamefront-playground preview",
41
+ "typegen": "pnpm --filter flamefront-playground typegen",
42
+ "routes": "pnpm --filter flamefront-playground routes",
43
+ "typecheck": "tsc -p tsconfig.json && pnpm --filter flamefront-playground typecheck",
44
+ "test": "vitest run",
45
+ "test:e2e": "pnpm --filter flamefront-playground build && vitest run --config vitest.e2e.config.ts",
46
+ "check": "oxlint && prettier --check . && pnpm typecheck && pnpm test && pnpm test:e2e",
47
+ "format": "oxlint --fix && prettier --write ."
48
+ },
49
+ "dependencies": {
50
+ "@alloc/cmd-ts": "0.17.1",
51
+ "@babel/generator": "^8.0.5",
52
+ "@babel/parser": "^8.0.5",
53
+ "@babel/traverse": "^8.0.5",
54
+ "@babel/types": "^8.0.5",
55
+ "@remix-run/route-pattern": "0.24.0",
56
+ "babel-dead-code-elimination": "^2.0.0",
57
+ "satteri": "^0.10.5",
58
+ "srvx": "1.0.4",
59
+ "vite-plugin-satteri": "^0.3.5"
60
+ },
61
+ "devDependencies": {
62
+ "@octanejs/remix-router": "0.1.48",
63
+ "@octanejs/vite-plugin": "0.1.54",
64
+ "@stylistic/eslint-plugin": "^5.10.0",
65
+ "@tsrx/prettier-plugin": "^0.3.137",
66
+ "@types/babel__generator": "^7.27.0",
67
+ "@types/babel__traverse": "^7.28.0",
68
+ "@types/node": "26.5.1",
69
+ "octane": "0.2.7",
70
+ "oxc-tsrx": "0.6.1",
71
+ "oxlint": "^1.82.0",
72
+ "oxlint-tsgolint": "^7.0.2001",
73
+ "playwright": "1.63.0",
74
+ "prettier": "^3.9.6",
75
+ "typescript": "5.9.3",
76
+ "vite": "8.3.0",
77
+ "vitest": "^5.0.0"
78
+ },
79
+ "peerDependencies": {
80
+ "@octanejs/remix-router": "0.1.48",
81
+ "octane": "0.2.7",
82
+ "vite": "^8.3.0"
8
83
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "All rights reserved",
12
- "type": "commonjs"
84
+ "peerDependenciesMeta": {
85
+ "@octanejs/remix-router": {
86
+ "optional": true
87
+ }
88
+ }
13
89
  }
package/src/babel.ts ADDED
@@ -0,0 +1,22 @@
1
+ import generatorModule from "@babel/generator"
2
+ import { parse, type ParseResult } from "@babel/parser"
3
+ import type { NodePath } from "@babel/traverse"
4
+ import traverseModule from "@babel/traverse"
5
+ import type * as Babel from "@babel/types"
6
+
7
+ type DefaultImport<T> = T | { default: T }
8
+
9
+ function unwrapDefault<T>(value: DefaultImport<T>): T {
10
+ return (value as { default?: T }).default ?? (value as T)
11
+ }
12
+
13
+ // Babel's CommonJS packages have different shapes across Node and bundlers.
14
+ const traverse = unwrapDefault(
15
+ traverseModule as DefaultImport<typeof import("@babel/traverse").default>,
16
+ )
17
+ const generate = unwrapDefault(
18
+ generatorModule as DefaultImport<typeof import("@babel/generator").default>,
19
+ )
20
+
21
+ export { generate, parse, traverse }
22
+ export type { Babel, NodePath, ParseResult }
package/src/cli.ts ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { relative } from "node:path"
4
+ import {
5
+ binary,
6
+ command,
7
+ flag,
8
+ number,
9
+ option,
10
+ optional,
11
+ run,
12
+ subcommands,
13
+ } from "@alloc/cmd-ts"
14
+ import {
15
+ buildProject,
16
+ devProject,
17
+ loadProject,
18
+ previewProject,
19
+ } from "./lifecycle.ts"
20
+ import { generateProjectTypes } from "./typegen.ts"
21
+
22
+ const routes = command({
23
+ name: "routes",
24
+ aliases: ["route"],
25
+ description: "List the centralized route manifest for the current app.",
26
+ args: {
27
+ json: flag({
28
+ long: "json",
29
+ description: "Print the manifest as JSON.",
30
+ }),
31
+ },
32
+ async handler({ json }) {
33
+ const { app } = await loadProject()
34
+
35
+ if (json) {
36
+ console.log(JSON.stringify(app.routes, null, 2))
37
+ return
38
+ }
39
+
40
+ for (const route of app.routes) {
41
+ const hydration =
42
+ typeof route.hydration === "object"
43
+ ? JSON.stringify(route.hydration)
44
+ : (route.hydration ?? "default")
45
+
46
+ console.log(`${route.path}\t${route.render}\t${hydration}`)
47
+ }
48
+ },
49
+ })
50
+
51
+ const dev = command({
52
+ name: "dev",
53
+ description: "Start the development server for every render mode.",
54
+ args: {
55
+ port: option({
56
+ long: "port",
57
+ type: optional(number),
58
+ description: "Port for the development server.",
59
+ }),
60
+ },
61
+ handler: ({ port }) => devProject(process.cwd(), port),
62
+ })
63
+
64
+ const build = command({
65
+ name: "build",
66
+ description: "Build client and server bundles, then prerender static routes.",
67
+ args: {},
68
+ handler: () => buildProject(),
69
+ })
70
+
71
+ const preview = command({
72
+ name: "preview",
73
+ description: "Serve a production build locally.",
74
+ args: {},
75
+ handler: () => previewProject(),
76
+ })
77
+
78
+ const typegen = command({
79
+ name: "typegen",
80
+ description: "Generate route import declarations for the current app.",
81
+ args: {},
82
+ async handler() {
83
+ const result = await generateProjectTypes()
84
+ const status = result.written ? "Generated" : "Unchanged"
85
+ const file = relative(process.cwd(), result.file) || "."
86
+
87
+ console.log(`${status} ${file}.`)
88
+ },
89
+ })
90
+
91
+ const cli = subcommands({
92
+ name: "ff",
93
+ version: "0.1.0-alpha.0",
94
+ description: "Flamefront, a small compiler-oriented framework for Octane.",
95
+ cmds: { build, dev, preview, routes, typegen },
96
+ })
97
+
98
+ await run(binary(cli), process.argv)
package/src/entry.ts ADDED
@@ -0,0 +1,49 @@
1
+ import type { RouteDefinition } from "./index.ts"
2
+
3
+ export type {
4
+ FetchMiddleware,
5
+ FetchServerAssets,
6
+ FetchServerEntryOptions,
7
+ FlamefrontFetchServerEntry,
8
+ ResponseHeaders,
9
+ ResponseHeadersContext,
10
+ ResponseHeadersHook,
11
+ ServerDocuments,
12
+ ServerEntryLifecycle,
13
+ StaticFragmentContext,
14
+ StaticFragmentLoader,
15
+ TemplateContext,
16
+ TemplateLoader,
17
+ } from "./fetch.ts"
18
+ export type {
19
+ FlamefrontServerEntry,
20
+ ServerAssets,
21
+ SrvxMiddleware,
22
+ SrvxServerEntryOptions,
23
+ } from "./srvx.ts"
24
+
25
+ import type {
26
+ FetchServerEntryOptions,
27
+ FlamefrontFetchServerEntry,
28
+ } from "./fetch.ts"
29
+ import type { FlamefrontServerEntry, SrvxServerEntryOptions } from "./srvx.ts"
30
+
31
+ export type ServerEntryOptions<
32
+ Route extends RouteDefinition = RouteDefinition,
33
+ > = FetchServerEntryOptions<Route> | SrvxServerEntryOptions<Route>
34
+
35
+ export type ServerEntry = FlamefrontFetchServerEntry | FlamefrontServerEntry
36
+
37
+ /**
38
+ * Create the server entry selected by the `flamefront` Vite plugin options.
39
+ * Vite replaces this placeholder with the generated adapter module at build
40
+ * time; the direct-import error prevents an accidental unconfigured entry.
41
+ */
42
+ export function createServerEntry<
43
+ Route extends RouteDefinition = RouteDefinition,
44
+ >(options: ServerEntryOptions<Route>): ServerEntry {
45
+ void options
46
+ throw new Error(
47
+ "flamefront/entry must be loaded through the flamefront Vite plugin.",
48
+ )
49
+ }