fullstacked 1.0.0-alpha.1699 → 1.0.0-alpha.1706

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
@@ -90,9 +90,11 @@ var Stream = 1;
90
90
  var Path = 4;
91
91
  var Os = 5;
92
92
  var Bundle = 9;
93
+ var Plugin = 15;
93
94
  var CoreResponseError = 0;
94
95
  var CoreResponseData = 1;
95
96
  var CoreResponseStream = 2;
97
+ var PluginTypeBuild = "build";
96
98
  var UNDEFINED = 0;
97
99
  var BOOLEAN = 1;
98
100
  var STRING = 2;
@@ -1248,11 +1250,22 @@ function createDuplex(id2, bridgeFn) {
1248
1250
  if (!duplex.open) {
1249
1251
  await open2();
1250
1252
  }
1251
- return bridgeFn({
1253
+ const res = await bridgeFn({
1252
1254
  mod: Stream,
1253
1255
  fn: Close,
1254
1256
  data: [id2]
1255
1257
  });
1258
+ if (duplex.done) {
1259
+ return res;
1260
+ }
1261
+ await new Promise((resolve2) => {
1262
+ const onClose = () => {
1263
+ duplex.listeners.close.delete(onClose);
1264
+ resolve2();
1265
+ };
1266
+ duplex.listeners.close.add(onClose);
1267
+ });
1268
+ return res;
1256
1269
  };
1257
1270
  stream.promise = async () => {
1258
1271
  let data = new Uint8Array();
@@ -1300,6 +1313,9 @@ function bridge(opts, sync) {
1300
1313
  }
1301
1314
  return new Promise(async (resolve2, reject) => {
1302
1315
  await platform_default.ready;
1316
+ if (globalThis.pluginConnectionPromise && !(opts.mod === 15 && opts.fn === 0)) {
1317
+ await globalThis.pluginConnectionPromise;
1318
+ }
1303
1319
  const payload = preparePayload();
1304
1320
  const responseBuffer = await platform_default.bridge.Async(
1305
1321
  payload.buffer
@@ -1338,7 +1354,6 @@ function processResponse(buffer) {
1338
1354
 
1339
1355
  // ../../core/internal/bundle/lib/@types/bundle.ts
1340
1356
  var BundleDir = 1;
1341
- var BuilderTailwindCSS = 3;
1342
1357
 
1343
1358
  // ../../core/internal/bundle/lib/@types/path.ts
1344
1359
  var Join = 0;
@@ -1557,12 +1572,101 @@ function bundle(entryPoint) {
1557
1572
  ee.on("result", resolve2);
1558
1573
  });
1559
1574
  }
1560
- async function builderTailwindCSS() {
1561
- return (await bridge({
1562
- mod: Bundle,
1563
- fn: BuilderTailwindCSS
1564
- })).eventEmitter();
1575
+
1576
+ // ../../core/internal/bundle/lib/@types/plugin.ts
1577
+ var StartPluginStream = 0;
1578
+ var Register = 1;
1579
+ var Unregister = 2;
1580
+
1581
+ // ../../core/internal/bundle/lib/plugin/index.ts
1582
+ var plugins = /* @__PURE__ */ new Map();
1583
+ var duplexStream = null;
1584
+ var eventEmitter = null;
1585
+ var connectionPromise = null;
1586
+ var te4 = new TextEncoder();
1587
+ async function connect() {
1588
+ if (duplexStream) {
1589
+ return;
1590
+ }
1591
+ const duplex = await bridge({
1592
+ mod: Plugin,
1593
+ fn: StartPluginStream
1594
+ });
1595
+ await duplex.open();
1596
+ duplexStream = duplex;
1597
+ eventEmitter = duplex.eventEmitter();
1598
+ eventEmitter.on(
1599
+ "plugin-call",
1600
+ async (pluginId, requestId, ...args2) => {
1601
+ let result2 = null;
1602
+ let errorMsg = null;
1603
+ try {
1604
+ const registeredPlugin = plugins.get(pluginId);
1605
+ if (registeredPlugin) {
1606
+ result2 = await registeredPlugin.callback(...args2);
1607
+ if (registeredPlugin.type === PluginTypeBuild) {
1608
+ const remappedResult = [];
1609
+ result2.forEach(({ outputName, contents }) => {
1610
+ contents = typeof contents === "string" ? te4.encode(contents) : contents;
1611
+ remappedResult.push(outputName, contents);
1612
+ });
1613
+ result2 = remappedResult;
1614
+ }
1615
+ } else {
1616
+ throw new Error(
1617
+ `No registered plugin found for id: ${pluginId}`
1618
+ );
1619
+ }
1620
+ } catch (err) {
1621
+ errorMsg = err.message || String(err);
1622
+ }
1623
+ if (Array.isArray(result2)) {
1624
+ eventEmitter.writeEvent(
1625
+ "plugin-response",
1626
+ pluginId,
1627
+ requestId,
1628
+ errorMsg,
1629
+ ...result2
1630
+ );
1631
+ } else {
1632
+ eventEmitter.writeEvent(
1633
+ "plugin-response",
1634
+ pluginId,
1635
+ requestId,
1636
+ errorMsg,
1637
+ result2
1638
+ );
1639
+ }
1640
+ }
1641
+ );
1565
1642
  }
1643
+ async function register(type2, plugin2) {
1644
+ if (!connectionPromise) {
1645
+ connectionPromise = connect();
1646
+ }
1647
+ await connectionPromise;
1648
+ const { name, ...pluginData } = plugin2.data || {};
1649
+ const id2 = await bridge({
1650
+ mod: Plugin,
1651
+ fn: Register,
1652
+ data: [type2, name || "plugin-" + type2, pluginData]
1653
+ });
1654
+ plugins.set(id2, { type: type2, callback: plugin2.callback });
1655
+ return {
1656
+ unregister: async () => {
1657
+ plugins.delete(id2);
1658
+ await bridge({
1659
+ mod: Plugin,
1660
+ fn: Unregister,
1661
+ data: [id2]
1662
+ });
1663
+ }
1664
+ };
1665
+ }
1666
+ var plugin = {
1667
+ register
1668
+ };
1669
+ var plugin_default = plugin;
1566
1670
 
1567
1671
  // ../../core/internal/bundle/lib/run/index.ts
1568
1672
  function run(directoryOrOptions) {
@@ -1577,14 +1681,7 @@ function run(directoryOrOptions) {
1577
1681
  }
1578
1682
 
1579
1683
  // ../../core/internal/bundle/lib/process/version.json
1580
- var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1699", hash: "aa5802548d594d22602bea0baa1f7beb875c521d" };
1581
-
1582
- // src/index.ts
1583
- import postcss from "postcss";
1584
- import atImport from "postcss-import";
1585
- import tailwindcss from "@tailwindcss/postcss";
1586
- import autoprefixer from "autoprefixer";
1587
- import fs3 from "node:fs";
1684
+ var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1706", hash: "83a224d4d1c01ade773cdc6ba8edf0074686f3e7" };
1588
1685
 
1589
1686
  // src/args.ts
1590
1687
  function findArg(aliases, hasValueOrArgs, customArgs) {
@@ -1668,11 +1765,16 @@ function getPositionalArgs(args2 = process.argv.slice(2)) {
1668
1765
  }
1669
1766
 
1670
1767
  // src/index.ts
1671
- var end = () => {
1768
+ import pluginTailwindcss, {
1769
+ initialize
1770
+ } from "@fullstacked/tailwindcss/index.ts";
1771
+ var end = (code2) => {
1672
1772
  core2.end();
1673
- process.exit();
1773
+ process.exit(code2);
1674
1774
  };
1675
- ["SIGINT", "SIGTERM", "SIGQUIT"].forEach((signal) => process.on(signal, end));
1775
+ ["SIGINT", "SIGTERM", "SIGQUIT"].forEach(
1776
+ (signal) => process.on(signal, () => end(0))
1777
+ );
1676
1778
  var webviews = /* @__PURE__ */ new Map();
1677
1779
  var core2 = await load(
1678
1780
  (ctx, streamId, buffer) => {
@@ -1741,35 +1843,23 @@ globalThis.bridges = {
1741
1843
  Sync: (payload) => core2.call(payload),
1742
1844
  Async: async (payload) => core2.call(payload)
1743
1845
  };
1744
- var tailwindcssBuilder = await builderTailwindCSS();
1745
- tailwindcssBuilder.on("build", async (entryfile, outfile) => {
1746
- const from = path3.resolve(directory, entryfile);
1747
- const to = path3.resolve(directory, outfile);
1748
- const css = await fs3.promises.readFile(from, "utf-8");
1749
- const result2 = await postcss([
1750
- atImport({
1751
- addModulesDirectories: [
1752
- path3.resolve(import.meta.dirname, "node_modules")
1753
- ]
1754
- }),
1755
- tailwindcss(),
1756
- autoprefixer()
1757
- ]).process(css, {
1758
- from,
1759
- to
1760
- });
1761
- await fs3.promises.writeFile(to, result2.css);
1762
- tailwindcssBuilder.writeEvent("build-done");
1846
+ await initialize({
1847
+ oxide: "node_modules/oxide-wasm/pkg/oxide_wasm_bg.wasm",
1848
+ lightningcss: "node_modules/lightningcss-wasm/lightningcss_node.wasm",
1849
+ tailwindcss: "node_modules/tailwindcss",
1850
+ baseDirectory: directory
1763
1851
  });
1852
+ await plugin_default.register("build", pluginTailwindcss);
1764
1853
  var result = await bundle();
1765
1854
  if (result.Warnings?.length) {
1766
1855
  console.warn("Warnings:", result.Warnings);
1767
1856
  }
1768
1857
  if (result.Errors?.length) {
1769
1858
  console.error("Errors:", result.Errors);
1859
+ end(1);
1770
1860
  } else if (!buildOnly) {
1771
1861
  run({ env });
1772
1862
  } else {
1773
1863
  console.log("Build complete.");
1774
- end();
1864
+ end(0);
1775
1865
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullstacked",
3
- "version": "1.0.0-alpha.1699",
3
+ "version": "1.0.0-alpha.1706",
4
4
  "bin": {
5
5
  "fullstacked": "index.js"
6
6
  },
@@ -10,12 +10,8 @@
10
10
  "prepack": "npm run build"
11
11
  },
12
12
  "dependencies": {
13
- "@tailwindcss/postcss": "^4.3.1",
14
- "autoprefixer": "^10.5.0",
13
+ "@fullstacked/tailwindcss": "github:fullstackedorg/tailwindcss",
15
14
  "open": "^11.0.0",
16
- "postcss": "^8.5.15",
17
- "postcss-import": "^16.1.1",
18
- "tailwindcss": "^4.3.1",
19
15
  "ws": "^8.21.0"
20
16
  },
21
17
  "devDependencies": {
@@ -25,12 +21,12 @@
25
21
  "node-addon-api": "^8.8.0"
26
22
  },
27
23
  "optionalDependencies": {
28
- "@fullstacked/darwin-arm64": "1.0.0-alpha.1699",
29
- "@fullstacked/darwin-x64": "1.0.0-alpha.1699",
30
- "@fullstacked/linux-arm64": "1.0.0-alpha.1699",
31
- "@fullstacked/linux-x64": "1.0.0-alpha.1699",
32
- "@fullstacked/win32-arm64": "1.0.0-alpha.1699",
33
- "@fullstacked/win32-x64": "1.0.0-alpha.1699"
24
+ "@fullstacked/darwin-arm64": "1.0.0-alpha.1706",
25
+ "@fullstacked/darwin-x64": "1.0.0-alpha.1706",
26
+ "@fullstacked/linux-arm64": "1.0.0-alpha.1706",
27
+ "@fullstacked/linux-x64": "1.0.0-alpha.1706",
28
+ "@fullstacked/win32-arm64": "1.0.0-alpha.1706",
29
+ "@fullstacked/win32-x64": "1.0.0-alpha.1706"
34
30
  },
35
31
  "author": "FullStacked",
36
32
  "license": "MIT",
@@ -53,6 +49,9 @@
53
49
  "./packages": {
54
50
  "types": "./types/packages/index.d.ts"
55
51
  },
52
+ "./plugin": {
53
+ "types": "./types/plugin/index.d.ts"
54
+ },
56
55
  "./run": {
57
56
  "types": "./types/run/index.d.ts"
58
57
  },
@@ -4,12 +4,27 @@ export declare const BundleDir: BundleFn;
4
4
  export declare const BundleFile: BundleFn;
5
5
  export declare const BuilderTailwindCSS: BundleFn;
6
6
  export declare const BuilderSASS: BundleFn;
7
- export interface TailwindCSSBuilder {
8
- }
9
7
  export interface EsbuildResult {
10
8
  OutputFiles: string[];
11
9
  Errors: any[];
12
10
  Warnings: any[];
13
11
  }
12
+ export interface PluginBuildData {
13
+ filter: string;
14
+ ext?: string[];
15
+ }
16
+ export interface PluginResolvedFile {
17
+ importer: string;
18
+ path: string;
19
+ resolvedDir: string;
20
+ }
21
+ export interface PluginParams {
22
+ sources: string[];
23
+ resolved: PluginResolvedFile[];
24
+ }
25
+ export interface BuildPluginOutputFile {
26
+ outputName: string;
27
+ contents: string;
28
+ }
14
29
  export interface DocumentHTML {
15
30
  }
@@ -12,7 +12,6 @@ export declare const RefTag: GitRefType;
12
12
  export interface CustomFS {
13
13
  }
14
14
  export type GitFn = number;
15
- export declare const AuthManager: GitFn;
16
15
  export declare const HasGit: GitFn;
17
16
  export declare const Init: GitFn;
18
17
  export declare const Head: GitFn;
@@ -30,7 +29,7 @@ export declare const Checkout: GitFn;
30
29
  export declare const Merge: GitFn;
31
30
  export declare const Restore: GitFn;
32
31
  export interface HTTPBasicAuth {
33
- GitAuth?: GitAuth;
32
+ GitAuth?: any;
34
33
  }
35
34
  export interface GitHead {
36
35
  branch: string;
@@ -60,12 +59,6 @@ export interface GitCommit {
60
59
  export declare const DateFormat = "Mon Jan 2 15:04:05 2006 -0700";
61
60
  export interface GitStream {
62
61
  }
63
- export interface GitAuth {
64
- host: string;
65
- username: string;
66
- password: string;
67
- email: string;
68
- }
69
62
  export interface GitBranch {
70
63
  name: string;
71
64
  remote: boolean;
@@ -14,6 +14,7 @@ export declare const Git: CoreModule;
14
14
  export declare const Packages: CoreModule;
15
15
  export declare const Sentry: CoreModule;
16
16
  export declare const Dgram: CoreModule;
17
+ export declare const Plugin: CoreModule;
17
18
  export type ModuleSwitch = any;
18
19
  export type CoreCallResponseType = number;
19
20
  export declare const CoreResponseError: CoreCallResponseType;
@@ -53,6 +54,30 @@ export interface ContextDirectories {
53
54
  Root: string;
54
55
  Build: string;
55
56
  }
57
+ export declare const PluginTypeGitAuth = "git-auth";
58
+ export declare const PluginTypeBuild = "build";
59
+ export type PluginType = typeof PluginTypeGitAuth | typeof PluginTypeBuild;
60
+ export interface PluginRequest {
61
+ Response: DeserializedData[];
62
+ ResponseError?: string;
63
+ Wg?: any;
64
+ }
65
+ export interface ContextPlugin {
66
+ Id: number;
67
+ Name: string;
68
+ Type: PluginType;
69
+ Data: DeserializedRawObject;
70
+ Requests: {
71
+ [key: number]: PluginRequest | undefined;
72
+ };
73
+ RequestsMutex?: any;
74
+ }
75
+ export interface GitAuth {
76
+ host: string;
77
+ username: string;
78
+ password: string;
79
+ email: string;
80
+ }
56
81
  export interface Context {
57
82
  Id: number;
58
83
  Directories: ContextDirectories;
@@ -68,6 +93,15 @@ export interface Context {
68
93
  };
69
94
  StreamsMutex?: any;
70
95
  NextStreamId: number;
96
+ PluginStreamId: number;
97
+ Plugins: {
98
+ [key: number]: ContextPlugin | undefined;
99
+ };
100
+ PluginsMutex?: any;
101
+ GitAuths: {
102
+ [key: string]: GitAuth | undefined;
103
+ };
104
+ GitAuthsMutex?: any;
71
105
  Exit: boolean;
72
106
  }
73
107
  export type SerializableData = any;
@@ -0,0 +1,4 @@
1
+ export type PluginFn = number;
2
+ export declare const StartPluginStream: PluginFn;
3
+ export declare const Register: PluginFn;
4
+ export declare const Unregister: PluginFn;
@@ -8,7 +8,7 @@ export interface Duplex extends ReadableStream<Uint8Array<ArrayBuffer>> {
8
8
  on(event: "close", callback: EndCallback): void;
9
9
  write(data: StreamData): Promise<any>;
10
10
  writeEvent(event: string, ...args: SerializableData[]): Promise<any>;
11
- end(chunk?: StreamData, encoding?: string | EndCallback, callback?: EndCallback): void;
11
+ end(): Promise<any>;
12
12
  promise(): Promise<any>;
13
13
  eventEmitter(): ReturnType<typeof createEventEmitter>;
14
14
  open(): Promise<void>;
@@ -1,12 +1,10 @@
1
1
  import { EsbuildResult } from "../@types/bundle.ts";
2
- import { EventEmitter } from "../bridge/eventEmitter.ts";
3
2
  export declare function esbuildVersion(): Promise<string>;
4
3
  export declare function bundle(entryPoint?: string): Promise<EsbuildResult>;
5
4
  export declare function bundleFile(entryPoint: string): Promise<EsbuildResult>;
6
- export declare function builderTailwindCSS(): Promise<EventEmitter<{
7
- build: string[];
8
- "build-done": [];
9
- }>>;
5
+ export declare function builderTailwindCSS(): Promise<{
6
+ on(): void;
7
+ }>;
10
8
  declare const bundler: {
11
9
  esbuildVersion: typeof esbuildVersion;
12
10
  bundle: typeof bundle;
@@ -1,10 +1,8 @@
1
- import { GitAuth, GitAuthor, GitBranch, GitCommit, GitHead, GitStatus, GitTag } from "../@types/git.ts";
1
+ import { GitAuthor, GitBranch, GitCommit, GitHead, GitStatus, GitTag } from "../@types/git.ts";
2
2
  import type { Duplex } from "../bridge/duplex.ts";
3
- import { EventEmitter } from "../bridge/eventEmitter.ts";
4
- export declare function createGitAuthManager(): Promise<EventEmitter<{
5
- auth: [string];
6
- authResponse: [string, Partial<GitAuth>];
7
- }>>;
3
+ export declare function createGitAuthManager(): Promise<{
4
+ on(): void;
5
+ }>;
8
6
  export declare function hasGit(directory: string): Promise<boolean>;
9
7
  export declare function init(directory: string, url: string): Promise<any>;
10
8
  export declare function head(directory: string): Promise<GitHead>;
@@ -22,7 +20,6 @@ export declare function checkout(directory: string, ref: string, create?: boolea
22
20
  export declare function merge(directory: string, branch: string): Promise<any>;
23
21
  export declare function restore(directory: string, ...files: string[]): Promise<any>;
24
22
  declare const git: {
25
- createGitAuthManager: typeof createGitAuthManager;
26
23
  hasGit: typeof hasGit;
27
24
  init: typeof init;
28
25
  head: typeof head;
@@ -39,5 +36,6 @@ declare const git: {
39
36
  checkout: typeof checkout;
40
37
  merge: typeof merge;
41
38
  restore: typeof restore;
39
+ createGitAuthManager: typeof createGitAuthManager;
42
40
  };
43
41
  export default git;
@@ -0,0 +1,32 @@
1
+ import { GitAuth, PluginTypeGitAuth, PluginTypeBuild } from "../@types/index.ts";
2
+ import { PluginBuildData, PluginResolvedFile } from "../@types/bundle.ts";
3
+ type CommonPluginData = {
4
+ name?: string;
5
+ };
6
+ export type PluginRegistry = {
7
+ [PluginTypeGitAuth]: {
8
+ data?: CommonPluginData;
9
+ callback: (host: string) => Promise<Partial<GitAuth>> | Partial<GitAuth>;
10
+ };
11
+ [PluginTypeBuild]: {
12
+ data?: CommonPluginData & PluginBuildData;
13
+ callback: (params: {
14
+ resolved: PluginResolvedFile[];
15
+ sources: string[];
16
+ }) => Promise<{
17
+ outputName: string;
18
+ contents: string | Uint8Array;
19
+ }[]>;
20
+ };
21
+ };
22
+ export interface JSPlugin {
23
+ type: string;
24
+ callback: (...args: any[]) => Promise<any | any[]> | any | any[];
25
+ }
26
+ export declare function register<T extends keyof PluginRegistry>(type: T, plugin: PluginRegistry[T]): Promise<{
27
+ unregister: () => Promise<void>;
28
+ }>;
29
+ declare const plugin: {
30
+ register: typeof register;
31
+ };
32
+ export default plugin;