fullstacked 0.12.0-1290 → 0.12.0-1292

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.
@@ -194373,7 +194373,10 @@ function createToolFS(opts) {
194373
194373
  schema: external_exports.object({
194374
194374
  path: external_exports.string()
194375
194375
  }),
194376
- fn: ({ path: path5 }) => fs5.mkdir(fixPath(path5)),
194376
+ fn: async ({ path: path5 }) => {
194377
+ const success = await fs5.mkdir(fixPath(path5));
194378
+ return success ? `Successfully created directory ${path5}.` : `Failed to create directory ${path5}.`;
194379
+ },
194377
194380
  message: ({ path: path5 }) => `Creating directory \`${path5}\``
194378
194381
  }),
194379
194382
  createTool({
@@ -194401,7 +194404,10 @@ function createToolFS(opts) {
194401
194404
  path: external_exports.string(),
194402
194405
  contents: external_exports.string()
194403
194406
  }),
194404
- fn: ({ path: path5, contents }) => fs5.writeFile(fixPath(path5), contents),
194407
+ fn: async ({ path: path5, contents }) => {
194408
+ const success = await fs5.writeFile(fixPath(path5), contents);
194409
+ return success ? `Successfully written ${contents.length} characters to ${path5}.` : `Failed to write to ${path5}.`;
194410
+ },
194405
194411
  message: ({ path: path5 }) => `Writing to \`${path5}\``
194406
194412
  })
194407
194413
  ];
@@ -25,7 +25,12 @@ export function createToolFS(opts?: Partial<ToolFSOptions>) {
25
25
  schema: z.object({
26
26
  path: z.string()
27
27
  }),
28
- fn: ({ path }) => fs.mkdir(fixPath(path)),
28
+ fn: async ({ path }) => {
29
+ const success = await fs.mkdir(fixPath(path));
30
+ return success
31
+ ? `Successfully created directory ${path}.`
32
+ : `Failed to create directory ${path}.`;
33
+ },
29
34
  message: ({ path }) => `Creating directory \`${path}\``
30
35
  }),
31
36
  createTool({
@@ -53,7 +58,12 @@ export function createToolFS(opts?: Partial<ToolFSOptions>) {
53
58
  path: z.string(),
54
59
  contents: z.string()
55
60
  }),
56
- fn: ({ path, contents }) => fs.writeFile(fixPath(path), contents),
61
+ fn: async ({ path, contents }) => {
62
+ const success = await fs.writeFile(fixPath(path), contents);
63
+ return success
64
+ ? `Successfully written ${contents.length} characters to ${path}.`
65
+ : `Failed to write to ${path}.`;
66
+ },
57
67
  message: ({ path }) => `Writing to \`${path}\``
58
68
  })
59
69
  ];
@@ -7,6 +7,7 @@ import {
7
7
  } from "../bridge/serialization";
8
8
  import core_message from "../core_message";
9
9
  import { ar } from "zod/v4/locales";
10
+ import platform, { Platform } from "../platform";
10
11
 
11
12
  const te = new TextEncoder();
12
13
 
@@ -122,14 +123,44 @@ export default function core_fetch(
122
123
  });
123
124
  }
124
125
 
125
- const activeFetch2Requests = new Map<
126
- number,
127
- {
128
- url: string;
129
- resolveResponse(response: Response): void;
130
- resolveStream?(param: { done: boolean; chunk: Uint8Array }): void;
131
- }
132
- >();
126
+ type ActiveRequest = {
127
+ url: string;
128
+ resolveResponse(response: Response): void;
129
+ resolveStream?: (param: { done: boolean; chunk: Uint8Array }) => void;
130
+ };
131
+
132
+ const activeFetch2Requests = new Map<number, ActiveRequest>();
133
+
134
+ // in WASM everything in synchronous and calling
135
+ // resolveStream on the next event loop assures the promise is well set
136
+ //
137
+ // this is call at a very high pace, so it's better to avoid the "if" at every streamed bit
138
+ const processStream =
139
+ platform === Platform.WASM
140
+ ? function (
141
+ id: number,
142
+ request: ActiveRequest,
143
+ done: boolean,
144
+ chunk: Uint8Array
145
+ ) {
146
+ setTimeout(() => {
147
+ request.resolveStream({ done, chunk });
148
+ if (done) {
149
+ activeFetch2Requests.delete(id);
150
+ }
151
+ });
152
+ }
153
+ : function (
154
+ id: number,
155
+ request: ActiveRequest,
156
+ done: boolean,
157
+ chunk: Uint8Array
158
+ ) {
159
+ request.resolveStream({ done, chunk });
160
+ if (done) {
161
+ activeFetch2Requests.delete(id);
162
+ }
163
+ };
133
164
 
134
165
  let addedListener2 = false;
135
166
  function receivedResponse2(base64Data: string) {
@@ -143,10 +174,7 @@ function receivedResponse2(base64Data: string) {
143
174
 
144
175
  if (request.resolveStream) {
145
176
  const [done, chunk] = args.slice(1);
146
- request.resolveStream({ done, chunk });
147
- if (done) {
148
- activeFetch2Requests.delete(id);
149
- }
177
+ processStream(id, request, done, chunk);
150
178
  return;
151
179
  }
152
180
 
@@ -32,7 +32,7 @@ export function writeFile(
32
32
 
33
33
  const payload = new Uint8Array([3, ...serializeArgs([path, data, origin])]);
34
34
 
35
- return bridge(payload, ([success]) => success);
35
+ return bridge(payload, ([errMessage]) => !errMessage);
36
36
  }
37
37
 
38
38
  // 4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullstacked",
3
- "version": "0.12.0-1290",
3
+ "version": "0.12.0-1292",
4
4
  "scripts": {
5
5
  "build": "node build.js",
6
6
  "start": "npm run build && node index.js --lib ../../core/bin --root ~/FullStacked --config ~/.config/fullstacked --editor ../../out/editor",