fullstacked 1.0.0-alpha.1744 → 1.0.0-alpha.1748

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/index.js CHANGED
@@ -1288,7 +1288,7 @@ var Exit = 5;
1288
1288
  init_isWorker();
1289
1289
 
1290
1290
  // ../../core/internal/bundle/lib/process/version.json with { type: 'json' }
1291
- var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1744", hash: "f8d6e514e172365705b0252622be609f819c4fef" };
1291
+ var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1748", hash: "7c960ea337e7106b199163dff256a67ddd78f29d" };
1292
1292
 
1293
1293
  // ../../core/internal/bundle/lib/timers/index.ts
1294
1294
  var setTimeout2 = globalThis.setTimeout.bind(globalThis);
@@ -1634,8 +1634,8 @@ var constants = {
1634
1634
  return sep;
1635
1635
  }
1636
1636
  };
1637
- function isAbsolute(path4) {
1638
- return path4.startsWith("/") || path4.startsWith("\\") || /^[a-zA-Z]:[/\\]/.test(path4);
1637
+ function isAbsolute(path6) {
1638
+ return path6.startsWith("/") || path6.startsWith("\\") || /^[a-zA-Z]:[/\\]/.test(path6);
1639
1639
  }
1640
1640
  function resolve(...paths) {
1641
1641
  if (paths[0].startsWith("build:")) {
@@ -1662,34 +1662,34 @@ function join(...paths) {
1662
1662
  true
1663
1663
  );
1664
1664
  }
1665
- function normalize(path4) {
1665
+ function normalize(path6) {
1666
1666
  return globalThis.fullstacked.bridge(
1667
1667
  {
1668
1668
  mod: Path,
1669
1669
  fn: Normalize,
1670
- data: [path4]
1670
+ data: [path6]
1671
1671
  },
1672
1672
  true
1673
1673
  );
1674
1674
  }
1675
- function parse(path4) {
1675
+ function parse(path6) {
1676
1676
  return globalThis.fullstacked.bridge(
1677
1677
  {
1678
1678
  mod: Path,
1679
1679
  fn: Parse,
1680
- data: [path4]
1680
+ data: [path6]
1681
1681
  },
1682
1682
  true
1683
1683
  );
1684
1684
  }
1685
- function extname(path4) {
1686
- return parse(path4).ext;
1685
+ function extname(path6) {
1686
+ return parse(path6).ext;
1687
1687
  }
1688
- function dirname(path4) {
1689
- return parse(path4).dir;
1688
+ function dirname(path6) {
1689
+ return parse(path6).dir;
1690
1690
  }
1691
- function basename(path4, suffix) {
1692
- const base = parse(path4).base;
1691
+ function basename(path6, suffix) {
1692
+ const base = parse(path6).base;
1693
1693
  if (suffix && base.endsWith(suffix)) {
1694
1694
  return base.slice(0, 0 - suffix.length);
1695
1695
  }
@@ -1723,8 +1723,8 @@ var path_default = mod;
1723
1723
 
1724
1724
  // ../../core/internal/bundle/lib/fs/common.ts
1725
1725
  init_base64();
1726
- function formatPathLike(path4) {
1727
- const pathStr = path4 instanceof URL ? path4.pathname : path4.toString();
1726
+ function formatPathLike(path6) {
1727
+ const pathStr = path6 instanceof URL ? path6.pathname : path6.toString();
1728
1728
  return pathStr;
1729
1729
  }
1730
1730
  function decodeStringData(data, options) {
@@ -1776,16 +1776,16 @@ function convertGoFileInfo(baseDir, items, withFileTypes) {
1776
1776
  }
1777
1777
 
1778
1778
  // ../../core/internal/bundle/lib/fs/promises.ts
1779
- async function readFile(path4, options) {
1779
+ async function readFile(path6, options) {
1780
1780
  const data = await globalThis.fullstacked.bridge({
1781
1781
  mod: Fs,
1782
1782
  fn: ReadFile,
1783
- data: [formatPathLike(path4)]
1783
+ data: [formatPathLike(path6)]
1784
1784
  });
1785
1785
  return decodeStringData(data, options);
1786
1786
  }
1787
- async function readdir(path4, options) {
1788
- const baseDir = formatPathLike(path4);
1787
+ async function readdir(path6, options) {
1788
+ const baseDir = formatPathLike(path6);
1789
1789
  const items = await globalThis.fullstacked.bridge({
1790
1790
  mod: Fs,
1791
1791
  fn: ReadDir,
@@ -1793,54 +1793,54 @@ async function readdir(path4, options) {
1793
1793
  });
1794
1794
  return convertGoFileInfo(baseDir, items, options?.withFileTypes);
1795
1795
  }
1796
- async function stat(path4, options) {
1796
+ async function stat(path6, options) {
1797
1797
  const fileInfo = await globalThis.fullstacked.bridge({
1798
1798
  mod: Fs,
1799
1799
  fn: Stats,
1800
- data: [formatPathLike(path4)]
1800
+ data: [formatPathLike(path6)]
1801
1801
  });
1802
1802
  return fileInfoToStat(fileInfo);
1803
1803
  }
1804
- function writeFile(path4, data) {
1804
+ function writeFile(path6, data) {
1805
1805
  return globalThis.fullstacked.bridge({
1806
1806
  mod: Fs,
1807
1807
  fn: WriteFile,
1808
- data: [formatPathLike(path4), data]
1808
+ data: [formatPathLike(path6), data]
1809
1809
  });
1810
1810
  }
1811
- function appendFile(path4, data) {
1811
+ function appendFile(path6, data) {
1812
1812
  return globalThis.fullstacked.bridge({
1813
1813
  mod: Fs,
1814
1814
  fn: AppendFile,
1815
- data: [formatPathLike(path4), data]
1815
+ data: [formatPathLike(path6), data]
1816
1816
  });
1817
1817
  }
1818
- function mkdir(path4) {
1818
+ function mkdir(path6) {
1819
1819
  return globalThis.fullstacked.bridge({
1820
1820
  mod: Fs,
1821
1821
  fn: Mkdir,
1822
- data: [formatPathLike(path4)]
1822
+ data: [formatPathLike(path6)]
1823
1823
  });
1824
1824
  }
1825
- function rm(path4) {
1825
+ function rm(path6) {
1826
1826
  return globalThis.fullstacked.bridge({
1827
1827
  mod: Fs,
1828
1828
  fn: Rm,
1829
- data: [formatPathLike(path4)]
1829
+ data: [formatPathLike(path6)]
1830
1830
  });
1831
1831
  }
1832
- function unlink(path4) {
1832
+ function unlink(path6) {
1833
1833
  return globalThis.fullstacked.bridge({
1834
1834
  mod: Fs,
1835
1835
  fn: Rm,
1836
- data: [formatPathLike(path4)]
1836
+ data: [formatPathLike(path6)]
1837
1837
  });
1838
1838
  }
1839
- function rename(path4, path22) {
1839
+ function rename(path6, path22) {
1840
1840
  return globalThis.fullstacked.bridge({
1841
1841
  mod: Fs,
1842
1842
  fn: Rename,
1843
- data: [formatPathLike(path4), formatPathLike(path22)]
1843
+ data: [formatPathLike(path6), formatPathLike(path22)]
1844
1844
  });
1845
1845
  }
1846
1846
  function cp(src, dst) {
@@ -1864,50 +1864,50 @@ var promises_default = {
1864
1864
  };
1865
1865
 
1866
1866
  // ../../core/internal/bundle/lib/fs/index.ts
1867
- function existsSync(path4) {
1867
+ function existsSync(path6) {
1868
1868
  return globalThis.fullstacked.bridge(
1869
1869
  {
1870
1870
  mod: Fs,
1871
1871
  fn: Exists,
1872
- data: [formatPathLike(path4)]
1872
+ data: [formatPathLike(path6)]
1873
1873
  },
1874
1874
  true
1875
1875
  );
1876
1876
  }
1877
- function statSync(path4, options) {
1877
+ function statSync(path6, options) {
1878
1878
  const fileInfo = globalThis.fullstacked.bridge(
1879
1879
  {
1880
1880
  mod: Fs,
1881
1881
  fn: Stats,
1882
- data: [formatPathLike(path4)]
1882
+ data: [formatPathLike(path6)]
1883
1883
  },
1884
1884
  true
1885
1885
  );
1886
1886
  return fileInfoToStat(fileInfo);
1887
1887
  }
1888
- function stat2(path4, options, callback) {
1888
+ function stat2(path6, options, callback) {
1889
1889
  const cb = typeof options === "function" ? options : callback;
1890
1890
  const opts = typeof options === "function" ? null : options;
1891
- promises_default.stat(formatPathLike(path4), opts).then((stats) => cb(null, stats)).catch((e) => cb(e, null));
1891
+ promises_default.stat(formatPathLike(path6), opts).then((stats) => cb(null, stats)).catch((e) => cb(e, null));
1892
1892
  }
1893
- function readFileSync(path4, options) {
1893
+ function readFileSync(path6, options) {
1894
1894
  const data = globalThis.fullstacked.bridge(
1895
1895
  {
1896
1896
  mod: Fs,
1897
1897
  fn: ReadFile,
1898
- data: [formatPathLike(path4)]
1898
+ data: [formatPathLike(path6)]
1899
1899
  },
1900
1900
  true
1901
1901
  );
1902
1902
  return decodeStringData(data, options);
1903
1903
  }
1904
- function readFile2(path4, options, callback) {
1904
+ function readFile2(path6, options, callback) {
1905
1905
  const cb = typeof options === "function" ? options : callback;
1906
1906
  const opts = typeof options === "function" ? null : options;
1907
- promises_default.readFile(formatPathLike(path4), opts).then((data) => cb(null, data)).catch((e) => cb(e, null));
1907
+ promises_default.readFile(formatPathLike(path6), opts).then((data) => cb(null, data)).catch((e) => cb(e, null));
1908
1908
  }
1909
- function readdirSync(path4, options) {
1910
- const baseDir = formatPathLike(path4);
1909
+ function readdirSync(path6, options) {
1910
+ const baseDir = formatPathLike(path6);
1911
1911
  const items = globalThis.fullstacked.bridge(
1912
1912
  {
1913
1913
  mod: Fs,
@@ -1918,10 +1918,10 @@ function readdirSync(path4, options) {
1918
1918
  );
1919
1919
  return convertGoFileInfo(baseDir, items, options?.withFileTypes);
1920
1920
  }
1921
- function readdir2(path4, options, callback) {
1921
+ function readdir2(path6, options, callback) {
1922
1922
  const cb = typeof options === "function" ? options : callback;
1923
1923
  const opts = typeof options === "function" ? {} : options;
1924
- const baseDir = formatPathLike(path4);
1924
+ const baseDir = formatPathLike(path6);
1925
1925
  globalThis.fullstacked.bridge({
1926
1926
  mod: Fs,
1927
1927
  fn: ReadDir,
@@ -1933,86 +1933,86 @@ function readdir2(path4, options, callback) {
1933
1933
  )
1934
1934
  ).catch((e) => cb(e, null));
1935
1935
  }
1936
- function mkdirSync(path4) {
1936
+ function mkdirSync(path6) {
1937
1937
  return globalThis.fullstacked.bridge(
1938
1938
  {
1939
1939
  mod: Fs,
1940
1940
  fn: Mkdir,
1941
- data: [formatPathLike(path4)]
1941
+ data: [formatPathLike(path6)]
1942
1942
  },
1943
1943
  true
1944
1944
  );
1945
1945
  }
1946
- async function mkdir2(path4, callback) {
1947
- promises_default.mkdir(path4).then(() => callback(null)).catch((e) => callback(e));
1946
+ async function mkdir2(path6, callback) {
1947
+ promises_default.mkdir(path6).then(() => callback(null)).catch((e) => callback(e));
1948
1948
  }
1949
- function rmSync(path4) {
1949
+ function rmSync(path6) {
1950
1950
  return globalThis.fullstacked.bridge(
1951
1951
  {
1952
1952
  mod: Fs,
1953
1953
  fn: Rm,
1954
- data: [formatPathLike(path4)]
1954
+ data: [formatPathLike(path6)]
1955
1955
  },
1956
1956
  true
1957
1957
  );
1958
1958
  }
1959
- async function rm2(path4, callback) {
1960
- promises_default.rm(path4).then(() => callback(null)).catch((e) => callback(e));
1959
+ async function rm2(path6, callback) {
1960
+ promises_default.rm(path6).then(() => callback(null)).catch((e) => callback(e));
1961
1961
  }
1962
- function unlinkSync(path4) {
1962
+ function unlinkSync(path6) {
1963
1963
  return globalThis.fullstacked.bridge(
1964
1964
  {
1965
1965
  mod: Fs,
1966
1966
  fn: Rm,
1967
- data: [formatPathLike(path4)]
1967
+ data: [formatPathLike(path6)]
1968
1968
  },
1969
1969
  true
1970
1970
  );
1971
1971
  }
1972
- async function unlink2(path4, callback) {
1973
- promises_default.unlink(path4).then(() => callback(null)).catch((e) => callback(e));
1972
+ async function unlink2(path6, callback) {
1973
+ promises_default.unlink(path6).then(() => callback(null)).catch((e) => callback(e));
1974
1974
  }
1975
- function writeFileSync(path4, data) {
1975
+ function writeFileSync(path6, data) {
1976
1976
  return globalThis.fullstacked.bridge(
1977
1977
  {
1978
1978
  mod: Fs,
1979
1979
  fn: WriteFile,
1980
- data: [formatPathLike(path4), data]
1980
+ data: [formatPathLike(path6), data]
1981
1981
  },
1982
1982
  true
1983
1983
  );
1984
1984
  }
1985
- function writeFile2(path4, data, callback) {
1986
- promises_default.writeFile(path4, data).then(() => callback(null)).catch((e) => callback(e));
1985
+ function writeFile2(path6, data, callback) {
1986
+ promises_default.writeFile(path6, data).then(() => callback(null)).catch((e) => callback(e));
1987
1987
  }
1988
- function appendFileSync(path4, data) {
1988
+ function appendFileSync(path6, data) {
1989
1989
  return globalThis.fullstacked.bridge(
1990
1990
  {
1991
1991
  mod: Fs,
1992
1992
  fn: AppendFile,
1993
- data: [formatPathLike(path4), data]
1993
+ data: [formatPathLike(path6), data]
1994
1994
  },
1995
1995
  true
1996
1996
  );
1997
1997
  }
1998
- function appendFile2(path4, data, callback) {
1999
- promises_default.appendFile(path4, data).then(() => callback(null)).catch((e) => callback(e));
1998
+ function appendFile2(path6, data, callback) {
1999
+ promises_default.appendFile(path6, data).then(() => callback(null)).catch((e) => callback(e));
2000
2000
  }
2001
- function renameSync(path4, path22) {
2001
+ function renameSync(path6, path22) {
2002
2002
  return globalThis.fullstacked.bridge(
2003
2003
  {
2004
2004
  mod: Fs,
2005
2005
  fn: Rename,
2006
- data: [formatPathLike(path4), formatPathLike(path22)]
2006
+ data: [formatPathLike(path6), formatPathLike(path22)]
2007
2007
  },
2008
2008
  true
2009
2009
  );
2010
2010
  }
2011
- function rename2(path4, path22, callback) {
2012
- promises_default.rename(path4, path22).then(() => callback(null)).catch((e) => callback(e));
2011
+ function rename2(path6, path22, callback) {
2012
+ promises_default.rename(path6, path22).then(() => callback(null)).catch((e) => callback(e));
2013
2013
  }
2014
- function realpathSync(path4) {
2015
- return resolve(formatPathLike(path4));
2014
+ function realpathSync(path6) {
2015
+ return resolve(formatPathLike(path6));
2016
2016
  }
2017
2017
  function cpSync(src, dst) {
2018
2018
  return globalThis.fullstacked.bridge(
@@ -2030,12 +2030,12 @@ function cp2(src, dst, callback) {
2030
2030
  var WriteStream = class extends Writable {
2031
2031
  duplex = null;
2032
2032
  eventEmitter = null;
2033
- constructor(path4, options) {
2033
+ constructor(path6, options) {
2034
2034
  super(options);
2035
2035
  globalThis.fullstacked.bridge({
2036
2036
  mod: Fs,
2037
2037
  fn: CreateWriteStream,
2038
- data: [formatPathLike(path4)]
2038
+ data: [formatPathLike(path6)]
2039
2039
  }).then((d) => {
2040
2040
  this.duplex = d;
2041
2041
  this.eventEmitter = d.eventEmitter();
@@ -2075,8 +2075,8 @@ var WriteStream = class extends Writable {
2075
2075
  }
2076
2076
  }
2077
2077
  };
2078
- function createWriteStream(path4, options) {
2079
- return new WriteStream(formatPathLike(path4), options);
2078
+ function createWriteStream(path6, options) {
2079
+ return new WriteStream(formatPathLike(path6), options);
2080
2080
  }
2081
2081
  var fs_default = {
2082
2082
  existsSync,
@@ -2271,9 +2271,7 @@ function processResponse(buffer) {
2271
2271
  }
2272
2272
 
2273
2273
  // src/index.ts
2274
- import path3 from "node:path";
2275
- import { createRequire as createRequire2 } from "node:module";
2276
- import { pathToFileURL } from "node:url";
2274
+ import path5 from "node:path";
2277
2275
 
2278
2276
  // src/core.ts
2279
2277
  import path2 from "node:path";
@@ -2549,36 +2547,8 @@ function createWebSocketServer(core3, ctx, server, close) {
2549
2547
  return webSockets;
2550
2548
  }
2551
2549
 
2552
- // ../../core/internal/bundle/lib/@types/bundle.ts
2553
- var BundleDir = 1;
2554
-
2555
- // ../../core/internal/bundle/lib/bundle/index.ts
2556
- function bundle(entryPoint) {
2557
- const resolved = path_default.resolve(entryPoint ?? ".");
2558
- return new Promise(async (resolve2) => {
2559
- const ee = (await globalThis.fullstacked.bridge({
2560
- mod: Bundle,
2561
- fn: BundleDir,
2562
- data: [resolved]
2563
- })).eventEmitter();
2564
- ee.on("result", resolve2);
2565
- });
2566
- }
2567
-
2568
- // ../../core/internal/bundle/lib/run/index.ts
2569
- function run(directoryOrOptions) {
2570
- const directory2 = typeof directoryOrOptions === "string" ? directoryOrOptions : directoryOrOptions?.directory;
2571
- const env3 = typeof directoryOrOptions === "object" ? directoryOrOptions.env : void 0;
2572
- const resolved = path_default.resolve(directory2 ?? ".");
2573
- return globalThis.fullstacked.bridge({
2574
- mod: Core,
2575
- fn: Run,
2576
- data: [resolved, env3]
2577
- });
2578
- }
2579
-
2580
2550
  // ../../core/internal/bundle/lib/process/version.json
2581
- var version_default2 = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1744", hash: "f8d6e514e172365705b0252622be609f819c4fef" };
2551
+ var version_default2 = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1748", hash: "7c960ea337e7106b199163dff256a67ddd78f29d" };
2582
2552
 
2583
2553
  // src/args.ts
2584
2554
  function findArg(aliases, hasValueOrArgs, customArgs) {
@@ -2661,6 +2631,119 @@ function getPositionalArgs(args2 = process.argv.slice(2)) {
2661
2631
  return positional;
2662
2632
  }
2663
2633
 
2634
+ // src/run/file.ts
2635
+ import path3 from "node:path";
2636
+ import fs3 from "node:fs";
2637
+ import { pathToFileURL } from "node:url";
2638
+
2639
+ // ../../core/internal/bundle/lib/@types/bundle.ts
2640
+ var BundleDir = 1;
2641
+ var BundleFile = 2;
2642
+
2643
+ // ../../core/internal/bundle/lib/bundle/index.ts
2644
+ function bundle(entryPoint) {
2645
+ const resolved = path_default.resolve(entryPoint ?? ".");
2646
+ return new Promise(async (resolve2) => {
2647
+ const ee = (await globalThis.fullstacked.bridge({
2648
+ mod: Bundle,
2649
+ fn: BundleDir,
2650
+ data: [resolved]
2651
+ })).eventEmitter();
2652
+ ee.on("result", resolve2);
2653
+ });
2654
+ }
2655
+ function bundleFile(entryPoint) {
2656
+ const resolved = path_default.resolve(entryPoint);
2657
+ return globalThis.fullstacked.bridge({
2658
+ mod: Bundle,
2659
+ fn: BundleFile,
2660
+ data: [resolved]
2661
+ });
2662
+ }
2663
+
2664
+ // src/run/file.ts
2665
+ async function runFile(positionalArgs2, end2) {
2666
+ if (positionalArgs2.length === 0) {
2667
+ console.error("Error: no file specified.");
2668
+ end2(1);
2669
+ }
2670
+ const scriptFile = positionalArgs2[0];
2671
+ const targetFilePath = path3.resolve(scriptFile);
2672
+ if (!fs3.existsSync(targetFilePath)) {
2673
+ console.error(`Error: file not found: ${scriptFile}`);
2674
+ end2(1);
2675
+ }
2676
+ try {
2677
+ const result = await bundleFile(
2678
+ path3.relative(process.cwd(), targetFilePath)
2679
+ );
2680
+ if (result.Errors?.length > 0) {
2681
+ result.Errors.forEach((e) => {
2682
+ if (e.text) {
2683
+ let out = e.text;
2684
+ if (e.location) {
2685
+ out += `
2686
+ at ${e.location.file}:${e.location.line}:${e.location.column}`;
2687
+ }
2688
+ console.error(out);
2689
+ } else {
2690
+ console.error(e);
2691
+ }
2692
+ });
2693
+ end2(1);
2694
+ }
2695
+ const outputFile = result.OutputFiles?.at(0);
2696
+ if (!outputFile) {
2697
+ console.error("Error: no output file generated.");
2698
+ end2(1);
2699
+ }
2700
+ const absoluteOutputFile = path3.resolve(outputFile);
2701
+ const cleanup = () => {
2702
+ try {
2703
+ const resolved = __require.resolve(absoluteOutputFile);
2704
+ delete __require.cache[resolved];
2705
+ } catch {
2706
+ }
2707
+ return fs3.promises.rm(absoluteOutputFile).catch(() => {
2708
+ });
2709
+ };
2710
+ process.argv = [
2711
+ process.argv[0],
2712
+ targetFilePath,
2713
+ ...positionalArgs2.slice(1)
2714
+ ];
2715
+ try {
2716
+ await import(pathToFileURL(absoluteOutputFile).href);
2717
+ } catch (e) {
2718
+ console.error(e.stack || e.message || String(e));
2719
+ await cleanup();
2720
+ end2(1);
2721
+ }
2722
+ await cleanup();
2723
+ end2(0);
2724
+ } catch (e) {
2725
+ console.error(`Error: ${e.message}`);
2726
+ end2(1);
2727
+ }
2728
+ }
2729
+
2730
+ // src/run/directory.ts
2731
+ import path4 from "node:path";
2732
+ import { createRequire as createRequire2 } from "node:module";
2733
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
2734
+
2735
+ // ../../core/internal/bundle/lib/run/index.ts
2736
+ function run(directoryOrOptions) {
2737
+ const directory2 = typeof directoryOrOptions === "string" ? directoryOrOptions : directoryOrOptions?.directory;
2738
+ const env3 = typeof directoryOrOptions === "object" ? directoryOrOptions.env : void 0;
2739
+ const resolved = path_default.resolve(directory2 ?? ".");
2740
+ return globalThis.fullstacked.bridge({
2741
+ mod: Core,
2742
+ fn: Run,
2743
+ data: [resolved, env3]
2744
+ });
2745
+ }
2746
+
2664
2747
  // ../../core/internal/bundle/lib/@types/plugin.ts
2665
2748
  var StartPluginStream = 0;
2666
2749
  var Register = 1;
@@ -2694,19 +2777,19 @@ async function connect() {
2694
2777
  eventEmitter.on(
2695
2778
  "plugin-call",
2696
2779
  async (pluginId, requestId, ...args2) => {
2697
- let result2 = null;
2780
+ let result = null;
2698
2781
  let errorMsg = null;
2699
2782
  try {
2700
2783
  const registeredPlugin = plugins.get(pluginId);
2701
2784
  if (registeredPlugin) {
2702
- result2 = await registeredPlugin.callback(...args2);
2785
+ result = await registeredPlugin.callback(...args2);
2703
2786
  if (registeredPlugin.type === PluginTypeBuild) {
2704
2787
  const remappedResult = [];
2705
- result2.forEach(({ outputName, contents }) => {
2788
+ result.forEach(({ outputName, contents }) => {
2706
2789
  contents = typeof contents === "string" ? te4.encode(contents) : contents;
2707
2790
  remappedResult.push(outputName, contents);
2708
2791
  });
2709
- result2 = remappedResult;
2792
+ result = remappedResult;
2710
2793
  }
2711
2794
  } else {
2712
2795
  throw new Error(
@@ -2716,13 +2799,13 @@ async function connect() {
2716
2799
  } catch (err) {
2717
2800
  errorMsg = err.message || String(err);
2718
2801
  }
2719
- if (Array.isArray(result2)) {
2802
+ if (Array.isArray(result)) {
2720
2803
  eventEmitter.writeEvent(
2721
2804
  "plugin-response",
2722
2805
  pluginId,
2723
2806
  requestId,
2724
2807
  errorMsg,
2725
- ...result2
2808
+ ...result
2726
2809
  );
2727
2810
  } else {
2728
2811
  eventEmitter.writeEvent(
@@ -2730,7 +2813,7 @@ async function connect() {
2730
2813
  pluginId,
2731
2814
  requestId,
2732
2815
  errorMsg,
2733
- result2
2816
+ result
2734
2817
  );
2735
2818
  }
2736
2819
  }
@@ -2764,6 +2847,48 @@ var plugin = {
2764
2847
  };
2765
2848
  var plugin_default = plugin;
2766
2849
 
2850
+ // src/run/directory.ts
2851
+ async function importPlugin(p) {
2852
+ if (p.startsWith(".") || path4.isAbsolute(p)) {
2853
+ return (await import(pathToFileURL2(path4.resolve(p)).href)).default;
2854
+ }
2855
+ try {
2856
+ const requireFromCwd = createRequire2(
2857
+ path4.join(process.cwd(), "index.js")
2858
+ );
2859
+ const resolved = requireFromCwd.resolve(p);
2860
+ return (await import(pathToFileURL2(resolved).href)).default;
2861
+ } catch {
2862
+ try {
2863
+ const requireFromModule = createRequire2(import.meta.url);
2864
+ const resolved = requireFromModule.resolve(p);
2865
+ return (await import(pathToFileURL2(resolved).href)).default;
2866
+ } catch {
2867
+ return (await import(p)).default;
2868
+ }
2869
+ }
2870
+ }
2871
+ async function runDirectory(pluginsArgs2, buildOnly2, env3, end2) {
2872
+ await Promise.all(
2873
+ pluginsArgs2.map(
2874
+ async (p) => plugin_default.register("build", await importPlugin(p))
2875
+ )
2876
+ );
2877
+ const result = await bundle();
2878
+ if (result.Warnings?.length) {
2879
+ console.warn("Warnings:", result.Warnings);
2880
+ }
2881
+ if (result.Errors?.length) {
2882
+ console.error("Errors:", result.Errors);
2883
+ end2(1);
2884
+ } else if (!buildOnly2) {
2885
+ run({ env: env3 });
2886
+ } else {
2887
+ console.log("Build complete.");
2888
+ end2(0);
2889
+ }
2890
+ }
2891
+
2767
2892
  // src/index.ts
2768
2893
  var end = (code2) => {
2769
2894
  core2.end();
@@ -2800,6 +2925,7 @@ var openBrowser = findArg(["-o", "--open"]);
2800
2925
  var buildOnly = findArg(["-b", "--build"]);
2801
2926
  var envArgs = findArg(["-e", "--env"], true);
2802
2927
  var pluginsArgs = findArg(["-p", "--plugin"], true);
2928
+ var fileFlag = findArg(["-f", "--file"]);
2803
2929
  var env2 = {};
2804
2930
  for (const val of envArgs) {
2805
2931
  const index = val.indexOf("=");
@@ -2812,7 +2938,7 @@ for (const val of envArgs) {
2812
2938
  }
2813
2939
  }
2814
2940
  var positionalArgs = getPositionalArgs();
2815
- var directory = path3.resolve(positionalArgs.at(-1) || ".");
2941
+ var directory = fileFlag ? process.cwd() : path5.resolve(positionalArgs.at(-1) || ".");
2816
2942
  if (showVersion) {
2817
2943
  console.log(
2818
2944
  `FullStacked v${version_default2.major}.${version_default2.minor}.${version_default2.patch} (build ${version_default2.build}), branch ${version_default2.branch}, hash ${version_default2.hash.slice(0, 8)}`
@@ -2821,13 +2947,38 @@ if (showVersion) {
2821
2947
  }
2822
2948
  if (help) {
2823
2949
  console.log(`
2824
- Usage: fullstacked [options] [directory]
2950
+ Usage:
2951
+ fullstacked [options] [directory]
2952
+
2953
+ Description:
2954
+ This CLI compiles and runs projects designed for the FullStacked runtime.
2955
+ Unlike traditional JS/TS projects with separate frontend and backend layers:
2956
+ - NodeJS and Browser APIs are available seamlessly within the same files.
2957
+ - ES module syntax.
2958
+ - TypeScript support.
2959
+ - No HTML files.
2960
+ - Start with an entrypoint: index.js(x) or index.ts(x).
2961
+
2962
+ Example:
2963
+ // index.jsx
2964
+ import React from "react";
2965
+ import { createRoot } from "react-dom/client";
2966
+ import fs from "node:fs";
2967
+
2968
+ const div = document.createElement("div");
2969
+ document.body.append(div);
2970
+
2971
+ const root = createRoot(div);
2972
+ root.render(<h1>{await fs.promises.readFile("hello-world.txt")}</h1>);
2825
2973
 
2826
2974
  Options:
2827
2975
  -v, --version Display the current version
2828
2976
  -p, --port Define the main starting port (defaults to 9000)
2977
+ -p, --plugin Specify a plugin for the build process (can be used multiple times)
2978
+ -e, --env Define environment variables in KEY=VALUE format (can be used multiple times)
2829
2979
  -o, --open Directly open the browser
2830
- -b, --build Only bundle, don't run afterward
2980
+ -b, --build Only bundle the project, don't run it afterward
2981
+ -f, --file Bundle and execute a single script file
2831
2982
  -h, --help Display this help message
2832
2983
 
2833
2984
  Directory:
@@ -2837,46 +2988,14 @@ Directory:
2837
2988
  }
2838
2989
  process.chdir(directory);
2839
2990
  var mainCtx = core2.start(directory, directory);
2991
+ globalThis.ctxId = mainCtx;
2840
2992
  globalThis.bridges = {
2841
2993
  ctxId: mainCtx,
2842
2994
  Sync: (payload) => core2.call(payload),
2843
2995
  Async: async (payload) => core2.call(payload)
2844
2996
  };
2845
- async function importPlugin(p) {
2846
- if (p.startsWith(".") || path3.isAbsolute(p)) {
2847
- return (await import(pathToFileURL(path3.resolve(p)).href)).default;
2848
- }
2849
- try {
2850
- const requireFromCwd = createRequire2(
2851
- path3.join(process.cwd(), "index.js")
2852
- );
2853
- const resolved = requireFromCwd.resolve(p);
2854
- return (await import(pathToFileURL(resolved).href)).default;
2855
- } catch {
2856
- try {
2857
- const requireFromModule = createRequire2(import.meta.url);
2858
- const resolved = requireFromModule.resolve(p);
2859
- return (await import(pathToFileURL(resolved).href)).default;
2860
- } catch {
2861
- return (await import(p)).default;
2862
- }
2863
- }
2864
- }
2865
- await Promise.all(
2866
- pluginsArgs.map(
2867
- async (p) => plugin_default.register("build", await importPlugin(p))
2868
- )
2869
- );
2870
- var result = await bundle();
2871
- if (result.Warnings?.length) {
2872
- console.warn("Warnings:", result.Warnings);
2873
- }
2874
- if (result.Errors?.length) {
2875
- console.error("Errors:", result.Errors);
2876
- end(1);
2877
- } else if (!buildOnly) {
2878
- run({ env: env2 });
2997
+ if (fileFlag) {
2998
+ await runFile(positionalArgs, end);
2879
2999
  } else {
2880
- console.log("Build complete.");
2881
- end(0);
3000
+ await runDirectory(pluginsArgs, buildOnly, env2, end);
2882
3001
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullstacked",
3
- "version": "1.0.0-alpha.1744",
3
+ "version": "1.0.0-alpha.1748",
4
4
  "bin": {
5
5
  "fullstacked": "index.js"
6
6
  },
@@ -11,21 +11,21 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "open": "^11.0.0",
14
- "ws": "^8.21.0"
14
+ "ws": "^8.21.1"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@nitrogql/esbuild-register": "^1.7.2",
18
18
  "@types/ws": "^8.18.1",
19
19
  "esbuild": "^0.28.1",
20
- "node-addon-api": "^8.8.0"
20
+ "node-addon-api": "^8.9.0"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@fullstacked/darwin-arm64": "1.0.0-alpha.1744",
24
- "@fullstacked/darwin-x64": "1.0.0-alpha.1744",
25
- "@fullstacked/linux-arm64": "1.0.0-alpha.1744",
26
- "@fullstacked/linux-x64": "1.0.0-alpha.1744",
27
- "@fullstacked/win32-arm64": "1.0.0-alpha.1744",
28
- "@fullstacked/win32-x64": "1.0.0-alpha.1744"
23
+ "@fullstacked/darwin-arm64": "1.0.0-alpha.1748",
24
+ "@fullstacked/darwin-x64": "1.0.0-alpha.1748",
25
+ "@fullstacked/linux-arm64": "1.0.0-alpha.1748",
26
+ "@fullstacked/linux-x64": "1.0.0-alpha.1748",
27
+ "@fullstacked/win32-arm64": "1.0.0-alpha.1748",
28
+ "@fullstacked/win32-x64": "1.0.0-alpha.1748"
29
29
  },
30
30
  "author": "FullStacked",
31
31
  "license": "MIT",
@@ -28,15 +28,15 @@ export declare const stdout: {
28
28
  export declare const stderr: {
29
29
  isTTY: boolean;
30
30
  };
31
- export declare const on: () => void;
32
- export declare const addListener: () => void;
33
- export declare const once: () => void;
34
- export declare const off: () => void;
35
- export declare const removeListener: () => void;
36
- export declare const removeAllListeners: () => void;
37
- export declare const emit: () => void;
38
- export declare const prependListener: () => void;
39
- export declare const prependOnceListener: () => void;
31
+ export declare const on: typeof noop;
32
+ export declare const addListener: typeof noop;
33
+ export declare const once: typeof noop;
34
+ export declare const off: typeof noop;
35
+ export declare const removeListener: typeof noop;
36
+ export declare const removeAllListeners: typeof noop;
37
+ export declare const emit: typeof noop;
38
+ export declare const prependListener: typeof noop;
39
+ export declare const prependOnceListener: typeof noop;
40
40
  export declare const process: {
41
41
  title: string;
42
42
  browser: boolean;
@@ -54,15 +54,15 @@ export declare const process: {
54
54
  };
55
55
  };
56
56
  nextTick: typeof nextTick;
57
- on: () => void;
58
- addListener: () => void;
59
- once: () => void;
60
- off: () => void;
61
- removeListener: () => void;
62
- removeAllListeners: () => void;
63
- emit: () => void;
64
- prependListener: () => void;
65
- prependOnceListener: () => void;
57
+ on: typeof noop;
58
+ addListener: typeof noop;
59
+ once: typeof noop;
60
+ off: typeof noop;
61
+ removeListener: typeof noop;
62
+ removeAllListeners: typeof noop;
63
+ emit: typeof noop;
64
+ prependListener: typeof noop;
65
+ prependOnceListener: typeof noop;
66
66
  listeners: typeof listeners;
67
67
  binding: typeof binding;
68
68
  cwd: typeof cwd;