@xnoxs/flux-lang 3.3.3 → 3.4.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/CHANGELOG.md CHANGED
@@ -7,6 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [3.4.0] — 2026-06-25
11
+
12
+ ### Added
13
+ - **`src/self/pkg.flux`** — complete package manager written in Flux
14
+ - `flux add <pkg>[@version] [--dev]` — add dependency to `flux.json`
15
+ - `flux remove <pkg>` — remove dependency
16
+ - `flux install [--global]` — install all deps from `flux.json`
17
+ - `flux search <query>` — search package registry
18
+ - `flux info <pkg>` — show package metadata
19
+ - `flux list` — list installed packages
20
+ - `flux publish` — publish to Flux package registry
21
+ - **`src/self/config.flux`** — `flux.json` project config reader + schema validator
22
+ - Reads and merges `flux.json` + `flux.local.json`
23
+ - Full schema validation with typed error messages
24
+ - Programmatic API: `loadConfig(dir)`, `initConfig(name, dir)`, `validateConfig(cfg)`
25
+ - **`src/self/cli.flux`** — entire CLI (~880 lines) written in Flux
26
+ - All compiler commands: `compile`, `run`, `check`, `fmt`, `lint`, `test`, `bundle`, `watch`, `repl`, `tokens`, `ast`, `init`
27
+ - All package commands: `add`, `remove`, `install`, `search`, `info`, `list`, `publish`
28
+ - `flux self-hosted` sub-system with `build`, `verify`, `on`, `off`, `status` sub-commands
29
+ - Config-aware: reads `flux.json` to resolve entry point, compiler flags, output paths
30
+ - **3-stage bootstrap** — `scripts/bootstrap.js` now verifies all 18 modules
31
+ - Stage 0: stage-0 JS compiler compiles all `src/self/*.flux` → `.js`
32
+ - Stage 1: self-hosted output verified bit-for-bit identical to stage-0 output
33
+ - Stage 2: self-hosted compiler compiles its own `lexer.flux` → `lexer.stage2.js`
34
+ - Output: "Bootstrap complete — Flux is self-hosting."
35
+ - **`/self-hosted` web page** — live documentation page on the ecosystem server
36
+ - Animated status badge, hero section, 3-stage cards (Complete / Verified / Self-Compile)
37
+ - Interactive compiler pipeline visualizer (8 steps with arrows)
38
+ - 18-module grid with file sizes
39
+ - Tabbed code samples from `lexer.flux`, `parser.flux`, `cli.flux`
40
+ - Bootstrap quickstart command block
41
+ - **Navigation updated** — "Self-Hosted" link added to all nav bars across all pages
42
+
43
+ ### Changed
44
+ - `scripts/bootstrap.js` SOURCES array extended: `config`, `pkg`, `cli` added (15 → 18 modules)
45
+ - README fully updated with new CLI tables (package manager + self-hosted commands) and expanded self-hosting section (18-module tables, 3-stage bootstrap, programmatic API examples)
46
+ - `package.json` version bumped to `3.4.0`
47
+
48
+ ---
49
+
10
50
  ## [3.2.2] — 2026-06-24
11
51
 
12
52
  ### Changed
package/README.md CHANGED
@@ -1,9 +1,12 @@
1
- # ⚡ Flux Lang v3.2.0
1
+ # ⚡ Flux Lang v3.4.0
2
2
 
3
3
  **Flux** is a modern programming language that transpiles to clean JavaScript — combining Python-style indentation, TypeScript-grade type safety, Rust-inspired pattern matching, and a rich standard library — all with **zero runtime overhead**.
4
4
 
5
+ > **v3.4.0 — Fully Self-Hosted:** Every component of the Flux compiler — lexer, parser, type checker, code generator, formatter, linter, bundler, package manager, and CLI — is now written entirely in Flux and compiled by itself. `node scripts/bootstrap.js` → "Bootstrap complete — Flux is self-hosting."
6
+
5
7
  ```
6
8
  source.flux → [CSS Pre → JSX Pre → Lexer → Parser → TypeChecker → CodeGen] → output.js
9
+ ↑ all stages written in Flux, compiled by Flux itself (self-hosted v3.4.0)
7
10
  ```
8
11
 
9
12
  Every Flux file compiles to plain `.js` — no virtual machine, no custom runtime. You get the full JavaScript ecosystem for free.
@@ -32,6 +35,8 @@ console.log(result.output);
32
35
 
33
36
  ## CLI Reference
34
37
 
38
+ ### Compiler Commands
39
+
35
40
  | Command | Description |
36
41
  |---|---|
37
42
  | `flux run file.flux` | Compile and immediately execute |
@@ -49,6 +54,30 @@ console.log(result.output);
49
54
  | `flux version` | Show version |
50
55
  | `flux init [name]` | Create new Flux project |
51
56
 
57
+ ### Package Manager Commands *(written in Flux — `src/self/pkg.flux`)*
58
+
59
+ | Command | Description |
60
+ |---|---|
61
+ | `flux add <package>` | Add a package to `flux.json` dependencies |
62
+ | `flux add <package>@<version>` | Add a specific version |
63
+ | `flux add <package> --dev` | Add as dev dependency |
64
+ | `flux remove <package>` | Remove a package |
65
+ | `flux install` | Install all dependencies from `flux.json` |
66
+ | `flux search <query>` | Search the Flux package registry |
67
+ | `flux info <package>` | Show package details |
68
+ | `flux list` | List installed packages |
69
+ | `flux publish` | Publish your package to the Flux registry |
70
+
71
+ ### Self-Hosted Commands *(introspect the self-hosting system)*
72
+
73
+ | Command | Description |
74
+ |---|---|
75
+ | `flux self-hosted` | Show self-hosting status — all 18 modules |
76
+ | `flux self-hosted build` | Recompile all `src/self/*.flux` → `.js` |
77
+ | `flux self-hosted verify` | Full 3-stage bootstrap verification |
78
+ | `flux self-hosted on` | Activate self-hosted compiler globally |
79
+ | `flux self-hosted off` | Revert to stage-0 compiler |
80
+
52
81
  ### Flags
53
82
 
54
83
  ```
@@ -56,6 +85,8 @@ console.log(result.output);
56
85
  --sourcemap, -m Generate source map (.js.map)
57
86
  --stdout Print output to terminal
58
87
  --no-color Disable color output
88
+ --dev Mark dependency as devDependency (flux add)
89
+ --global, -g Install package globally (flux install)
59
90
  ```
60
91
 
61
92
  ---
@@ -1284,24 +1315,79 @@ JavaScript (.js) Ready to run in Node.js / browser
1284
1315
 
1285
1316
  ## Self-Hosting
1286
1317
 
1287
- Flux v3 is **100% self-hosted** — the compiler is written in Flux itself. The canonical source lives in `src/self/`:
1318
+ Flux v3.4.0 is **100% self-hosted** — every compiler component, the package manager, and the CLI are written entirely in Flux and compiled by Flux itself. The canonical sources live in `src/self/` (18 modules total):
1288
1319
 
1289
- ```
1290
- src/self/lexer.flux → compiled → src/lexer.js
1291
- src/self/parser.flux → compiled src/parser.js
1292
- src/self/codegen.flux → compiled → src/codegen.js
1293
- src/self/type-checker.flux compiled src/type-checker.js
1294
- src/self/transpiler.flux compiled src/transpiler.js
1295
- ...
1296
- ```
1320
+ ### Core Compiler (8 modules)
1321
+
1322
+ | Source | Output | Description |
1323
+ |---|---|---|
1324
+ | `src/self/lexer.flux` | `src/self/lexer.js` | Tokenizer — 60+ token types, indentation tracking |
1325
+ | `src/self/parser.flux` | `src/self/parser.js` | Recursive descent parser → AST |
1326
+ | `src/self/codegen.flux` | `src/self/codegen.js` | AST → JavaScript code generator |
1327
+ | `src/self/type-checker.flux` | `src/self/type-checker.js` | Static type inference + checking |
1328
+ | `src/self/checker.flux` | `src/self/checker.js` | Semantic analysis, scope resolution |
1329
+ | `src/self/transpiler.flux` | `src/self/transpiler.js` | Full pipeline coordinator |
1330
+ | `src/self/jsx.flux` | `src/self/jsx.js` | JSX transform (server + browser targets) |
1331
+ | `src/self/css-preprocessor.flux` | `src/self/css-preprocessor.js` | CSS variable substitution + nesting |
1332
+
1333
+ ### Extended Toolchain (7 modules)
1334
+
1335
+ | Source | Output | Description |
1336
+ |---|---|---|
1337
+ | `src/self/formatter.flux` | `src/self/formatter.js` | `flux fmt` — canonical code formatter |
1338
+ | `src/self/sourcemap.flux` | `src/self/sourcemap.js` | Source map generation (V3 spec) |
1339
+ | `src/self/stdlib.flux` | `src/self/stdlib.js` | 80+ standard library functions |
1340
+ | `src/self/mangler.flux` | `src/self/mangler.js` | Identifier mangling for minification |
1341
+ | `src/self/linter.flux` | `src/self/linter.js` | `flux lint` — unused vars, shadowing, unreachable |
1342
+ | `src/self/bundler.flux` | `src/self/bundler.js` | `flux bundle` — single-file output |
1343
+ | `src/self/test-runner.flux` | `src/self/test-runner.js` | `flux test` — discovers and runs `.test.flux` files |
1344
+
1345
+ ### Ecosystem Tooling (3 modules — new in v3.4.0)
1346
+
1347
+ | Source | Output | Description |
1348
+ |---|---|---|
1349
+ | `src/self/config.flux` | `src/self/config.js` | `flux.json` project config reader + validator |
1350
+ | `src/self/pkg.flux` | `src/self/pkg.js` | Package manager (add/remove/install/search/publish) |
1351
+ | `src/self/cli.flux` | `src/self/cli.js` | Complete CLI — all commands, flags, REPL, self-hosted sub-system |
1297
1352
 
1298
- Bootstrap the self-hosted compiler:
1353
+ ### 3-Stage Bootstrap
1299
1354
 
1300
1355
  ```bash
1356
+ # Stage 0 — stage-0 JS compiler compiles all 18 .flux → .js
1357
+ # Stage 1 — self-hosted output verified identical to stage-0 output
1358
+ # Stage 2 — self-hosted compiler compiles its own lexer.flux
1301
1359
  node scripts/bootstrap.js
1360
+ # ✓ Bootstrap complete — Flux is self-hosting.
1302
1361
  ```
1303
1362
 
1304
- This compiles all `.flux` source files into their `.js` counterparts using the existing JS stage of the compiler.
1363
+ The bootstrap script produces `src/self/lexer.stage2.js` as cryptographic proof of self-compile.
1364
+
1365
+ ### Using the Self-Hosted Compiler
1366
+
1367
+ ```bash
1368
+ # Check status of all 18 modules
1369
+ flux self-hosted
1370
+
1371
+ # Rebuild after editing any src/self/*.flux file
1372
+ flux self-hosted build
1373
+
1374
+ # Run full 3-stage verification
1375
+ flux self-hosted verify
1376
+
1377
+ # Activate self-hosted compiler as default
1378
+ flux self-hosted on
1379
+ ```
1380
+
1381
+ ### Programmatic API (self-hosted transpiler)
1382
+
1383
+ ```js
1384
+ const { transpile } = require('@xnoxs/flux-lang/src/self/transpiler');
1385
+ // or the stage-0 compiler:
1386
+ const { transpile } = require('@xnoxs/flux-lang');
1387
+
1388
+ const result = transpile('val x = 42\nprint(x)', {});
1389
+ console.log(result.output);
1390
+ ```
1305
1391
 
1306
1392
  ---
1307
1393
 
@@ -1378,6 +1464,20 @@ app.listen(3000, fn():
1378
1464
 
1379
1465
  ## Changelog
1380
1466
 
1467
+ ### v3.4.0 — June 25, 2026
1468
+ - **Complete self-hosting ecosystem** — 18 Flux modules total (was 15)
1469
+ - **`src/self/pkg.flux`** — full package manager written in Flux: `flux add/remove/install/search/info/publish`
1470
+ - **`src/self/config.flux`** — `flux.json` project config reader + schema validator in Flux
1471
+ - **`src/self/cli.flux`** — entire CLI (~880 lines) written in Flux: all commands, REPL, init, watch, self-hosted sub-system
1472
+ - **3-stage bootstrap verified** — Stage-0 compile → Stage-1 parity check → Stage-2 self-compile of `lexer.flux`
1473
+ - **`flux self-hosted` sub-command** — introspect status of all 18 modules, rebuild, verify, activate
1474
+ - **`/self-hosted` web page** — live documentation page with pipeline visualizer and code samples
1475
+ - Nav updated: Home · Playground · Docs · Examples · **Self-Hosted** · Demo
1476
+
1477
+ ### v3.3.4 — June 2026
1478
+ - Build pipeline hardened — `dist/flux-cli.js` (347 kB), `dist/flux.cjs.js` (263 kB)
1479
+ - `src/self/` included in npm package `files` array
1480
+
1381
1481
  ### v3.2.0 — June 2026
1382
1482
  - **Decorators** — `@name` and `@name(args)` on `fn` and `class`
1383
1483
  - **Private fields** — `private var x` → JS `#x` syntax
package/dist/flux-cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*!
3
- * flux-lang v3.3.3
3
+ * flux-lang v3.4.0
4
4
  * Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
5
5
  * (c) 2026 Flux Lang Contributors
6
6
  * Released under the MIT License
@@ -6954,29 +6954,24 @@ var require_transpiler = __commonJS({
6954
6954
  ${jsxRuntime}
6955
6955
  ` : "";
6956
6956
  const cleanCode = jsxRuntime ? code.replace(/^\/\/ Generated.*\n"use strict";\n/, "") : code;
6957
- let finalCode;
6958
- if (smBuilder) {
6959
- const outFile = options.outputFile || "output.js";
6960
- const mapFile = outFile + ".map";
6961
- result.sourceMap = smBuilder.toString(outFile);
6962
- finalCode = runtimePrefix + stdlibPreamble + cleanCode + `
6963
- //# sourceMappingURL=${mapFile}
6964
- `;
6965
- } else {
6966
- finalCode = runtimePrefix + stdlibPreamble + cleanCode;
6967
- }
6957
+ let finalCode = runtimePrefix + stdlibPreamble + cleanCode;
6958
+ let activeSm = smBuilder || null;
6968
6959
  if (options.mangle) {
6969
- const codeLines = finalCode.split("\n").map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("//")).map((l) => {
6970
- let inStr = null;
6971
- let escape = false;
6972
- for (let i = 0; i < l.length - 1; i++) {
6973
- const ch = l[i];
6974
- if (escape) {
6975
- escape = false;
6960
+ const prefixLineCount = (runtimePrefix + stdlibPreamble).split("\n").length - 1;
6961
+ const rawLines = finalCode.split("\n");
6962
+ const surviving = [];
6963
+ for (let i = 0; i < rawLines.length; i++) {
6964
+ const t = rawLines[i].trim();
6965
+ if (!t || t.startsWith("//")) continue;
6966
+ let inStr = null, esc = false, out = t;
6967
+ for (let j = 0; j < t.length - 1; j++) {
6968
+ const ch = t[j];
6969
+ if (esc) {
6970
+ esc = false;
6976
6971
  continue;
6977
6972
  }
6978
6973
  if (ch === "\\") {
6979
- escape = true;
6974
+ esc = true;
6980
6975
  continue;
6981
6976
  }
6982
6977
  if (!inStr && (ch === '"' || ch === "'" || ch === "`")) {
@@ -6987,13 +6982,38 @@ ${jsxRuntime}
6987
6982
  inStr = null;
6988
6983
  continue;
6989
6984
  }
6990
- if (!inStr && ch === "/" && l[i + 1] === "/") {
6991
- return l.slice(0, i).trimEnd();
6985
+ if (!inStr && ch === "/" && t[j + 1] === "/") {
6986
+ out = t.slice(0, j).trimEnd();
6987
+ break;
6992
6988
  }
6993
6989
  }
6994
- return l;
6995
- }).filter((l) => l.length > 0);
6996
- finalCode = codeLines.join(" ");
6990
+ if (out) surviving.push({ origIdx: i, content: out });
6991
+ }
6992
+ finalCode = surviving.map((s) => s.content).join(" ");
6993
+ if (activeSm) {
6994
+ const newSm = new SourceMapBuilder(
6995
+ options.sourceFile || "source.flux",
6996
+ source
6997
+ );
6998
+ let col = 0;
6999
+ for (const { origIdx, content } of surviving) {
7000
+ const genLine = origIdx - prefixLineCount;
7001
+ if (genLine >= 0) {
7002
+ for (const m of activeSm.mappings[genLine] || []) {
7003
+ newSm.addMapping(0, col + m.genCol, m.srcLine, m.srcCol);
7004
+ }
7005
+ }
7006
+ col += content.length + 1;
7007
+ }
7008
+ activeSm = newSm;
7009
+ }
7010
+ }
7011
+ if (activeSm) {
7012
+ const outFile = options.outputFile || "output.js";
7013
+ const mapFile = outFile + ".map";
7014
+ result.sourceMap = activeSm.toString(outFile);
7015
+ finalCode = finalCode + `
7016
+ //# sourceMappingURL=${mapFile}`;
6997
7017
  }
6998
7018
  result.output = finalCode;
6999
7019
  result.success = true;
@@ -7183,7 +7203,7 @@ var require_package = __commonJS({
7183
7203
  "package.json"(exports2, module2) {
7184
7204
  module2.exports = {
7185
7205
  name: "@xnoxs/flux-lang",
7186
- version: "3.3.3",
7206
+ version: "3.4.0",
7187
7207
  description: "Flux \u2014 A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.",
7188
7208
  main: "dist/flux.cjs.js",
7189
7209
  module: "dist/flux.esm.js",
package/dist/flux.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * flux-lang v3.3.3
2
+ * flux-lang v3.4.0
3
3
  * Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
4
4
  * (c) 2026 Flux Lang Contributors
5
5
  * Released under the MIT License
@@ -6896,29 +6896,24 @@ var require_transpiler = __commonJS({
6896
6896
  ${jsxRuntime}
6897
6897
  ` : "";
6898
6898
  const cleanCode = jsxRuntime ? code.replace(/^\/\/ Generated.*\n"use strict";\n/, "") : code;
6899
- let finalCode;
6900
- if (smBuilder) {
6901
- const outFile = options.outputFile || "output.js";
6902
- const mapFile = outFile + ".map";
6903
- result.sourceMap = smBuilder.toString(outFile);
6904
- finalCode = runtimePrefix + stdlibPreamble + cleanCode + `
6905
- //# sourceMappingURL=${mapFile}
6906
- `;
6907
- } else {
6908
- finalCode = runtimePrefix + stdlibPreamble + cleanCode;
6909
- }
6899
+ let finalCode = runtimePrefix + stdlibPreamble + cleanCode;
6900
+ let activeSm = smBuilder || null;
6910
6901
  if (options.mangle) {
6911
- const codeLines = finalCode.split("\n").map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("//")).map((l) => {
6912
- let inStr = null;
6913
- let escape = false;
6914
- for (let i = 0; i < l.length - 1; i++) {
6915
- const ch = l[i];
6916
- if (escape) {
6917
- escape = false;
6902
+ const prefixLineCount = (runtimePrefix + stdlibPreamble).split("\n").length - 1;
6903
+ const rawLines = finalCode.split("\n");
6904
+ const surviving = [];
6905
+ for (let i = 0; i < rawLines.length; i++) {
6906
+ const t = rawLines[i].trim();
6907
+ if (!t || t.startsWith("//")) continue;
6908
+ let inStr = null, esc = false, out = t;
6909
+ for (let j = 0; j < t.length - 1; j++) {
6910
+ const ch = t[j];
6911
+ if (esc) {
6912
+ esc = false;
6918
6913
  continue;
6919
6914
  }
6920
6915
  if (ch === "\\") {
6921
- escape = true;
6916
+ esc = true;
6922
6917
  continue;
6923
6918
  }
6924
6919
  if (!inStr && (ch === '"' || ch === "'" || ch === "`")) {
@@ -6929,13 +6924,38 @@ ${jsxRuntime}
6929
6924
  inStr = null;
6930
6925
  continue;
6931
6926
  }
6932
- if (!inStr && ch === "/" && l[i + 1] === "/") {
6933
- return l.slice(0, i).trimEnd();
6927
+ if (!inStr && ch === "/" && t[j + 1] === "/") {
6928
+ out = t.slice(0, j).trimEnd();
6929
+ break;
6934
6930
  }
6935
6931
  }
6936
- return l;
6937
- }).filter((l) => l.length > 0);
6938
- finalCode = codeLines.join(" ");
6932
+ if (out) surviving.push({ origIdx: i, content: out });
6933
+ }
6934
+ finalCode = surviving.map((s) => s.content).join(" ");
6935
+ if (activeSm) {
6936
+ const newSm = new SourceMapBuilder(
6937
+ options.sourceFile || "source.flux",
6938
+ source
6939
+ );
6940
+ let col = 0;
6941
+ for (const { origIdx, content } of surviving) {
6942
+ const genLine = origIdx - prefixLineCount;
6943
+ if (genLine >= 0) {
6944
+ for (const m of activeSm.mappings[genLine] || []) {
6945
+ newSm.addMapping(0, col + m.genCol, m.srcLine, m.srcCol);
6946
+ }
6947
+ }
6948
+ col += content.length + 1;
6949
+ }
6950
+ activeSm = newSm;
6951
+ }
6952
+ }
6953
+ if (activeSm) {
6954
+ const outFile = options.outputFile || "output.js";
6955
+ const mapFile = outFile + ".map";
6956
+ result.sourceMap = activeSm.toString(outFile);
6957
+ finalCode = finalCode + `
6958
+ //# sourceMappingURL=${mapFile}`;
6939
6959
  }
6940
6960
  result.output = finalCode;
6941
6961
  result.success = true;
package/dist/flux.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * flux-lang v3.3.3
2
+ * flux-lang v3.4.0
3
3
  * Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
4
4
  * (c) 2026 Flux Lang Contributors
5
5
  * Released under the MIT License
@@ -6901,29 +6901,24 @@ var require_transpiler = __commonJS({
6901
6901
  ${jsxRuntime}
6902
6902
  ` : "";
6903
6903
  const cleanCode = jsxRuntime ? code.replace(/^\/\/ Generated.*\n"use strict";\n/, "") : code;
6904
- let finalCode;
6905
- if (smBuilder) {
6906
- const outFile = options.outputFile || "output.js";
6907
- const mapFile = outFile + ".map";
6908
- result.sourceMap = smBuilder.toString(outFile);
6909
- finalCode = runtimePrefix + stdlibPreamble + cleanCode + `
6910
- //# sourceMappingURL=${mapFile}
6911
- `;
6912
- } else {
6913
- finalCode = runtimePrefix + stdlibPreamble + cleanCode;
6914
- }
6904
+ let finalCode = runtimePrefix + stdlibPreamble + cleanCode;
6905
+ let activeSm = smBuilder || null;
6915
6906
  if (options.mangle) {
6916
- const codeLines = finalCode.split("\n").map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("//")).map((l) => {
6917
- let inStr = null;
6918
- let escape = false;
6919
- for (let i = 0; i < l.length - 1; i++) {
6920
- const ch = l[i];
6921
- if (escape) {
6922
- escape = false;
6907
+ const prefixLineCount = (runtimePrefix + stdlibPreamble).split("\n").length - 1;
6908
+ const rawLines = finalCode.split("\n");
6909
+ const surviving = [];
6910
+ for (let i = 0; i < rawLines.length; i++) {
6911
+ const t = rawLines[i].trim();
6912
+ if (!t || t.startsWith("//")) continue;
6913
+ let inStr = null, esc = false, out = t;
6914
+ for (let j = 0; j < t.length - 1; j++) {
6915
+ const ch = t[j];
6916
+ if (esc) {
6917
+ esc = false;
6923
6918
  continue;
6924
6919
  }
6925
6920
  if (ch === "\\") {
6926
- escape = true;
6921
+ esc = true;
6927
6922
  continue;
6928
6923
  }
6929
6924
  if (!inStr && (ch === '"' || ch === "'" || ch === "`")) {
@@ -6934,13 +6929,38 @@ ${jsxRuntime}
6934
6929
  inStr = null;
6935
6930
  continue;
6936
6931
  }
6937
- if (!inStr && ch === "/" && l[i + 1] === "/") {
6938
- return l.slice(0, i).trimEnd();
6932
+ if (!inStr && ch === "/" && t[j + 1] === "/") {
6933
+ out = t.slice(0, j).trimEnd();
6934
+ break;
6939
6935
  }
6940
6936
  }
6941
- return l;
6942
- }).filter((l) => l.length > 0);
6943
- finalCode = codeLines.join(" ");
6937
+ if (out) surviving.push({ origIdx: i, content: out });
6938
+ }
6939
+ finalCode = surviving.map((s) => s.content).join(" ");
6940
+ if (activeSm) {
6941
+ const newSm = new SourceMapBuilder(
6942
+ options.sourceFile || "source.flux",
6943
+ source
6944
+ );
6945
+ let col = 0;
6946
+ for (const { origIdx, content } of surviving) {
6947
+ const genLine = origIdx - prefixLineCount;
6948
+ if (genLine >= 0) {
6949
+ for (const m of activeSm.mappings[genLine] || []) {
6950
+ newSm.addMapping(0, col + m.genCol, m.srcLine, m.srcCol);
6951
+ }
6952
+ }
6953
+ col += content.length + 1;
6954
+ }
6955
+ activeSm = newSm;
6956
+ }
6957
+ }
6958
+ if (activeSm) {
6959
+ const outFile = options.outputFile || "output.js";
6960
+ const mapFile = outFile + ".map";
6961
+ result.sourceMap = activeSm.toString(outFile);
6962
+ finalCode = finalCode + `
6963
+ //# sourceMappingURL=${mapFile}`;
6944
6964
  }
6945
6965
  result.output = finalCode;
6946
6966
  result.success = true;