fullstacked 1.0.0-alpha.1774 → 1.0.0-alpha.1783

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
@@ -6498,7 +6498,7 @@ var init_isWorker = __esm({
6498
6498
  // ../../core/internal/bundle/lib/bridge/platform/node.ts
6499
6499
  async function BridgeNodeInit() {
6500
6500
  if (isWorker) {
6501
- const asyncResponsePromises4 = /* @__PURE__ */ new Map();
6501
+ const asyncResponsePromises5 = /* @__PURE__ */ new Map();
6502
6502
  globalThis.onmessage = (event) => {
6503
6503
  if (!(event.data instanceof ArrayBuffer)) {
6504
6504
  return;
@@ -6508,9 +6508,9 @@ async function BridgeNodeInit() {
6508
6508
  const id = dataView.getUint8(0);
6509
6509
  const response = new Uint8Array(buffer.byteLength - 1);
6510
6510
  response.set(new Uint8Array(buffer, 1));
6511
- const promise = asyncResponsePromises4.get(id);
6511
+ const promise = asyncResponsePromises5.get(id);
6512
6512
  promise?.(response.buffer);
6513
- asyncResponsePromises4.delete(id);
6513
+ asyncResponsePromises5.delete(id);
6514
6514
  };
6515
6515
  const ctx2 = await (await fetch("/ctx")).json();
6516
6516
  return {
@@ -6531,7 +6531,7 @@ async function BridgeNodeInit() {
6531
6531
  const dataView = new DataView(payload);
6532
6532
  const id = dataView.getUint8(1);
6533
6533
  return new Promise((resolve3) => {
6534
- asyncResponsePromises4.set(id, resolve3);
6534
+ asyncResponsePromises5.set(id, resolve3);
6535
6535
  globalThis.postMessage(payload);
6536
6536
  });
6537
6537
  }
@@ -6867,6 +6867,103 @@ var init_android = __esm({
6867
6867
  }
6868
6868
  });
6869
6869
 
6870
+ // ../../core/internal/bundle/lib/bridge/platform/linux.ts
6871
+ async function BridgeLinuxInit() {
6872
+ globalThis.fullstacked.respond = (id, responseBase64) => {
6873
+ const promise = asyncResponsePromises4.get(id);
6874
+ promise?.(toByteArray(responseBase64).buffer);
6875
+ asyncResponsePromises4.delete(id);
6876
+ };
6877
+ const ctx = await (await fetch("/ctx")).json();
6878
+ if (isWorker) {
6879
+ globalThis.onmessage = (event) => {
6880
+ if (!(event.data instanceof ArrayBuffer)) {
6881
+ return;
6882
+ }
6883
+ const buffer = event.data;
6884
+ const dataView = new DataView(buffer);
6885
+ const id = dataView.getUint8(0);
6886
+ const response = new Uint8Array(buffer.byteLength - 1);
6887
+ response.set(new Uint8Array(buffer, 1));
6888
+ const promise = asyncResponsePromises4.get(id);
6889
+ promise?.(response.buffer);
6890
+ asyncResponsePromises4.delete(id);
6891
+ };
6892
+ } else {
6893
+ globalThis.fullstacked.exit = () => {
6894
+ if (globalThis.webkit?.messageHandlers?.exit) {
6895
+ globalThis.webkit.messageHandlers.exit.postMessage("");
6896
+ } else {
6897
+ (globalThis.fullstacked.fetch || fetch)("/exit");
6898
+ }
6899
+ };
6900
+ globalThis.fullstacked.open = (ctx2) => {
6901
+ if (globalThis.webkit?.messageHandlers?.open) {
6902
+ globalThis.webkit.messageHandlers.open.postMessage(ctx2);
6903
+ } else {
6904
+ (globalThis.fullstacked.fetch || fetch)(`/open?ctx=${ctx2}`);
6905
+ }
6906
+ };
6907
+ globalThis.fullstacked.window = globalThis.fullstacked.window || {};
6908
+ globalThis.fullstacked.window.getSize = () => (globalThis.fullstacked.fetch || fetch)("/resize").then((r) => r.text());
6909
+ globalThis.fullstacked.window.resize = function(size) {
6910
+ (globalThis.fullstacked.fetch || fetch)(`/resize?size=${size}`);
6911
+ };
6912
+ }
6913
+ const postBridgeMessage = (base64) => {
6914
+ if (globalThis.webkit?.messageHandlers?.bridge) {
6915
+ globalThis.webkit.messageHandlers.bridge.postMessage(base64);
6916
+ } else if (globalThis.bridge?.postMessage) {
6917
+ globalThis.bridge.postMessage(base64);
6918
+ } else if (globalThis.chrome?.webview) {
6919
+ globalThis.chrome.webview.postMessage(base64);
6920
+ }
6921
+ };
6922
+ return {
6923
+ ctx,
6924
+ async Async(payload) {
6925
+ const dataView = new DataView(payload);
6926
+ const id = dataView.getUint8(1);
6927
+ return new Promise((resolve3) => {
6928
+ asyncResponsePromises4.set(id, resolve3);
6929
+ if (isWorker) {
6930
+ globalThis.postMessage(payload, {
6931
+ targetOrigin: "bridge"
6932
+ });
6933
+ } else {
6934
+ const base64 = fromByteArray(new Uint8Array(payload));
6935
+ postBridgeMessage(base64);
6936
+ }
6937
+ });
6938
+ },
6939
+ Sync(payload) {
6940
+ const uint8array = new Uint8Array(payload);
6941
+ const id = uint8array[1];
6942
+ if (isWorker) {
6943
+ globalThis.postMessage(payload, {
6944
+ targetOrigin: "bridge"
6945
+ });
6946
+ } else {
6947
+ const base64 = fromByteArray(uint8array);
6948
+ postBridgeMessage(base64);
6949
+ }
6950
+ const xmlHttpRequest = new XMLHttpRequest();
6951
+ xmlHttpRequest.open("POST", `/sync/${id}`, false);
6952
+ xmlHttpRequest.send();
6953
+ const response = xmlHttpRequest.response;
6954
+ return toByteArray(response).buffer;
6955
+ }
6956
+ };
6957
+ }
6958
+ var asyncResponsePromises4;
6959
+ var init_linux = __esm({
6960
+ "../../core/internal/bundle/lib/bridge/platform/linux.ts"() {
6961
+ init_base64();
6962
+ init_isWorker();
6963
+ asyncResponsePromises4 = /* @__PURE__ */ new Map();
6964
+ }
6965
+ });
6966
+
6870
6967
  // ../../core/internal/bundle/lib/bridge/platform/index.ts
6871
6968
  var platform_exports = {};
6872
6969
  __export(platform_exports, {
@@ -6880,6 +6977,7 @@ var init_platform = __esm({
6880
6977
  init_isWorker();
6881
6978
  init_windows();
6882
6979
  init_android();
6980
+ init_linux();
6883
6981
  platformBridge = null;
6884
6982
  if (isWorker) {
6885
6983
  self.addEventListener("message", (event) => {
@@ -6933,6 +7031,9 @@ var init_platform = __esm({
6933
7031
  case "android":
6934
7032
  platformBridge.bridge = await BridgeAndroidInit();
6935
7033
  break;
7034
+ case "linux":
7035
+ platformBridge.bridge = await BridgeLinuxInit();
7036
+ break;
6936
7037
  }
6937
7038
  resolve3();
6938
7039
  })
@@ -7535,7 +7636,7 @@ function bodyInitToBuffer(body) {
7535
7636
  function urlOrStringToUrl(url2) {
7536
7637
  return url2 instanceof URL ? url2 : new URL(
7537
7638
  url2,
7538
- url2.startsWith("/") ? globalThis?.location?.host : void 0
7639
+ url2.startsWith("/") ? globalThis?.location?.origin || globalThis?.location?.href || "http://localhost" : void 0
7539
7640
  );
7540
7641
  }
7541
7642
  function getAbortError() {
@@ -7560,6 +7661,12 @@ async function fetchCore(request, init2) {
7560
7661
  } catch (e) {
7561
7662
  }
7562
7663
  }
7664
+ if (typeof requestUrl === "string" && (requestUrl.startsWith("/") || requestUrl.startsWith("fs://"))) {
7665
+ const nativeFetch = globalThis.fullstacked?.fetch || window.fetch;
7666
+ if (nativeFetch && nativeFetch !== fetchCore) {
7667
+ return nativeFetch(request, init2);
7668
+ }
7669
+ }
7563
7670
  const signal = init2?.signal;
7564
7671
  const cleanupAbortListener = () => signal?.removeEventListener("abort", onAbort);
7565
7672
  if (signal?.aborted) {
@@ -7748,7 +7855,7 @@ var Exit = 5;
7748
7855
  init_isWorker();
7749
7856
 
7750
7857
  // ../../core/internal/bundle/lib/process/version.json
7751
- var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1774", hash: "0a57b14b28367c1508278235c98903a1dfd38899" };
7858
+ var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1783", hash: "58f6546ee36a4629ac9a7e4ffba71d768b42fdbb" };
7752
7859
 
7753
7860
  // ../../core/internal/bundle/lib/timers/index.ts
7754
7861
  var setTimeout2 = globalThis.setTimeout.bind(globalThis);
@@ -8027,7 +8134,6 @@ var Arch = 1;
8027
8134
  var Endieness = 2;
8028
8135
  var Uname = 3;
8029
8136
  var Hostname = 4;
8030
- var Tmpdir = 5;
8031
8137
 
8032
8138
  // ../../core/internal/bundle/lib/os/index.ts
8033
8139
  var cache = {
@@ -8103,14 +8209,12 @@ function hostname() {
8103
8209
  }
8104
8210
  return cache.hostname;
8105
8211
  }
8212
+ var tmpDirectory = "/.tmp";
8106
8213
  function tmpdir() {
8107
- return globalThis.fullstacked.bridge(
8108
- {
8109
- mod: Os,
8110
- fn: Tmpdir
8111
- },
8112
- true
8113
- );
8214
+ if (!fs_default.existsSync(tmpDirectory)) {
8215
+ fs_default.mkdirSync(tmpDirectory);
8216
+ }
8217
+ return tmpDirectory;
8114
8218
  }
8115
8219
  var os_default = {
8116
8220
  platform,
@@ -8134,10 +8238,16 @@ var constants = {
8134
8238
  return sep;
8135
8239
  }
8136
8240
  };
8241
+ function cleanPath(p) {
8242
+ if (typeof p !== "string") return p;
8243
+ return p.replace(/^[/\\]+(?=[a-zA-Z]:)/, "");
8244
+ }
8137
8245
  function isAbsolute(path3) {
8246
+ path3 = cleanPath(path3);
8138
8247
  return path3.startsWith("/") || path3.startsWith("\\") || /^[a-zA-Z]:[/\\]/.test(path3);
8139
8248
  }
8140
8249
  function resolve(...paths) {
8250
+ paths = paths.map(cleanPath);
8141
8251
  if (paths[0].startsWith("build:")) {
8142
8252
  return paths.join(constants.sep);
8143
8253
  } else if (!isAbsolute(paths[0])) {
@@ -8157,7 +8267,7 @@ function join(...paths) {
8157
8267
  {
8158
8268
  mod: Path,
8159
8269
  fn: Join,
8160
- data: paths
8270
+ data: paths.map(cleanPath)
8161
8271
  },
8162
8272
  true
8163
8273
  );
@@ -8167,7 +8277,7 @@ function normalize(path3) {
8167
8277
  {
8168
8278
  mod: Path,
8169
8279
  fn: Normalize,
8170
- data: [path3]
8280
+ data: [cleanPath(path3)]
8171
8281
  },
8172
8282
  true
8173
8283
  );
@@ -8177,7 +8287,7 @@ function parse(path3) {
8177
8287
  {
8178
8288
  mod: Path,
8179
8289
  fn: Parse,
8180
- data: [path3]
8290
+ data: [cleanPath(path3)]
8181
8291
  },
8182
8292
  true
8183
8293
  );
@@ -8186,7 +8296,10 @@ function extname(path3) {
8186
8296
  return parse(path3).ext;
8187
8297
  }
8188
8298
  function dirname(path3) {
8189
- return parse(path3).dir;
8299
+ const parsed = parse(path3);
8300
+ if (parsed.dir) return parsed.dir;
8301
+ if (parsed.root) return parsed.root;
8302
+ return ".";
8190
8303
  }
8191
8304
  function basename(path3, suffix) {
8192
8305
  const base = parse(path3).base;
@@ -8200,7 +8313,7 @@ function relative(from, to) {
8200
8313
  {
8201
8314
  mod: Path,
8202
8315
  fn: Relative,
8203
- data: [from, to]
8316
+ data: [cleanPath(from), cleanPath(to)]
8204
8317
  },
8205
8318
  true
8206
8319
  );
@@ -8679,14 +8792,14 @@ var parentWindow_default = parentWindow;
8679
8792
  // ../../core/internal/bundle/lib/bridge/index.ts
8680
8793
  globalThis.__dirname = "/";
8681
8794
  async function init() {
8682
- if (globalThis.fullstacked) {
8795
+ if (globalThis.fullstacked?.bridge) {
8683
8796
  return;
8684
8797
  }
8685
- globalThis.fullstacked = {
8686
- clipboard: {},
8687
- window: {},
8688
- workerStreams: /* @__PURE__ */ new Map()
8689
- };
8798
+ globalThis.fullstacked = globalThis.fullstacked || {};
8799
+ globalThis.fullstacked.clipboard = globalThis.fullstacked.clipboard || {};
8800
+ globalThis.fullstacked.plugins = globalThis.fullstacked.plugins || /* @__PURE__ */ new Map();
8801
+ globalThis.fullstacked.window = globalThis.fullstacked.window || {};
8802
+ globalThis.fullstacked.workerStreams = globalThis.fullstacked.workerStreams || /* @__PURE__ */ new Map();
8690
8803
  const platformBridge2 = (await Promise.resolve().then(() => (init_platform(), platform_exports))).default;
8691
8804
  try {
8692
8805
  await platformBridge2.ready;
@@ -8815,7 +8928,12 @@ var Register = 1;
8815
8928
  var Unregister = 2;
8816
8929
 
8817
8930
  // ../../core/internal/bundle/lib/plugin/index.ts
8818
- var plugins = /* @__PURE__ */ new Map();
8931
+ if (!globalThis.fullstacked) {
8932
+ globalThis.fullstacked = {};
8933
+ }
8934
+ if (!globalThis.fullstacked.plugins) {
8935
+ globalThis.fullstacked.plugins = /* @__PURE__ */ new Map();
8936
+ }
8819
8937
  var duplexStream = null;
8820
8938
  var eventEmitter = null;
8821
8939
  var connectionPromise = null;
@@ -8845,7 +8963,7 @@ async function connect() {
8845
8963
  let result = null;
8846
8964
  let errorMsg = null;
8847
8965
  try {
8848
- const registeredPlugin = plugins.get(pluginId);
8966
+ const registeredPlugin = globalThis.fullstacked.plugins.get(pluginId);
8849
8967
  if (registeredPlugin) {
8850
8968
  result = await registeredPlugin.callback(...args2);
8851
8969
  if (registeredPlugin.type === PluginTypeBuild) {
@@ -8895,10 +9013,13 @@ async function register(type2, plugin2) {
8895
9013
  fn: Register,
8896
9014
  data: [type2, name || "plugin-" + type2, pluginData]
8897
9015
  });
8898
- plugins.set(id, { type: type2, callback: plugin2.callback });
9016
+ globalThis.fullstacked.plugins.set(id, {
9017
+ type: type2,
9018
+ callback: plugin2.callback
9019
+ });
8899
9020
  return {
8900
9021
  unregister: async () => {
8901
- plugins.delete(id);
9022
+ globalThis.fullstacked.plugins.delete(id);
8902
9023
  await globalThis.fullstacked.bridge({
8903
9024
  mod: Plugin,
8904
9025
  fn: Unregister,
@@ -9333,10 +9454,10 @@ async function runDirectory(positionals, pluginsArgs, buildOnly, noOpen, env2, w
9333
9454
  return 0;
9334
9455
  }
9335
9456
  const newCtx = await run_default({ directory: targetDirectory, env: env2 });
9457
+ await cleanupPlugins();
9336
9458
  if (!noOpen && typeof newCtx === "number") {
9337
9459
  globalThis.fullstacked.open?.(newCtx);
9338
9460
  }
9339
- await cleanupPlugins();
9340
9461
  return 0;
9341
9462
  }
9342
9463
  function validateCommand(command) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullstacked",
3
- "version": "1.0.0-alpha.1774",
3
+ "version": "1.0.0-alpha.1783",
4
4
  "bin": {
5
5
  "fullstacked": "index.js"
6
6
  },
@@ -20,12 +20,12 @@
20
20
  "node-addon-api": "^8.9.0"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@fullstacked/darwin-arm64": "1.0.0-alpha.1774",
24
- "@fullstacked/darwin-x64": "1.0.0-alpha.1774",
25
- "@fullstacked/linux-arm64": "1.0.0-alpha.1774",
26
- "@fullstacked/linux-x64": "1.0.0-alpha.1774",
27
- "@fullstacked/win32-arm64": "1.0.0-alpha.1774",
28
- "@fullstacked/win32-x64": "1.0.0-alpha.1774"
23
+ "@fullstacked/darwin-arm64": "1.0.0-alpha.1783",
24
+ "@fullstacked/darwin-x64": "1.0.0-alpha.1783",
25
+ "@fullstacked/linux-arm64": "1.0.0-alpha.1783",
26
+ "@fullstacked/linux-x64": "1.0.0-alpha.1783",
27
+ "@fullstacked/win32-arm64": "1.0.0-alpha.1783",
28
+ "@fullstacked/win32-x64": "1.0.0-alpha.1783"
29
29
  },
30
30
  "author": "FullStacked",
31
31
  "license": "MIT",
@@ -4,7 +4,6 @@ export declare const Arch: OsFn;
4
4
  export declare const Endieness: OsFn;
5
5
  export declare const Uname: OsFn;
6
6
  export declare const Hostname: OsFn;
7
- export declare const Tmpdir: OsFn;
8
7
  export interface UnameInfo {
9
8
  sysname: string;
10
9
  nodename: string;
@@ -1,5 +1,6 @@
1
1
  import { CoreModule, SerializableData } from "../@types/index.ts";
2
2
  import type platformBridgeType from "./platform/index.ts";
3
+ import type { JSPlugin } from "../plugin/index.ts";
3
4
  declare global {
4
5
  var fullstacked: Partial<FullStacked>;
5
6
  var __dirname: string;
@@ -10,6 +11,7 @@ type FullStacked = {
10
11
  respond(id: number, responseBase64: string): void;
11
12
  onStreamData: (id: number, payload: ArrayBuffer | string) => void;
12
13
  workerStreams: Map<number, any>;
14
+ plugins: Map<number, JSPlugin>;
13
15
  exit: () => void;
14
16
  clipboard: {
15
17
  copy?: (text: string) => void;
@@ -0,0 +1,8 @@
1
+ import { PlatformBridge } from "./index.ts";
2
+ declare global {
3
+ var webkit: any;
4
+ var chrome: any;
5
+ var qt: any;
6
+ var bridge: any;
7
+ }
8
+ export declare function BridgeLinuxInit(): Promise<PlatformBridge>;