code.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.globalCode = exports.restoreGlobalCode = exports.polyfillCode = exports.arrayBufferCode = void 0;
  4. exports.arrayBufferCode = `
  5. if (typeof uni !== 'undefined' && uni && uni.requireGlobal) {
  6. const global = uni.requireGlobal()
  7. ArrayBuffer = global.ArrayBuffer
  8. Int8Array = global.Int8Array
  9. Uint8Array = global.Uint8Array
  10. Uint8ClampedArray = global.Uint8ClampedArray
  11. Int16Array = global.Int16Array
  12. Uint16Array = global.Uint16Array
  13. Int32Array = global.Int32Array
  14. Uint32Array = global.Uint32Array
  15. Float32Array = global.Float32Array
  16. Float64Array = global.Float64Array
  17. BigInt64Array = global.BigInt64Array
  18. BigUint64Array = global.BigUint64Array
  19. };
  20. `;
  21. exports.polyfillCode = `
  22. if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
  23. Promise.prototype.finally = function(callback) {
  24. const promise = this.constructor
  25. return this.then(
  26. value => promise.resolve(callback()).then(() => value),
  27. reason => promise.resolve(callback()).then(() => {
  28. throw reason
  29. })
  30. )
  31. }
  32. };
  33. ${exports.arrayBufferCode}
  34. `;
  35. exports.restoreGlobalCode = `
  36. if(uni.restoreGlobal){
  37. uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
  38. }
  39. `;
  40. const GLOBALS = [
  41. 'global',
  42. 'window',
  43. 'document',
  44. 'frames',
  45. 'self',
  46. 'location',
  47. 'navigator',
  48. 'localStorage',
  49. 'history',
  50. 'Caches',
  51. 'screen',
  52. 'alert',
  53. 'confirm',
  54. 'prompt',
  55. 'fetch',
  56. 'XMLHttpRequest',
  57. 'WebSocket',
  58. 'webkit',
  59. 'print',
  60. ];
  61. exports.globalCode = GLOBALS.map((g) => `${g}:u`).join(',');