smoldot 1.0.2 → 1.0.3

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.
@@ -86,10 +86,10 @@ function start(options, platformBindings) {
86
86
  // For each chain object returned by `addChain`, the associated internal chain id.
87
87
  //
88
88
  // Immediately cleared when `remove()` is called on a chain.
89
- let chainIds = new WeakMap();
89
+ const chainIds = new WeakMap();
90
90
  // If `Client.terminate()̀ is called, this error is set to a value.
91
91
  // All the functions of the public API check if this contains a value.
92
- let alreadyDestroyedError = null;
92
+ const alreadyDestroyedError = { value: null };
93
93
  const instance = (0, instance_js_1.start)({
94
94
  // Maximum level of log entries sent by the client.
95
95
  // 0 = Logging disabled, 1 = Error, 2 = Warn, 3 = Info, 4 = Debug, 5 = Trace
@@ -103,8 +103,8 @@ function start(options, platformBindings) {
103
103
  }, platformBindings);
104
104
  return {
105
105
  addChain: (options) => __awaiter(this, void 0, void 0, function* () {
106
- if (alreadyDestroyedError)
107
- throw alreadyDestroyedError;
106
+ if (alreadyDestroyedError.value)
107
+ throw alreadyDestroyedError.value;
108
108
  // Passing a JSON object for the chain spec is an easy mistake, so we provide a more
109
109
  // readable error.
110
110
  if (!(typeof options.chainSpec === 'string'))
@@ -129,8 +129,8 @@ function start(options, platformBindings) {
129
129
  // Resolve the promise that `addChain` returned to the user.
130
130
  const newChain = {
131
131
  sendJsonRpc: (request) => {
132
- if (alreadyDestroyedError)
133
- throw alreadyDestroyedError;
132
+ if (alreadyDestroyedError.value)
133
+ throw alreadyDestroyedError.value;
134
134
  if (wasDestroyed.destroyed)
135
135
  throw new AlreadyDestroyedError();
136
136
  if (options.disableJsonRpc)
@@ -142,8 +142,8 @@ function start(options, platformBindings) {
142
142
  instance.request(request, chainId);
143
143
  },
144
144
  nextJsonRpcResponse: () => {
145
- if (alreadyDestroyedError)
146
- return Promise.reject(alreadyDestroyedError);
145
+ if (alreadyDestroyedError.value)
146
+ return Promise.reject(alreadyDestroyedError.value);
147
147
  if (wasDestroyed.destroyed)
148
148
  return Promise.reject(new AlreadyDestroyedError());
149
149
  if (options.disableJsonRpc)
@@ -151,8 +151,8 @@ function start(options, platformBindings) {
151
151
  return instance.nextJsonRpcResponse(chainId);
152
152
  },
153
153
  remove: () => {
154
- if (alreadyDestroyedError)
155
- throw alreadyDestroyedError;
154
+ if (alreadyDestroyedError.value)
155
+ throw alreadyDestroyedError.value;
156
156
  if (wasDestroyed.destroyed)
157
157
  throw new AlreadyDestroyedError();
158
158
  wasDestroyed.destroyed = true;
@@ -165,9 +165,9 @@ function start(options, platformBindings) {
165
165
  return newChain;
166
166
  }),
167
167
  terminate: () => __awaiter(this, void 0, void 0, function* () {
168
- if (alreadyDestroyedError)
169
- throw alreadyDestroyedError;
170
- alreadyDestroyedError = new AlreadyDestroyedError();
168
+ if (alreadyDestroyedError.value)
169
+ throw alreadyDestroyedError.value;
170
+ alreadyDestroyedError.value = new AlreadyDestroyedError();
171
171
  instance.startShutdown();
172
172
  })
173
173
  };