vis-core 0.33.17 → 0.33.18

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.
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n as r,r as s,t as i}from"./sha2-DroCzeNH.js";function n(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 a,o,l,c=new class{constructor(t=32,r=67108864){e(this,"pending",/* @__PURE__ */new Map),e(this,"values",/* @__PURE__ */new Map),e(this,"bytes",0),e(this,"maxEntries",void 0),e(this,"maxBytes",void 0),this.maxEntries=t,this.maxBytes=r}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)}},d=e=>!!/\.(gzip|gz)(?:[?#]|$)/i.test(e),u=(a=s(function*(e,t,r=d){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 a;yield null===(a=s.body)||void 0===a?void 0:a.cancel(c)}catch(u){}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 o=yield n.text();return{json:JSON.parse(o),bytes:2*o.length}}),function(e,t){return a.apply(this,arguments)}),p=(o=s(function*(e,t,r=d,s){try{var i,n;const a=null!==(i=null==s||null===(n=s.resolveURL)||void 0===n?void 0:n.call(s,e))&&void 0!==i?i:e,o=((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}})(a,s),l=()=>u(a,t,()=>r(e)),d=(yield o.enabled?c.load(o.key,l):l()).json;return{res:o.enabled&&o.clone?structuredClone(d):d,err:void 0}}catch(a){return{res:void 0,err:a}}}),function(e,t){return o.apply(this,arguments)}),f=/^(?:[a-z]+:)?\/\//i,h=(l=s(function*(e,t){const{res:r,err:s}=yield p(((e,t="")=>f.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(s)throw s;return r}),function(e,t){return l.apply(this,arguments)}),y=e=>"string"==typeof e&&!!e&&!/[:\\?#\0]/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e);function m(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 g(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)||!y(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||!["province","city","district"].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||!["province","city","district"].includes(a.scope.maxLevel)||!a.templates||"object"!=typeof a.templates||Array.isArray(a.templates)||Object.entries(a.templates).some(([e,t])=>!["province","city","district"].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 v(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 w(e){return e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function b(e){return A.apply(this,arguments)}function A(){return A=s(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("")}),A.apply(this,arguments)}function x(e,t){return E.apply(this,arguments)}function E(){return(E=s(function*(e,t){if(t.length!==e.bytes||(yield b(t))!==e.sha256)throw Error(`资源校验失败:${e.path}`)})).apply(this,arguments)}function S(e,r){var s,i,n,a;if(!r)return e;if(!e)return structuredClone(r);const o=structuredClone(e),l=new Map(o.entries.map(e=>[e.id,e])),c=new Map(o.entries.flatMap(e=>e.sources.map(t=>[t,e.sha256])));for(const t of r.entries){for(const r of t.sources)if(c.has(r)&&c.get(r)!==t.sha256)throw Error(`资源地址存在不同内容:${r}。请修改资源地址或使用“打开项目”导入。`);const e=l.get(t.id);if(e)e.sources=[.../* @__PURE__ */new Set([...e.sources,...t.sources])];else{const e=structuredClone(t);o.entries.push(e),l.set(e.id,e)}for(const r of t.sources)c.set(r,t.sha256)}o.regions=t(t({},e.regions),r.regions),o.declaredSources=[.../* @__PURE__ */new Set([...null!==(s=e.declaredSources)&&void 0!==s?s:[],...null!==(i=r.declaredSources)&&void 0!==i?i:[]])];const d=[.../* @__PURE__ */new Set([...null!==(n=e.externalSources)&&void 0!==n?n:[],...null!==(a=r.externalSources)&&void 0!==a?a:[]])].filter(e=>!c.has(e));return d.length?o.externalSources=d:delete o.externalSources,g(o),o}var I=class{constructor(t,s="",n=!0){var a;e(this,"sources",/* @__PURE__ */new Map),e(this,"resolved",/* @__PURE__ */new Map),e(this,"externals",/* @__PURE__ */new Map),e(this,"catalog",void 0),e(this,"strict",void 0),e(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 s=this.resolved.get(t.id);if(!s){if(void 0!==t.data){const e=w(t.data);if(e.byteLength!==t.bytes||r(i(e))!==t.sha256)throw Error(`资源校验失败:${t.path}`);s=URL.createObjectURL(new Blob([e],{type:"gzip"===t.encoding?"application/gzip":t.mimeType}))}else{const e=this.catalog.baseUrl;if(!e)throw Error(`资源缺少文件内容或部署地址:${t.path}`);const r="undefined"==typeof location?"https://bundle.invalid/":location.href;s=new URL(t.path,new URL(e,r)).href}this.resolved.set(t.id,s)}return s}),this.catalog=t,this.strict=n,g(t);const o=(e,t)=>{const r=this.sources.get(e);if(r&&r.id!==t.id)throw Error(`资源地址重复:${e}`);this.sources.set(e,t)},l=e=>/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)?[e,...s?[s+e]:[]]:[e,s+e,`${s.replace(/\/$/,"")}/${e.replace(/^\//,"")}`,`/${e.replace(/^\//,"")}`];for(const e of t.entries)for(const t of[...e.sources,`asset://${e.id}`])for(const r of l(t))o(r,e);for(const e of null!==(a=t.externalSources)&&void 0!==a?a:[]){const t=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)?e:`${s.replace(/\/$/,"")}/${e.replace(/^\//,"")}`;for(const r of l(e))this.externals.set(r,t)}}dispose(){for(const e of this.resolved.values())e.startsWith("blob:")&&URL.revokeObjectURL(e);this.resolved.clear()}},j=["format","schemaVersion","scenes","assets"];function $(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 B(e,t){return U.apply(this,arguments)}function U(){return(U=s(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 k(e){return O.apply(this,arguments)}function O(){return O=s(function*(e,r="project.zip"){var i;const[{default:a},o,{createTextureFile:l},{SCENE_DOCUMENT_FORMAT:c},{resolveRuntimeImages:d}]=yield Promise.all([import("jszip"),import("./validation-BGRVMCXQ.js").then(e=>e.r),import("./dist-CurDDdRW.js").then(e=>e.B),import("./schema-B2o51seO.js").then(e=>e.c),import("./runtimeImages-BFvQYajK.js").then(e=>e.a)]),u=o;let p;try{p=yield a.loadAsync(e instanceof Blob?yield e.arrayBuffer():e)}catch(N){throw new Error(`无法解压 ZIP 文件 ${r}`,{cause:N})}const f=Object.values(p.files).filter(e=>!e.dir&&/(^|\/)manifest\.json$/.test(e.name)&&!e.name.startsWith("__MACOSX/")),h=null!==(i=p.file("manifest.json"))&&void 0!==i?i:1===f.length?f[0]:void 0;if(!h)throw new Error(f.length>1?"ZIP 中有多个 manifest.json,无法确定要导入的项目":"ZIP 中缺少 manifest.json,请选择平台导出的场景分包 ZIP");const y=h.name.slice(0,-13),m=yield B(new Blob([yield h.async("uint8array")]),h.name);u.assertSceneManifest(m);const g=function(){var e=s(function*(e){if(/[:\\?#\0]/.test(e)||e.split("/").some(e=>!e||"."===e||".."===e))throw new Error(`ZIP 内文件路径无效:${e}`);const t=p.file(y+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 t of m.scenes){var w,b;const e=yield B(yield g(t.source),t.source);if(!(null===(w=e.scene)||void 0===w?void 0:w.object)||e.id!==t.id||(null===(b=e.vis)||void 0===b?void 0:b.type)!==t.vis.type)throw new Error(`场景文件与 manifest 不匹配:${t.source}`);v.push(e)}const{format:A,schemaVersion:E,scenes:S,assets:I}=m,$=t(t({},n(m,j)),{},{format:c,schemaVersion:6,scenes:v});if(u.assertRuntimeSceneDocument($),$.runtimeAssets){delete $.runtimeAssets.baseUrl;for(const e of $.runtimeAssets.entries){const t=new Uint8Array(yield(yield g(e.path)).arrayBuffer());yield x(e,t),e.data=t.buffer}}const U=/* @__PURE__ */new Map,k={png:"image/png",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",bmp:"image/bmp"};for(const t of Object.keys(null!=I?I:{})){var O,T,L;const e=new Uint8Array(yield(yield g(t)).arrayBuffer()),r=null!==(O=null!==(T=null==I||null===(L=I[t])||void 0===L?void 0:L.mimeType)&&void 0!==T?T:k[t.split(".").pop()])&&void 0!==O?O:"application/octet-stream";U.set(t,l(e.buffer,r))}return d($,I,e=>U.get(e)),$}),O.apply(this,arguments)}var T=["assets"],L=e=>r(i(new Uint8Array(e))),N={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array},M={"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"},z=e=>"string"==typeof e&&/^assets\/[\w.-]+$/.test(e)&&!e.includes("..");function P(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(!z(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(N,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%N[e.type].BYTES_PER_ELEMENT)throw Error(`Invalid pixel asset: ${t}`)}else if(void 0!==r.pixels)throw Error(`Unexpected pixel metadata: ${t}`)}}}function C(e,r){if(r instanceof ArrayBuffer&&(r.byteLength!==e.bytes||L(r)!==e.sha256))throw Error("Media resource checksum mismatch");return"pixels"===e.kind?t(t({},e.pixels),{},{encoding:"binary",sha256:e.sha256,data:r}):{encoding:"file",kind:e.kind,mimeType:e.mimeType,sha256:e.sha256,data:r}}var D=class{constructor(){e(this,"payloads",/* @__PURE__ */new WeakMap),e(this,"graphs",/* @__PURE__ */new WeakMap),e(this,"rows",/* @__PURE__ */new WeakMap)}row(e,r,s){const i=this.rows.get(e);if(i&&i.graph===s)return i.row;const n=t(t({},e),{},{[r]:s});return this.rows.set(e,{graph:s,row:n}),n}writePayload(e){var r;if("string"==typeof e){const t=/^data:((?:image|video)\/[^;,]+);base64,([\s\S]*)$/i.exec(e);if(!t)return;const r=w(t[2]).buffer;e={encoding:"file",kind:t[1].toLowerCase().startsWith("video/")?"video":"image",mimeType:t[1],sha256:L(r),data:r}}if(!e||"object"!=typeof e)return;const s=this.payloads.get(e);if(s)return s;let i,n;if("file"===e.encoding){if(!(e.data instanceof ArrayBuffer))throw Error("Media export requires owned file bytes");if(i=e.data,n={kind:e.kind,mimeType:e.mimeType,sha256:L(i),bytes:i.byteLength},n.sha256!==e.sha256)throw Error("Media resource checksum mismatch")}else{if(!("binary"===e.encoding||Object.hasOwn(N,e.type)&&(Array.isArray(e.data)||ArrayBuffer.isView(e.data))))return;{const r=N[e.type];if(!r)throw Error("Invalid pixel array type");if("binary"===e.encoding){if(!(e.data instanceof ArrayBuffer)||L(e.data)!==e.sha256)throw Error("Invalid binary pixel resource");i=e.data}else{const t=Array.isArray(e.data)?new r(e.data):e.data;i=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}n={kind:"pixels",mimeType:"application/octet-stream",sha256:L(i),bytes:i.byteLength,pixels:t({type:e.type,width:e.width,height:e.height},void 0===e.depth?{}:{depth:e.depth})}}}const a=n.pixels?"-"+L((new TextEncoder).encode(JSON.stringify(n.pixels)).buffer).slice(0,16):"",o="pixels"===n.kind?"bin":null!==(r=M[n.mimeType])&&void 0!==r?r:"bin",l=`assets/${"video"===n.kind?"video":"image"}-${n.sha256}${a}.${o}`;P({[l]:n});const c={path:l,info:n,file:{data:new Uint8Array(i),mimeType:n.mimeType}};return this.payloads.set(e,c),c}prepare(e){var r;const s={},i={};if(void 0!==e._resourcePool||void 0!==e.imageAssets)throw Error("Import legacy resources in editor-platform");const a=e=>{s[e.path]=e.info,i[e.path]=e.file},o=e=>{if(!e)return e;const r=this.graphs.get(e);if(r)return r.files.forEach(a),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},n=t({},e);e.images&&(n.images=e.images.map(e=>t(t({},e),{},{url:i(e.url)}))),e.textures&&(n.textures=e.textures.map(r=>{let s=r.userData;if(!s)return r;if(void 0!==s._dataTexBase64||"number"==typeof s._videoSrc||void 0!==e._texDataPool)throw Error("Import legacy texture data in editor-platform");return void 0!==s._videoSrc&&(s=t(t({},s),{},{_videoSrc:i(s._videoSrc)})),s===r.userData?r:t(t({},r),{},{userData:s})}));const o=[...s.values()];return o.forEach(a),this.graphs.set(e,{graph:n,files:o}),n},{assets:l}=e,c=t({},n(e,T));if(e.scene&&(c.scene=o(e.scene)),e.scenes&&(c.scenes=e.scenes.map(e=>this.row(e,"scene",o(e.scene)))),e.materialLibrary&&(c.materialLibrary=e.materialLibrary.map(e=>this.row(e,"material",o(e.material)))),e.prefabLibrary&&(c.prefabLibrary=e.prefabLibrary.map(e=>this.row(e,"snapshot",o(e.snapshot)))),null===(r=e.d)||void 0===r?void 0:r.chartBg){const r=e.d.chartBg,s=o({images:r.images,textures:[r]});c.d=t(t({},e.d),{},{chartBg:t(t({},s.textures[0]),s.images?{images:s.images}:{})})}return{document:c,assets:s,files:i}}};function _(e,t,r){var s,i,n,a;if(!t)return;P(t);const o=/* @__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 o.has(e)||o.set(e,C(t[e],r(e,t[e]))),o.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===(a=e.d)||void 0===a?void 0:a.chartBg)&&c({images:e.d.chartBg.images,textures:[e.d.chartBg]})}var R="undefined"!=typeof crypto&&void 0!==crypto.subtle;function Z(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 K(){return(K=s(function*(e){return crypto.subtle.importKey("spki",Z(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])})).apply(this,arguments)}var V="-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEU2vGIjpJQFRkGxVrw4gZL3dXm/1\nfrZBlUc8gjzam/VNZbT1swQSq/kLPmYH7ZykBvLzp7SpNdvOQ8rAqdSdvg==\n-----END PUBLIC KEY-----";var F=R?function(e){return K.apply(this,arguments)}(V):null,W=R?null:new Uint8Array(Z(V)).slice(26);function Y(e){return J.apply(this,arguments)}function J(){return(J=s(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(a){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(R){const e=yield F;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(o){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,a=1;if(1&t){if(e.length<a+4)return null;n=36e5*((e[a]<<24|e[a+1]<<16|e[a+2]<<8|e[a+3])>>>0),a+=4}let o=null;if(!r){if(e.length<a+1)return null;let t=e[a++];if(i){if(e.length<a+1)return null;t=t<<8|e[a++]}if(!t||e.length!==a+3*t)return null;o=[];for(let r=0;r<t;r++){const t=e[a]<<16|e[a+1]<<8|e[a+2];o.push(t),a+=3}}return a!==e.length?null:{adcodes:o,expire:n,prefixMatch:s}}(r);return n?n.expire&&Date.now()>n.expire?null:n:null})).apply(this,arguments)}function Q(e,t,r){return q.apply(this,arguments)}function q(){return(q=s(function*(e,t,r){const s=yield Y(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 G(e,t){return H.apply(this,arguments)}function H(){return(H=s(function*(e,t){const r=yield Y(t);return!(!(null==r?void 0:r.adcodes)||r.prefixMatch||"preview"===r.purpose)&&r.adcodes.includes(e)})).apply(this,arguments)}var X=(e,t)=>{const r=ee(e),s=ee(t).map(function(e,t){return e^r[Math.floor(t%r.length)]}).join(",");return btoa(s)};function ee(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{x as _,P as a,h as b,k as c,m as d,g as f,S as g,v as h,D as i,$ as l,w as m,G as n,C as o,b as p,Q as r,_ as s,X as t,I as u,d as v,n as x,p as y};
package/dist/index.d.ts CHANGED
@@ -242,7 +242,7 @@ declare class Area extends GroupObject {
242
242
  }
243
243
 
244
244
  /** Validation is read-only and does not materialize or allocate runtime resources. */
245
- export declare function assertProjectMaterials(document: Pick<VisSceneDocument, 'schemaVersion' | 'scenes' | 'materialLibrary' | 'prefabLibrary' | '_resourcePool'>): void;
245
+ export declare function assertProjectMaterials(document: Pick<VisSceneDocument, 'schemaVersion' | 'scenes' | 'materialLibrary' | 'prefabLibrary'>): void;
246
246
 
247
247
  /** vis-core 的运行时入口只接受编辑平台导出的完整场景文档。 */
248
248
  export declare function assertRuntimeSceneDocument(value: unknown): asserts value is VisSceneDocument & Record<string, any>;
@@ -1858,6 +1858,8 @@ declare class CityPlane extends MeshObject {
1858
1858
  rebuildFromScene(): void;
1859
1859
  }
1860
1860
 
1861
+ export declare function cloneSceneDocument<T extends VisSceneDocument>(document: T): T;
1862
+
1861
1863
  /** Duplicate scene-owned definitions, while retaining references to project assets. */
1862
1864
  export declare function cloneSceneMaterials(document: VisSceneDocument, sourceId: string, newSceneId: string): {
1863
1865
  scene: SceneViewportDocument;
@@ -2505,12 +2507,6 @@ declare class EventDispatcher {
2505
2507
  dispatchEvent(event: DispatcherEvent): void;
2506
2508
  }
2507
2509
 
2508
- /** Internal: Consume an exclusively owned import copy; pooled slots still get independent payloads. */
2509
- export declare function expandOwnedSceneDocumentResources<T extends VisSceneDocument>(expanded: T): T;
2510
-
2511
- /** Expand at the editor import boundary so independently edited scenes own their data. */
2512
- export declare function expandSceneDocumentResources<T extends VisSceneDocument>(document: T): T;
2513
-
2514
2510
  /** Expand renderer pools, including snapshots retained as prefab baselines. */
2515
2511
  export declare function expandStructureSnapshot<T extends Record<string, any>>(input: T): T;
2516
2512
 
@@ -3005,6 +3001,7 @@ declare class Map_4 extends Base_3 {
3005
3001
  private authoredCameraPose?;
3006
3002
  private cameraAngleOverrides?;
3007
3003
  private bundledMapSwitchKey?;
3004
+ private navigationAssets?;
3008
3005
  setRuntimeAssets(catalog?: RuntimeAssetCatalog): void;
3009
3006
  private requireMapAuthorization;
3010
3007
  protected authorizeSceneOptions(options: Record<string, any>): Promise<void>;
@@ -3263,6 +3260,14 @@ declare interface MapLabelStyle {
3263
3260
  fontWeight?: string;
3264
3261
  }
3265
3262
 
3263
+ export declare type MapNavigation = {
3264
+ mode: 'static';
3265
+ } | {
3266
+ mode: 'dynamic';
3267
+ scope: MapExportScope;
3268
+ templates: Partial<Record<MapExportScope['maxLevel'], string>>;
3269
+ };
3270
+
3266
3271
  declare interface MapOptions extends BaseOptions {
3267
3272
  adcode: number;
3268
3273
  mapData?: MapBoundaryData;
@@ -3494,6 +3499,22 @@ declare type MatrixState = {
3494
3499
  matrixAutoUpdate?: boolean;
3495
3500
  };
3496
3501
 
3502
+ /** File metadata belongs to the manifest, never to a Three image URL. */
3503
+ declare interface MediaAssetInfo {
3504
+ sha256: string;
3505
+ bytes: number;
3506
+ mimeType: string;
3507
+ kind: 'image' | 'hdr' | 'tga' | 'video' | 'pixels';
3508
+ pixels?: {
3509
+ type: string;
3510
+ width: number;
3511
+ height: number;
3512
+ depth?: number;
3513
+ };
3514
+ }
3515
+
3516
+ declare type MediaAssetManifest = Record<string, MediaAssetInfo>;
3517
+
3497
3518
  /** Save author edits without promoting page-local region textures into a shared definition. */
3498
3519
  export declare function mergeAuthoredMaterialDefinition(savedDefinition: Record<string, any>, runtimeDefinition: Record<string, any>, options?: {
3499
3520
  editedProperties?: string[];
@@ -4091,11 +4112,6 @@ declare class OrigonPages<T = any> {
4091
4112
  dispose(): void;
4092
4113
  }
4093
4114
 
4094
- /** Pack an export copy only; preserve the editor's independent scene snapshots. */
4095
- export declare function packSceneDocumentResources<T extends VisSceneDocument>(document: T, options?: {
4096
- encodePixels?: boolean;
4097
- }): T;
4098
-
4099
4115
  /** Page identities are independent of Three's 32 rendering layers. */
4100
4116
  declare class Pages {
4101
4117
  private readonly indices;
@@ -4922,6 +4938,8 @@ declare interface RestoreBaseObjectOptions {
4922
4938
  strictResourceReuse?: boolean;
4923
4939
  }
4924
4940
 
4941
+ export declare function restoreRuntimeImageFiles(value: any, sources: MediaAssetManifest | undefined, files: Record<string, RuntimeImageAsset>): void;
4942
+
4925
4943
  /**
4926
4944
  * Live resources whose serialized definitions the caller has already verified.
4927
4945
  * Reuse is explicit: equal UUIDs alone do not establish equal definitions.
@@ -4957,14 +4975,16 @@ export declare interface RuntimeAsset {
4957
4975
  encoding: 'identity' | 'gzip';
4958
4976
  bytes: number;
4959
4977
  sha256: string;
4960
- /** Compressed/original file bytes, base64 encoded for project persistence. */
4961
- data?: string;
4978
+ /** Owned file bytes; legacy encoded catalogs must be imported by the platform. */
4979
+ data?: ArrayBuffer;
4962
4980
  }
4963
4981
 
4964
4982
  export declare interface RuntimeAssetCatalog {
4965
4983
  version: 1;
4966
4984
  entries: RuntimeAsset[];
4967
4985
  scope?: MapExportScope;
4986
+ /** Explicit delivery contract; omitted only in older packages. */
4987
+ mapNavigation?: MapNavigation;
4968
4988
  /** Enumerated interaction targets, including regions never opened in the editor. */
4969
4989
  regions?: Record<string, number[]>;
4970
4990
  declaredSources?: string[];
@@ -4978,23 +4998,18 @@ export declare interface RuntimeAssetCatalog {
4978
4998
  baseUrl?: string;
4979
4999
  }
4980
5000
 
4981
- /** Only ordinary encoded images are externalized. Typed pixel data, videos and
4982
- * custom payloads keep their original serialization contract. */
4983
- declare interface RuntimeImageAsset {
5001
+ export declare interface RuntimeImageAsset {
4984
5002
  data: Uint8Array;
4985
5003
  mimeType: string;
4986
5004
  }
4987
5005
 
4988
5006
  export declare const SCENE_DOCUMENT_FORMAT: "vis-scene";
4989
5007
 
4990
- /** Schema 6 extends the document pool to authored material dependencies. */
4991
- export declare const SCENE_DOCUMENT_RESOURCE_POOL_SCHEMA_VERSION: 6;
4992
-
4993
5008
  export declare const SCENE_DOCUMENT_SCHEMA_VERSION: 6;
4994
5009
 
4995
5010
  export declare const SCENE_MANIFEST_FORMAT: "vis-scene-manifest";
4996
5011
 
4997
- export declare const SCENE_MANIFEST_SCHEMA_VERSION: 4;
5012
+ export declare const SCENE_MANIFEST_SCHEMA_VERSION: 5;
4998
5013
 
4999
5014
  export declare interface SceneBackInteraction {
5000
5015
  trigger: 'click' | 'clickOutside';
@@ -5098,7 +5113,6 @@ export declare class SceneManager extends Event_2 {
5098
5113
  private identityTrackedScenes;
5099
5114
  private prefabOperations;
5100
5115
  private transactionCacheDepth;
5101
- private materialLibraryResources?;
5102
5116
  private invalidatePendingOperations;
5103
5117
  private assertGeneration;
5104
5118
  private debugInteraction;
@@ -5140,7 +5154,7 @@ export declare class SceneManager extends Event_2 {
5140
5154
  private playTransition;
5141
5155
  /** 更新可编辑文档,并释放已经不属于文档的非活动场景实例。 */
5142
5156
  setDocument(document: VisSceneDocument): void;
5143
- /** Standalone material consumers cannot retain document-level pool references. */
5157
+ /** Standalone material consumers own independent definitions. */
5144
5158
  private resolvedMaterialLibrary;
5145
5159
  /** Keep scene payloads lazy, while independent material APIs own a resolved catalog. */
5146
5160
  private ownDocument;
@@ -5448,7 +5462,7 @@ declare type SceneSnapshot = Object3DJSON & {
5448
5462
  /** File transport accepts ZIP bundles; in-memory documents remain available for editor integration. */
5449
5463
  export declare type SceneSource = VisSceneDocument | VisSceneManifest | string | SceneBundleBinary;
5450
5464
 
5451
- export declare type SceneStructureGraphKey = 'materialAliases' | 'shapes' | '_sharedOptionsPool' | '_texDataPool';
5465
+ export declare type SceneStructureGraphKey = 'materialAliases' | 'shapes' | '_sharedOptionsPool';
5452
5466
 
5453
5467
  /** Metadata is part of an owned structure transaction, never a scalar runtime patch. */
5454
5468
  export declare interface SceneStructureObjectPatch {
@@ -5640,14 +5654,11 @@ declare class SphereShadow extends MeshObject {
5640
5654
  rebuildFromScene(): void;
5641
5655
  }
5642
5656
 
5643
- /**
5644
- * Creates independently fetchable scene JSON values. Manifest 3 owns shared
5645
- * payloads so scene and catalog copies do not multiply the deployed bytes.
5646
- */
5657
+ /** Create independently fetchable scenes; manifest 5 owns file metadata while
5658
+ * each native Three image URL points to one deduplicated media file. */
5647
5659
  export declare function splitSceneDocument(document: VisSceneDocument, options?: {
5648
5660
  sceneDirectory?: string;
5649
5661
  extension?: '.json' | '.json.gz';
5650
- externalizeImages?: boolean;
5651
5662
  omitEditorAssets?: boolean;
5652
5663
  }): SplitSceneDocumentBundle;
5653
5664
 
@@ -5941,7 +5952,7 @@ declare class UseMaterial extends PointerEvent_2 {
5941
5952
 
5942
5953
  declare type ValuesOf<T extends readonly any[]> = T[number];
5943
5954
 
5944
- export declare const VERSION = "0.33.17";
5955
+ export declare const VERSION = "0.33.18";
5945
5956
 
5946
5957
  declare interface Viewport {
5947
5958
  left: number;
@@ -5959,8 +5970,6 @@ export declare interface VisSceneDocument extends SceneDocumentMarker {
5959
5970
  runtimeAssets?: RuntimeAssetCatalog;
5960
5971
  entrySceneId: string;
5961
5972
  scenes: SceneViewportDocument[];
5962
- /** Schema 3: scene payloads; schema 6 also shares material-library payloads. */
5963
- _resourcePool?: any[];
5964
5973
  /** Schema 4: serializable definitions shared by explicit asset identity. */
5965
5974
  materialLibrary?: MaterialAsset[];
5966
5975
  /** Reusable definitions. SDK-enabled assets are retained in deployment exports. */
@@ -5973,16 +5982,14 @@ export declare interface VisSceneDocument extends SceneDocumentMarker {
5973
5982
 
5974
5983
  export declare interface VisSceneManifest {
5975
5984
  format: typeof SCENE_MANIFEST_FORMAT;
5976
- schemaVersion: 1 | 2 | 3 | typeof SCENE_MANIFEST_SCHEMA_VERSION;
5985
+ schemaVersion: typeof SCENE_MANIFEST_SCHEMA_VERSION;
5977
5986
  /** Manifest 4: complete static dependencies, shared by every scene. */
5978
5987
  runtimeAssets?: RuntimeAssetCatalog;
5979
5988
  entrySceneId: string;
5980
5989
  scenes: SceneManifestEntry[];
5981
5990
  materialLibrary?: MaterialAsset[];
5982
- /** Manifest 3: payloads referenced by the material catalog and scene files. */
5983
- _resourcePool?: any[];
5984
- /** Externalized image files, relative to the manifest URL. */
5985
- imageAssets?: string[];
5991
+ /** Manifest 5: media metadata keyed by native image URL. */
5992
+ assets?: MediaAssetManifest;
5986
5993
  /** Reusable definitions. Only assets with sdkKey are available for SDK instantiation. */
5987
5994
  prefabLibrary?: PrefabAsset[];
5988
5995
  c?: Record<string, any>;