yeow-api 0.2.27 → 0.2.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeow-api",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "description": "Yeow API �?TypeScript OOP wrappers over the task protocol",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/assets.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  function _sendAssets(payload) {
2
- const raw = $send('assets', JSON.stringify(payload));
3
- if (!raw) return undefined;
4
- const r = JSON.parse(raw);
2
+ const r = $send('assets', payload);
3
+ if (!r) return undefined;
5
4
  if (r.err) throw new Error(r.err);
6
5
  return r;
7
6
  }
package/src/fs.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  function _sendFs(payload) {
2
- const raw = $send('fs', JSON.stringify(payload));
3
- if (!raw) return undefined;
4
- const r = JSON.parse(raw);
2
+ const r = $send('fs', payload);
3
+ if (!r) return undefined;
5
4
  if (r.err) throw new Error(r.err);
6
5
  return r;
7
6
  }
package/src/http.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  const _servers = new Set();
2
2
 
3
3
  function _sendHttp(payload) {
4
- const raw = $send('http', JSON.stringify(payload));
5
- if (!raw) return undefined;
6
- const r = JSON.parse(raw);
4
+ const r = $send('http', payload);
5
+ if (!r) return undefined;
7
6
  if (r.err) throw new Error(r.err);
8
7
  return r;
9
8
  }
package/src/task.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  export function post(type: string, params: Record<string, unknown> = {}, priority?: string): Promise<unknown> {
2
2
  return new Promise((resolve, reject) => {
3
3
  const cbId = (globalThis as any)._registerCallback((result: any) => {
4
- if (result?.err) reject(new Error(result.err));
5
- else resolve(result);
4
+ if (result?.err) {
5
+ const e = new Error(result.err);
6
+ const regStack = typeof (globalThis as any)._getCurrentCbStack === 'function' ? (globalThis as any)._getCurrentCbStack() : null;
7
+ if (regStack) e.stack += '\n --- registered at ---\n' + regStack;
8
+ reject(e);
9
+ } else resolve(result);
6
10
  });
7
11
  const pld: Record<string, unknown> = { type, params, cb: cbId };
8
12
  if (priority) pld.priority = priority;