@rstest/core 0.8.4 → 0.9.0

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/dist/0~89.js CHANGED
@@ -3,9 +3,9 @@ import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import node_events from "node:events";
4
4
  import { Tinypool } from "tinypool";
5
5
  import node_inspector from "node:inspector";
6
- import { basename, needFlagExperimentalDetectModule, isDeno, dirname, castArray, resolve as pathe_M_eThtNZ_resolve, serializableConfig, node_process, isDebug, color, getForceColorEnv, ADDITIONAL_NODE_BUILTINS, bgColor, join } from "./3160.js";
6
+ import { basename, bgColor, isDeno, dirname, castArray, resolve as pathe_M_eThtNZ_resolve, node_process, isDebug, color, getForceColorEnv, ADDITIONAL_NODE_BUILTINS, join, needFlagExperimentalDetectModule } from "./3160.js";
7
7
  import { fileURLToPath } from "./6198.js";
8
- import { node_v8, parseWorkerMetaMessage, createBirpc } from "./9869.js";
8
+ import { parseWorkerMetaMessage, createBirpc } from "./4597.js";
9
9
  import { TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB } from "./1157.js";
10
10
  import { posix } from "./7011.js";
11
11
  import { isBuiltin } from "./4881.js";
@@ -198,9 +198,8 @@ const createWorkerStderrCapture = (pool)=>{
198
198
  };
199
199
  const forks_filename = fileURLToPath(import.meta.url);
200
200
  const forks_dirname = dirname(forks_filename);
201
- function createChannel(rpcMethods, onWorkerMeta) {
201
+ function createForksChannel(rpcMethods, onWorkerMeta, createBirpcImpl = createBirpc) {
202
202
  const emitter = new node_events();
203
- const cleanup = ()=>emitter.removeAllListeners();
204
203
  const events = {
205
204
  message: 'message',
206
205
  response: 'response'
@@ -215,9 +214,8 @@ function createChannel(rpcMethods, onWorkerMeta) {
215
214
  emitter.emit(events.response, message);
216
215
  }
217
216
  };
218
- createBirpc(rpcMethods, {
219
- serialize: node_v8.serialize,
220
- deserialize: (v)=>node_v8.deserialize(Buffer.from(v)),
217
+ const rpc = createBirpcImpl(rpcMethods, {
218
+ timeout: -1,
221
219
  post (v) {
222
220
  emitter.emit(events.message, v);
223
221
  },
@@ -225,9 +223,13 @@ function createChannel(rpcMethods, onWorkerMeta) {
225
223
  emitter.on(events.response, fn);
226
224
  }
227
225
  });
226
+ const cleanup = ()=>{
227
+ rpc.$close(new Error('[rstest-pool]: Pending methods while closing rpc'));
228
+ emitter.removeAllListeners();
229
+ };
228
230
  return {
229
- channel,
230
- cleanup
231
+ channel: channel,
232
+ cleanup: cleanup
231
233
  };
232
234
  }
233
235
  const createForksPool = (poolOptions)=>{
@@ -240,7 +242,8 @@ const createForksPool = (poolOptions)=>{
240
242
  maxThreads,
241
243
  minThreads,
242
244
  concurrentTasksPerWorker: 1,
243
- isolateWorkers: isolate
245
+ isolateWorkers: isolate,
246
+ serialization: 'advanced'
244
247
  };
245
248
  const pool = new Tinypool(options);
246
249
  const stderrCapture = createWorkerStderrCapture(pool);
@@ -250,7 +253,7 @@ const createForksPool = (poolOptions)=>{
250
253
  runTest: async ({ options, rpcMethods })=>{
251
254
  const taskId = ++nextTaskId;
252
255
  stderrCapture.createTask(taskId);
253
- const { channel, cleanup } = createChannel(rpcMethods, ({ pid })=>{
256
+ const { channel, cleanup } = createForksChannel(rpcMethods, ({ pid })=>{
254
257
  stderrCapture.bindTaskToPid(taskId, pid);
255
258
  });
256
259
  try {
@@ -268,7 +271,7 @@ const createForksPool = (poolOptions)=>{
268
271
  collectTests: async ({ options, rpcMethods })=>{
269
272
  const taskId = ++nextTaskId;
270
273
  stderrCapture.createTask(taskId);
271
- const { channel, cleanup } = createChannel(rpcMethods, ({ pid })=>{
274
+ const { channel, cleanup } = createForksChannel(rpcMethods, ({ pid })=>{
272
275
  stderrCapture.bindTaskToPid(taskId, pid);
273
276
  });
274
277
  try {
@@ -431,7 +434,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
431
434
  project: projectName,
432
435
  rootPath: context.rootPath,
433
436
  projectRoot: project.rootPath,
434
- runtimeConfig: serializableConfig(runtimeConfig)
437
+ runtimeConfig
435
438
  },
436
439
  type: 'run',
437
440
  setupEntries,
@@ -501,7 +504,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
501
504
  outputModule: project.outputModule,
502
505
  rootPath: context.rootPath,
503
506
  projectRoot: project.rootPath,
504
- runtimeConfig: serializableConfig(runtimeConfig)
507
+ runtimeConfig
505
508
  },
506
509
  type: 'collect',
507
510
  setupEntries,
@@ -534,7 +537,7 @@ function applyEnvChanges(changes) {
534
537
  }
535
538
  const globalSetup_filename = fileURLToPath(import.meta.url);
536
539
  const globalSetup_dirname = dirname(globalSetup_filename);
537
- async function createSetupPool() {
540
+ function createSetupPool() {
538
541
  const options = {
539
542
  runtime: 'child_process',
540
543
  filename: pathe_M_eThtNZ_resolve(globalSetup_dirname, './globalSetupWorker.js'),
@@ -548,6 +551,7 @@ async function createSetupPool() {
548
551
  minThreads: 1,
549
552
  concurrentTasksPerWorker: 1,
550
553
  isolateWorkers: false,
554
+ serialization: 'advanced',
551
555
  env: {
552
556
  NODE_ENV: 'test',
553
557
  ...getForceColorEnv(),
@@ -558,7 +562,7 @@ async function createSetupPool() {
558
562
  return pool;
559
563
  }
560
564
  async function runGlobalSetup({ globalSetupEntries, assetFiles, sourceMaps, interopDefault, outputModule }) {
561
- const pool = await createSetupPool();
565
+ const pool = createSetupPool();
562
566
  const result = await pool.run({
563
567
  type: 'setup',
564
568
  entries: globalSetupEntries,
@@ -610,12 +614,11 @@ const pluginBasic = (context)=>({
610
614
  chain.optimization.splitChunks({
611
615
  chunks: 'all'
612
616
  });
613
- chain.module.rule(CHAIN_ID.RULE.JS).delete('type');
617
+ chain.module.rule(CHAIN_ID.RULE.JS).oneOf(CHAIN_ID.ONE_OF.JS_MAIN).delete('type');
614
618
  });
615
- api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig, name })=>{
616
- const { normalizedConfig: { resolve, source, output, tools, performance, dev, testEnvironment }, outputModule, rootPath } = context.projects.find((p)=>p.environmentName === name);
619
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig, name })=>{
620
+ const { normalizedConfig: { resolve, source, output, tools, dev, testEnvironment }, outputModule, rootPath } = context.projects.find((p)=>p.environmentName === name);
617
621
  return mergeEnvironmentConfig(config, {
618
- performance,
619
622
  tools,
620
623
  resolve,
621
624
  source,
@@ -720,7 +723,7 @@ const pluginCSSFilter = ()=>({
720
723
  setup (api) {
721
724
  api.modifyBundlerChain({
722
725
  order: 'post',
723
- handler: async (chain, { target, CHAIN_ID, environment })=>{
726
+ handler: (chain, { target, CHAIN_ID, environment })=>{
724
727
  const emitCss = environment.config.output.emitCss ?? 'web' === target;
725
728
  if (!emitCss) {
726
729
  const ruleIds = [
@@ -731,7 +734,7 @@ const pluginCSSFilter = ()=>({
731
734
  ];
732
735
  for (const ruleId of ruleIds){
733
736
  if (!chain.module.rules.has(ruleId)) continue;
734
- const rule = chain.module.rule(ruleId);
737
+ const rule = chain.module.rule(ruleId).oneOf(CHAIN_ID.ONE_OF.CSS_MAIN);
735
738
  if (!rule.uses.has(CHAIN_ID.USE.CSS)) continue;
736
739
  const cssLoaderOptions = rule.use(CHAIN_ID.USE.CSS).get('options');
737
740
  if (cssLoaderOptions.modules && ('object' != typeof cssLoaderOptions.modules || false !== cssLoaderOptions.modules.auto)) rule.use('rstest-css-pre-filter').loader(external_node_path_["default"].join(css_filter_dirname, 'cssFilterLoader.mjs')).options({
@@ -817,7 +820,7 @@ function autoExternalNodeBuiltin({ request, dependencyType }, callback) {
817
820
  const pluginExternal = (context)=>({
818
821
  name: 'rstest:external',
819
822
  setup: (api)=>{
820
- api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig, name })=>{
823
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig, name })=>{
821
824
  const { normalizedConfig: { testEnvironment }, outputModule } = context.projects.find((p)=>p.environmentName === name);
822
825
  return mergeEnvironmentConfig(config, {
823
826
  output: {
@@ -850,7 +853,7 @@ class IgnoreModuleNotFoundErrorPlugin {
850
853
  const pluginIgnoreResolveError = {
851
854
  name: 'rstest:ignore-resolve-error',
852
855
  setup: (api)=>{
853
- api.modifyRspackConfig(async (config)=>{
856
+ api.modifyRspackConfig((config)=>{
854
857
  config.plugins.push(new IgnoreModuleNotFoundErrorPlugin());
855
858
  config.optimization ??= {};
856
859
  config.optimization.emitOnErrors = true;
@@ -865,7 +868,7 @@ const pluginInspect = (options)=>{
865
868
  return enable ? {
866
869
  name: 'rstest:inspect',
867
870
  setup: (api)=>{
868
- api.modifyRspackConfig(async (config)=>{
871
+ api.modifyRspackConfig((config)=>{
869
872
  config.devtool = 'inline-nosources-source-map';
870
873
  config.optimization ??= {};
871
874
  config.optimization.splitChunks = {
@@ -925,7 +928,7 @@ class MockRuntimeRspackPlugin {
925
928
  const pluginMockRuntime = {
926
929
  name: 'rstest:mock-runtime',
927
930
  setup: (api)=>{
928
- api.modifyRspackConfig(async (config)=>{
931
+ api.modifyRspackConfig((config)=>{
929
932
  config.plugins.push(new MockRuntimeRspackPlugin(Boolean(config.output.module)));
930
933
  });
931
934
  }
@@ -975,7 +978,7 @@ const pluginCacheControl = (setupFiles)=>({
975
978
  }
976
979
  `
977
980
  }));
978
- api.modifyRspackConfig(async (config)=>{
981
+ api.modifyRspackConfig((config)=>{
979
982
  config.plugins.push(new RstestCacheControlPlugin());
980
983
  });
981
984
  }
@@ -1192,7 +1195,7 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSe
1192
1195
  return promise;
1193
1196
  };
1194
1197
  const buildData = {};
1195
- const getEntryFiles = async (manifest, outputPath)=>{
1198
+ const getEntryFiles = (manifest, outputPath)=>{
1196
1199
  const entryFiles = {};
1197
1200
  const entries = Object.keys(manifest.entries);
1198
1201
  for (const entry of entries){
@@ -1216,7 +1219,7 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSe
1216
1219
  chunks: true,
1217
1220
  timings: true
1218
1221
  });
1219
- const entryFiles = await getEntryFiles(manifest, outputPath);
1222
+ const entryFiles = getEntryFiles(manifest, outputPath);
1220
1223
  const entries = [];
1221
1224
  const setupEntries = [];
1222
1225
  const globalSetupEntries = [];
package/dist/0~9634.js CHANGED
@@ -11,8 +11,8 @@ const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries }
11
11
  }));
12
12
  if (0 === nodeProjects.length) return {
13
13
  list: [],
14
- getSourceMap: async (_name)=>null,
15
- close: async ()=>{}
14
+ getSourceMap: async ()=>null,
15
+ close: async ()=>void 0
16
16
  };
17
17
  const setupFiles = Object.fromEntries(nodeProjects.map((project)=>{
18
18
  const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
@@ -101,7 +101,7 @@ const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries }
101
101
  const collectBrowserTests = async ({ context, browserProjects, shardedEntries })=>{
102
102
  if (0 === browserProjects.length) return {
103
103
  list: [],
104
- close: async ()=>{}
104
+ close: async ()=>void 0
105
105
  };
106
106
  const { loadBrowserModule } = await import("./0~1472.js").then((mod)=>({
107
107
  loadBrowserModule: mod.loadBrowserModule
@@ -126,10 +126,10 @@ const collectTestFiles = async ({ context, globTestSourceEntries })=>{
126
126
  })));
127
127
  }
128
128
  return {
129
- close: async ()=>{},
129
+ close: async ()=>void 0,
130
130
  errors: [],
131
131
  list,
132
- getSourceMap: async (_name)=>null
132
+ getSourceMap: async ()=>null
133
133
  };
134
134
  };
135
135
  const collectAllTests = async ({ context, globTestSourceEntries, shardedEntries })=>{
package/dist/1294.js CHANGED
@@ -4821,7 +4821,7 @@ __webpack_require__.add({
4821
4821
  },
4822
4822
  "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js" (module, __unused_rspack_exports, __webpack_require__) {
4823
4823
  const os = __webpack_require__("node:os");
4824
- const tty = __webpack_require__("node:tty");
4824
+ const tty = __webpack_require__("tty");
4825
4825
  const hasFlag = __webpack_require__("../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
4826
4826
  const { env } = process;
4827
4827
  let forceColor;
@@ -4906,6 +4906,7 @@ build_1["default"];
4906
4906
  const REAL_TIMERS = {};
4907
4907
  const setRealTimers = ()=>{
4908
4908
  REAL_TIMERS.setTimeout ??= globalThis.setTimeout.bind(globalThis);
4909
+ REAL_TIMERS.clearTimeout ??= globalThis.clearTimeout.bind(globalThis);
4909
4910
  };
4910
4911
  const getRealTimers = ()=>REAL_TIMERS;
4911
4912
  const formatTestError = (err, test)=>{
package/dist/3160.js CHANGED
@@ -82,12 +82,12 @@ __webpack_require__.add({
82
82
  "node:path" (module) {
83
83
  module.exports = __rspack_external_node_path_c5b9b54f;
84
84
  },
85
- "node:tty" (module) {
85
+ tty (module) {
86
86
  module.exports = __rspack_external_node_tty_c64aab7e;
87
87
  }
88
88
  });
89
89
  const external_node_os_ = __webpack_require__("node:os");
90
- const external_node_tty_ = __webpack_require__("node:tty");
90
+ const external_node_tty_ = __webpack_require__("tty");
91
91
  function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
92
92
  const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
93
93
  const position = argv.indexOf(prefix + flag);
@@ -347,27 +347,6 @@ let createLogger = (options = {})=>{
347
347
  return logger;
348
348
  };
349
349
  let src_logger = createLogger();
350
- /*!
351
- * Copyright 2017 Vercel, Inc.
352
- *
353
- * This file is derived from Vercel's detect-agent:
354
- * https://github.com/vercel/vercel/tree/main/packages/detect-agent
355
- *
356
- * Licensed under the Apache License, Version 2.0 (the "License");
357
- * you may not use this file except in compliance with the License.
358
- * You may obtain a copy of the License at
359
- *
360
- * http://www.apache.org/licenses/LICENSE-2.0
361
- *
362
- * Unless required by applicable law or agreed to in writing, software
363
- * distributed under the License is distributed on an "AS IS" BASIS,
364
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
365
- * See the License for the specific language governing permissions and
366
- * limitations under the License.
367
- *
368
- * Modifications in this derived work:
369
- * - Removed async determine logic, kept only env detection.
370
- */ const CURSOR = 'cursor';
371
350
  const CURSOR_CLI = 'cursor-cli';
372
351
  const CLAUDE = 'claude';
373
352
  const REPLIT = 'replit';
@@ -389,12 +368,6 @@ function determineAgent() {
389
368
  }
390
369
  };
391
370
  }
392
- if (process.env.CURSOR_TRACE_ID) return {
393
- isAgent: true,
394
- agent: {
395
- name: CURSOR
396
- }
397
- };
398
371
  if (process.env.CURSOR_AGENT) return {
399
372
  isAgent: true,
400
373
  agent: {
@@ -940,17 +913,6 @@ const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(B
940
913
  const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(delimiter ? ` ${delimiter} ` : ' ');
941
914
  const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
942
915
  const wrapRegex = (value)=>`${REGEXP_FLAG_PREFIX}${value.toString()}`;
943
- const unwrapRegex = (value)=>{
944
- if (value.startsWith(REGEXP_FLAG_PREFIX)) {
945
- const regexStr = value.slice(REGEXP_FLAG_PREFIX.length);
946
- const matches = regexStr.match(/^\/(.+)\/([gimuy]*)$/);
947
- if (matches) {
948
- const [, pattern, flags] = matches;
949
- return new RegExp(pattern, flags);
950
- }
951
- }
952
- return value;
953
- };
954
916
  const serializableConfig = (normalizedConfig)=>{
955
917
  const { testNamePattern } = normalizedConfig;
956
918
  return {
@@ -958,13 +920,6 @@ const serializableConfig = (normalizedConfig)=>{
958
920
  testNamePattern: testNamePattern && 'string' != typeof testNamePattern ? wrapRegex(testNamePattern) : testNamePattern
959
921
  };
960
922
  };
961
- const undoSerializableConfig = (normalizedConfig)=>{
962
- const { testNamePattern } = normalizedConfig;
963
- return {
964
- ...normalizedConfig,
965
- testNamePattern: testNamePattern && 'string' == typeof testNamePattern ? unwrapRegex(testNamePattern) : testNamePattern
966
- };
967
- };
968
923
  const getNodeVersion = ()=>{
969
924
  if ('string' == typeof process.versions?.node) {
970
925
  const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
@@ -1044,4 +999,4 @@ const logger_logger = {
1044
999
  console.error(message, ...args);
1045
1000
  }
1046
1001
  };
1047
- export { ADDITIONAL_NODE_BUILTINS, _path, basename, bgColor, castArray, clearScreen, color, determineAgent, dirname, formatError, formatRootStr, getAbsolutePath, getForceColorEnv, getTaskNameWithPrefix, isAbsolute, isDebug, isDeno, isObject, isTTY, join, logger_logger as logger, needFlagExperimentalDetectModule, node_process, normalize, parsePosix, prettyTime, relative, resolve, serializableConfig, stdin, stdout, undoSerializableConfig };
1002
+ export { ADDITIONAL_NODE_BUILTINS, _path, basename, bgColor, castArray, clearScreen, color, determineAgent, dirname, formatError, formatRootStr, getAbsolutePath, getForceColorEnv, getTaskNameWithPrefix, isAbsolute, isDebug, isDeno, isObject, isTTY, join, logger_logger as logger, needFlagExperimentalDetectModule, node_process, normalize, parsePosix, prettyTime, relative, resolve, serializableConfig, stdin, stdout };
@@ -19,15 +19,32 @@ const parseWorkerMetaMessage = (message)=>{
19
19
  };
20
20
  const TYPE_REQUEST = "q";
21
21
  const TYPE_RESPONSE = "s";
22
- const DEFAULT_TIMEOUT = 6e4;
23
- function defaultSerialize(i) {
24
- return i;
22
+ function createPromiseWithResolvers() {
23
+ let resolve;
24
+ let reject;
25
+ return {
26
+ promise: new Promise((res, rej)=>{
27
+ resolve = res;
28
+ reject = rej;
29
+ }),
30
+ resolve,
31
+ reject
32
+ };
33
+ }
34
+ const random = Math.random.bind(Math);
35
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
36
+ function nanoid(size = 21) {
37
+ let id = "";
38
+ let i = size;
39
+ while(i--)id += urlAlphabet[64 * random() | 0];
40
+ return id;
25
41
  }
42
+ const DEFAULT_TIMEOUT = 6e4;
43
+ const defaultSerialize = (i)=>i;
26
44
  const defaultDeserialize = defaultSerialize;
27
45
  const { clearTimeout: dist_clearTimeout, setTimeout: dist_setTimeout } = globalThis;
28
- const random = Math.random.bind(Math);
29
46
  function createBirpc($functions, options) {
30
- const { post, on, off = ()=>{}, eventNames = [], serialize = defaultSerialize, deserialize = defaultDeserialize, resolver, bind = "rpc", timeout = DEFAULT_TIMEOUT } = options;
47
+ const { post, on, off = ()=>{}, eventNames = [], serialize = defaultSerialize, deserialize = defaultDeserialize, resolver, bind = "rpc", timeout = DEFAULT_TIMEOUT, proxify = true } = options;
31
48
  let $closed = false;
32
49
  const _rpcPromiseMap = /* @__PURE__ */ new Map();
33
50
  let _promiseInit;
@@ -55,8 +72,7 @@ function createBirpc($functions, options) {
55
72
  if (timeout >= 0) {
56
73
  timeoutId = dist_setTimeout(()=>{
57
74
  try {
58
- const handleResult = options.onTimeoutError?.call(rpc, method, args);
59
- if (true !== handleResult) throw new Error(`[birpc] timeout on calling "${method}"`);
75
+ if (options.onTimeoutError?.call(rpc, method, args) !== true) throw new Error(`[birpc] timeout on calling "${method}"`);
60
76
  } catch (e) {
61
77
  reject(e);
62
78
  }
@@ -85,15 +101,11 @@ function createBirpc($functions, options) {
85
101
  }
86
102
  return promise;
87
103
  }
88
- const $call = (method, ...args)=>_call(method, args, false);
89
- const $callOptional = (method, ...args)=>_call(method, args, false, true);
90
- const $callEvent = (method, ...args)=>_call(method, args, true);
91
- const $callRaw = (options2)=>_call(options2.method, options2.args, options2.event, options2.optional);
92
104
  const builtinMethods = {
93
- $call,
94
- $callOptional,
95
- $callEvent,
96
- $callRaw,
105
+ $call: (method, ...args)=>_call(method, args, false),
106
+ $callOptional: (method, ...args)=>_call(method, args, false, true),
107
+ $callEvent: (method, ...args)=>_call(method, args, true),
108
+ $callRaw: (options$1)=>_call(options$1.method, options$1.args, options$1.event, options$1.optional),
97
109
  $rejectPendingCalls,
98
110
  get $closed () {
99
111
  return $closed;
@@ -104,7 +116,7 @@ function createBirpc($functions, options) {
104
116
  $close,
105
117
  $functions
106
118
  };
107
- rpc = new Proxy({}, {
119
+ rpc = proxify ? new Proxy({}, {
108
120
  get (_, method) {
109
121
  if (Object.prototype.hasOwnProperty.call(builtinMethods, method)) return builtinMethods[method];
110
122
  if ("then" === method && !eventNames.includes("then") && !("then" in $functions)) return;
@@ -117,11 +129,11 @@ function createBirpc($functions, options) {
117
129
  sendCall.asEvent = sendEvent;
118
130
  return sendCall;
119
131
  }
120
- });
132
+ }) : builtinMethods;
121
133
  function $close(customError) {
122
134
  $closed = true;
123
135
  _rpcPromiseMap.forEach(({ reject, method })=>{
124
- const error = new Error(`[birpc] rpc is closed, cannot call "${method}"`);
136
+ const error = /* @__PURE__ */ new Error(`[birpc] rpc is closed, cannot call "${method}"`);
125
137
  if (customError) {
126
138
  customError.cause ??= error;
127
139
  return reject(customError);
@@ -132,9 +144,8 @@ function createBirpc($functions, options) {
132
144
  off(onMessage);
133
145
  }
134
146
  function $rejectPendingCalls(handler) {
135
- const entries = Array.from(_rpcPromiseMap.values());
136
- const handlerResults = entries.map(({ method, reject })=>{
137
- if (!handler) return reject(new Error(`[birpc]: rejected pending call "${method}".`));
147
+ const handlerResults = Array.from(_rpcPromiseMap.values()).map(({ method, reject })=>{
148
+ if (!handler) return reject(/* @__PURE__ */ new Error(`[birpc]: rejected pending call "${method}".`));
138
149
  return handler({
139
150
  method,
140
151
  reject
@@ -161,9 +172,8 @@ function createBirpc($functions, options) {
161
172
  } catch (e) {
162
173
  error = e;
163
174
  }
164
- else error = new Error(`[birpc] function "${method}" not found`);
175
+ else error = /* @__PURE__ */ new Error(`[birpc] function "${method}" not found`);
165
176
  if (msg.i) {
166
- if (error && options.onError) options.onError.call(rpc, error, method, args);
167
177
  if (error && options.onFunctionError) {
168
178
  if (true === options.onFunctionError.call(rpc, error, method, args)) return;
169
179
  }
@@ -202,25 +212,4 @@ function createBirpc($functions, options) {
202
212
  _promiseInit = on(onMessage);
203
213
  return rpc;
204
214
  }
205
- function createPromiseWithResolvers() {
206
- let resolve;
207
- let reject;
208
- const promise = new Promise((res, rej)=>{
209
- resolve = res;
210
- reject = rej;
211
- });
212
- return {
213
- promise,
214
- resolve,
215
- reject
216
- };
217
- }
218
- const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
219
- function nanoid(size = 21) {
220
- let id = "";
221
- let i = size;
222
- while(i--)id += urlAlphabet[64 * random() | 0];
223
- return id;
224
- }
225
- export { default as node_v8 } from "node:v8";
226
215
  export { createBirpc, createWorkerMetaMessage, parseWorkerMetaMessage };