UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 591 B
import{Http as e,http as r}from"../../platform/net/http.js";import{ResourceHandler as o}from"./handler.js";class t extends o{constructor(e){super(e,"json"),this.decoder=null}load(o,t){"string"==typeof o&&(o={load:o,original:o});const s={retry:this.maxRetries>0,maxRetries:this.maxRetries};o.load.startsWith("blob:")&&(s.responseType=e.ResponseType.JSON),r.get(o.load,s,((e,r)=>{e?t(`Error loading JSON resource: ${o.original} [${e}]`):t(null,r)}))}openBinary(e){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),JSON.parse(this.decoder.decode(e))}}export{t as JsonHandler};