| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- diff --git a/node_modules/open-im-sdk-wasm/lib/index.es.js b/node_modules/open-im-sdk-wasm/lib/index.es.js
- index 64c4047..3400689 100644
- --- a/node_modules/open-im-sdk-wasm/lib/index.es.js
- +++ b/node_modules/open-im-sdk-wasm/lib/index.es.js
- @@ -472,38 +472,32 @@ function supportsModuleWorkers() {
- }
- }
- function initWorker() {
- - if (typeof window === 'undefined') {
- - return;
- - }
- - // use for webpack 4
- - // const IMWorker = require('worker-loader!./worker.js');
- - // worker = new IMWorker.default();
- - // use for webpack5+ or vite
- - const isViteEnvironment = import.meta.url.includes('.vite/deps');
- - const isNuxtEnvironment = import.meta.url.includes('_nuxt/node_modules');
- - const isSupportModuleWorker = supportsModuleWorkers();
- - let workerUrl = isSupportModuleWorker
- - ? new URL('worker.js', import.meta.url)
- - : new URL('worker-legacy.js', import.meta.url);
- - if (isViteEnvironment) {
- - workerUrl = workerUrl.href.replace('.vite/deps', 'open-im-sdk-wasm/lib');
- - }
- - if (isNuxtEnvironment) {
- - workerUrl = workerUrl.href.replace('.cache/vite/client/deps', 'open-im-sdk-wasm/lib');
- - }
- - worker = new Worker(workerUrl, {
- - type: isSupportModuleWorker ? 'module' : 'classic',
- - });
- - // This is only required because Safari doesn't support nested
- - // workers. This installs a handler that will proxy creating web
- - // workers through the main thread
- - initBackend(worker);
- - rpc = new RPC({
- - event: new RPCMessageEvent({
- - currentEndpoint: worker,
- - targetEndpoint: worker,
- - }),
- - });
- + if (typeof window === 'undefined') {
- + return;
- + }
- + // use for webpack 4
- + const IMWorker = require('worker-loader!./worker.js');
- + worker = new IMWorker.default();
- + // use for webpack5+ or vite
- + // const isViteEnvironment = import.meta.url.includes('.vite/deps');
- + // const isSupportModuleWorker = supportsModuleWorkers();
- + // const getWorkerUrl = (url) => url.href.replace('.vite/deps', 'open-im-sdk-wasm/lib');
- + // const workerUrl = isSupportModuleWorker
- + // ? new URL('worker.js', import.meta.url)
- + // : new URL('worker-legacy.js', import.meta.url);
- + // worker = new Worker(isViteEnvironment ? getWorkerUrl(workerUrl) : workerUrl, {
- + // type: isSupportModuleWorker ? 'module' : 'classic',
- + // });
- + // This is only required because Safari doesn't support nested
- + // workers. This installs a handler that will proxy creating web
- + // workers through the main thread
- + initBackend(worker);
- + rpc = new RPC({
- + event: new RPCMessageEvent({
- + currentEndpoint: worker,
- + targetEndpoint: worker,
- + }),
- + });
- }
- function resetWorker() {
- if (rpc) {
- diff --git a/node_modules/open-im-sdk-wasm/lib/index.js b/node_modules/open-im-sdk-wasm/lib/index.js
- index cd572cc..e0e7ea5 100644
- --- a/node_modules/open-im-sdk-wasm/lib/index.js
- +++ b/node_modules/open-im-sdk-wasm/lib/index.js
- @@ -476,48 +476,32 @@ function supportsModuleWorkers() {
- }
- }
- function initWorker() {
- - if (typeof window === 'undefined') {
- - return;
- - }
- - // use for webpack 4
- - // const IMWorker = require('worker-loader!./worker.js');
- - // worker = new IMWorker.default();
- - // use for webpack5+ or vite
- - const isViteEnvironment = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href)).includes('.vite/deps');
- - const isNuxtEnvironment = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href)).includes('_nuxt/node_modules');
- - const isSupportModuleWorker = supportsModuleWorkers();
- - let workerUrl = isSupportModuleWorker
- - ? new URL('worker.js', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href)))
- - : new URL('worker-legacy.js', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href)));
- - if (isViteEnvironment) {
- - workerUrl = workerUrl.href.replace('.vite/deps', 'open-im-sdk-wasm/lib');
- - }
- - if (isNuxtEnvironment) {
- - workerUrl = workerUrl.href.replace('.cache/vite/client/deps', 'open-im-sdk-wasm/lib');
- - }
- - worker = new Worker(workerUrl, {
- - type: isSupportModuleWorker ? 'module' : 'classic',
- - });
- - // This is only required because Safari doesn't support nested
- - // workers. This installs a handler that will proxy creating web
- - // workers through the main thread
- - initBackend(worker);
- - rpc = new RPC({
- - event: new RPCMessageEvent({
- - currentEndpoint: worker,
- - targetEndpoint: worker,
- - }),
- - });
- -}
- -function resetWorker() {
- - if (rpc) {
- - rpc.destroy();
- - rpc = undefined;
- - }
- - if (worker) {
- - worker.terminate();
- - worker = undefined;
- - }
- + if (typeof window === 'undefined') {
- + return;
- + }
- + // use for webpack 4
- + const IMWorker = require('worker-loader!./worker.js');
- + worker = new IMWorker.default();
- + // use for webpack5+ or vite
- + // const isViteEnvironment = import.meta.url.includes('.vite/deps');
- + // const isSupportModuleWorker = supportsModuleWorkers();
- + // const getWorkerUrl = (url) => url.href.replace('.vite/deps', 'open-im-sdk-wasm/lib');
- + // const workerUrl = isSupportModuleWorker
- + // ? new URL('worker.js', import.meta.url)
- + // : new URL('worker-legacy.js', import.meta.url);
- + // worker = new Worker(isViteEnvironment ? getWorkerUrl(workerUrl) : workerUrl, {
- + // type: isSupportModuleWorker ? 'module' : 'classic',
- + // });
- + // This is only required because Safari doesn't support nested
- + // workers. This installs a handler that will proxy creating web
- + // workers through the main thread
- + initBackend(worker);
- + rpc = new RPC({
- + event: new RPCMessageEvent({
- + currentEndpoint: worker,
- + targetEndpoint: worker,
- + }),
- + });
- }
- initWorker();
- function catchErrorHandle(error) {
|