@xyo-network/sdk-protocol 7.4.2 → 8.0.1

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.
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  (() => {
3
- // ../../node_modules/.pnpm/@ariestools+threads@8.1.9_@opentelemetry+api@1.9.1_observable-fns@0.6.1_supports-color@7.2.0_zod@4.4.3/node_modules/@ariestools/threads/dist/browser/worker/worker.browser.mjs
3
+ // ../../node_modules/.pnpm/@ariestools+sdk@9.0.0_@opentelemetry+api@1.9.1_zod@4.6.5/node_modules/@ariestools/sdk/dist/neutral/enum.mjs
4
+ var Enum = (obj) => {
5
+ return obj;
6
+ };
7
+
8
+ // ../../node_modules/.pnpm/@ariestools+threads@9.0.0_@opentelemetry+api@1.9.1_observable-fns@0.6.1_supports-color@7.2.0_zod@4.6.5/node_modules/@ariestools/threads/dist/browser/worker/worker.browser.mjs
4
9
  var DefaultErrorSerializer = {
5
10
  deserialize: (message) => {
6
11
  const error = Object.create(Error.prototype);
@@ -44,12 +49,30 @@
44
49
  function isTransferDescriptor(thing) {
45
50
  return thing != null && typeof thing === "object" && Reflect.get(thing, $transferable) === true;
46
51
  }
52
+ var MasterMessageType = Enum({
53
+ /** Cancel a previously submitted job. */
54
+ cancel: "cancel",
55
+ /** Run a job in the worker. */
56
+ run: "run"
57
+ });
58
+ var WorkerMessageType = Enum({
59
+ /** A job failed. */
60
+ error: "error",
61
+ /** The worker exposed its callable API. */
62
+ init: "init",
63
+ /** A job produced a result. */
64
+ result: "result",
65
+ /** A job started running. */
66
+ running: "running",
67
+ /** An error escaped the worker job handler. */
68
+ uncaughtError: "uncaughtError"
69
+ });
47
70
  var isErrorEvent = (value) => value !== void 0 && value.error !== void 0;
48
71
  function createExpose(implementation, self2) {
49
72
  let exposeCalled = false;
50
73
  const activeSubscriptions = /* @__PURE__ */ new Map();
51
- const isMasterJobCancelMessage = (thing) => thing?.type === "cancel";
52
- const isMasterJobRunMessage = (thing) => thing?.type === "run";
74
+ const isMasterJobCancelMessage = (thing) => thing?.type === MasterMessageType.cancel;
75
+ const isMasterJobRunMessage = (thing) => thing?.type === MasterMessageType.run;
53
76
  const isObservable = (thing) => isSomeObservable(thing) || isZenObservable(thing);
54
77
  function isZenObservable(thing) {
55
78
  return thing != null && typeof thing === "object" && typeof thing.subscribe === "function";
@@ -60,8 +83,7 @@
60
83
  function postFunctionInitMessage() {
61
84
  const initMessage = {
62
85
  exposed: { type: "function" },
63
- type: "init"
64
- /* init */
86
+ type: WorkerMessageType.init
65
87
  };
66
88
  implementation.postMessageToMaster(initMessage);
67
89
  }
@@ -71,8 +93,7 @@
71
93
  methods: methodNames,
72
94
  type: "module"
73
95
  },
74
- type: "init"
75
- /* init */
96
+ type: WorkerMessageType.init
76
97
  };
77
98
  implementation.postMessageToMaster(initMessage);
78
99
  }
@@ -80,7 +101,7 @@
80
101
  const { payload: error, transferables } = deconstructTransfer(rawError);
81
102
  const errorMessage = {
82
103
  error: serialize(error),
83
- type: "error",
104
+ type: WorkerMessageType.error,
84
105
  uid
85
106
  };
86
107
  implementation.postMessageToMaster(errorMessage, transferables);
@@ -90,7 +111,7 @@
90
111
  const resultMessage = {
91
112
  complete: completed ? true : void 0,
92
113
  payload,
93
- type: "result",
114
+ type: WorkerMessageType.result,
94
115
  uid
95
116
  };
96
117
  implementation.postMessageToMaster(resultMessage, transferables);
@@ -98,7 +119,7 @@
98
119
  function postJobStartMessage(uid, resultType) {
99
120
  const startMessage = {
100
121
  resultType,
101
- type: "running",
122
+ type: WorkerMessageType.running,
102
123
  uid
103
124
  };
104
125
  implementation.postMessageToMaster(startMessage);
@@ -107,8 +128,7 @@
107
128
  try {
108
129
  const errorMessage = {
109
130
  error: serialize(error),
110
- type: "uncaughtError"
111
- /* uncaughtError */
131
+ type: WorkerMessageType.uncaughtError
112
132
  };
113
133
  implementation.postMessageToMaster(errorMessage);
114
134
  } catch (subError) {