@openim+wasm-client-sdk+3.8.3-patch.3.patch 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. diff --git a/node_modules/@openim/wasm-client-sdk/lib/index.es.js b/node_modules/@openim/wasm-client-sdk/lib/index.es.js
  2. index daa048f..28bd430 100644
  3. --- a/node_modules/@openim/wasm-client-sdk/lib/index.es.js
  4. +++ b/node_modules/@openim/wasm-client-sdk/lib/index.es.js
  5. @@ -475,42 +475,32 @@ function supportsModuleWorkers() {
  6. }
  7. }
  8. function initWorker() {
  9. - if (typeof window === 'undefined') {
  10. - return;
  11. - }
  12. - // use for webpack 4
  13. - // const IMWorker = require('worker-loader!./worker.js');
  14. - // worker = new IMWorker.default();
  15. - // use for webpack5+ or vite
  16. - const isViteEnvironment = import.meta.url.includes('.vite/deps');
  17. - const isNuxtEnvironment = import.meta.url.includes('_nuxt/node_modules');
  18. - const isQuasarEnvironment = import.meta.url.includes('.q-cache');
  19. - const isSupportModuleWorker = supportsModuleWorkers();
  20. - let workerUrl = isSupportModuleWorker
  21. - ? new URL('worker.js', import.meta.url)
  22. - : new URL('worker-legacy.js', import.meta.url);
  23. - if (isViteEnvironment) {
  24. - workerUrl = workerUrl.href.replace('.vite/deps', '@openim/wasm-client-sdk/lib');
  25. - }
  26. - if (isNuxtEnvironment) {
  27. - workerUrl = workerUrl.href.replace('.cache/vite/client/deps', '@openim/wasm-client-sdk/lib');
  28. - }
  29. - if (isQuasarEnvironment) {
  30. - workerUrl = workerUrl.href.replace(/\.q-cache\/dev-spa\/[^/]+\/deps/, '@openim/wasm-client-sdk/lib');
  31. - }
  32. - worker = new Worker(workerUrl, {
  33. - type: isSupportModuleWorker ? 'module' : 'classic',
  34. - });
  35. - // This is only required because Safari doesn't support nested
  36. - // workers. This installs a handler that will proxy creating web
  37. - // workers through the main thread
  38. - initBackend(worker);
  39. - rpc = new RPC({
  40. - event: new RPCMessageEvent({
  41. - currentEndpoint: worker,
  42. - targetEndpoint: worker,
  43. - }),
  44. - });
  45. + if (typeof window === 'undefined') {
  46. + return;
  47. + }
  48. + // use for webpack 4
  49. + const IMWorker = require('worker-loader!./worker.js');
  50. + worker = new IMWorker.default();
  51. + // use for webpack5+ or vite
  52. + // const isViteEnvironment = import.meta.url.includes('.vite/deps');
  53. + // const isSupportModuleWorker = supportsModuleWorkers();
  54. + // const getWorkerUrl = (url) => url.href.replace('.vite/deps', 'open-im-sdk-wasm/lib');
  55. + // const workerUrl = isSupportModuleWorker
  56. + // ? new URL('worker.js', import.meta.url)
  57. + // : new URL('worker-legacy.js', import.meta.url);
  58. + // worker = new Worker(isViteEnvironment ? getWorkerUrl(workerUrl) : workerUrl, {
  59. + // type: isSupportModuleWorker ? 'module' : 'classic',
  60. + // });
  61. + // This is only required because Safari doesn't support nested
  62. + // workers. This installs a handler that will proxy creating web
  63. + // workers through the main thread
  64. + initBackend(worker);
  65. + rpc = new RPC({
  66. + event: new RPCMessageEvent({
  67. + currentEndpoint: worker,
  68. + targetEndpoint: worker,
  69. + }),
  70. + });
  71. }
  72. function resetWorker() {
  73. if (rpc) {
  74. diff --git a/node_modules/@openim/wasm-client-sdk/lib/index.js b/node_modules/@openim/wasm-client-sdk/lib/index.js
  75. index 61b6467..31253c3 100644
  76. --- a/node_modules/@openim/wasm-client-sdk/lib/index.js
  77. +++ b/node_modules/@openim/wasm-client-sdk/lib/index.js
  78. @@ -479,42 +479,32 @@ function supportsModuleWorkers() {
  79. }
  80. }
  81. function initWorker() {
  82. - if (typeof window === 'undefined') {
  83. - return;
  84. - }
  85. - // use for webpack 4
  86. - // const IMWorker = require('worker-loader!./worker.js');
  87. - // worker = new IMWorker.default();
  88. - // use for webpack5+ or vite
  89. - 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');
  90. - 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');
  91. - const isQuasarEnvironment = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href)).includes('.q-cache');
  92. - const isSupportModuleWorker = supportsModuleWorkers();
  93. - let workerUrl = isSupportModuleWorker
  94. - ? 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)))
  95. - : 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)));
  96. - if (isViteEnvironment) {
  97. - workerUrl = workerUrl.href.replace('.vite/deps', '@openim/wasm-client-sdk/lib');
  98. - }
  99. - if (isNuxtEnvironment) {
  100. - workerUrl = workerUrl.href.replace('.cache/vite/client/deps', '@openim/wasm-client-sdk/lib');
  101. - }
  102. - if (isQuasarEnvironment) {
  103. - workerUrl = workerUrl.href.replace(/\.q-cache\/dev-spa\/[^/]+\/deps/, '@openim/wasm-client-sdk/lib');
  104. - }
  105. - worker = new Worker(workerUrl, {
  106. - type: isSupportModuleWorker ? 'module' : 'classic',
  107. - });
  108. - // This is only required because Safari doesn't support nested
  109. - // workers. This installs a handler that will proxy creating web
  110. - // workers through the main thread
  111. - initBackend(worker);
  112. - rpc = new RPC({
  113. - event: new RPCMessageEvent({
  114. - currentEndpoint: worker,
  115. - targetEndpoint: worker,
  116. - }),
  117. - });
  118. + if (typeof window === 'undefined') {
  119. + return;
  120. + }
  121. + // use for webpack 4
  122. + const IMWorker = require('worker-loader!./worker.js');
  123. + worker = new IMWorker.default();
  124. + // use for webpack5+ or vite
  125. + // const isViteEnvironment = import.meta.url.includes('.vite/deps');
  126. + // const isSupportModuleWorker = supportsModuleWorkers();
  127. + // const getWorkerUrl = (url) => url.href.replace('.vite/deps', 'open-im-sdk-wasm/lib');
  128. + // const workerUrl = isSupportModuleWorker
  129. + // ? new URL('worker.js', import.meta.url)
  130. + // : new URL('worker-legacy.js', import.meta.url);
  131. + // worker = new Worker(isViteEnvironment ? getWorkerUrl(workerUrl) : workerUrl, {
  132. + // type: isSupportModuleWorker ? 'module' : 'classic',
  133. + // });
  134. + // This is only required because Safari doesn't support nested
  135. + // workers. This installs a handler that will proxy creating web
  136. + // workers through the main thread
  137. + initBackend(worker);
  138. + rpc = new RPC({
  139. + event: new RPCMessageEvent({
  140. + currentEndpoint: worker,
  141. + targetEndpoint: worker,
  142. + }),
  143. + });
  144. }
  145. function resetWorker() {
  146. if (rpc) {