mirror of
https://gitlab.com/jiehong/jq_offline.git
synced 2024-12-12 09:20:56 +01:00
feature: depend on Aioli.js directly instead of in local
This commit is contained in:
parent
ba63c00c31
commit
4de330f3ea
@ -5,18 +5,9 @@
|
||||
<meta charset="utf-8">
|
||||
<title>Jq Play Offline</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<!-- <script defer src="https://cdn.biowasm.com/v2/aioli/latest/aioli.js"></script> -->
|
||||
<script defer src="./js/aioli.js"></script>
|
||||
<script src="https://cdn.biowasm.com/v2/aioli/latest/aioli.js"></script>
|
||||
<script defer type="module">
|
||||
// let CLI = await new Aioli("jq/1.6");
|
||||
let CLI = await new Aioli({
|
||||
tool: "jq",
|
||||
version: "1.6",
|
||||
urlPrefix: "https://jiehong.gitlab.io/jq_offline/wasm",
|
||||
loading: "eager",
|
||||
}, {
|
||||
urlAioli: "./js/aioli.worker.js",
|
||||
});
|
||||
let CLI = await new Aioli("jq/1.6");
|
||||
|
||||
async function jq() {
|
||||
let data = document.getElementById("input-json").value;
|
||||
|
@ -1 +0,0 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Aioli=t()}(this,(function(){"use strict";var e="2.3.0";const t=Symbol("Comlink.proxy"),n=Symbol("Comlink.endpoint"),r=Symbol("Comlink.releaseProxy"),a=Symbol("Comlink.thrown"),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,i=new Map([["proxy",{canHandle:e=>o(e)&&e[t],serialize(e){const{port1:t,port2:n}=new MessageChannel;return s(e,t),[n,[n]]},deserialize:e=>(e.start(),l(e))}],["throw",{canHandle:e=>o(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function s(e,n=self){n.addEventListener("message",(function r(o){if(!o||!o.data)return;const{id:i,type:l,path:u}=Object.assign({path:[]},o.data),p=(o.data.argumentList||[]).map(g);let d;try{const n=u.slice(0,-1).reduce(((e,t)=>e[t]),e),r=u.reduce(((e,t)=>e[t]),e);switch(l){case"GET":d=r;break;case"SET":n[u.slice(-1)[0]]=g(o.data.value),d=!0;break;case"APPLY":d=r.apply(n,p);break;case"CONSTRUCT":d=function(e){return Object.assign(e,{[t]:!0})}(new r(...p));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;s(e,n),d=function(e,t){return f.set(e,t),e}(t,[t])}break;case"RELEASE":d=void 0;break;default:return}}catch(e){d={value:e,[a]:0}}Promise.resolve(d).catch((e=>({value:e,[a]:0}))).then((e=>{const[t,a]=h(e);n.postMessage(Object.assign(Object.assign({},t),{id:i}),a),"RELEASE"===l&&(n.removeEventListener("message",r),c(n))}))})),n.start&&n.start()}function c(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function l(e,t){return p(e,[],t)}function u(e){if(e)throw new Error("Proxy has been released and is not useable")}function p(e,t=[],a=function(){}){let o=!1;const i=new Proxy(a,{get(n,a){if(u(o),a===r)return()=>m(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{c(e),o=!0}));if("then"===a){if(0===t.length)return{then:()=>i};const n=m(e,{type:"GET",path:t.map((e=>e.toString()))}).then(g);return n.then.bind(n)}return p(e,[...t,a])},set(n,r,a){u(o);const[i,s]=h(a);return m(e,{type:"SET",path:[...t,r].map((e=>e.toString())),value:i},s).then(g)},apply(r,a,i){u(o);const s=t[t.length-1];if(s===n)return m(e,{type:"ENDPOINT"}).then(g);if("bind"===s)return p(e,t.slice(0,-1));const[c,l]=d(i);return m(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:c},l).then(g)},construct(n,r){u(o);const[a,i]=d(r);return m(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:a},i).then(g)}});return i}function d(e){const t=e.map(h);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const f=new WeakMap;function h(e){for(const[t,n]of i)if(n.canHandle(e)){const[r,a]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},a]}return[{type:"RAW",value:e},f.get(e)||[]]}function g(e){switch(e.type){case"HANDLER":return i.get(e.name).deserialize(e.value);case"RAW":return e.value}}function m(e,t,n){return new Promise((r=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===a&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),n)}))}const y="https://cdn.biowasm.com/v2",b={urlCDN:y,urlAioli:`${y}/aioli/${e}/aioli.worker.js`,urlBaseModule:null,dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};return class{constructor(t,n={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),n=Object.assign({},b,n),t=t.map(this._parseTool),"prd"!=n.env&&(n.urlCDN=n.urlCDN.replace("cdn",`cdn-${n.env}`),n.urlAioli=n.urlAioli.replace("cdn",`cdn-${n.env}`)),t=[{tool:"base",version:e,urlPrefix:n.urlBaseModule},...t],this.tools=t,this.config=n,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const e=await(await fetch(this.config.urlAioli)).text(),t=new Blob([e],{type:"application/javascript"}),n=new Worker(URL.createObjectURL(t));this.callback&&(n.onmessage=e=>{"biowasm"==e.data.type&&this.callback(e.data.value)});const r=l(n);return r.tools=this.tools,r.config=this.config,await r.init(),r}_parseTool(e){if("string"!=typeof e)return e;const t=e.split("/");if(2!=t.length&&3!=t.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:t[0],program:3==t.length?t[1]:t[0],version:t[t.length-1]}}}}));
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@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CAsBAQBBvAgLDgIAAAADAAAAyAQAAAAEAEHUCAsBAQBB4wgLBQr/////AEGoCQsDwApQ
|
@ -1 +0,0 @@
|
||||
{"wasm-features":[]}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user