vis-core 0.33.15 → 0.33.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.
- package/dist/e-DDhN_TXt.js +1 -0
- package/dist/index.d.ts +222 -134
- package/dist/index.js +1 -46
- package/dist/io.d.ts +192 -0
- package/dist/io.js +1 -1
- package/dist/rolldown-runtime-NMqb_1LM.js +1 -0
- package/dist/runtimeImages-BnSAIZUX.js +1 -0
- package/dist/schema-BpVVlDZn.js +1 -0
- package/dist/validation-DiMfvx_5.js +46 -0
- package/package.json +4 -3
- package/dist/jsonFetch-BQr9Uqag.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,r||"default");if("object"!=e(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function r(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?n(Object(s),!0).forEach(function(t){r(e,t,s[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):n(Object(s)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))})}return e}function o(e,t,r,n,s,o,i){try{var a=e[o](i),l=a.value}catch(e){return void r(e)}a.done?t(l):Promise.resolve(l).then(n,s)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(n,s){var i=e.apply(t,r);function a(e){o(i,n,s,a,l,"next",e)}function l(e){o(i,n,s,a,l,"throw",e)}a(void 0)})}}function a(e,t){if(null==e)return{};var r,n,s=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var l,c,u,d=new class{constructor(e=32,t=67108864){r(this,"pending",/* @__PURE__ */new Map),r(this,"values",/* @__PURE__ */new Map),r(this,"bytes",0),r(this,"maxEntries",void 0),r(this,"maxBytes",void 0),this.maxEntries=e,this.maxBytes=t}load(e,t){const r=this.values.get(e);if(r)return this.values.delete(e),this.values.set(e,r),Promise.resolve(r);const n=this.pending.get(e);if(n)return n;const s=Promise.resolve().then(t).then(t=>{if(this.pending.get(e)===s&&(this.pending.delete(e),this.maxEntries>0&&t.bytes<=this.maxBytes))for(this.values.set(e,t),this.bytes+=t.bytes;this.values.size>this.maxEntries||this.bytes>this.maxBytes;)this.deleteValue(this.values.keys().next().value);return t},t=>{throw this.pending.get(e)===s&&this.pending.delete(e),t});return this.pending.set(e,s),s}deleteValue(e){const t=this.values.get(e);t&&(this.bytes-=t.bytes),this.values.delete(e)}clear(e){void 0!==e?(this.pending.delete(e),this.deleteValue(e)):(this.pending.clear(),this.values.clear(),this.bytes=0)}},p=e=>!!/\.(gzip|gz)(?:[?#]|$)/i.test(e),f=(l=i(function*(e,t,r=p){const n=yield window.fetch(e);if(!n.ok){try{var s;yield null===(s=n.body)||void 0===s?void 0:s.cancel()}catch(l){}throw new Error("Network response was not ok.")}let o=n;if(t)try{o=((e,t)=>{const r=Number(e.headers.get("content-length"))||0;let n=0;return e.body?new globalThis.Response(e.body.pipeThrough(new globalThis.TransformStream({start(){t({percent:0,transferredBytes:0,totalBytes:r})},transform(e,s){n+=e.byteLength,t({percent:0===r?0:n/r,transferredBytes:n,totalBytes:r}),s.enqueue(e)},flush(){t({percent:1,transferredBytes:n,totalBytes:r})}})),{status:e.status,statusText:e.statusText,headers:e.headers}):(t({percent:1,totalBytes:r,transferredBytes:n}),new globalThis.Response(null,{status:e.status,statusText:e.statusText,headers:e.headers}))})(o,t)}catch(c){try{var i;yield null===(i=n.body)||void 0===i?void 0:i.cancel(c)}catch(u){}throw c}if(r(e)&&"gzip"!==o.headers.get("content-encoding")){const e=new DecompressionStream("gzip"),t=o.body.pipeThrough(e);o=new Response(t)}const a=yield o.text();return{json:JSON.parse(a),bytes:2*a.length}}),function(e,t){return l.apply(this,arguments)}),h=(c=i(function*(e,t,r=p,n){try{var s,o;const i=null!==(s=null==n||null===(o=n.resolveURL)||void 0===o?void 0:o.call(n,e))&&void 0!==s?s:e,a=((e,t)=>{const r=null==t?void 0:t.cache;if(!1===r)return{enabled:!1,key:e,clone:!1};if(!0===r)return{enabled:!0,key:e,clone:!0};if(r&&"object"==typeof r){var n,s,o;const t=null===(n=r.enabled)||void 0===n||n;return{enabled:t,key:null!==(s=r.key)&&void 0!==s?s:e,clone:!!t&&(null===(o=r.clone)||void 0===o||o)}}return{enabled:!1,key:e,clone:!1}})(i,n),l=()=>f(i,t,()=>r(e)),c=(yield a.enabled?d.load(a.key,l):l()).json;return{res:a.enabled&&a.clone?structuredClone(c):c,err:void 0}}catch(i){return{res:void 0,err:i}}}),function(e,t){return c.apply(this,arguments)}),y=/^(?:[a-z]+:)?\/\//i,g=(u=i(function*(e,t){const{res:r,err:n}=yield h(((e,t="")=>y.test(e)?e:`${t.endsWith("/")?t.slice(0,-1):t}${e.startsWith("/")?e:`/${e}`}`)(e,null==t?void 0:t.assetsPrefix),void 0,void 0,(null==t?void 0:t.fetchOptions)||{cache:!0});if(n)throw n;return r}),function(e,t){return u.apply(this,arguments)}),v=e=>"string"==typeof e&&!!e&&!/[:\\?#\0]/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e);function m(e){if(void 0===e)return;const t=e;if(!t||1!==t.version||!Array.isArray(t.entries))throw Error("Invalid runtime asset catalog");const r=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set;for(const i of t.entries){var o;if(!i||"string"!=typeof i.id||!i.id||r.has(i.id)||!v(i.path)||n.has(i.path)||!Array.isArray(i.sources)||!i.sources.length||i.sources.some(e=>"string"!=typeof e||!e||s.has(e))||new Set(i.sources).size!==i.sources.length||"string"!=typeof i.mimeType||!/^[\w.+-]+\/[\w.+-]+$/.test(i.mimeType)||!["identity","gzip"].includes(i.encoding)||!Number.isSafeInteger(i.bytes)||i.bytes<0||!/^[a-f0-9]{64}$/.test(i.sha256)||void 0!==i.data&&("string"!=typeof i.data||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i.data)))throw Error(`Invalid runtime asset: ${null!==(o=null==i?void 0:i.path)&&void 0!==o?o:"unknown"}`);r.add(i.id),n.add(i.path),i.sources.forEach(e=>s.add(e))}if(t.scope&&(!Number.isInteger(t.scope.rootAdcode)||t.scope.rootAdcode<0||!["province","city","district"].includes(t.scope.maxLevel)))throw Error("Invalid map export scope");if(t.regions&&("object"!=typeof t.regions||Array.isArray(t.regions)||Object.values(t.regions).some(e=>!Array.isArray(e)||e.some(e=>!Number.isInteger(e)||e<0))))throw Error("Invalid runtime region catalog");if(void 0!==t.declaredSources&&(!Array.isArray(t.declaredSources)||t.declaredSources.some(e=>"string"!=typeof e||!e.trim())))throw Error("Invalid declared asset sources");if(void 0!==t.externalSources&&(!Array.isArray(t.externalSources)||t.externalSources.some(e=>"string"!=typeof e||!e.trim()||/[{}\0]/.test(e)||/^(?:data:|blob:|asset:)/i.test(e)||s.has(e))||new Set(t.externalSources).size!==t.externalSources.length))throw Error("Invalid external asset sources");if(void 0!==t.mapDataMode&&!["bundled","external"].includes(t.mapDataMode))throw Error("Invalid map data mode");if(void 0!==t.mapSwitchKey&&("string"!=typeof t.mapSwitchKey||!t.mapSwitchKey.trim()))throw Error("Invalid bundled map switch key");if(void 0!==t.projectId&&("string"!=typeof t.projectId||!t.projectId.trim()||t.projectId.length>64))throw Error("Invalid runtime asset project")}function w(e){const t=[];for(let r=0;r<e.length;r+=32768)t.push(String.fromCharCode(...e.subarray(r,r+32768)));return btoa(t.join(""))}function b(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function S(e){return j.apply(this,arguments)}function j(){return(j=i(function*(e){const t=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,"0")).join("")})).apply(this,arguments)}function A(e,t){return x.apply(this,arguments)}function x(){return(x=i(function*(e,t){if(t.length!==e.bytes||(yield S(t))!==e.sha256)throw Error(`资源校验失败:${e.path}`)})).apply(this,arguments)}function E(e,t){var r,n,o,i;if(!t)return e;if(!e)return structuredClone(t);const a=structuredClone(e),l=new Map(a.entries.map(e=>[e.id,e])),c=new Map(a.entries.flatMap(e=>e.sources.map(t=>[t,e.sha256])));for(const s of t.entries){for(const t of s.sources)if(c.has(t)&&c.get(t)!==s.sha256)throw Error(`资源地址存在不同内容:${t}。请修改资源地址或使用“打开项目”导入。`);const e=l.get(s.id);if(e)e.sources=[.../* @__PURE__ */new Set([...e.sources,...s.sources])];else{const e=structuredClone(s);a.entries.push(e),l.set(e.id,e)}for(const t of s.sources)c.set(t,s.sha256)}a.regions=s(s({},e.regions),t.regions),a.declaredSources=[.../* @__PURE__ */new Set([...null!==(r=e.declaredSources)&&void 0!==r?r:[],...null!==(n=t.declaredSources)&&void 0!==n?n:[]])];const u=[.../* @__PURE__ */new Set([...null!==(o=e.externalSources)&&void 0!==o?o:[],...null!==(i=t.externalSources)&&void 0!==i?i:[]])].filter(e=>!c.has(e));return u.length?a.externalSources=u:delete a.externalSources,m(a),a}var I=class{constructor(e,t="",n=!0){var s;r(this,"sources",/* @__PURE__ */new Map),r(this,"resolved",/* @__PURE__ */new Map),r(this,"externals",/* @__PURE__ */new Map),r(this,"catalog",void 0),r(this,"strict",void 0),r(this,"resolve",e=>{if(/^(data:|blob:)/i.test(e))return e;const t=this.sources.get(e);if(!t){const t=this.externals.get(e);if(void 0!==t)return t;if(!this.strict)return e;throw Error(`资源包未包含:${e}。请扩大导出范围或补充资源后重新导出。`)}let r=this.resolved.get(t.id);if(!r){if(void 0!==t.data)r=`data:${"gzip"===t.encoding?"application/gzip":t.mimeType};base64,${t.data}`;else{const e=this.catalog.baseUrl;if(!e)throw Error(`资源缺少文件内容或部署地址:${t.path}`);const n="undefined"==typeof location?"https://bundle.invalid/":location.href;r=new URL(t.path,new URL(e,n)).href}this.resolved.set(t.id,r)}return r}),this.catalog=e,this.strict=n,m(e);const o=(e,t)=>{const r=this.sources.get(e);if(r&&r.id!==t.id)throw Error(`资源地址重复:${e}`);this.sources.set(e,t)},i=e=>/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)?[e,...t?[t+e]:[]]:[e,t+e,`${t.replace(/\/$/,"")}/${e.replace(/^\//,"")}`,`/${e.replace(/^\//,"")}`];for(const r of e.entries)for(const e of[...r.sources,`asset://${r.id}`])for(const t of i(e))o(t,r);for(const r of null!==(s=e.externalSources)&&void 0!==s?s:[]){const e=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(r)?r:`${t.replace(/\/$/,"")}/${r.replace(/^\//,"")}`;for(const t of i(r))this.externals.set(t,e)}}},$=["format","schemaVersion","scenes","imageAssets"];function O(e){const t=e.replace(/[?#].*$/,""),r=e.slice(t.length),n=new URL(e,"https://bundle.invalid").pathname;if(/\.zip$/i.test(n)||/(?:^|\/)manifest\.json$/i.test(n))return e;if(/\.[^/]+$/.test(n))throw Error("vis-core 仅支持 ZIP、分包目录或 manifest.json;独立 JSON/GZ 请先通过编辑平台导入并导出 ZIP。");return`${t.replace(/\/$/,"")}/manifest.json${r}`}function P(e,t){return z.apply(this,arguments)}function z(){return(z=i(function*(e,t){try{const r=new Uint8Array(yield e.slice(0,2).arrayBuffer()),n=/\.(gz|gzip)$/i.test(t)||31===r[0]&&139===r[1]?yield new Response(e.stream().pipeThrough(new DecompressionStream("gzip"))).text():yield e.text(),s=JSON.parse(n);if(!s||"object"!=typeof s||Array.isArray(s))throw Error("需要 JSON 对象");return s}catch(r){throw new Error(`无法读取文件 ${t}:${r instanceof Error?r.message:String(r)}`,{cause:r})}})).apply(this,arguments)}function B(e){return C.apply(this,arguments)}function C(){return C=i(function*(e,t="project.zip"){var r;const[{default:n},o,{SCENE_DOCUMENT_FORMAT:l},{resolveRuntimeImages:c}]=yield Promise.all([import("jszip"),import("./validation-DiMfvx_5.js").then(e=>e.r),import("./schema-BpVVlDZn.js").then(e=>e.c),import("./runtimeImages-BnSAIZUX.js").then(e=>e.r)]),u=o;let d;try{d=yield n.loadAsync(e instanceof Blob?yield e.arrayBuffer():e)}catch(B){throw new Error(`无法解压 ZIP 文件 ${t}`,{cause:B})}const p=Object.values(d.files).filter(e=>!e.dir&&/(^|\/)manifest\.json$/.test(e.name)&&!e.name.startsWith("__MACOSX/")),f=null!==(r=d.file("manifest.json"))&&void 0!==r?r:1===p.length?p[0]:void 0;if(!f)throw new Error(p.length>1?"ZIP 中有多个 manifest.json,无法确定要导入的项目":"ZIP 中缺少 manifest.json,请选择平台导出的场景分包 ZIP");const h=f.name.slice(0,-13),y=yield P(new Blob([yield f.async("uint8array")]),f.name);u.assertSceneManifest(y);const g=function(){var e=i(function*(e){if(/[:\\?#\0]/.test(e)||e.split("/").some(e=>!e||"."===e||".."===e))throw new Error(`ZIP 内文件路径无效:${e}`);const t=d.file(h+e);if(!t)throw new Error(`ZIP 中缺少文件:${e}`);if(t.unsafeOriginalName&&t.unsafeOriginalName!==t.name)throw new Error(`ZIP 内文件路径无效:${e}`);return new Blob([yield t.async("uint8array")])});return function(t){return e.apply(this,arguments)}}(),v=[];for(const s of y.scenes){var m,b;const e=yield P(yield g(s.source),s.source);if(!(null===(m=e.scene)||void 0===m?void 0:m.object)||e.id!==s.id||(null===(b=e.vis)||void 0===b?void 0:b.type)!==s.vis.type)throw new Error(`场景文件与 manifest 不匹配:${s.source}`);v.push(e)}const{format:S,schemaVersion:j,scenes:x,imageAssets:E}=y,I=s(s({},a(y,$)),{},{format:l,schemaVersion:1===j?4:2===j?5:6,scenes:v});if(u.assertRuntimeSceneDocument(I),I.runtimeAssets){delete I.runtimeAssets.baseUrl;for(const e of I.runtimeAssets.entries){const t=new Uint8Array(yield(yield g(e.path)).arrayBuffer());yield A(e,t),e.data=w(t)}}const O=/* @__PURE__ */new Map,z={png:"image/png",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",bmp:"image/bmp"};for(const s of null!=E?E:[]){const e=new Uint8Array(yield(yield g(s)).arrayBuffer()),t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode(...e.subarray(n,n+32768)));const r=z[s.split(".").pop()];O.set(s,`data:${r};base64,${btoa(t.join(""))}`)}return c(I,E,e=>O.get(e)),I}),C.apply(this,arguments)}var N="undefined"!=typeof crypto&&void 0!==crypto.subtle;function U(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/g,"").replace(/-----END PUBLIC KEY-----/g,"").replace(/\s/g,""),r=atob(t),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return n.buffer}function M(){return(M=i(function*(e){return crypto.subtle.importKey("spki",U(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])})).apply(this,arguments)}var T="-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEU2vGIjpJQFRkGxVrw4gZL3dXm/1\nfrZBlUc8gjzam/VNZbT1swQSq/kLPmYH7ZykBvLzp7SpNdvOQ8rAqdSdvg==\n-----END PUBLIC KEY-----";var Z=N?function(e){return M.apply(this,arguments)}(T):null,k=N?null:new Uint8Array(U(T)).slice(26);function D(e){return L.apply(this,arguments)}function L(){return(L=i(function*(e){let t;try{t=function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=atob(t+"=".repeat(r)),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return s}(e)}catch(i){return null}if(t.length<=64)return null;const r=t.slice(0,t.length-64),n=t.slice(t.length-64);let s;try{if(N){const e=yield Z;s=yield crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},e,n,r)}else{const{p256:e}=yield import("@noble/curves/nist.js");s=e.verify(n,r,k,{lowS:!1})}}catch(a){return null}if(!s)return null;const o=function(e){if(e.length<1)return null;if(123===e[0])try{const t=JSON.parse((new TextDecoder).decode(e));return 2!==t.version||!["runtime","preview"].includes(t.purpose)||"string"!=typeof t.projectId||!t.projectId.trim()||t.projectId.length>64||!Array.isArray(t.adcodes)||!t.adcodes.length||t.adcodes.length>65535||t.adcodes.some(e=>!Number.isInteger(e)||e<0||e>16777215)||new Set(t.adcodes).size!==t.adcodes.length||void 0!==t.expire&&(!Number.isSafeInteger(t.expire)||t.expire<=0)||"preview"===t.purpose&&!t.expire?null:{purpose:t.purpose,projectId:t.projectId,adcodes:t.adcodes,expire:t.expire}}catch(l){return null}const t=e[0],r=!!(2&t),n=!!(4&t),s=!!(8&t);if(-16&t||r&&(n||s))return null;let o,i=1;if(1&t){if(e.length<i+4)return null;o=36e5*((e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])>>>0),i+=4}let a=null;if(!r){if(e.length<i+1)return null;let t=e[i++];if(s){if(e.length<i+1)return null;t=t<<8|e[i++]}if(!t||e.length!==i+3*t)return null;a=[];for(let r=0;r<t;r++){const t=e[i]<<16|e[i+1]<<8|e[i+2];a.push(t),i+=3}}return i!==e.length?null:{adcodes:a,expire:o,prefixMatch:n}}(r);return o?o.expire&&Date.now()>o.expire?null:o:null})).apply(this,arguments)}function R(e,t,r){return K.apply(this,arguments)}function K(){return(K=i(function*(e,t,r){const n=yield D(t);if(!(null==n?void 0:n.adcodes)||n.prefixMatch||"preview"===n.purpose||void 0!==r&&n.projectId!==r)return!1;const s=new Set(e),o=new Set(n.adcodes);return s.size>0&&s.size===o.size&&[...s].every(e=>o.has(e))})).apply(this,arguments)}function V(e,t){return Y.apply(this,arguments)}function Y(){return(Y=i(function*(e,t){const r=yield D(t);return!(!(null==r?void 0:r.adcodes)||r.prefixMatch||"preview"===r.purpose)&&r.adcodes.includes(e)})).apply(this,arguments)}var J=(e,t)=>{const r=Q(e),n=Q(t).map(function(e,t){return e^r[Math.floor(t%r.length)]}).join(",");return btoa(n)};function Q(e){const t=[];let r=0;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);s<128?t[r++]=s:s<2048?(t[r++]=s>>6|192,t[r++]=63&s|128):55296==(64512&s)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++n)),t[r++]=s>>18|240,t[r++]=s>>12&63|128,t[r++]=s>>6&63|128,t[r++]=63&s|128):(t[r++]=s>>12|224,t[r++]=s>>6&63|128,t[r++]=63&s|128)}return t}export{i as _,O as a,S as c,E as d,A as f,a as g,g as h,B as i,b as l,h as m,V as n,I as o,p,R as r,m as s,J as t,w as u,s as v,r as y};
|