@impui/imp 1.0.17-beta.6 → 1.0.17
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../go2/index.es.js";import{getConfig as s,getCodeVer as o,getApiurl as t}from"../../config/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/core/index.es/index.es.js";import{getLog as i}from"../../packages/imp/node_modules/@impui/com/dist/log/index.es/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/browser/index.es/index.es.js";import{bufferToBase64 as r,base64ToBuffer as n}from"../../packages/imp/node_modules/@impui/com/dist/data/index.es/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/str/index.es/index.es.js";import{getAndWaitCache as a}from"../../packages/imp/node_modules/@impui/com/dist/req/index.es/index.es.js";import{urltool as
|
|
1
|
+
import e from"../go2/index.es.js";import{getConfig as s,getCodeVer as o,getApiurl as t}from"../../config/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/core/index.es/index.es.js";import{getLog as i}from"../../packages/imp/node_modules/@impui/com/dist/log/index.es/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/browser/index.es/index.es.js";import{bufferToBase64 as r,base64ToBuffer as n}from"../../packages/imp/node_modules/@impui/com/dist/data/index.es/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/str/index.es/index.es.js";import{getAndWaitCache as a}from"../../packages/imp/node_modules/@impui/com/dist/req/index.es/index.es.js";import{urltool as m}from"../../packages/imp/node_modules/@impui/com/dist/url/index.es/index.es.js";import"../../packages/imp/node_modules/@impui/com/dist/message/index.es/index.es.js";import"../../axios/index.es.js";import c from"../../node_modules/axios/lib/axios/index.es.js";import"../../node_modules/axios/index/index.es.js";const d={},p=(await s()).allsr+"/plug/gotool/lib/imptool.wasm",u=await i(),l="1"===m.getPar("__down"),g=async function(){return console.warn("⚠️ 降级方案已启用"),{encrypt:function(){throw new Error("❌ 降级方案未实现:encrypt方法")},parseRes:async function(e,s){try{if("true"!==e.headers["res-encrypt"])return e;const s={data:e.data},o=await t(),i=encodeURIComponent(JSON.stringify(s)),r=await c.post(o.parseRes,{res:i,config:null});return e.data=JSON.parse(r.data),e}catch(o){console.error("❌ 降级方案请求接口失败:",o)}},parseServer:function(){throw new Error("❌ 降级方案未实现:parseServer方法")}}};const w=new class{constructor(e){this.isbase=e===p,this.url=e}async#e(){if(!this.url){const e=await s();this.url=e.allsr+"plug/gotool/lib/imptool.wasm"}return this.url}async#s(s,o){return async function(s,o,t=!1){try{const i=new e;u("=== WASM加载调试开始 ==="),u("URL:",s),u("UserAgent:",navigator.userAgent);const m=await a(s,async()=>{const e=await fetch(s+o);u("✅ 响应状态:",e.status);const t=await e.arrayBuffer();return u("✅ ArrayBuffer大小:",t.byteLength,"bytes"),r(t,{type:"application/wasm"})}),c=await n(m),d=new Uint8Array(c.slice(0,4));u("🔍 WASM文件头:",Array.from(d)),u("🔍 Go importObject结构:",Object.keys(i.importObject)),i.importObject.go&&u("🔍 GoJS导入键:",Object.keys(i.importObject.go)),u("🚀 开始WebAssembly.instantiate...");const p=await WebAssembly.instantiate(c,i.importObject);if(u("✅ WebAssembly实例化成功"),u("🚀 开始go.run..."),i.run(p.instance),u("✅ go.run执行完成"),l)return await g();if(window.goCrypto){const e=window.goCrypto;return delete window.goCrypto,u("✅ goCrypto加载成功"),e}if(t)return await g();throw console.warn("❌ window.goCrypto未定义,进入诊断模式"),await loadGoWasmWithDiagnosis(s),new Error("❌ window.goCrypto未定义")}catch(i){throw console.error("💥 完整错误堆栈:",i),console.error("错误名称:",i.name),console.error("错误信息:",i.message),i}}(s=s||await this.#e(),o,this.isbase)}async getRunTimes(e=!1){const s=await this.#e();if(!e&&d[s])return d[s];const t=o(),i=t.config?"?d="+t.config:"",r=await this.#s(s,i),n={};if(r)for(let o in r)n[o]=r[o];return d[s]=n,n}async init(){return this.getRunTimes()}async run(e,s){const o=await this.getRunTimes();return o[e]||console.error(`[${e}] 方法不在默认wasm中!`),o[e].apply(null,s)}}(p);export{w as gotool};
|