vis-core 0.33.20 → 0.33.21

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{a as e,i as t,n as r,o as s,r as i,t as n}from"./resource-url-MTT03G1N.js";var o=["world","country","province","city","district"];function a(e,t,r,s){var i;return s&&"dynamic"===(null==e?void 0:e.mode)&&o.includes(t)&&null!==(i=e.templates[t])&&void 0!==i?i:r}var l=e=>"string"==typeof e&&!!e&&!/[:\\?#\0]/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e);function c(e,t,r){var s,i;if(!(null==e?void 0:e.mapNavigation))return;if("static"===e.mapNavigation.mode)throw Error("此作品为固定场景展示,不支持运行时区域切换或重建。请以动态模式重新导出。");const n=void 0===r?Object.values(null!==(s=e.regions)&&void 0!==s?s:{}).flat():null===(i=e.regions)||void 0===i?void 0:i[r];if(void 0!==r&&!Object.values(e.mapNavigation.templates).includes(r)||!(null==n?void 0:n.includes(t)))throw Error(`区域 ${t} 或场景模板不在动态导出范围内,请调整范围和模板后重新导出。`)}function d(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,s=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const o of t.entries){var n;if(!o||"string"!=typeof o.id||!o.id||r.has(o.id)||!l(o.path)||s.has(o.path)||!Array.isArray(o.sources)||!o.sources.length||o.sources.some(e=>"string"!=typeof e||!e||i.has(e))||new Set(o.sources).size!==o.sources.length||"string"!=typeof o.mimeType||!/^[\w.+-]+\/[\w.+-]+$/.test(o.mimeType)||!["identity","gzip"].includes(o.encoding)||!Number.isSafeInteger(o.bytes)||o.bytes<0||!/^[a-f0-9]{64}$/.test(o.sha256)||void 0!==o.data&&!(o.data instanceof ArrayBuffer))throw Error(`Invalid runtime asset: ${null!==(n=null==o?void 0:o.path)&&void 0!==n?n:"unknown"}`);r.add(o.id),s.add(o.path),o.sources.forEach(e=>i.add(e))}if(t.scope&&(!Number.isInteger(t.scope.rootAdcode)||t.scope.rootAdcode<0||!o.includes(t.scope.maxLevel)))throw Error("Invalid map export scope");const a=t.mapNavigation;if(void 0!==a){if(!a||!["static","dynamic"].includes(a.mode))throw Error("Invalid map navigation mode");if("dynamic"===a.mode&&(!a.scope||!Number.isInteger(a.scope.rootAdcode)||a.scope.rootAdcode<0||!o.includes(a.scope.maxLevel)||!a.templates||"object"!=typeof a.templates||Array.isArray(a.templates)||Object.entries(a.templates).some(([e,t])=>!o.includes(e)||"string"!=typeof t||!t.trim())))throw Error("Invalid map navigation templates or 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)||i.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 u(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 p(e){return e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function f(e){return h.apply(this,arguments)}function h(){return h=t(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("")}),h.apply(this,arguments)}function y(e,t){return m.apply(this,arguments)}function m(){return(m=t(function*(e,t){if(t.length!==e.bytes||(yield f(t))!==e.sha256)throw Error(`资源校验失败:${e.path}`)})).apply(this,arguments)}function g(t,r){var s,i,n,o;if(!r)return t;if(!t)return structuredClone(r);const a=structuredClone(t),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 e of r.entries){for(const r of e.sources)if(c.has(r)&&c.get(r)!==e.sha256)throw Error(`资源地址存在不同内容:${r}。请修改资源地址或使用“打开项目”导入。`);const t=l.get(e.id);if(t)t.sources=[.../* @__PURE__ */new Set([...t.sources,...e.sources])];else{const t=structuredClone(e);a.entries.push(t),l.set(t.id,t)}for(const r of e.sources)c.set(r,e.sha256)}a.regions=e(e({},t.regions),r.regions),a.declaredSources=[.../* @__PURE__ */new Set([...null!==(s=t.declaredSources)&&void 0!==s?s:[],...null!==(i=r.declaredSources)&&void 0!==i?i:[]])];const u=[.../* @__PURE__ */new Set([...null!==(n=t.externalSources)&&void 0!==n?n:[],...null!==(o=r.externalSources)&&void 0!==o?o:[]])].filter(e=>!c.has(e));return u.length?a.externalSources=u:delete a.externalSources,d(a),a}var v=class{constructor(e,t="",o=!0){var a;s(this,"sources",/* @__PURE__ */new Map),s(this,"resolved",/* @__PURE__ */new Map),s(this,"externals",/* @__PURE__ */new Map),s(this,"catalog",void 0),s(this,"strict",void 0),s(this,"prefix",void 0),s(this,"resolve",e=>{var t;if(/^(data:|blob:)/i.test(e))return e;const s=n(e,this.prefix),o=null!==(t=this.sources.get(e))&&void 0!==t?t:this.sources.get(s);if(!o){var a;const t=null!==(a=this.externals.get(e))&&void 0!==a?a:this.externals.get(s);if(void 0!==t)return t;if(!this.strict)return s;throw Error(`资源包未包含:${e}。请扩大导出范围或补充资源后重新导出。`)}let l=this.resolved.get(o.id);if(!l){if(void 0!==o.data){const e=p(o.data);if(e.byteLength!==o.bytes||i(r(e))!==o.sha256)throw Error(`资源校验失败:${o.path}`);l=URL.createObjectURL(new Blob([e],{type:"gzip"===o.encoding?"application/gzip":o.mimeType}))}else{const e=this.catalog.baseUrl;if(!e)throw Error(`资源缺少文件内容或部署地址:${o.path}`);const t="undefined"==typeof location?"https://bundle.invalid/":location.href;l=new URL(o.path,new URL(e,t)).href}this.resolved.set(o.id,l)}return l}),this.catalog=e,this.prefix=t,this.strict=o,d(e);const l=(e,t)=>{const r=this.sources.get(e);if(r&&r.id!==t.id)throw Error(`资源地址重复:${e}`);this.sources.set(e,t)},c=e=>/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)?[e]:[e,n(e,t),`/${e.replace(/^\/+/,"")}`];for(const r of e.entries)for(const e of[...r.sources,`asset://${r.id}`])for(const t of c(e))l(t,r);for(const r of null!==(a=e.externalSources)&&void 0!==a?a:[]){const e=n(r,t);for(const t of c(r))this.externals.set(t,e)}}dispose(){for(const e of this.resolved.values())e.startsWith("blob:")&&URL.revokeObjectURL(e);this.resolved.clear()}};function w(e,t){if(null==e)return{};var r,s,i=function(e,t){if(null==e)return{};var r={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;r[s]=e[s]}return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)r=n[s],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var b,A,x,S=new class{constructor(e=32,t=67108864){s(this,"pending",/* @__PURE__ */new Map),s(this,"values",/* @__PURE__ */new Map),s(this,"bytes",0),s(this,"maxEntries",void 0),s(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 s=this.pending.get(e);if(s)return s;const i=Promise.resolve().then(t).then(t=>{if(this.pending.get(e)===i&&(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)===i&&this.pending.delete(e),t});return this.pending.set(e,i),i}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)}},E=e=>!!/\.(gzip|gz)(?:[?#]|$)/i.test(e),I=(b=t(function*(e,t,r=E){const s=yield window.fetch(e);if(!s.ok){try{var i;yield null===(i=s.body)||void 0===i?void 0:i.cancel()}catch(l){}throw new Error("Network response was not ok.")}let n=s;if(t)try{n=((e,t)=>{const r=Number(e.headers.get("content-length"))||0;let s=0;return e.body?new globalThis.Response(e.body.pipeThrough(new globalThis.TransformStream({start(){t({percent:0,transferredBytes:0,totalBytes:r})},transform(e,i){s+=e.byteLength,t({percent:0===r?0:s/r,transferredBytes:s,totalBytes:r}),i.enqueue(e)},flush(){t({percent:1,transferredBytes:s,totalBytes:r})}})),{status:e.status,statusText:e.statusText,headers:e.headers}):(t({percent:1,totalBytes:r,transferredBytes:s}),new globalThis.Response(null,{status:e.status,statusText:e.statusText,headers:e.headers}))})(n,t)}catch(c){try{var o;yield null===(o=s.body)||void 0===o?void 0:o.cancel(c)}catch(d){}throw c}if(r(e)&&"gzip"!==n.headers.get("content-encoding")){const e=new DecompressionStream("gzip"),t=n.body.pipeThrough(e);n=new Response(t)}const a=yield n.text();return{json:JSON.parse(a),bytes:2*a.length}}),function(e,t){return b.apply(this,arguments)}),j=(A=t(function*(e,t,r=E,s){try{var i,n;const o=null!==(i=null==s||null===(n=s.resolveURL)||void 0===n?void 0:n.call(s,e))&&void 0!==i?i: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 s,i,n;const t=null===(s=r.enabled)||void 0===s||s;return{enabled:t,key:null!==(i=r.key)&&void 0!==i?i:e,clone:!!t&&(null===(n=r.clone)||void 0===n||n)}}return{enabled:!1,key:e,clone:!1}})(o,s),l=()=>I(o,t,()=>r(e)),c=(yield a.enabled?S.load(a.key,l):l()).json;return{res:a.enabled&&a.clone?structuredClone(c):c,err:void 0}}catch(o){return{res:void 0,err:o}}}),function(e,t){return A.apply(this,arguments)}),B=n,$=(x=t(function*(e,t){const{res:r,err:s}=yield j(B(e,null==t?void 0:t.assetsPrefix),void 0,void 0,(null==t?void 0:t.fetchOptions)||{cache:!0});if(s)throw s;return r}),function(e,t){return x.apply(this,arguments)}),U=["format","schemaVersion","scenes","assets"];function k(e){const t=e.replace(/[?#].*$/,""),r=e.slice(t.length),s=new URL(e,"https://bundle.invalid").pathname;if(/\.zip$/i.test(s)||/(?:^|\/)manifest\.json$/i.test(s))return e;if(/\.[^/]+$/.test(s))throw Error("vis-core 仅支持 ZIP、分包目录或 manifest.json;独立 JSON/GZ 请先通过编辑平台导入并导出 ZIP。");return`${t.replace(/\/$/,"")}/manifest.json${r}`}function O(e,t){return T.apply(this,arguments)}function T(){return(T=t(function*(e,t){try{const r=new Uint8Array(yield e.slice(0,2).arrayBuffer()),s=/\.(gz|gzip)$/i.test(t)||31===r[0]&&139===r[1]?yield new Response(e.stream().pipeThrough(new DecompressionStream("gzip"))).text():yield e.text(),i=JSON.parse(s);if(!i||"object"!=typeof i||Array.isArray(i))throw Error("需要 JSON 对象");return i}catch(r){throw new Error(`无法读取文件 ${t}:${r instanceof Error?r.message:String(r)}`,{cause:r})}})).apply(this,arguments)}function L(e){return N.apply(this,arguments)}function N(){return N=t(function*(r,s="project.zip"){var i;const[{default:n},o,{createTextureFile:a},{SCENE_DOCUMENT_FORMAT:l},{resolveRuntimeImages:c}]=yield Promise.all([import("jszip"),import("./validation-BOlQdEPC.js").then(e=>e.r),import("./dist-CBwlzuju.js").then(e=>e.R),import("./schema-DCtwlcYa.js").then(e=>e.c),import("./runtimeImages-CJx9KQkc.js").then(e=>e.a)]),d=o;let u;try{u=yield n.loadAsync(r instanceof Blob?yield r.arrayBuffer():r)}catch(N){throw new Error(`无法解压 ZIP 文件 ${s}`,{cause:N})}const p=Object.values(u.files).filter(e=>!e.dir&&/(^|\/)manifest\.json$/.test(e.name)&&!e.name.startsWith("__MACOSX/")),f=null!==(i=u.file("manifest.json"))&&void 0!==i?i: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),m=yield O(new Blob([yield f.async("uint8array")]),f.name);d.assertSceneManifest(m);const g=function(){var e=t(function*(e){if(/[:\\?#\0]/.test(e)||e.split("/").some(e=>!e||"."===e||".."===e))throw new Error(`ZIP 内文件路径无效:${e}`);const t=u.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 e of m.scenes){var b,A;const t=yield O(yield g(e.source),e.source);if(!(null===(b=t.scene)||void 0===b?void 0:b.object)||t.id!==e.id||(null===(A=t.vis)||void 0===A?void 0:A.type)!==e.vis.type)throw new Error(`场景文件与 manifest 不匹配:${e.source}`);v.push(t)}const{format:x,schemaVersion:S,scenes:E,assets:I}=m,j=e(e({},w(m,U)),{},{format:l,schemaVersion:6,scenes:v});if(d.assertRuntimeSceneDocument(j),j.runtimeAssets){delete j.runtimeAssets.baseUrl;for(const e of j.runtimeAssets.entries){const t=new Uint8Array(yield(yield g(e.path)).arrayBuffer());yield y(e,t),e.data=t.buffer}}const B=/* @__PURE__ */new Map,$={png:"image/png",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",bmp:"image/bmp"};for(const e of Object.keys(null!=I?I:{})){var k,T,L;const t=new Uint8Array(yield(yield g(e)).arrayBuffer()),r=null!==(k=null!==(T=null==I||null===(L=I[e])||void 0===L?void 0:L.mimeType)&&void 0!==T?T:$[e.split(".").pop()])&&void 0!==k?k:"application/octet-stream";B.set(e,a(t.buffer,r))}return c(j,I,e=>B.get(e)),j}),N.apply(this,arguments)}var M=["assets"],C=e=>i(r(new Uint8Array(e))),P={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array},z={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/avif":"avif","image/bmp":"bmp","image/svg+xml":"svg","image/vnd.radiance":"hdr","image/x-tga":"tga","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","video/quicktime":"mov","video/x-m4v":"m4v"},D=e=>"string"==typeof e&&/^assets\/[\w.-]+$/.test(e)&&!e.includes("..");function R(e){if(void 0!==e){if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Invalid media asset manifest");for(const[t,r]of Object.entries(e)){if(!D(t)||!r||!/^[a-f0-9]{64}$/.test(r.sha256)||!Number.isSafeInteger(r.bytes)||r.bytes<0||!/^[\w.+-]+\/[\w.+-]+$/.test(r.mimeType)||!["image","hdr","tga","video","pixels"].includes(r.kind))throw Error(`Invalid media asset: ${t}`);if("pixels"===r.kind){const e=r.pixels;if(!e||!Object.hasOwn(P,e.type)||!Number.isSafeInteger(e.width)||e.width<=0||!Number.isSafeInteger(e.height)||e.height<=0||void 0!==e.depth&&(!Number.isSafeInteger(e.depth)||e.depth<=0)||r.bytes%P[e.type].BYTES_PER_ELEMENT)throw Error(`Invalid pixel asset: ${t}`)}else if(void 0!==r.pixels)throw Error(`Unexpected pixel metadata: ${t}`)}}}function _(t,r){if(r instanceof ArrayBuffer&&(r.byteLength!==t.bytes||C(r)!==t.sha256))throw Error("Media resource checksum mismatch");return"pixels"===t.kind?e(e({},t.pixels),{},{encoding:"binary",sha256:t.sha256,data:r}):{encoding:"file",kind:t.kind,mimeType:t.mimeType,sha256:t.sha256,data:r}}var Z=class{constructor(){s(this,"payloads",/* @__PURE__ */new WeakMap),s(this,"graphs",/* @__PURE__ */new WeakMap),s(this,"rows",/* @__PURE__ */new WeakMap)}row(t,r,s){const i=this.rows.get(t);if(i&&i.graph===s)return i.row;const n=e(e({},t),{},{[r]:s});return this.rows.set(t,{graph:s,row:n}),n}writePayload(t){var r;if("string"==typeof t){const e=/^data:((?:image|video)\/[^;,]+);base64,([\s\S]*)$/i.exec(t);if(!e)return;const r=p(e[2]).buffer;t={encoding:"file",kind:e[1].toLowerCase().startsWith("video/")?"video":"image",mimeType:e[1],sha256:C(r),data:r}}if(!t||"object"!=typeof t)return;const s=this.payloads.get(t);if(s)return s;let i,n;if("file"===t.encoding){if(!(t.data instanceof ArrayBuffer))throw Error("Media export requires owned file bytes");if(i=t.data,n={kind:t.kind,mimeType:t.mimeType,sha256:C(i),bytes:i.byteLength},n.sha256!==t.sha256)throw Error("Media resource checksum mismatch")}else{if(!("binary"===t.encoding||Object.hasOwn(P,t.type)&&(Array.isArray(t.data)||ArrayBuffer.isView(t.data))))return;{const r=P[t.type];if(!r)throw Error("Invalid pixel array type");if("binary"===t.encoding){if(!(t.data instanceof ArrayBuffer)||C(t.data)!==t.sha256)throw Error("Invalid binary pixel resource");i=t.data}else{const e=Array.isArray(t.data)?new r(t.data):t.data;i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}n={kind:"pixels",mimeType:"application/octet-stream",sha256:C(i),bytes:i.byteLength,pixels:e({type:t.type,width:t.width,height:t.height},void 0===t.depth?{}:{depth:t.depth})}}}const o=n.pixels?"-"+C((new TextEncoder).encode(JSON.stringify(n.pixels)).buffer).slice(0,16):"",a="pixels"===n.kind?"bin":null!==(r=z[n.mimeType])&&void 0!==r?r:"bin",l=`assets/${"video"===n.kind?"video":"image"}-${n.sha256}${o}.${a}`;R({[l]:n});const c={path:l,info:n,file:{data:new Uint8Array(i),mimeType:n.mimeType}};return this.payloads.set(t,c),c}prepare(t){var r;const s={},i={};if(void 0!==t._resourcePool||void 0!==t.imageAssets)throw Error("Import legacy resources in editor-platform");const n=e=>{s[e.path]=e.info,i[e.path]=e.file},o=t=>{if(!t)return t;const r=this.graphs.get(t);if(r)return r.files.forEach(n),r.graph;const s=/* @__PURE__ */new Map,i=e=>{const t=e;if(Array.isArray(t))return t.map(i);const r=this.writePayload(t);return r?(s.set(r.path,r),r.path):t},o=e({},t);t.images&&(o.images=t.images.map(t=>e(e({},t),{},{url:i(t.url)}))),t.textures&&(o.textures=t.textures.map(r=>{let s=r.userData;if(!s)return r;if(void 0!==s._dataTexBase64||"number"==typeof s._videoSrc||void 0!==t._texDataPool)throw Error("Import legacy texture data in editor-platform");return void 0!==s._videoSrc&&(s=e(e({},s),{},{_videoSrc:i(s._videoSrc)})),s===r.userData?r:e(e({},r),{},{userData:s})}));const a=[...s.values()];return a.forEach(n),this.graphs.set(t,{graph:o,files:a}),o},{assets:a}=t,l=e({},w(t,M));if(t.scene&&(l.scene=o(t.scene)),t.scenes&&(l.scenes=t.scenes.map(e=>this.row(e,"scene",o(e.scene)))),t.materialLibrary&&(l.materialLibrary=t.materialLibrary.map(e=>this.row(e,"material",o(e.material)))),t.prefabLibrary&&(l.prefabLibrary=t.prefabLibrary.map(e=>this.row(e,"snapshot",o(e.snapshot)))),null===(r=t.d)||void 0===r?void 0:r.chartBg){const r=t.d.chartBg,s=o({images:r.images,textures:[r]});l.d=e(e({},t.d),{},{chartBg:e(e({},s.textures[0]),s.images?{images:s.images}:{})})}return{document:l,assets:s,files:i}}};function K(e,t,r){var s,i,n,o;if(!t)return;R(t);const a=/* @__PURE__ */new Map,l=e=>{if(Array.isArray(e))return e.map(l);if("string"!=typeof e)return e;if(!Object.hasOwn(t,e)){if(/^assets\/(image|video)-[a-f0-9]{64}[.-]/.test(e))throw Error(`Missing media asset metadata: ${e}`);return e}return a.has(e)||a.set(e,_(t[e],r(e,t[e]))),a.get(e)},c=e=>{var t,r,s;for(const i of null!==(t=null==e?void 0:e.images)&&void 0!==t?t:[])i.url=l(i.url);for(const i of null!==(r=null==e?void 0:e.textures)&&void 0!==r?r:[])void 0!==(null===(s=i.userData)||void 0===s?void 0:s._videoSrc)&&(i.userData._videoSrc=l(i.userData._videoSrc))};c(e.scene);for(const d of null!==(s=e.scenes)&&void 0!==s?s:[])c(d.scene);for(const d of null!==(i=e.materialLibrary)&&void 0!==i?i:[])c(d.material);for(const d of null!==(n=e.prefabLibrary)&&void 0!==n?n:[])c(d.snapshot);(null===(o=e.d)||void 0===o?void 0:o.chartBg)&&c({images:e.d.chartBg.images,textures:[e.d.chartBg]})}var V="undefined"!=typeof crypto&&void 0!==crypto.subtle;function F(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/g,"").replace(/-----END PUBLIC KEY-----/g,"").replace(/\s/g,""),r=atob(t),s=new Uint8Array(r.length);for(let i=0;i<r.length;i++)s[i]=r.charCodeAt(i);return s.buffer}function Y(){return(Y=t(function*(e){return crypto.subtle.importKey("spki",F(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])})).apply(this,arguments)}var J="-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEU2vGIjpJQFRkGxVrw4gZL3dXm/1\nfrZBlUc8gjzam/VNZbT1swQSq/kLPmYH7ZykBvLzp7SpNdvOQ8rAqdSdvg==\n-----END PUBLIC KEY-----";var Q=V?function(e){return Y.apply(this,arguments)}(J):null,W=V?null:new Uint8Array(F(J)).slice(26);function q(e){return G.apply(this,arguments)}function G(){return(G=t(function*(e){let t;try{t=function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,s=atob(t+"=".repeat(r)),i=new Uint8Array(s.length);for(let n=0;n<s.length;n++)i[n]=s.charCodeAt(n);return i}(e)}catch(o){return null}if(t.length<=64)return null;const r=t.slice(0,t.length-64),s=t.slice(t.length-64);let i;try{if(V){const e=yield Q;i=yield crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},e,s,r)}else{const{p256:e}=yield import("@noble/curves/nist.js");i=e.verify(s,r,W,{lowS:!1})}}catch(a){return null}if(!i)return null;const n=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),s=!!(4&t),i=!!(8&t);if(-16&t||r&&(s||i))return null;let n,o=1;if(1&t){if(e.length<o+4)return null;n=36e5*((e[o]<<24|e[o+1]<<16|e[o+2]<<8|e[o+3])>>>0),o+=4}let a=null;if(!r){if(e.length<o+1)return null;let t=e[o++];if(i){if(e.length<o+1)return null;t=t<<8|e[o++]}if(!t||e.length!==o+3*t)return null;a=[];for(let r=0;r<t;r++){const t=e[o]<<16|e[o+1]<<8|e[o+2];a.push(t),o+=3}}return o!==e.length?null:{adcodes:a,expire:n,prefixMatch:s}}(r);return n?n.expire&&Date.now()>n.expire?null:n:null})).apply(this,arguments)}function H(e,t,r){return X.apply(this,arguments)}function X(){return(X=t(function*(e,t,r){const s=yield q(t);if(!(null==s?void 0:s.adcodes)||s.prefixMatch||"preview"===s.purpose||void 0!==r&&s.projectId!==r)return!1;const i=new Set(e),n=new Set(s.adcodes);return i.size>0&&i.size===n.size&&[...i].every(e=>n.has(e))})).apply(this,arguments)}function ee(e,t){return te.apply(this,arguments)}function te(){return(te=t(function*(e,t){const r=yield q(t);return!(!(null==r?void 0:r.adcodes)||r.prefixMatch||"preview"===r.purpose)&&r.adcodes.includes(e)})).apply(this,arguments)}var re=(e,t)=>{const r=se(e),s=se(t).map(function(e,t){return e^r[Math.floor(t%r.length)]}).join(",");return btoa(s)};function se(e){const t=[];let r=0;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296==(64512&i)&&s+1<e.length&&56320==(64512&e.charCodeAt(s+1))?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++s)),t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128)}return t}export{y as C,a as S,f as _,R as a,o as b,L as c,j as d,$ as f,d as g,c as h,Z as i,k as l,v as m,ee as n,_ as o,w as p,H as r,K as s,re as t,E as u,p as v,g as x,u as y};
1
+ import{a as e,i as t,n as r,o as s,r as i,t as n}from"./resource-url-MTT03G1N.js";var o=["world","country","province","city","district"];function a(e,t,r,s){var i;return s&&"dynamic"===(null==e?void 0:e.mode)&&o.includes(t)&&null!==(i=e.templates[t])&&void 0!==i?i:r}var l=e=>"string"==typeof e&&!!e&&!/[:\\?#\0]/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e);function c(e,t,r){var s,i;if(!(null==e?void 0:e.mapNavigation))return;if("static"===e.mapNavigation.mode)throw Error("此作品为固定场景展示,不支持运行时区域切换或重建。请以动态模式重新导出。");const n=void 0===r?Object.values(null!==(s=e.regions)&&void 0!==s?s:{}).flat():null===(i=e.regions)||void 0===i?void 0:i[r];if(void 0!==r&&!Object.values(e.mapNavigation.templates).includes(r)||!(null==n?void 0:n.includes(t)))throw Error(`区域 ${t} 或场景模板不在动态导出范围内,请调整范围和模板后重新导出。`)}function d(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,s=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const o of t.entries){var n;if(!o||"string"!=typeof o.id||!o.id||r.has(o.id)||!l(o.path)||s.has(o.path)||!Array.isArray(o.sources)||!o.sources.length||o.sources.some(e=>"string"!=typeof e||!e||i.has(e))||new Set(o.sources).size!==o.sources.length||"string"!=typeof o.mimeType||!/^[\w.+-]+\/[\w.+-]+$/.test(o.mimeType)||!["identity","gzip"].includes(o.encoding)||!Number.isSafeInteger(o.bytes)||o.bytes<0||!/^[a-f0-9]{64}$/.test(o.sha256)||void 0!==o.data&&!(o.data instanceof ArrayBuffer))throw Error(`Invalid runtime asset: ${null!==(n=null==o?void 0:o.path)&&void 0!==n?n:"unknown"}`);r.add(o.id),s.add(o.path),o.sources.forEach(e=>i.add(e))}if(t.scope&&(!Number.isInteger(t.scope.rootAdcode)||t.scope.rootAdcode<0||!o.includes(t.scope.maxLevel)))throw Error("Invalid map export scope");const a=t.mapNavigation;if(void 0!==a){if(!a||!["static","dynamic"].includes(a.mode))throw Error("Invalid map navigation mode");if("dynamic"===a.mode&&(!a.scope||!Number.isInteger(a.scope.rootAdcode)||a.scope.rootAdcode<0||!o.includes(a.scope.maxLevel)||!a.templates||"object"!=typeof a.templates||Array.isArray(a.templates)||Object.entries(a.templates).some(([e,t])=>!o.includes(e)||"string"!=typeof t||!t.trim())))throw Error("Invalid map navigation templates or 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)||i.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 u(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 p(e){return e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function f(e){return h.apply(this,arguments)}function h(){return h=t(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("")}),h.apply(this,arguments)}function y(e,t){return m.apply(this,arguments)}function m(){return(m=t(function*(e,t){if(t.length!==e.bytes||(yield f(t))!==e.sha256)throw Error(`资源校验失败:${e.path}`)})).apply(this,arguments)}function g(t,r){var s,i,n,o;if(!r)return t;if(!t)return structuredClone(r);const a=structuredClone(t),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 e of r.entries){for(const r of e.sources)if(c.has(r)&&c.get(r)!==e.sha256)throw Error(`资源地址存在不同内容:${r}。请修改资源地址或使用“打开项目”导入。`);const t=l.get(e.id);if(t)t.sources=[.../* @__PURE__ */new Set([...t.sources,...e.sources])];else{const t=structuredClone(e);a.entries.push(t),l.set(t.id,t)}for(const r of e.sources)c.set(r,e.sha256)}a.regions=e(e({},t.regions),r.regions),a.declaredSources=[.../* @__PURE__ */new Set([...null!==(s=t.declaredSources)&&void 0!==s?s:[],...null!==(i=r.declaredSources)&&void 0!==i?i:[]])];const u=[.../* @__PURE__ */new Set([...null!==(n=t.externalSources)&&void 0!==n?n:[],...null!==(o=r.externalSources)&&void 0!==o?o:[]])].filter(e=>!c.has(e));return u.length?a.externalSources=u:delete a.externalSources,d(a),a}var v=class{constructor(e,t="",o=!0){var a;s(this,"sources",/* @__PURE__ */new Map),s(this,"resolved",/* @__PURE__ */new Map),s(this,"externals",/* @__PURE__ */new Map),s(this,"catalog",void 0),s(this,"strict",void 0),s(this,"prefix",void 0),s(this,"resolve",e=>{var t;if(/^(data:|blob:)/i.test(e))return e;const s=n(e,this.prefix),o=null!==(t=this.sources.get(e))&&void 0!==t?t:this.sources.get(s);if(!o){var a;const t=null!==(a=this.externals.get(e))&&void 0!==a?a:this.externals.get(s);if(void 0!==t)return t;if(!this.strict)return s;throw Error(`资源包未包含:${e}。请扩大导出范围或补充资源后重新导出。`)}let l=this.resolved.get(o.id);if(!l){if(void 0!==o.data){const e=p(o.data);if(e.byteLength!==o.bytes||i(r(e))!==o.sha256)throw Error(`资源校验失败:${o.path}`);l=URL.createObjectURL(new Blob([e],{type:"gzip"===o.encoding?"application/gzip":o.mimeType}))}else{const e=this.catalog.baseUrl;if(!e)throw Error(`资源缺少文件内容或部署地址:${o.path}`);const t="undefined"==typeof location?"https://bundle.invalid/":location.href;l=new URL(o.path,new URL(e,t)).href}this.resolved.set(o.id,l)}return l}),this.catalog=e,this.prefix=t,this.strict=o,d(e);const l=(e,t)=>{const r=this.sources.get(e);if(r&&r.id!==t.id)throw Error(`资源地址重复:${e}`);this.sources.set(e,t)},c=e=>/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)?[e]:[e,n(e,t),`/${e.replace(/^\/+/,"")}`];for(const r of e.entries)for(const e of[...r.sources,`asset://${r.id}`])for(const t of c(e))l(t,r);for(const r of null!==(a=e.externalSources)&&void 0!==a?a:[]){const e=n(r,t);for(const t of c(r))this.externals.set(t,e)}}dispose(){for(const e of this.resolved.values())e.startsWith("blob:")&&URL.revokeObjectURL(e);this.resolved.clear()}};function w(e,t){if(null==e)return{};var r,s,i=function(e,t){if(null==e)return{};var r={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;r[s]=e[s]}return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)r=n[s],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var b,A,x,S=new class{constructor(e=32,t=67108864){s(this,"pending",/* @__PURE__ */new Map),s(this,"values",/* @__PURE__ */new Map),s(this,"bytes",0),s(this,"maxEntries",void 0),s(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 s=this.pending.get(e);if(s)return s;const i=Promise.resolve().then(t).then(t=>{if(this.pending.get(e)===i&&(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)===i&&this.pending.delete(e),t});return this.pending.set(e,i),i}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)}},E=e=>!!/\.(gzip|gz)(?:[?#]|$)/i.test(e),I=(b=t(function*(e,t,r=E){const s=yield window.fetch(e);if(!s.ok){try{var i;yield null===(i=s.body)||void 0===i?void 0:i.cancel()}catch(l){}throw new Error("Network response was not ok.")}let n=s;if(t)try{n=((e,t)=>{const r=Number(e.headers.get("content-length"))||0;let s=0;return e.body?new globalThis.Response(e.body.pipeThrough(new globalThis.TransformStream({start(){t({percent:0,transferredBytes:0,totalBytes:r})},transform(e,i){s+=e.byteLength,t({percent:0===r?0:s/r,transferredBytes:s,totalBytes:r}),i.enqueue(e)},flush(){t({percent:1,transferredBytes:s,totalBytes:r})}})),{status:e.status,statusText:e.statusText,headers:e.headers}):(t({percent:1,totalBytes:r,transferredBytes:s}),new globalThis.Response(null,{status:e.status,statusText:e.statusText,headers:e.headers}))})(n,t)}catch(c){try{var o;yield null===(o=s.body)||void 0===o?void 0:o.cancel(c)}catch(d){}throw c}if(r(e)&&"gzip"!==n.headers.get("content-encoding")){const e=new DecompressionStream("gzip"),t=n.body.pipeThrough(e);n=new Response(t)}const a=yield n.text();return{json:JSON.parse(a),bytes:2*a.length}}),function(e,t){return b.apply(this,arguments)}),j=(A=t(function*(e,t,r=E,s){try{var i,n;const o=null!==(i=null==s||null===(n=s.resolveURL)||void 0===n?void 0:n.call(s,e))&&void 0!==i?i: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 s,i,n;const t=null===(s=r.enabled)||void 0===s||s;return{enabled:t,key:null!==(i=r.key)&&void 0!==i?i:e,clone:!!t&&(null===(n=r.clone)||void 0===n||n)}}return{enabled:!1,key:e,clone:!1}})(o,s),l=()=>I(o,t,()=>r(e)),c=(yield a.enabled?S.load(a.key,l):l()).json;return{res:a.enabled&&a.clone?structuredClone(c):c,err:void 0}}catch(o){return{res:void 0,err:o}}}),function(e,t){return A.apply(this,arguments)}),B=n,$=(x=t(function*(e,t){const{res:r,err:s}=yield j(B(e,null==t?void 0:t.assetsPrefix),void 0,void 0,(null==t?void 0:t.fetchOptions)||{cache:!0});if(s)throw s;return r}),function(e,t){return x.apply(this,arguments)}),U=["format","schemaVersion","scenes","assets"];function k(e){const t=e.replace(/[?#].*$/,""),r=e.slice(t.length),s=new URL(e,"https://bundle.invalid").pathname;if(/\.zip$/i.test(s)||/(?:^|\/)manifest\.json$/i.test(s))return e;if(/\.[^/]+$/.test(s))throw Error("vis-core 仅支持 ZIP、分包目录或 manifest.json;独立 JSON/GZ 请先通过编辑平台导入并导出 ZIP。");return`${t.replace(/\/$/,"")}/manifest.json${r}`}function O(e,t){return T.apply(this,arguments)}function T(){return(T=t(function*(e,t){try{const r=new Uint8Array(yield e.slice(0,2).arrayBuffer()),s=/\.(gz|gzip)$/i.test(t)||31===r[0]&&139===r[1]?yield new Response(e.stream().pipeThrough(new DecompressionStream("gzip"))).text():yield e.text(),i=JSON.parse(s);if(!i||"object"!=typeof i||Array.isArray(i))throw Error("需要 JSON 对象");return i}catch(r){throw new Error(`无法读取文件 ${t}:${r instanceof Error?r.message:String(r)}`,{cause:r})}})).apply(this,arguments)}function L(e){return N.apply(this,arguments)}function N(){return N=t(function*(r,s="project.zip"){var i;const[{default:n},o,{createTextureFile:a},{SCENE_DOCUMENT_FORMAT:l},{resolveRuntimeImages:c}]=yield Promise.all([import("jszip"),import("./validation-ByK1cs9B.js").then(e=>e.r),import("./dist-CBwlzuju.js").then(e=>e.R),import("./schema-DCtwlcYa.js").then(e=>e.c),import("./runtimeImages-bGdtc9BO.js").then(e=>e.a)]),d=o;let u;try{u=yield n.loadAsync(r instanceof Blob?yield r.arrayBuffer():r)}catch(N){throw new Error(`无法解压 ZIP 文件 ${s}`,{cause:N})}const p=Object.values(u.files).filter(e=>!e.dir&&/(^|\/)manifest\.json$/.test(e.name)&&!e.name.startsWith("__MACOSX/")),f=null!==(i=u.file("manifest.json"))&&void 0!==i?i: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),m=yield O(new Blob([yield f.async("uint8array")]),f.name);d.assertSceneManifest(m);const g=function(){var e=t(function*(e){if(/[:\\?#\0]/.test(e)||e.split("/").some(e=>!e||"."===e||".."===e))throw new Error(`ZIP 内文件路径无效:${e}`);const t=u.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 e of m.scenes){var b,A;const t=yield O(yield g(e.source),e.source);if(!(null===(b=t.scene)||void 0===b?void 0:b.object)||t.id!==e.id||(null===(A=t.vis)||void 0===A?void 0:A.type)!==e.vis.type)throw new Error(`场景文件与 manifest 不匹配:${e.source}`);v.push(t)}const{format:x,schemaVersion:S,scenes:E,assets:I}=m,j=e(e({},w(m,U)),{},{format:l,schemaVersion:6,scenes:v});if(d.assertRuntimeSceneDocument(j),j.runtimeAssets){delete j.runtimeAssets.baseUrl;for(const e of j.runtimeAssets.entries){const t=new Uint8Array(yield(yield g(e.path)).arrayBuffer());yield y(e,t),e.data=t.buffer}}const B=/* @__PURE__ */new Map,$={png:"image/png",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",bmp:"image/bmp"};for(const e of Object.keys(null!=I?I:{})){var k,T,L;const t=new Uint8Array(yield(yield g(e)).arrayBuffer()),r=null!==(k=null!==(T=null==I||null===(L=I[e])||void 0===L?void 0:L.mimeType)&&void 0!==T?T:$[e.split(".").pop()])&&void 0!==k?k:"application/octet-stream";B.set(e,a(t.buffer,r))}return c(j,I,e=>B.get(e)),j}),N.apply(this,arguments)}var M=["assets"],C=e=>i(r(new Uint8Array(e))),P={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array},z={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/avif":"avif","image/bmp":"bmp","image/svg+xml":"svg","image/vnd.radiance":"hdr","image/x-tga":"tga","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","video/quicktime":"mov","video/x-m4v":"m4v"},D=e=>"string"==typeof e&&/^assets\/[\w.-]+$/.test(e)&&!e.includes("..");function R(e){if(void 0!==e){if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Invalid media asset manifest");for(const[t,r]of Object.entries(e)){if(!D(t)||!r||!/^[a-f0-9]{64}$/.test(r.sha256)||!Number.isSafeInteger(r.bytes)||r.bytes<0||!/^[\w.+-]+\/[\w.+-]+$/.test(r.mimeType)||!["image","hdr","tga","video","pixels"].includes(r.kind))throw Error(`Invalid media asset: ${t}`);if("pixels"===r.kind){const e=r.pixels;if(!e||!Object.hasOwn(P,e.type)||!Number.isSafeInteger(e.width)||e.width<=0||!Number.isSafeInteger(e.height)||e.height<=0||void 0!==e.depth&&(!Number.isSafeInteger(e.depth)||e.depth<=0)||r.bytes%P[e.type].BYTES_PER_ELEMENT)throw Error(`Invalid pixel asset: ${t}`)}else if(void 0!==r.pixels)throw Error(`Unexpected pixel metadata: ${t}`)}}}function _(t,r){if(r instanceof ArrayBuffer&&(r.byteLength!==t.bytes||C(r)!==t.sha256))throw Error("Media resource checksum mismatch");return"pixels"===t.kind?e(e({},t.pixels),{},{encoding:"binary",sha256:t.sha256,data:r}):{encoding:"file",kind:t.kind,mimeType:t.mimeType,sha256:t.sha256,data:r}}var Z=class{constructor(){s(this,"payloads",/* @__PURE__ */new WeakMap),s(this,"graphs",/* @__PURE__ */new WeakMap),s(this,"rows",/* @__PURE__ */new WeakMap)}row(t,r,s){const i=this.rows.get(t);if(i&&i.graph===s)return i.row;const n=e(e({},t),{},{[r]:s});return this.rows.set(t,{graph:s,row:n}),n}writePayload(t){var r;if("string"==typeof t){const e=/^data:((?:image|video)\/[^;,]+);base64,([\s\S]*)$/i.exec(t);if(!e)return;const r=p(e[2]).buffer;t={encoding:"file",kind:e[1].toLowerCase().startsWith("video/")?"video":"image",mimeType:e[1],sha256:C(r),data:r}}if(!t||"object"!=typeof t)return;const s=this.payloads.get(t);if(s)return s;let i,n;if("file"===t.encoding){if(!(t.data instanceof ArrayBuffer))throw Error("Media export requires owned file bytes");if(i=t.data,n={kind:t.kind,mimeType:t.mimeType,sha256:C(i),bytes:i.byteLength},n.sha256!==t.sha256)throw Error("Media resource checksum mismatch")}else{if(!("binary"===t.encoding||Object.hasOwn(P,t.type)&&(Array.isArray(t.data)||ArrayBuffer.isView(t.data))))return;{const r=P[t.type];if(!r)throw Error("Invalid pixel array type");if("binary"===t.encoding){if(!(t.data instanceof ArrayBuffer)||C(t.data)!==t.sha256)throw Error("Invalid binary pixel resource");i=t.data}else{const e=Array.isArray(t.data)?new r(t.data):t.data;i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}n={kind:"pixels",mimeType:"application/octet-stream",sha256:C(i),bytes:i.byteLength,pixels:e({type:t.type,width:t.width,height:t.height},void 0===t.depth?{}:{depth:t.depth})}}}const o=n.pixels?"-"+C((new TextEncoder).encode(JSON.stringify(n.pixels)).buffer).slice(0,16):"",a="pixels"===n.kind?"bin":null!==(r=z[n.mimeType])&&void 0!==r?r:"bin",l=`assets/${"video"===n.kind?"video":"image"}-${n.sha256}${o}.${a}`;R({[l]:n});const c={path:l,info:n,file:{data:new Uint8Array(i),mimeType:n.mimeType}};return this.payloads.set(t,c),c}prepare(t){var r;const s={},i={};if(void 0!==t._resourcePool||void 0!==t.imageAssets)throw Error("Import legacy resources in editor-platform");const n=e=>{s[e.path]=e.info,i[e.path]=e.file},o=t=>{if(!t)return t;const r=this.graphs.get(t);if(r)return r.files.forEach(n),r.graph;const s=/* @__PURE__ */new Map,i=e=>{const t=e;if(Array.isArray(t))return t.map(i);const r=this.writePayload(t);return r?(s.set(r.path,r),r.path):t},o=e({},t);t.images&&(o.images=t.images.map(t=>e(e({},t),{},{url:i(t.url)}))),t.textures&&(o.textures=t.textures.map(r=>{let s=r.userData;if(!s)return r;if(void 0!==s._dataTexBase64||"number"==typeof s._videoSrc||void 0!==t._texDataPool)throw Error("Import legacy texture data in editor-platform");return void 0!==s._videoSrc&&(s=e(e({},s),{},{_videoSrc:i(s._videoSrc)})),s===r.userData?r:e(e({},r),{},{userData:s})}));const a=[...s.values()];return a.forEach(n),this.graphs.set(t,{graph:o,files:a}),o},{assets:a}=t,l=e({},w(t,M));if(t.scene&&(l.scene=o(t.scene)),t.scenes&&(l.scenes=t.scenes.map(e=>this.row(e,"scene",o(e.scene)))),t.materialLibrary&&(l.materialLibrary=t.materialLibrary.map(e=>this.row(e,"material",o(e.material)))),t.prefabLibrary&&(l.prefabLibrary=t.prefabLibrary.map(e=>this.row(e,"snapshot",o(e.snapshot)))),null===(r=t.d)||void 0===r?void 0:r.chartBg){const r=t.d.chartBg,s=o({images:r.images,textures:[r]});l.d=e(e({},t.d),{},{chartBg:e(e({},s.textures[0]),s.images?{images:s.images}:{})})}return{document:l,assets:s,files:i}}};function K(e,t,r){var s,i,n,o;if(!t)return;R(t);const a=/* @__PURE__ */new Map,l=e=>{if(Array.isArray(e))return e.map(l);if("string"!=typeof e)return e;if(!Object.hasOwn(t,e)){if(/^assets\/(image|video)-[a-f0-9]{64}[.-]/.test(e))throw Error(`Missing media asset metadata: ${e}`);return e}return a.has(e)||a.set(e,_(t[e],r(e,t[e]))),a.get(e)},c=e=>{var t,r,s;for(const i of null!==(t=null==e?void 0:e.images)&&void 0!==t?t:[])i.url=l(i.url);for(const i of null!==(r=null==e?void 0:e.textures)&&void 0!==r?r:[])void 0!==(null===(s=i.userData)||void 0===s?void 0:s._videoSrc)&&(i.userData._videoSrc=l(i.userData._videoSrc))};c(e.scene);for(const d of null!==(s=e.scenes)&&void 0!==s?s:[])c(d.scene);for(const d of null!==(i=e.materialLibrary)&&void 0!==i?i:[])c(d.material);for(const d of null!==(n=e.prefabLibrary)&&void 0!==n?n:[])c(d.snapshot);(null===(o=e.d)||void 0===o?void 0:o.chartBg)&&c({images:e.d.chartBg.images,textures:[e.d.chartBg]})}var V="undefined"!=typeof crypto&&void 0!==crypto.subtle;function F(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/g,"").replace(/-----END PUBLIC KEY-----/g,"").replace(/\s/g,""),r=atob(t),s=new Uint8Array(r.length);for(let i=0;i<r.length;i++)s[i]=r.charCodeAt(i);return s.buffer}function Y(){return(Y=t(function*(e){return crypto.subtle.importKey("spki",F(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])})).apply(this,arguments)}var J="-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEU2vGIjpJQFRkGxVrw4gZL3dXm/1\nfrZBlUc8gjzam/VNZbT1swQSq/kLPmYH7ZykBvLzp7SpNdvOQ8rAqdSdvg==\n-----END PUBLIC KEY-----";var Q=V?function(e){return Y.apply(this,arguments)}(J):null,W=V?null:new Uint8Array(F(J)).slice(26);function q(e){return G.apply(this,arguments)}function G(){return(G=t(function*(e){let t;try{t=function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,s=atob(t+"=".repeat(r)),i=new Uint8Array(s.length);for(let n=0;n<s.length;n++)i[n]=s.charCodeAt(n);return i}(e)}catch(o){return null}if(t.length<=64)return null;const r=t.slice(0,t.length-64),s=t.slice(t.length-64);let i;try{if(V){const e=yield Q;i=yield crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},e,s,r)}else{const{p256:e}=yield import("@noble/curves/nist.js");i=e.verify(s,r,W,{lowS:!1})}}catch(a){return null}if(!i)return null;const n=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),s=!!(4&t),i=!!(8&t);if(-16&t||r&&(s||i))return null;let n,o=1;if(1&t){if(e.length<o+4)return null;n=36e5*((e[o]<<24|e[o+1]<<16|e[o+2]<<8|e[o+3])>>>0),o+=4}let a=null;if(!r){if(e.length<o+1)return null;let t=e[o++];if(i){if(e.length<o+1)return null;t=t<<8|e[o++]}if(!t||e.length!==o+3*t)return null;a=[];for(let r=0;r<t;r++){const t=e[o]<<16|e[o+1]<<8|e[o+2];a.push(t),o+=3}}return o!==e.length?null:{adcodes:a,expire:n,prefixMatch:s}}(r);return n?n.expire&&Date.now()>n.expire?null:n:null})).apply(this,arguments)}function H(e,t,r){return X.apply(this,arguments)}function X(){return(X=t(function*(e,t,r){const s=yield q(t);if(!(null==s?void 0:s.adcodes)||s.prefixMatch||"preview"===s.purpose||void 0!==r&&s.projectId!==r)return!1;const i=new Set(e),n=new Set(s.adcodes);return i.size>0&&i.size===n.size&&[...i].every(e=>n.has(e))})).apply(this,arguments)}function ee(e,t){return te.apply(this,arguments)}function te(){return(te=t(function*(e,t){const r=yield q(t);return!(!(null==r?void 0:r.adcodes)||r.prefixMatch||"preview"===r.purpose)&&r.adcodes.includes(e)})).apply(this,arguments)}var re=(e,t)=>{const r=se(e),s=se(t).map(function(e,t){return e^r[Math.floor(t%r.length)]}).join(",");return btoa(s)};function se(e){const t=[];let r=0;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296==(64512&i)&&s+1<e.length&&56320==(64512&e.charCodeAt(s+1))?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++s)),t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128)}return t}export{y as C,a as S,f as _,R as a,o as b,L as c,j as d,$ as f,d as g,c as h,Z as i,k as l,v as m,ee as n,_ as o,w as p,H as r,K as s,re as t,E as u,p as v,g as x,u as y};
package/dist/index.d.ts CHANGED
@@ -367,11 +367,12 @@ declare class Base_3 extends Camera {
367
367
  private prefabAssets;
368
368
  private prefabMaterials;
369
369
  private prefabOperations;
370
- /** Inspect SDK-enabled definitions without creating scene objects or resources. */
370
+ /** Inspect Prefab definitions without creating scene objects or resources. */
371
371
  getPrefabLibrary(): PrefabAsset[];
372
372
  /** Internal: Update definitions for future instances without rebuilding live content. */
373
373
  setPrefabLibrary(assets?: readonly PrefabAsset[], materials?: MaterialAsset[]): void;
374
- instantiatePrefab(keyOrAssetId: string, options?: InstantiatePrefabOptions): Promise<BaseObject>;
374
+ /** Instantiate by the unique asset name. */
375
+ instantiatePrefab(name: string, options?: InstantiatePrefabOptions): Promise<BaseObject>;
375
376
  private cancelPrefabOperations;
376
377
  constructor(options: BaseOptions);
377
378
  getMaterialGroup(group: string): Record<string, _THREE.Material<_THREE.MaterialEventMap>> | null;
@@ -4608,10 +4609,9 @@ declare type PointsInput_2 = Vector3[] | Vector2_2[] | number[][] | number[];
4608
4609
 
4609
4610
  export declare interface PrefabAsset {
4610
4611
  id: string;
4612
+ /** Nonempty, trimmed, project-unique name used for SDK instantiation. */
4611
4613
  name: string;
4612
4614
  revision: number;
4613
- /** Stable public SDK identifier. Omit for assets used only by the editor. */
4614
- sdkKey?: string;
4615
4615
  /** Legacy business templates own complete material snapshots, without promoting scene assets. */
4616
4616
  materialMode?: 'embedded';
4617
4617
  snapshot: Record<string, any>;
@@ -5267,9 +5267,10 @@ export declare class SceneManager extends Event_2 {
5267
5267
  private getSceneByType;
5268
5268
  /** Inspect saved definitions without creating or pinning runtime materials. */
5269
5269
  getMaterialLibrary(): MaterialAsset[];
5270
- /** SDK-enabled definitions stay unloaded until explicitly instantiated. */
5270
+ /** Prefab definitions stay unloaded until explicitly instantiated. */
5271
5271
  getPrefabLibrary(): PrefabAsset[];
5272
- instantiatePrefab(keyOrAssetId: string, options?: SceneInstantiatePrefabOptions): Promise< BaseObject>;
5272
+ /** Instantiate by the unique asset name. */
5273
+ instantiatePrefab(name: string, options?: SceneInstantiatePrefabOptions): Promise< BaseObject>;
5273
5274
  /**
5274
5275
  * Update a saved asset and transactionally rebuild each affected cached page.
5275
5276
  * Reacquire Base/Object handles after this call: replaced pages are disposed.
@@ -5956,7 +5957,7 @@ declare class UseMaterial extends PointerEvent_2 {
5956
5957
 
5957
5958
  declare type ValuesOf<T extends readonly any[]> = T[number];
5958
5959
 
5959
- export declare const VERSION = "0.33.20";
5960
+ export declare const VERSION = "0.33.21";
5960
5961
 
5961
5962
  declare interface Viewport {
5962
5963
  left: number;
@@ -5976,7 +5977,7 @@ export declare interface VisSceneDocument extends SceneDocumentMarker {
5976
5977
  scenes: SceneViewportDocument[];
5977
5978
  /** Schema 4: serializable definitions shared by explicit asset identity. */
5978
5979
  materialLibrary?: MaterialAsset[];
5979
- /** Reusable definitions. SDK-enabled assets are retained in deployment exports. */
5980
+ /** Reusable definitions retained in deployment exports and instantiated by name. */
5980
5981
  prefabLibrary?: PrefabAsset[];
5981
5982
  c?: Record<string, any>;
5982
5983
  d?: Record<string, any>;
@@ -5994,7 +5995,7 @@ export declare interface VisSceneManifest {
5994
5995
  materialLibrary?: MaterialAsset[];
5995
5996
  /** Manifest 5: media metadata keyed by native image URL. */
5996
5997
  assets?: MediaAssetManifest;
5997
- /** Reusable definitions. Only assets with sdkKey are available for SDK instantiation. */
5998
+ /** Reusable definitions, instantiated by their unique asset names. */
5998
5999
  prefabLibrary?: PrefabAsset[];
5999
6000
  c?: Record<string, any>;
6000
6001
  d?: Record<string, any>;