@aceshooting/lyra-ui 30.7.0 → 30.9.0
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/CHANGELOG.md +28 -0
- package/dist/components/charts/chart/box-plot-loader.js +1 -1
- package/dist/components/charts/chart/chart-core-loader.js +1 -1
- package/dist/components/charts/chart/chart-feature-loader.js +1 -1
- package/dist/components/charts/chart-3d/chart-3d-engine.js +1 -1
- package/dist/components/conversation/code-block/code-loader.js +1 -1
- package/dist/components/conversation/code-block/shiki-oniguruma.js +1 -1
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/markdown/katex-loader.js +1 -1
- package/dist/components/conversation/markdown/markdown-loader.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +30 -5
- package/dist/components/layout/dock-panel/dock-panel.class.js +8 -5
- package/dist/components/layout/dock-panel/dock-panel.styles.js +1 -1
- package/dist/components/media/flag/flag-peer-bulk-standard.js +1 -1
- package/dist/components/media/flag/flag-peer-bulk.js +1 -1
- package/dist/components/media/flag/flag-peer.js +1 -1
- package/dist/components/media/map/map-feature-loader.js +1 -1
- package/dist/components/media/map/map-loader.js +1 -1
- package/dist/components/media/map/map-scene-elevated-lines.js +36 -0
- package/dist/components/media/map/map-scene-line-encoding.js +1 -0
- package/dist/components/media/map/map-scene-lines.js +1 -1
- package/dist/components/media/map/map-scene-render-controller.js +1 -1
- package/dist/components/media/map/map-scene-types.d.ts +10 -5
- package/dist/components/media/map/map.class.d.ts +3 -3
- package/dist/components/media/map/map.class.js +4 -4
- package/dist/components/media/qr-code/qr-code-loader.js +1 -1
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
- package/dist/components/retrieval/graph/graph-engine-adapter.js +1 -1
- package/dist/components/retrieval/graph/graph-loader.js +1 -1
- package/dist/components/utility/icon/dompurify-loader.js +1 -1
- package/dist/components/viewers/calendar-viewer/calendar-loader.js +1 -1
- package/dist/components/viewers/docx-viewer/docx-loader.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-loader.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
- package/dist/components/viewers/ebook-viewer/epub-unload-guard.js +1 -0
- package/dist/components/viewers/email-viewer/email-loader.js +1 -1
- package/dist/components/viewers/html-viewer/dompurify-loader.js +1 -1
- package/dist/components/viewers/model-viewer/model-viewer-loader.js +1 -1
- package/dist/components/viewers/notebook-viewer/dompurify-loader.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
- package/dist/components/viewers/pptx-viewer/pptx-loader.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-loader.js +1 -1
- package/dist/components/viewers/svg-viewer/dompurify-loader.js +1 -1
- package/dist/internal/dompurify-loader.js +1 -1
- package/dist/internal/locale-loaders.generated.js +1 -1
- package/dist/internal/map-custom-layer-attachment.js +1 -0
- package/dist/internal/map-custom-layer-controller.js +1 -0
- package/dist/internal/map-custom-layer-types.d.ts +63 -0
- package/dist/internal/map-scene-layer-runtime.js +1 -0
- package/dist/internal/media-panorama.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/papaparse-loader.js +1 -1
- package/dist/map-custom-layers.d.ts +16 -0
- package/dist/map-custom-layers.js +1 -0
- package/dist/theme/theme.js +1 -1
- package/dist/theme-core.css +1 -0
- package/dist/utilities/scoped-registry.js +1 -1
- package/llms/components/lr-dock-panel.md +23 -8
- package/llms/components/lr-map.md +93 -7
- package/llms/peers.md +2 -2
- package/llms/shared/ai-and-peers.md +34 -0
- package/llms/shared/imports-and-registration.md +2 -0
- package/llms/shared/styles-and-tokens.md +47 -1
- package/llms/shared/testing-and-utilities.md +77 -0
- package/llms/shared.md +160 -1
- package/package.json +16 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const QR_CODE_PEER_WARNING_KEY="lyra-qr-code-peer-unavailable",QR_CODE_PEER_WARNING="<lr-qr-code> could not load its optional qrcode peer.";function isQrCodeApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"create"in value&&typeof value.create=="function"}const qrCode=createOptionalPeerLoader({load:()=>import("qrcode"),isCapability:candidate=>{try{return isQrCodeApi(candidate)}catch{return!1}},warningKey:QR_CODE_PEER_WARNING_KEY,warning:QR_CODE_PEER_WARNING});function loadQrCode(importQrCode){return qrCode.loadWith(importQrCode)}function loadQrCodeCached(){return qrCode.get()}function clearQrCodeCache(){qrCode.clear()}export{clearQrCodeCache,loadQrCode,loadQrCodeCached};
|
|
1
|
+
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const QR_CODE_PEER_WARNING_KEY="lyra-qr-code-peer-unavailable",QR_CODE_PEER_WARNING="<lr-qr-code> could not load its optional qrcode peer.";function isQrCodeApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"create"in value&&typeof value.create=="function"}const qrCode=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("qrcode")}catch(e){throw e}})(),isCapability:candidate=>{try{return isQrCodeApi(candidate)}catch{return!1}},warningKey:QR_CODE_PEER_WARNING_KEY,warning:QR_CODE_PEER_WARNING});function loadQrCode(importQrCode){return qrCode.loadWith(importQrCode)}function loadQrCodeCached(){return qrCode.get()}function clearQrCodeCache(){qrCode.clear()}export{clearQrCodeCache,loadQrCode,loadQrCodeCached};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{Engine3dSelection,engine3dFailureReason,webgl2Available}from"../../../internal/engine-3d.js";import{resolveCanvasColor}from"../../../internal/canvas-color.js";import{finiteRange}from"../../../internal/numbers.js";import{tag}from"../../../internal/prefix.js";import{isAccessibilityVisible}from"../../../internal/accessibility-visibility.js";const embeddingPointsLoader=createEngine3dLoader({entry:"points",tag:tag("embedding-explorer"),load:()=>import("@aceshooting/lyra-3d/points")}),embeddingEngineEnvironment={available:document=>webgl2Available(()=>document.createElement("canvas"))};class EmbeddingEngineController{constructor(host,changed,fallback,pick){this.host=host,this.changed=changed,this.fallback=fallback,this.pick=pick,this.selection=new Engine3dSelection(!0),this.notice=null,this.loading=!1,this.ready=!1,this.software=!1,this.generation=0,this.revision=0,this.rows=null,this.container=null,this.intersecting=!1,this.pending=!1,this.attempted=!1,this.preference="builtin",this.sourceMode=!1,this.mediaCleanup=[],this.hover=-1,this.selected=-1,this.focus=-1}releaseEngine(){this.generation++,this.observer?.disconnect(),this.observer=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.intersecting=!1,this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.styleObserver?.disconnect(),this.styleObserver=void 0;for(const cleanup of this.mediaCleanup)cleanup();this.mediaCleanup=[];const engine=this.engine;this.engine=void 0,this.ready=this.loading=this.pending=!1,this.software=!1,this.hover=-1,engine?.dispose()}invalidate(){this.releaseEngine(),this.attempted=!1,this.selection.prefer(this.preference),this.notice=null}disconnect(){this.invalidate(),this.container=null,this.rows=null}update(preference,rows,sourceMode,container,selected,focus){if((preference!==this.preference||rows!==this.rows||sourceMode!==this.sourceMode||container!==this.container)&&(this.invalidate(),this.preference=preference,this.rows=rows,this.sourceMode=sourceMode,this.container=container,this.selection.prefer(preference),this.notice=null),this.selected=selected,this.focus=focus,preference!=="webgl"||!this.host.isConnected)return;if(sourceMode){this.attempted||(this.attempted=!0,this.fail("unsupported"));return}if(!rows?.count||!container)return;if(this.engine&&this.ready){try{this.engine.setStyle(this.style()),this.syncState()}catch{this.fail("error")}return}if(this.pending||this.attempted||this.selection.renderer!=="webgl"||this.observer||this.eligibility)return;const view=this.host.ownerDocument.defaultView,generation=this.generation;this.intersecting=view?.IntersectionObserver===void 0;const admit=()=>{generation!==this.generation||this.pending||this.attempted||!this.intersecting||!isAccessibilityVisible(this.host)||(this.observer?.disconnect(),this.observer=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.start())};if(view?.IntersectionObserver&&(this.observer=new view.IntersectionObserver(entries=>{if(generation===this.generation){for(const entry of entries)entry.target===container&&(this.intersecting=entry.isIntersecting);admit()}}),this.observer.observe(container)),view?.MutationObserver){this.eligibility=new view.MutationObserver(admit);let ancestor=this.host,depth=0;for(;ancestor&&depth++<=256;){this.eligibility.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","inert","hidden","style","class","open"]});const root=ancestor.getRootNode();ancestor=ancestor.assignedSlot??ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}admit()}fail(reason){const detail=this.selection.renderer==="webgl"?this.selection.fail(reason):null;this.loading=this.ready=!1,reason!=="context-lost"&&(this.releaseEngine(),this.attempted=!0),detail&&(this.notice=detail,this.changed(),this.fallback(detail))}syncState(){this.engine?.setState?.({selected:new Set(this.selected<0?[]:[this.selected]),dimmed:new Set,hover:this.hover,focus:this.focus})}async start(){const container=this.container,rows=this.rows,owner=this.host.ownerDocument;if(!container||!rows||!this.host.isConnected||this.preference!=="webgl")return;const generation=this.generation,current=()=>generation===this.generation&&this.host.isConnected&&this.host.ownerDocument===owner&&this.container===container;if(this.attempted=this.pending=!0,!embeddingEngineEnvironment.available(owner)){this.pending=!1,this.fail("unsupported");return}this.loading=!0,this.changed();let engine=null;try{if(engine=await embeddingPointsLoader.create(),!current()){engine?.dispose();return}if(!engine){this.pending=!1,this.fail("unavailable");return}if(this.engine=engine,await engine.mount(container,{hover:index=>{if(!(!current()||!this.ready)){this.hover=index!==null&&rows.point(index)?index:-1;try{this.syncState()}catch{this.fail("error")}}},pick:index=>{current()&&this.ready&&index!==null&&rows.point(index)&&this.pick(index)},camera:()=>{},lost:reason=>{current()&&this.fail(reason)},rendering:info=>{current()&&(this.software=info.software,this.changed())},restored:()=>{if(!(!current()||!this.engine||!this.selection.restore()))try{this.ready=!0,this.notice=null,this.syncState(),this.changed()}catch{this.fail("error")}}}),!current()){engine.dispose();return}engine.setStyle(this.style()),engine.setData(rows.data(),++this.revision);const resize=()=>{if(!current())return;const box=container.getBoundingClientRect();engine.resize(Math.max(1,box.width),Math.max(1,box.height))};resize(),engine.fit?.();const view=owner.defaultView;view?.ResizeObserver&&(this.resizeObserver=new view.ResizeObserver(()=>{if(!(!current()||!this.ready))try{engine.setStyle(this.style()),resize()}catch{this.fail("error")}}),this.resizeObserver.observe(container));const refreshStyle=()=>{if(!(!current()||!this.ready))try{engine.setStyle(this.style())}catch{this.fail("error")}};if(view?.MutationObserver){this.styleObserver=new view.MutationObserver(refreshStyle);let ancestor=this.host;for(;ancestor;){this.styleObserver.observe(ancestor,{attributes:!0});const root=ancestor.getRootNode();ancestor=ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}for(const query of["(prefers-reduced-motion: reduce)","(forced-colors: active)","(prefers-color-scheme: dark)"]){const media=view?.matchMedia(query);media?.addEventListener("change",refreshStyle),media&&this.mediaCleanup.push(()=>media.removeEventListener("change",refreshStyle))}this.pending=this.loading=!1,this.ready=this.selection.renderer==="webgl",this.syncState(),this.changed()}catch(error){if(!current()){engine?.dispose();return}this.fail(engine3dFailureReason(error))}}style(){const view=this.host.ownerDocument.defaultView,computed=view.getComputedStyle(this.host),canvas=this.host.ownerDocument.createElement("canvas");canvas.width=canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0}),color=name=>{const resolved=resolveCanvasColor(this.host,`var(${name})`,computed.color);if(!context)return resolved;context.clearRect(0,0,1,1),context.fillStyle=resolved,context.fillRect(0,0,1,1);const rgba=context.getImageData(0,0,1,1).data;return`rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]/255})`};return{background:color("--lr-color-surface"),foreground:color("--lr-color-text"),muted:color("--lr-color-text-quiet"),accent:color("--lr-color-brand"),focus:color("--lr-focus-ring-color"),palette:Array.from({length:8},(_,index)=>color(`--lr-color-chart-${index+1}`)),fontFamily:computed.fontFamily,fontSize:finiteRange(Number.parseFloat(computed.fontSize),14,1,128),pointSize:12,lineWidth:1,devicePixelRatio:finiteRange(view.devicePixelRatio,1,.25,4),reducedMotion:view.matchMedia("(prefers-reduced-motion: reduce)").matches,forcedColors:view.matchMedia("(forced-colors: active)").matches}}}export{EmbeddingEngineController,embeddingEngineEnvironment,embeddingPointsLoader};
|
|
1
|
+
import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{Engine3dSelection,engine3dFailureReason,webgl2Available}from"../../../internal/engine-3d.js";import{resolveCanvasColor}from"../../../internal/canvas-color.js";import{finiteRange}from"../../../internal/numbers.js";import{tag}from"../../../internal/prefix.js";import{isAccessibilityVisible}from"../../../internal/accessibility-visibility.js";const embeddingPointsLoader=createEngine3dLoader({entry:"points",tag:tag("embedding-explorer"),load:()=>(async()=>{try{return await import("@aceshooting/lyra-3d/points")}catch(e){throw e}})()}),embeddingEngineEnvironment={available:document=>webgl2Available(()=>document.createElement("canvas"))};class EmbeddingEngineController{constructor(host,changed,fallback,pick){this.host=host,this.changed=changed,this.fallback=fallback,this.pick=pick,this.selection=new Engine3dSelection(!0),this.notice=null,this.loading=!1,this.ready=!1,this.software=!1,this.generation=0,this.revision=0,this.rows=null,this.container=null,this.intersecting=!1,this.pending=!1,this.attempted=!1,this.preference="builtin",this.sourceMode=!1,this.mediaCleanup=[],this.hover=-1,this.selected=-1,this.focus=-1}releaseEngine(){this.generation++,this.observer?.disconnect(),this.observer=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.intersecting=!1,this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.styleObserver?.disconnect(),this.styleObserver=void 0;for(const cleanup of this.mediaCleanup)cleanup();this.mediaCleanup=[];const engine=this.engine;this.engine=void 0,this.ready=this.loading=this.pending=!1,this.software=!1,this.hover=-1,engine?.dispose()}invalidate(){this.releaseEngine(),this.attempted=!1,this.selection.prefer(this.preference),this.notice=null}disconnect(){this.invalidate(),this.container=null,this.rows=null}update(preference,rows,sourceMode,container,selected,focus){if((preference!==this.preference||rows!==this.rows||sourceMode!==this.sourceMode||container!==this.container)&&(this.invalidate(),this.preference=preference,this.rows=rows,this.sourceMode=sourceMode,this.container=container,this.selection.prefer(preference),this.notice=null),this.selected=selected,this.focus=focus,preference!=="webgl"||!this.host.isConnected)return;if(sourceMode){this.attempted||(this.attempted=!0,this.fail("unsupported"));return}if(!rows?.count||!container)return;if(this.engine&&this.ready){try{this.engine.setStyle(this.style()),this.syncState()}catch{this.fail("error")}return}if(this.pending||this.attempted||this.selection.renderer!=="webgl"||this.observer||this.eligibility)return;const view=this.host.ownerDocument.defaultView,generation=this.generation;this.intersecting=view?.IntersectionObserver===void 0;const admit=()=>{generation!==this.generation||this.pending||this.attempted||!this.intersecting||!isAccessibilityVisible(this.host)||(this.observer?.disconnect(),this.observer=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.start())};if(view?.IntersectionObserver&&(this.observer=new view.IntersectionObserver(entries=>{if(generation===this.generation){for(const entry of entries)entry.target===container&&(this.intersecting=entry.isIntersecting);admit()}}),this.observer.observe(container)),view?.MutationObserver){this.eligibility=new view.MutationObserver(admit);let ancestor=this.host,depth=0;for(;ancestor&&depth++<=256;){this.eligibility.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","inert","hidden","style","class","open"]});const root=ancestor.getRootNode();ancestor=ancestor.assignedSlot??ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}admit()}fail(reason){const detail=this.selection.renderer==="webgl"?this.selection.fail(reason):null;this.loading=this.ready=!1,reason!=="context-lost"&&(this.releaseEngine(),this.attempted=!0),detail&&(this.notice=detail,this.changed(),this.fallback(detail))}syncState(){this.engine?.setState?.({selected:new Set(this.selected<0?[]:[this.selected]),dimmed:new Set,hover:this.hover,focus:this.focus})}async start(){const container=this.container,rows=this.rows,owner=this.host.ownerDocument;if(!container||!rows||!this.host.isConnected||this.preference!=="webgl")return;const generation=this.generation,current=()=>generation===this.generation&&this.host.isConnected&&this.host.ownerDocument===owner&&this.container===container;if(this.attempted=this.pending=!0,!embeddingEngineEnvironment.available(owner)){this.pending=!1,this.fail("unsupported");return}this.loading=!0,this.changed();let engine=null;try{if(engine=await embeddingPointsLoader.create(),!current()){engine?.dispose();return}if(!engine){this.pending=!1,this.fail("unavailable");return}if(this.engine=engine,await engine.mount(container,{hover:index=>{if(!(!current()||!this.ready)){this.hover=index!==null&&rows.point(index)?index:-1;try{this.syncState()}catch{this.fail("error")}}},pick:index=>{current()&&this.ready&&index!==null&&rows.point(index)&&this.pick(index)},camera:()=>{},lost:reason=>{current()&&this.fail(reason)},rendering:info=>{current()&&(this.software=info.software,this.changed())},restored:()=>{if(!(!current()||!this.engine||!this.selection.restore()))try{this.ready=!0,this.notice=null,this.syncState(),this.changed()}catch{this.fail("error")}}}),!current()){engine.dispose();return}engine.setStyle(this.style()),engine.setData(rows.data(),++this.revision);const resize=()=>{if(!current())return;const box=container.getBoundingClientRect();engine.resize(Math.max(1,box.width),Math.max(1,box.height))};resize(),engine.fit?.();const view=owner.defaultView;view?.ResizeObserver&&(this.resizeObserver=new view.ResizeObserver(()=>{if(!(!current()||!this.ready))try{engine.setStyle(this.style()),resize()}catch{this.fail("error")}}),this.resizeObserver.observe(container));const refreshStyle=()=>{if(!(!current()||!this.ready))try{engine.setStyle(this.style())}catch{this.fail("error")}};if(view?.MutationObserver){this.styleObserver=new view.MutationObserver(refreshStyle);let ancestor=this.host;for(;ancestor;){this.styleObserver.observe(ancestor,{attributes:!0});const root=ancestor.getRootNode();ancestor=ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}for(const query of["(prefers-reduced-motion: reduce)","(forced-colors: active)","(prefers-color-scheme: dark)"]){const media=view?.matchMedia(query);media?.addEventListener("change",refreshStyle),media&&this.mediaCleanup.push(()=>media.removeEventListener("change",refreshStyle))}this.pending=this.loading=!1,this.ready=this.selection.renderer==="webgl",this.syncState(),this.changed()}catch(error){if(!current()){engine?.dispose();return}this.fail(engine3dFailureReason(error))}}style(){const view=this.host.ownerDocument.defaultView,computed=view.getComputedStyle(this.host),canvas=this.host.ownerDocument.createElement("canvas");canvas.width=canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0}),color=name=>{const resolved=resolveCanvasColor(this.host,`var(${name})`,computed.color);if(!context)return resolved;context.clearRect(0,0,1,1),context.fillStyle=resolved,context.fillRect(0,0,1,1);const rgba=context.getImageData(0,0,1,1).data;return`rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]/255})`};return{background:color("--lr-color-surface"),foreground:color("--lr-color-text"),muted:color("--lr-color-text-quiet"),accent:color("--lr-color-brand"),focus:color("--lr-focus-ring-color"),palette:Array.from({length:8},(_,index)=>color(`--lr-color-chart-${index+1}`)),fontFamily:computed.fontFamily,fontSize:finiteRange(Number.parseFloat(computed.fontSize),14,1,128),pointSize:12,lineWidth:1,devicePixelRatio:finiteRange(view.devicePixelRatio,1,.25,4),reducedMotion:view.matchMedia("(prefers-reduced-motion: reduce)").matches,forcedColors:view.matchMedia("(forced-colors: active)").matches}}}export{EmbeddingEngineController,embeddingEngineEnvironment,embeddingPointsLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{engine3dFailureReason,webgl2Available}from"../../../internal/engine-3d.js";import{tag}from"../../../internal/prefix.js";const loader=createEngine3dLoader({entry:"graph",tag:tag("graph"),load:()=>import("@aceshooting/lyra-3d/graph")});class GraphEngineAdapter{constructor(services={}){this.services=services,this.generation=0,this.disposed=new WeakSet}release(engine){this.disposed.has(engine)||(this.disposed.add(engine),engine.dispose())}close(){this.generation++;const previous=this.engine;this.engine=void 0,previous&&this.release(previous)}async open(request){this.close();const generation=this.generation;if(request.preference!=="webgl"||!request.eligible||!request.visible)return null;const available=(this.services.available??webgl2Available)();if(generation!==this.generation)return null;if(!available)return request.failure("unsupported"),null;let engine;try{engine=await(this.services.create??(()=>loader.create()))()}catch{return generation===this.generation&&request.failure("unavailable"),null}if(generation!==this.generation)return engine&&this.release(engine),null;if(!engine)return request.failure("unavailable"),null;let appearance=!1;try{appearance=typeof engine.setAppearance=="function"}catch{}if(generation!==this.generation)return this.release(engine),null;if(!appearance)return this.release(engine),request.failure("unavailable"),null;this.engine=engine;const current=()=>generation===this.generation&&this.engine===engine;let callbackThrew=!1,callbackError;const invoke=action=>{if(current())try{action()}catch(error){throw callbackThrew=!0,callbackError=error,error}},host={hover:item=>{invoke(()=>request.host.hover(item))},pick:(item,modifiers)=>{invoke(()=>request.host.pick(item,modifiers))},camera:camera=>{invoke(()=>request.host.camera(camera))},lost:(reason,detail)=>{invoke(()=>request.host.lost(reason,detail))},restored:()=>{invoke(()=>request.host.restored?.())},rendering:info=>{invoke(()=>request.host.rendering?.(info))},progress:(loaded,total)=>{invoke(()=>request.host.progress?.(loaded,total))}};try{await engine.mount(request.container,host)}catch(error){const active=current();if(active&&(this.engine=void 0,this.generation++),this.release(engine),callbackThrew&&Object.is(error,callbackError))throw error;return active&&request.failure(engine3dFailureReason(error)),null}return current()?engine:(this.release(engine),null)}}export{GraphEngineAdapter};
|
|
1
|
+
import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{engine3dFailureReason,webgl2Available}from"../../../internal/engine-3d.js";import{tag}from"../../../internal/prefix.js";const loader=createEngine3dLoader({entry:"graph",tag:tag("graph"),load:()=>(async()=>{try{return await import("@aceshooting/lyra-3d/graph")}catch(e){throw e}})()});class GraphEngineAdapter{constructor(services={}){this.services=services,this.generation=0,this.disposed=new WeakSet}release(engine){this.disposed.has(engine)||(this.disposed.add(engine),engine.dispose())}close(){this.generation++;const previous=this.engine;this.engine=void 0,previous&&this.release(previous)}async open(request){this.close();const generation=this.generation;if(request.preference!=="webgl"||!request.eligible||!request.visible)return null;const available=(this.services.available??webgl2Available)();if(generation!==this.generation)return null;if(!available)return request.failure("unsupported"),null;let engine;try{engine=await(this.services.create??(()=>loader.create()))()}catch{return generation===this.generation&&request.failure("unavailable"),null}if(generation!==this.generation)return engine&&this.release(engine),null;if(!engine)return request.failure("unavailable"),null;let appearance=!1;try{appearance=typeof engine.setAppearance=="function"}catch{}if(generation!==this.generation)return this.release(engine),null;if(!appearance)return this.release(engine),request.failure("unavailable"),null;this.engine=engine;const current=()=>generation===this.generation&&this.engine===engine;let callbackThrew=!1,callbackError;const invoke=action=>{if(current())try{action()}catch(error){throw callbackThrew=!0,callbackError=error,error}},host={hover:item=>{invoke(()=>request.host.hover(item))},pick:(item,modifiers)=>{invoke(()=>request.host.pick(item,modifiers))},camera:camera=>{invoke(()=>request.host.camera(camera))},lost:(reason,detail)=>{invoke(()=>request.host.lost(reason,detail))},restored:()=>{invoke(()=>request.host.restored?.())},rendering:info=>{invoke(()=>request.host.rendering?.(info))},progress:(loaded,total)=>{invoke(()=>request.host.progress?.(loaded,total))}};try{await engine.mount(request.container,host)}catch(error){const active=current();if(active&&(this.engine=void 0,this.generation++),this.release(engine),callbackThrew&&Object.is(error,callbackError))throw error;return active&&request.failure(engine3dFailureReason(error)),null}return current()?engine:(this.release(engine),null)}}export{GraphEngineAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader,resolveOptionalPeerCapability}from"../../../internal/optional-peer-capabilities.js";function optionalPeerRecord(value){return(typeof value=="object"||typeof value=="function")&&value!==null?value:{}}const forceApiNames=["forceSimulation","forceLink","forceManyBody","forceCenter","forceCollide"];function hasRequiredCallables(value,names){const candidate=optionalPeerRecord(value);return names.every(name=>typeof candidate[name]=="function")}function isD3ForceApi(value){return hasRequiredCallables(value,forceApiNames)}function isD3DragApi(value){return hasRequiredCallables(value,["drag"])}function isD3ZoomApi(value){if(!hasRequiredCallables(value,["zoom","zoomTransform"]))return!1;const identity=optionalPeerRecord(optionalPeerRecord(value).zoomIdentity);return typeof identity.translate=="function"&&typeof identity.scale=="function"}function isD3SelectionApi(value){return hasRequiredCallables(value,["select"])}async function loadD3Modules(importForce=()=>import("d3-force"),importDrag=()=>import("d3-drag"),importZoom=()=>import("d3-zoom"),importSelection=()=>import("d3-selection")){try{const[force,dragMod,zoomMod,selectionMod]=await Promise.all([importForce(),importDrag(),importZoom(),importSelection()]),forceApi=optionalPeerRecord(resolveOptionalPeerCapability(force,isD3ForceApi)),dragApi=optionalPeerRecord(resolveOptionalPeerCapability(dragMod,isD3DragApi)),zoomApi=optionalPeerRecord(resolveOptionalPeerCapability(zoomMod,isD3ZoomApi)),selectionApi=optionalPeerRecord(resolveOptionalPeerCapability(selectionMod,isD3SelectionApi)),modules={forceSimulation:forceApi.forceSimulation,forceLink:forceApi.forceLink,forceManyBody:forceApi.forceManyBody,forceCenter:forceApi.forceCenter,forceCollide:forceApi.forceCollide,drag:dragApi.drag,zoom:zoomApi.zoom,zoomIdentity:zoomApi.zoomIdentity,zoomTransform:zoomApi.zoomTransform,select:selectionApi.select},missing=["forceSimulation","forceLink","forceManyBody","forceCenter","forceCollide","drag","zoom","zoomTransform","select"].some(name=>typeof modules[name]!="function"),identity=modules.zoomIdentity;return missing||typeof identity?.translate!="function"||typeof identity.scale!="function"?null:modules}catch{return null}}const d3=createOptionalPeerLoader({load:()=>loadD3Modules(),isCapability:candidate=>candidate!==null,warningKey:"lyra-graph-d3-unavailable",warning:"<lr-graph> needs the optional peers d3-force, d3-drag, d3-zoom and d3-selection (pnpm add d3-force d3-drag d3-zoom d3-selection)."});function loadD3(){return d3.get()}export{loadD3,loadD3Modules};
|
|
1
|
+
import{createOptionalPeerLoader,resolveOptionalPeerCapability}from"../../../internal/optional-peer-capabilities.js";function optionalPeerRecord(value){return(typeof value=="object"||typeof value=="function")&&value!==null?value:{}}const forceApiNames=["forceSimulation","forceLink","forceManyBody","forceCenter","forceCollide"];function hasRequiredCallables(value,names){const candidate=optionalPeerRecord(value);return names.every(name=>typeof candidate[name]=="function")}function isD3ForceApi(value){return hasRequiredCallables(value,forceApiNames)}function isD3DragApi(value){return hasRequiredCallables(value,["drag"])}function isD3ZoomApi(value){if(!hasRequiredCallables(value,["zoom","zoomTransform"]))return!1;const identity=optionalPeerRecord(optionalPeerRecord(value).zoomIdentity);return typeof identity.translate=="function"&&typeof identity.scale=="function"}function isD3SelectionApi(value){return hasRequiredCallables(value,["select"])}async function loadD3Modules(importForce=()=>(async()=>{try{return await import("d3-force")}catch(e){throw e}})(),importDrag=()=>(async()=>{try{return await import("d3-drag")}catch(e){throw e}})(),importZoom=()=>(async()=>{try{return await import("d3-zoom")}catch(e){throw e}})(),importSelection=()=>(async()=>{try{return await import("d3-selection")}catch(e){throw e}})()){try{const[force,dragMod,zoomMod,selectionMod]=await Promise.all([importForce(),importDrag(),importZoom(),importSelection()]),forceApi=optionalPeerRecord(resolveOptionalPeerCapability(force,isD3ForceApi)),dragApi=optionalPeerRecord(resolveOptionalPeerCapability(dragMod,isD3DragApi)),zoomApi=optionalPeerRecord(resolveOptionalPeerCapability(zoomMod,isD3ZoomApi)),selectionApi=optionalPeerRecord(resolveOptionalPeerCapability(selectionMod,isD3SelectionApi)),modules={forceSimulation:forceApi.forceSimulation,forceLink:forceApi.forceLink,forceManyBody:forceApi.forceManyBody,forceCenter:forceApi.forceCenter,forceCollide:forceApi.forceCollide,drag:dragApi.drag,zoom:zoomApi.zoom,zoomIdentity:zoomApi.zoomIdentity,zoomTransform:zoomApi.zoomTransform,select:selectionApi.select},missing=["forceSimulation","forceLink","forceManyBody","forceCenter","forceCollide","drag","zoom","zoomTransform","select"].some(name=>typeof modules[name]!="function"),identity=modules.zoomIdentity;return missing||typeof identity?.translate!="function"||typeof identity.scale!="function"?null:modules}catch{return null}}const d3=createOptionalPeerLoader({load:()=>loadD3Modules(),isCapability:candidate=>candidate!==null,warningKey:"lyra-graph-d3-unavailable",warning:"<lr-graph> needs the optional peers d3-force, d3-drag, d3-zoom and d3-selection (pnpm add d3-force d3-drag d3-zoom d3-selection)."});function loadD3(){return d3.get()}export{loadD3,loadD3Modules};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";function loadIconSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadIconSanitizer(importer){return loadDompurify(importer)}function clearIconSanitizerCache(){clearDompurifyCache()}export{clearIconSanitizerCache,loadIconSanitizer,loadIconSanitizerDeps};
|
|
1
|
+
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";function loadIconSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadIconSanitizer(importer){return loadDompurify(importer)}function clearIconSanitizerCache(){clearDompurifyCache()}export{clearIconSanitizerCache,loadIconSanitizer,loadIconSanitizerDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const CALENDAR_ICAL_WARNING_KEY="lyra-calendar-viewer-ical-unavailable",CALENDAR_ICAL_WARNING="<lr-calendar-viewer> could not load its optional ical.js peer.";function isIcalApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"&&"Component"in value&&typeof value.Component=="function"&&"Event"in value&&typeof value.Event=="function"}const ical=createOptionalPeerLoader({load:()=>import("ical.js"),isCapability:isIcalApi,warningKey:CALENDAR_ICAL_WARNING_KEY,warning:CALENDAR_ICAL_WARNING});function loadIcalDeps(importIcal){return ical.loadWith(importIcal)}function loadIcal(){return ical.get()}function clearIcalCache(){ical.clear()}export{clearIcalCache,loadIcal,loadIcalDeps};
|
|
1
|
+
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const CALENDAR_ICAL_WARNING_KEY="lyra-calendar-viewer-ical-unavailable",CALENDAR_ICAL_WARNING="<lr-calendar-viewer> could not load its optional ical.js peer.";function isIcalApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"&&"Component"in value&&typeof value.Component=="function"&&"Event"in value&&typeof value.Event=="function"}const ical=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("ical.js")}catch(e){throw e}})(),isCapability:isIcalApi,warningKey:CALENDAR_ICAL_WARNING_KEY,warning:CALENDAR_ICAL_WARNING});function loadIcalDeps(importIcal){return ical.loadWith(importIcal)}function loadIcal(){return ical.get()}function clearIcalCache(){ical.clear()}export{clearIcalCache,loadIcal,loadIcalDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{loadDompurify}from"../../../internal/dompurify-loader.js";import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";let depsPromise,resolvedDeps;function isMammothApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"convertToHtml"in value&&typeof value.convertToHtml=="function"}const mammothLoader=createOptionalPeerLoader({load:()=>import("mammoth/mammoth.browser.js"),isCapability:isMammothApi,warningKey:"lyra-docx-viewer-mammoth-unavailable",warning:"<lr-docx-viewer> could not load its optional mammoth peer."});async function loadMammothAndSanitizer(importMammoth,importDompurify){const[mammoth,DOMPurify]=await Promise.all([importMammoth?mammothLoader.loadWith(importMammoth):mammothLoader.get(),loadDompurify(importDompurify)]);return{mammoth:mammoth??void 0,DOMPurify:DOMPurify??void 0}}function loadDocxDeps(){return depsPromise||(depsPromise=loadMammothAndSanitizer().then(resolved=>(resolvedDeps=resolved,resolved))),depsPromise}function getDocxDepsIfLoaded(){return resolvedDeps}function clearDocxDepsCache(){depsPromise=void 0,resolvedDeps=void 0,mammothLoader.clear()}export{clearDocxDepsCache,getDocxDepsIfLoaded,loadDocxDeps,loadMammothAndSanitizer};
|
|
1
|
+
import{loadDompurify}from"../../../internal/dompurify-loader.js";import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";let depsPromise,resolvedDeps;function isMammothApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"convertToHtml"in value&&typeof value.convertToHtml=="function"}const mammothLoader=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("mammoth/mammoth.browser.js")}catch(e){throw e}})(),isCapability:isMammothApi,warningKey:"lyra-docx-viewer-mammoth-unavailable",warning:"<lr-docx-viewer> could not load its optional mammoth peer."});async function loadMammothAndSanitizer(importMammoth,importDompurify){const[mammoth,DOMPurify]=await Promise.all([importMammoth?mammothLoader.loadWith(importMammoth):mammothLoader.get(),loadDompurify(importDompurify)]);return{mammoth:mammoth??void 0,DOMPurify:DOMPurify??void 0}}function loadDocxDeps(){return depsPromise||(depsPromise=loadMammothAndSanitizer().then(resolved=>(resolvedDeps=resolved,resolved))),depsPromise}function getDocxDepsIfLoaded(){return resolvedDeps}function clearDocxDepsCache(){depsPromise=void 0,resolvedDeps=void 0,mammothLoader.clear()}export{clearDocxDepsCache,getDocxDepsIfLoaded,loadDocxDeps,loadMammothAndSanitizer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";function isEpubFactory(value){return typeof value=="function"}let override;const epub=createOptionalPeerLoader({load:()=>import("epubjs"),isCapability:isEpubFactory,warningKey:"lyra-ebook-viewer-epubjs-unavailable",warning:"<lr-ebook-viewer> could not load its optional epubjs peer."});function loadEpubJs(importEpub){return epub.loadWith(importEpub)}function getEpubJs(){return override??epub.get()}function __setEpubJsForTesting(factory){override=factory===void 0?void 0:Promise.resolve(factory),epub.clear()}export{__setEpubJsForTesting,getEpubJs,loadEpubJs};
|
|
1
|
+
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";function isEpubFactory(value){return typeof value=="function"}let override;const epub=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("epubjs")}catch(e){throw e}})(),isCapability:isEpubFactory,warningKey:"lyra-ebook-viewer-epubjs-unavailable",warning:"<lr-ebook-viewer> could not load its optional epubjs peer."});function loadEpubJs(importEpub){return epub.loadWith(importEpub)}function getEpubJs(){return override??epub.get()}function __setEpubJsForTesting(factory){override=factory===void 0?void 0:Promise.resolve(factory),epub.clear()}export{__setEpubJsForTesting,getEpubJs,loadEpubJs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{createRef,ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DEFAULT_CANVAS_COLOR}from"../../../internal/canvas-color.js";import{isAbortError,isResourceLimitError,LyraUserFacingError,readResponseArrayBuffer,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{srOnly}from"../../../internal/a11y.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{getOwnDataDescriptor,isObjectValue,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{DocumentAnchorTarget,prioritizedHighlightCandidates}from"../../../internal/anchor-target.js";import{textQuoteContextScore}from"../document-viewer/anchors.js";import{getEpubJs}from"./ebook-loader.js";import{assertEpubArchiveWithinLimits}from"./epub-resource-guard.js";import{styles}from"./ebook-viewer.styles.js";import{ViewerAnnouncementController}from"../viewer-announcements.js";import{viewerSemanticLabel,viewerSemanticRole}from"../viewer-semantic-owner.js";import{renderViewerLoading,viewerLoadingStyles}from"../viewer-loading.js";import{renderViewerPagerButton,viewerPagerStyles}from"../viewer-pager.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{boundedViewerSearchQuery,ViewerSearchWorkBudget,VIEWER_SEARCH_QUERY_LIMIT}from"../viewer-search-limits.js";import{boundedSelectionRects,boundedSelectionText}from"../../../internal/text-quote.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_documentPreviewEmpty}from"../../../internal/default-strings/shared.generated.js";import{LYRA_DEFAULT_documentPreviewResourceTooLarge,LYRA_DEFAULT_documentPreviewTypeDocument,LYRA_DEFAULT_documentPreviewUrlNotAllowed,LYRA_DEFAULT_ebookViewerLoadError,LYRA_DEFAULT_ebookViewerMissingLibrary,LYRA_DEFAULT_ebookViewerNextChapter,LYRA_DEFAULT_ebookViewerPreviousChapter,LYRA_DEFAULT_ebookViewerRegionLabel,LYRA_DEFAULT_loadingDocument}from"../../../internal/default-strings/viewers.generated.js";const MAX_TOC_ITEMS=1e4,MAX_TOC_DEPTH=100,MAX_SEARCH_MATCHES=1e4,MAX_SEARCH_SPINE_ITEMS=1e3,MAX_FIND_RESULTS=1e4,MAX_PAINTED_HIGHLIGHTS=100,MAX_PEER_PROTOTYPES=100;function isArrayValue(value){try{return Array.isArray(value)}catch{return!1}}function inheritedDataDescriptor(value,key){let current=value;for(let depth=0;current&&depth<MAX_PEER_PROTOTYPES;depth+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(current,key)}catch{return}if(descriptor)return"value"in descriptor?descriptor:void 0;try{current=Object.getPrototypeOf(current)}catch{return}}}function inheritedDataValue(value,key){return isObjectValue(value)?inheritedDataDescriptor(value,key)?.value:void 0}function savedCallable(value,key){if(!isObjectValue(value))return;const candidate=inheritedDataDescriptor(value,key)?.value;if(typeof candidate=="function")return(...args)=>Reflect.apply(candidate,value,args)}function savedThenable(value){const then=savedCallable(value,"then");if(then)return new Promise((resolve,reject)=>{try{then(()=>resolve(),reject)}catch(error){reject(error)}})}function taskFrom(call,...args){try{return savedThenable(call(...args))??Promise.resolve()}catch(error){return Promise.reject(error)}}function awaitPeerResult(value){const then=savedCallable(value,"then"),wrap=resolved=>Object.freeze({value:resolved});return then?new Promise((resolve,reject)=>{try{then(resolved=>resolve(wrap(resolved)),reject)}catch(error){reject(error)}}):Promise.resolve(wrap(value))}function quoteContextScore(excerpt,quote,prefix,suffix){const text=excerpt.replace(/\s+/g," ").toLowerCase(),needle=quote.replace(/\s+/g," ").toLowerCase();let best=0;for(let at=text.indexOf(needle);at>=0;at=text.indexOf(needle,at+1))best=Math.max(best,textQuoteContextScore(text,at,at+needle.length,prefix,suffix));return best}const EPUB_CHAPTER_CONTENT_SECURITY_POLICY="default-src 'none'; img-src blob: data:; media-src blob: data:; font-src blob: data:; style-src blob: 'unsafe-inline'";function silenceChapterNetwork(chapter){const root=chapter.documentElement;if(!root)return;for(const node of[...chapter.childNodes])node.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&chapter.removeChild(node);for(const element of[...chapter.querySelectorAll("link, meta")]){const rel=` ${(element.getAttribute("rel")??"").toLowerCase()} `;(/ (?:dns-prefetch|preconnect) /.test(rel)||(element.getAttribute("http-equiv")??"").trim().toLowerCase()==="refresh")&&element.remove()}const namespace=root.namespaceURI??"http://www.w3.org/1999/xhtml";let head=chapter.querySelector("head");head||(head=chapter.createElementNS(namespace,"head"),root.insertBefore(head,root.firstChild));const policy=chapter.createElementNS(namespace,"meta");policy.setAttribute("http-equiv","Content-Security-Policy"),policy.setAttribute("content",EPUB_CHAPTER_CONTENT_SECURITY_POLICY),head.insertBefore(policy,head.firstChild)}function registerNetworkSilentChapters(book){const contentHooks=inheritedDataValue(inheritedDataValue(book.spine,"hooks"),"content");savedCallable(contentHooks,"register")?.(silenceChapterNetwork)}function normalizeBook(value){if(!isObjectValue(value))return;const ready=savedThenable(inheritedDataValue(value,"ready")),renderTo=savedCallable(value,"renderTo"),destroy=savedCallable(value,"destroy");if(!ready||!renderTo||!destroy)return;let navigationCaptured=!1,navigation;const getNavigation=()=>(navigationCaptured||(navigationCaptured=!0,navigation=inheritedDataValue(value,"navigation")),navigation),spine=inheritedDataValue(value,"spine"),load=savedCallable(value,"load");return Object.freeze({ready,...spine===void 0?{}:{spine},...load===void 0?{}:{load},getNavigation,renderTo:(element,options)=>renderTo(element,options),destroy:()=>{destroy()}})}function normalizeRendition(value){if(!isObjectValue(value))return;const display=savedCallable(value,"display"),prev=savedCallable(value,"prev"),next=savedCallable(value,"next"),on=savedCallable(value,"on"),annotationsValue=inheritedDataValue(value,"annotations"),highlight=savedCallable(annotationsValue,"highlight"),remove=savedCallable(annotationsValue,"remove");if(!(!display||!prev||!next||!on||!highlight||!remove))return Object.freeze({display:target=>taskFrom(display,target),prev:()=>taskFrom(prev),next:()=>taskFrom(next),on:(type,callback)=>{on(type,callback)},annotations:Object.freeze({highlight:(cfi,data,callback,className,styles2)=>highlight(cfi,data,callback,className,styles2),remove:(cfi,type)=>{remove(cfi,type)}})})}function normalizeSpineItem(value){const load=savedCallable(value,"load"),find=savedCallable(value,"find"),unload=savedCallable(value,"unload");if(!(!load||!find||!unload))return Object.freeze({load:request=>load(request),find:query=>find(query),unload:()=>{unload()}})}function projectSpineItems(book){const spineItems=inheritedDataValue(book.spine,"spineItems");if(!isArrayValue(spineItems))return Object.freeze({items:Object.freeze([]),exact:spineItems===void 0});const length=getOwnDataDescriptor(spineItems,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({items:Object.freeze([]),exact:!1});const items=[];let exact=length.value<=MAX_SEARCH_SPINE_ITEMS;const count=Math.min(length.value,MAX_SEARCH_SPINE_ITEMS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(spineItems,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR){exact=!1;continue}const item=normalizeSpineItem(descriptor.value);if(!item){exact=!1;continue}items.push(item)}return Object.freeze({items:Object.freeze(items),exact})}function projectFindResults(value,work){if(!isArrayValue(value))return Object.freeze({matches:Object.freeze([]),exact:!1});const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({matches:Object.freeze([]),exact:!1});const matches=[];let exact=length.value<=MAX_FIND_RESULTS;const count=Math.min(length.value,MAX_FIND_RESULTS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!isObjectValue(descriptor.value)){exact=!1;continue}const cfi=getOwnDataDescriptor(descriptor.value,"cfi"),excerpt=getOwnDataDescriptor(descriptor.value,"excerpt");if(cfi===MISSING_OWN_DATA_DESCRIPTOR||cfi===UNSAFE_OWN_DATA_DESCRIPTOR||typeof cfi.value!="string"){exact=!1;continue}if(!work.canConsume(cfi.value)||!work.consume(cfi.value)||cfi.value.trim()===""){exact=!1;continue}let excerptValue="";excerpt!==MISSING_OWN_DATA_DESCRIPTOR&&(excerpt===UNSAFE_OWN_DATA_DESCRIPTOR||typeof excerpt.value!="string"||!work.canConsume(excerpt.value)||!work.consume(excerpt.value)?exact=!1:excerptValue=excerpt.value),matches.push({cfi:cfi.value,excerpt:excerptValue})}return Object.freeze({matches:Object.freeze(matches),exact})}function pushTocEntries(value,level,budget,stack){if(!isArrayValue(value)||budget.positions>=MAX_TOC_ITEMS)return;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const count=Math.min(length.value,MAX_TOC_ITEMS-budget.positions);for(let index=count-1;index>=0;index-=1){budget.positions+=1;const descriptor=getOwnDataDescriptor(value,String(index));descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||stack.push({value:descriptor.value,level})}}function projectToc(value){const budget={positions:0,nodes:0,seen:new WeakSet},stack=[];pushTocEntries(value,1,budget,stack);const items=[];for(;stack.length>0&&budget.nodes<MAX_TOC_ITEMS;){const current=stack.pop();if(!isObjectValue(current.value)||budget.seen.has(current.value))continue;budget.seen.add(current.value),budget.nodes+=1;const href=getOwnDataDescriptor(current.value,"href"),id=getOwnDataDescriptor(current.value,"id"),label=getOwnDataDescriptor(current.value,"label"),children=getOwnDataDescriptor(current.value,"subitems");if(href!==MISSING_OWN_DATA_DESCRIPTOR&&href!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof href.value=="string"){const idValue=id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof id.value=="string"&&id.value!==""?id.value:href.value,labelValue=label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?label.value.trim():"";items.push({id:idValue,label:labelValue,href:href.value,level:current.level})}current.level<MAX_TOC_DEPTH&&children!==MISSING_OWN_DATA_DESCRIPTOR&&children!==UNSAFE_OWN_DATA_DESCRIPTOR&&pushTocEntries(children.value,current.level+1,budget,stack)}return Object.freeze(items)}const TONE_FILL_TOKEN={accent:{token:"--lr-color-brand-quiet",fallback:"#ddf4ff"},success:{token:"--lr-color-success-quiet",fallback:"#dafbe1"},warning:{token:"--lr-color-warning-quiet",fallback:"#fff8c5"},danger:{token:"--lr-color-danger-quiet",fallback:"#ffebe9"},neutral:{token:"--lr-color-surface-raised",fallback:"#f6f8fa"}},SEARCH_MATCH_FILL_TOKEN={token:"--lr-color-warning",fallback:"#9a6700"},ACTIVE_HIGHLIGHT_STROKE_TOKEN={token:"--lr-focus-ring-color",fallback:DEFAULT_CANVAS_COLOR};class LyraEbookViewerBase extends LyraElement{}class LyraEbookViewer extends DocumentAnchorTarget(LyraEbookViewerBase){static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,documentPreviewEmpty:LYRA_DEFAULT_documentPreviewEmpty,documentPreviewResourceTooLarge:LYRA_DEFAULT_documentPreviewResourceTooLarge,documentPreviewTypeDocument:LYRA_DEFAULT_documentPreviewTypeDocument,documentPreviewUrlNotAllowed:LYRA_DEFAULT_documentPreviewUrlNotAllowed,ebookViewerLoadError:LYRA_DEFAULT_ebookViewerLoadError,ebookViewerMissingLibrary:LYRA_DEFAULT_ebookViewerMissingLibrary,ebookViewerNextChapter:LYRA_DEFAULT_ebookViewerNextChapter,ebookViewerPreviousChapter:LYRA_DEFAULT_ebookViewerPreviousChapter,ebookViewerRegionLabel:LYRA_DEFAULT_ebookViewerRegionLabel,loadingDocument:LYRA_DEFAULT_loadingDocument}}static{this.styles=[LyraElement.styles,styles,viewerPagerStyles,srOnly,viewerLoadingStyles]}constructor(){super(),this.src="",this.name="",this.maxHeight="",this.location="",this.anchorKinds=["cfi","text-quote"],this.ebookState={kind:"idle"},this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.mountRef=createRef(),this.generation=0,this.failedGeneration=-1,this.searchQuery="",this.lastSearchLocale="",this.searchGeneration=0,this.pendingSearchResetEvent=!1,this.anchorOperationGeneration=0,this.paintedHighlightCfis=[],this.announcements=new ViewerAnnouncementController(this),this.chapterButtonFocused=!1,this.previous=()=>{this.runRenditionNavigation("previous")},this.next=()=>{this.runRenditionNavigation("next")},new ThemeWatcher(this,()=>this.repaintAnnotations())}updated(changed){if(super.updated(changed),this.chapterButtonFocused&&this.ebookState.kind!=="ready"&&this.shadowRoot?.querySelector('[part="mount"]')?.focus(),this.chapterButtonFocused=!1,this.announcements.transition("load",this.ebookState.kind,this.ebookState.kind==="error"?this.ebookState.message:this.localize("loadingDocument")),changed.has("src")&&this.scheduleAfterUpdate(()=>{this.load()}),changed.has("src")&&this.pendingSearchResetEvent&&(this.pendingSearchResetEvent=!1,this.emitSearchChange()),changed.has("location")){const fromRelocated=this.relocatedLocation===this.location;this.relocatedLocation=void 0,!fromRelocated&&this.rendition&&this.location&&this.displayLocation(this.location)}(changed.has("highlights")||changed.has("activeHighlightId"))&&this.rendition&&this.repaintAnnotations();const locale=this.effectiveLocale;if(locale!==this.lastSearchLocale){const shouldRecompute=this.searchQuery!=="";this.lastSearchLocale=locale,shouldRecompute&&this.scheduleAfterUpdate(()=>{this.search(this.searchQuery)},"search")}}willUpdate(changed){super.willUpdate(changed);const active=shadowFocusTarget(this);this.chapterButtonFocused=active?.localName==="button"&&!active.disabled&&active.getAttribute("part")?.endsWith("-button")===!0,changed.has("src")&&(this.pendingSearchResetEvent||=this.hasSearchState(),this.resetSearchState())}connectedCallback(){super.connectedCallback(),this.announcements.connect(),this.hasUpdated&&this.src.trim()&&this.scheduleAfterUpdate(()=>{this.load()})}disconnectedCallback(){this.generation++,this.anchorOperationGeneration++,this.announcements.disconnect(),this.teardown(),this.ebookState={kind:"idle"},super.disconnectedCallback()}connectedMoveCallback(){}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}teardown(){const shouldEmitSearchReset=this.hasSearchState();this.destroyBook(this.book),this.book=void 0,this.rendition=void 0,this.resetSearchState(),this.paintedHighlightCfis=[],shouldEmitSearchReset&&this.isConnected&&this.emitSearchChange()}destroyBook(book){try{book?.destroy()}catch{}}isCurrentLoad(generation,ownerView){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView}isCurrentBookRendition(generation,ownerView,book,rendition){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView&&this.book===book&&this.rendition===rendition}failCurrentLoad(error,message=this.localize("ebookViewerLoadError")){this.failedGeneration!==this.generation&&(this.failedGeneration=this.generation,this.ebookState={kind:"error",message},this.emit("lr-render-error",{error}))}hasSearchState(){return this.searchQuery!==""||this.searchMatches.length>0||!this.searchMatchCountExact||this.searchActiveIndex!==-1}resetSearchState(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.searchAnnotationCfi=void 0}async load(){const generation=++this.generation,signal=this.beginAbortableLoad();if(this.teardown(),!this.src.trim()){this.ebookState={kind:"idle"};return}const fetchTarget=resolveOwnerFetchTarget(this,this.src);if(!fetchTarget){this.failWithLocalizedMessage(this.localize("documentPreviewUrlNotAllowed"));return}this.ebookState={kind:"loading"};let data,factory;try{if([data,factory]=await Promise.all([fetchTarget.view.fetch(fetchTarget.url,signal?{signal}:void 0).then(response=>{if(!response.ok)throw new Error(`${response.status} ${response.statusText}`);return readResponseArrayBuffer(response)}),getEpubJs()]),!this.isCurrentLoad(generation,fetchTarget.view)||(await assertEpubArchiveWithinLimits(data,void 0,void 0,{signal}),!this.isCurrentLoad(generation,fetchTarget.view)))return}catch(error){if(isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error,this.localize(isResourceLimitError(error)?"documentPreviewResourceTooLarge":"ebookViewerLoadError"));return}if(!factory){this.failWithLocalizedMessage(this.localize("ebookViewerMissingLibrary"));return}const mount=this.mountRef.value;if(!mount){this.failWithLocalizedMessage(this.localize("ebookViewerLoadError"));return}let candidateBook;try{const book=normalizeBook(factory(data));if(!book)throw new Error("EPUB peer returned an unusable book.");candidateBook=book,registerNetworkSilentChapters(book);const rendition=normalizeRendition(book.renderTo(mount,{width:"100%",height:"100%"}));if(!rendition)throw new Error("EPUB peer returned an unusable rendition.");if(await book.ready,!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}if(book.getNavigation(),await rendition.display(this.location||void 0),!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}rendition.on("relocated",loc=>{if(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition))return;const start=inheritedDataValue(loc,"start"),cfi=inheritedDataValue(start,"cfi"),href=inheritedDataValue(start,"href");typeof cfi!="string"||cfi.trim()===""||!cfi||cfi===this.location||(this.relocatedLocation=cfi,this.location=cfi,this.emit("lr-location-change",{cfi,href:typeof href=="string"?href:""}))}),rendition.on("selected",(cfiRange,contents)=>{if(!(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition)||typeof cfiRange!="string"))try{const contentsWindow=inheritedDataValue(contents,"window"),selection=savedCallable(contentsWindow,"getSelection")?.(),range=this.selectedRange(selection);if(!range)return;const text=boundedSelectionText(range);if(!text)return;const rects=this.translateSelectionRects(boundedSelectionRects(range),contentsWindow);this.emit("lr-text-select",{text,anchor:{kind:"cfi",cfi:cfiRange},rects})}catch{}}),this.book=book,this.rendition=rendition,candidateBook=void 0,this.ebookState={kind:"ready"},this.repaintAnnotations()}catch(error){if(this.destroyBook(candidateBook),isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error)}}selectedRange(selection){const prototype=this.ownerDocument.defaultView?.Selection.prototype;if(prototype)try{const count2=Object.getOwnPropertyDescriptor(prototype,"rangeCount")?.get?.call(selection);if(typeof count2=="number")return count2>0?prototype.getRangeAt.call(selection,0):null}catch{}const count=inheritedDataValue(selection,"rangeCount"),getRangeAt=savedCallable(selection,"getRangeAt");return typeof count=="number"&&count>0&&getRangeAt?getRangeAt(0):null}failWithLocalizedMessage(message){const error=new LyraUserFacingError(message);this.failCurrentLoad(error,message)}reportRenditionFailure(error,rendition,generation,ownerView=this.ownerDocument.defaultView){!this.isConnected||generation!==this.generation||this.ownerDocument.defaultView!==ownerView||rendition!==this.rendition||this.failCurrentLoad(error)}translateSelectionRects(rects,sourceWindow){const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow||!sourceWindow)return[];const translated=[];for(const rect of rects){let x=Number(rect.x??rect.left),y=Number(rect.y??rect.top),width=Number(rect.width),height=Number(rect.height);if(![x,y,width,height].every(Number.isFinite))continue;let current=sourceWindow,valid=!0;for(;current&¤t!==ownerWindow;){if(!("frameElement"in current)){current=ownerWindow;break}let frameElement;try{frameElement=current.frameElement}catch{valid=!1;break}const frameWindow=frameElement?.ownerDocument.defaultView;if(!frameElement||!frameWindow||!(frameElement instanceof frameWindow.HTMLElement)){valid=!1;break}const frame=frameElement,frameRect=frame.getBoundingClientRect(),borderBoxWidth=frame.offsetWidth||frame.clientWidth,borderBoxHeight=frame.offsetHeight||frame.clientHeight,viewportWidth=current.innerWidth||frame.clientWidth,viewportHeight=current.innerHeight||frame.clientHeight;if(borderBoxWidth<=0||borderBoxHeight<=0||viewportWidth<=0||viewportHeight<=0){valid=!1;break}const borderScaleX=frameRect.width/borderBoxWidth,borderScaleY=frameRect.height/borderBoxHeight,contentScaleX=frame.clientWidth*borderScaleX/viewportWidth,contentScaleY=frame.clientHeight*borderScaleY/viewportHeight;x=frameRect.left+frame.clientLeft*borderScaleX+x*contentScaleX,y=frameRect.top+frame.clientTop*borderScaleY+y*contentScaleY,width*=contentScaleX,height*=contentScaleY,current=frame.ownerDocument.defaultView}!valid||current!==ownerWindow||translated.push(Object.freeze({x,y,width,height,top:y,right:x+width,bottom:y+height,left:x}))}return translated}displayLocation(location){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{Promise.resolve(rendition.display(location)).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}runRenditionNavigation(action){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{const task=action==="previous"?rendition.prev():rendition.next();Promise.resolve(task).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async getToc(){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!book||!ownerView)return[];try{await book.ready}catch{return[]}return!this.isCurrentLoad(generation,ownerView)||this.book!==book?[]:[...projectToc(inheritedDataValue(book.getNavigation(),"toc"))]}async scrollToAnchor(target){const operation=++this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView,book=this.book,rendition=this.rendition;try{return await Object.getPrototypeOf(LyraEbookViewer.prototype).performScrollToAnchor.call(this,target)}catch(error){return operation!==this.anchorOperationGeneration||!ownerView||!this.isCurrentLoad(generation,ownerView)||this.book!==book||this.rendition!==rendition||(rendition&&this.reportRenditionFailure(error,rendition,generation,ownerView),this.emit("lr-anchor-result",{found:!1})),!1}}async applyAnchor(anchor){const rendition=this.rendition,operation=this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!rendition||!ownerView)return!1;if(anchor.kind==="cfi")return operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(anchor.cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition);if(anchor.kind==="text-quote"){const cfi=await this.findTextQuoteCfi(anchor);return!cfi||operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition)}return!1}async findTextQuoteCfi(anchor){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,quote=anchor.quote.trim(),boundedQuery=boundedViewerSearchQuery(quote,this.effectiveLocale);if(!book||!ownerView||!boundedQuery.accepted||!boundedQuery.needle)return null;const fullContextScore=(anchor.prefix?.trim()?1:0)+(anchor.suffix?.trim()?1:0);let bestMatch=null,bestScore=-1;const work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);for(const item of spine.items){if(!work.consume(""))return bestMatch;let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;const{value:rawResults}=await awaitPeerResult(item.find(quote)),results=projectFindResults(rawResults,work);if(!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;for(const result of results.matches){if(!work.consume(""))return bestMatch;const score=fullContextScore===0?0:quoteContextScore(result.excerpt,quote,anchor.prefix,anchor.suffix);if(score===fullContextScore)return result.cfi;score>bestScore&&(bestMatch=result.cfi,bestScore=score)}}catch{continue}finally{if(loaded)try{item.unload()}catch{}}}return bestMatch}repaintHighlights(){const rendition=this.rendition;if(!rendition)return;const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,work=new ViewerSearchWorkBudget;for(const cfi of this.paintedHighlightCfis){if(!work.consume(cfi))break;rendition.annotations.remove(cfi,"highlight")}this.paintedHighlightCfis=[];let painted=0;const fillCache=new Map,resolveFill=pair=>{let value=fillCache.get(pair.token);return value===void 0&&(value=this.resolveHighlightFill(pair).fill,fillCache.set(pair.token,value)),value};for(const highlight of prioritizedHighlightCandidates(this.highlights,this.activeHighlightId)){if(highlight.anchor.kind!=="cfi")continue;if(painted>=MAX_PAINTED_HIGHLIGHTS)break;const cfi=highlight.anchor.cfi.trim();if(!cfi||cfi.length>VIEWER_SEARCH_QUERY_LIMIT||!work.consume(cfi))continue;const tone=highlight.tone??"accent",active=highlight.id===this.activeHighlightId,styles2={fill:resolveFill(TONE_FILL_TOKEN[tone])};if(active){const forcedColors=this.ownerDocument.defaultView?.matchMedia?.("(forced-colors: active)").matches??!1;styles2.stroke=forcedColors?"CanvasText":resolveFill(ACTIVE_HIGHLIGHT_STROKE_TOKEN),styles2["stroke-width"]="3",styles2["stroke-dasharray"]="2 1"}rendition.annotations.highlight(cfi,{id:highlight.id},()=>{!book||!ownerView||!this.isCurrentBookRendition(generation,ownerView,book,rendition)||this.emit("lr-highlight-activate",{highlightId:highlight.id})},active?`lr-hl-${tone} lr-ebook-highlight-active`:`lr-hl-${tone}`,styles2),this.paintedHighlightCfis.push(cfi),painted++}}repaintSearchAnnotation(){const rendition=this.rendition,cfi=this.searchAnnotationCfi;!rendition||!cfi||(rendition.annotations.remove(cfi,"highlight"),rendition.annotations.highlight(cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN)))}repaintAnnotations(){const rendition=this.rendition;if(rendition)try{this.repaintHighlights(),this.repaintSearchAnnotation()}catch(error){this.reportRenditionFailure(error,rendition,this.generation)}}async search(query){const generation=++this.searchGeneration,ownerView=this.ownerDocument.defaultView,boundedQuery=boundedViewerSearchQuery(query,this.effectiveLocale);if(this.searchQuery=query,this.lastSearchLocale=this.effectiveLocale,this.clearSearchAnnotation(),!boundedQuery.accepted)return this.searchMatches=[],this.searchMatchCountExact=!1,this.searchActiveIndex=-1,this.emitSearchChange(),0;if(!this.book||!ownerView||!boundedQuery.needle)return this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.emitSearchChange(),0;const matches=[];let matchCountExact=!0,matchCeilingExceeded=!1;const book=this.book,work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);spine.exact||(matchCountExact=!1);for(const item of spine.items){if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected)return this.searchMatches.length;if(!work.consume("")){matchCountExact=!1;break}let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;const{value:rawResults}=await awaitPeerResult(item.find(query.trim())),results=projectFindResults(rawResults,work);if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;results.exact||(matchCountExact=!1);for(const r of results.matches){if(!work.consume("")){matchCountExact=!1,matchCeilingExceeded=!0;break}if(matches.length===MAX_SEARCH_MATCHES){matchCountExact=!1,matchCeilingExceeded=!0;break}matches.push(r)}}catch{matchCountExact=!1;continue}finally{if(loaded)try{item.unload()}catch{matchCountExact=!1}}if(matchCeilingExceeded)break}return generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book?this.searchMatches.length:(this.searchMatches=matches,this.searchMatchCountExact=matchCountExact,this.searchActiveIndex=matches.length>0?0:-1,this.emitSearchChange(),this.searchActiveIndex>=0&&await this.showSearchMatch(this.searchActiveIndex,generation,ownerView),matches.length)}async searchNext(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex+1)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}async searchPrevious(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex-1+this.searchMatches.length)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}clearSearch(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.clearSearchAnnotation(),this.emit("lr-search-change",{query:"",matchCount:0,matchCountExact:!0,activeIndex:-1})}clearSearchAnnotation(){const cfi=this.searchAnnotationCfi;this.searchAnnotationCfi=void 0;const rendition=this.rendition,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!(!cfi||!rendition||!ownerView))try{rendition.annotations.remove(cfi,"highlight")}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async showSearchMatch(index,generation=this.searchGeneration,ownerView=this.ownerDocument.defaultView){const match=this.searchMatches[index],rendition=this.rendition;if(!match||!rendition||generation!==this.searchGeneration||!ownerView||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;this.clearSearchAnnotation();try{await rendition.display(match.cfi)}catch(error){return generation===this.searchGeneration&&rendition===this.rendition&&this.ownerDocument.defaultView===ownerView&&this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}if(generation!==this.searchGeneration||rendition!==this.rendition||this.searchMatches[index]!==match||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;try{rendition.annotations.highlight(match.cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN))}catch(error){return this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}return this.searchAnnotationCfi=match.cfi,!0}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:this.searchMatchCountExact,activeIndex:this.searchActiveIndex})}resolveHighlightFill({token,fallback}){return{fill:(this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(token).trim()??"")||fallback}}renderStatus(){return this.ebookState.kind==="loading"?renderViewerLoading(this.localize("loadingDocument")):this.ebookState.kind==="error"?html`<div part="error">${this.ebookState.message}</div>`:this.ebookState.kind==="idle"?html`<p class="status-note">${this.localize("documentPreviewEmpty",void 0,{type:this.localize("documentPreviewTypeDocument")})}</p>`:nothing}render(){const maxHeight=sanitizeCssLength(this.maxHeight),disabled=this.ebookState.kind!=="ready";return html`
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{createRef,ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DEFAULT_CANVAS_COLOR}from"../../../internal/canvas-color.js";import{isAbortError,isResourceLimitError,LyraUserFacingError,readResponseArrayBuffer,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{srOnly}from"../../../internal/a11y.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{getOwnDataDescriptor,isObjectValue,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{DocumentAnchorTarget,prioritizedHighlightCandidates}from"../../../internal/anchor-target.js";import{textQuoteContextScore}from"../document-viewer/anchors.js";import{getEpubJs}from"./ebook-loader.js";import{assertEpubArchiveWithinLimits}from"./epub-resource-guard.js";import{guardEpubUnloadListener}from"./epub-unload-guard.js";import{styles}from"./ebook-viewer.styles.js";import{ViewerAnnouncementController}from"../viewer-announcements.js";import{viewerSemanticLabel,viewerSemanticRole}from"../viewer-semantic-owner.js";import{renderViewerLoading,viewerLoadingStyles}from"../viewer-loading.js";import{renderViewerPagerButton,viewerPagerStyles}from"../viewer-pager.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{boundedViewerSearchQuery,ViewerSearchWorkBudget,VIEWER_SEARCH_QUERY_LIMIT}from"../viewer-search-limits.js";import{boundedSelectionRects,boundedSelectionText}from"../../../internal/text-quote.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_documentPreviewEmpty}from"../../../internal/default-strings/shared.generated.js";import{LYRA_DEFAULT_documentPreviewResourceTooLarge,LYRA_DEFAULT_documentPreviewTypeDocument,LYRA_DEFAULT_documentPreviewUrlNotAllowed,LYRA_DEFAULT_ebookViewerLoadError,LYRA_DEFAULT_ebookViewerMissingLibrary,LYRA_DEFAULT_ebookViewerNextChapter,LYRA_DEFAULT_ebookViewerPreviousChapter,LYRA_DEFAULT_ebookViewerRegionLabel,LYRA_DEFAULT_loadingDocument}from"../../../internal/default-strings/viewers.generated.js";const MAX_TOC_ITEMS=1e4,MAX_TOC_DEPTH=100,MAX_SEARCH_MATCHES=1e4,MAX_SEARCH_SPINE_ITEMS=1e3,MAX_FIND_RESULTS=1e4,MAX_PAINTED_HIGHLIGHTS=100,MAX_PEER_PROTOTYPES=100;function isArrayValue(value){try{return Array.isArray(value)}catch{return!1}}function inheritedDataDescriptor(value,key){let current=value;for(let depth=0;current&&depth<MAX_PEER_PROTOTYPES;depth+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(current,key)}catch{return}if(descriptor)return"value"in descriptor?descriptor:void 0;try{current=Object.getPrototypeOf(current)}catch{return}}}function inheritedDataValue(value,key){return isObjectValue(value)?inheritedDataDescriptor(value,key)?.value:void 0}function savedCallable(value,key){if(!isObjectValue(value))return;const candidate=inheritedDataDescriptor(value,key)?.value;if(typeof candidate=="function")return(...args)=>Reflect.apply(candidate,value,args)}function savedThenable(value){const then=savedCallable(value,"then");if(then)return new Promise((resolve,reject)=>{try{then(()=>resolve(),reject)}catch(error){reject(error)}})}function taskFrom(call,...args){try{return savedThenable(call(...args))??Promise.resolve()}catch(error){return Promise.reject(error)}}function awaitPeerResult(value){const then=savedCallable(value,"then"),wrap=resolved=>Object.freeze({value:resolved});return then?new Promise((resolve,reject)=>{try{then(resolved=>resolve(wrap(resolved)),reject)}catch(error){reject(error)}}):Promise.resolve(wrap(value))}function quoteContextScore(excerpt,quote,prefix,suffix){const text=excerpt.replace(/\s+/g," ").toLowerCase(),needle=quote.replace(/\s+/g," ").toLowerCase();let best=0;for(let at=text.indexOf(needle);at>=0;at=text.indexOf(needle,at+1))best=Math.max(best,textQuoteContextScore(text,at,at+needle.length,prefix,suffix));return best}const EPUB_CHAPTER_CONTENT_SECURITY_POLICY="default-src 'none'; img-src blob: data:; media-src blob: data:; font-src blob: data:; style-src blob: 'unsafe-inline'";function silenceChapterNetwork(chapter){const root=chapter.documentElement;if(!root)return;for(const node of[...chapter.childNodes])node.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&chapter.removeChild(node);for(const element of[...chapter.querySelectorAll("link, meta")]){const rel=` ${(element.getAttribute("rel")??"").toLowerCase()} `;(/ (?:dns-prefetch|preconnect) /.test(rel)||(element.getAttribute("http-equiv")??"").trim().toLowerCase()==="refresh")&&element.remove()}const namespace=root.namespaceURI??"http://www.w3.org/1999/xhtml";let head=chapter.querySelector("head");head||(head=chapter.createElementNS(namespace,"head"),root.insertBefore(head,root.firstChild));const policy=chapter.createElementNS(namespace,"meta");policy.setAttribute("http-equiv","Content-Security-Policy"),policy.setAttribute("content",EPUB_CHAPTER_CONTENT_SECURITY_POLICY),head.insertBefore(policy,head.firstChild)}function registerNetworkSilentChapters(book){const contentHooks=inheritedDataValue(inheritedDataValue(book.spine,"hooks"),"content");savedCallable(contentHooks,"register")?.(silenceChapterNetwork)}function normalizeBook(value){if(!isObjectValue(value))return;const ready=savedThenable(inheritedDataValue(value,"ready")),renderTo=savedCallable(value,"renderTo"),destroy=savedCallable(value,"destroy");if(!ready||!renderTo||!destroy)return;let navigationCaptured=!1,navigation;const getNavigation=()=>(navigationCaptured||(navigationCaptured=!0,navigation=inheritedDataValue(value,"navigation")),navigation),spine=inheritedDataValue(value,"spine"),load=savedCallable(value,"load");return Object.freeze({ready,...spine===void 0?{}:{spine},...load===void 0?{}:{load},getNavigation,renderTo:(element,options)=>renderTo(element,options),destroy:()=>{destroy()}})}function normalizeRendition(value){if(!isObjectValue(value))return;const display=savedCallable(value,"display"),prev=savedCallable(value,"prev"),next=savedCallable(value,"next"),on=savedCallable(value,"on"),annotationsValue=inheritedDataValue(value,"annotations"),highlight=savedCallable(annotationsValue,"highlight"),remove=savedCallable(annotationsValue,"remove");if(!(!display||!prev||!next||!on||!highlight||!remove))return Object.freeze({display:target=>taskFrom(display,target),prev:()=>taskFrom(prev),next:()=>taskFrom(next),on:(type,callback)=>{on(type,callback)},annotations:Object.freeze({highlight:(cfi,data,callback,className,styles2)=>highlight(cfi,data,callback,className,styles2),remove:(cfi,type)=>{remove(cfi,type)}})})}function normalizeSpineItem(value){const load=savedCallable(value,"load"),find=savedCallable(value,"find"),unload=savedCallable(value,"unload");if(!(!load||!find||!unload))return Object.freeze({load:request=>load(request),find:query=>find(query),unload:()=>{unload()}})}function projectSpineItems(book){const spineItems=inheritedDataValue(book.spine,"spineItems");if(!isArrayValue(spineItems))return Object.freeze({items:Object.freeze([]),exact:spineItems===void 0});const length=getOwnDataDescriptor(spineItems,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({items:Object.freeze([]),exact:!1});const items=[];let exact=length.value<=MAX_SEARCH_SPINE_ITEMS;const count=Math.min(length.value,MAX_SEARCH_SPINE_ITEMS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(spineItems,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR){exact=!1;continue}const item=normalizeSpineItem(descriptor.value);if(!item){exact=!1;continue}items.push(item)}return Object.freeze({items:Object.freeze(items),exact})}function projectFindResults(value,work){if(!isArrayValue(value))return Object.freeze({matches:Object.freeze([]),exact:!1});const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({matches:Object.freeze([]),exact:!1});const matches=[];let exact=length.value<=MAX_FIND_RESULTS;const count=Math.min(length.value,MAX_FIND_RESULTS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!isObjectValue(descriptor.value)){exact=!1;continue}const cfi=getOwnDataDescriptor(descriptor.value,"cfi"),excerpt=getOwnDataDescriptor(descriptor.value,"excerpt");if(cfi===MISSING_OWN_DATA_DESCRIPTOR||cfi===UNSAFE_OWN_DATA_DESCRIPTOR||typeof cfi.value!="string"){exact=!1;continue}if(!work.canConsume(cfi.value)||!work.consume(cfi.value)||cfi.value.trim()===""){exact=!1;continue}let excerptValue="";excerpt!==MISSING_OWN_DATA_DESCRIPTOR&&(excerpt===UNSAFE_OWN_DATA_DESCRIPTOR||typeof excerpt.value!="string"||!work.canConsume(excerpt.value)||!work.consume(excerpt.value)?exact=!1:excerptValue=excerpt.value),matches.push({cfi:cfi.value,excerpt:excerptValue})}return Object.freeze({matches:Object.freeze(matches),exact})}function pushTocEntries(value,level,budget,stack){if(!isArrayValue(value)||budget.positions>=MAX_TOC_ITEMS)return;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const count=Math.min(length.value,MAX_TOC_ITEMS-budget.positions);for(let index=count-1;index>=0;index-=1){budget.positions+=1;const descriptor=getOwnDataDescriptor(value,String(index));descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||stack.push({value:descriptor.value,level})}}function projectToc(value){const budget={positions:0,nodes:0,seen:new WeakSet},stack=[];pushTocEntries(value,1,budget,stack);const items=[];for(;stack.length>0&&budget.nodes<MAX_TOC_ITEMS;){const current=stack.pop();if(!isObjectValue(current.value)||budget.seen.has(current.value))continue;budget.seen.add(current.value),budget.nodes+=1;const href=getOwnDataDescriptor(current.value,"href"),id=getOwnDataDescriptor(current.value,"id"),label=getOwnDataDescriptor(current.value,"label"),children=getOwnDataDescriptor(current.value,"subitems");if(href!==MISSING_OWN_DATA_DESCRIPTOR&&href!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof href.value=="string"){const idValue=id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof id.value=="string"&&id.value!==""?id.value:href.value,labelValue=label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?label.value.trim():"";items.push({id:idValue,label:labelValue,href:href.value,level:current.level})}current.level<MAX_TOC_DEPTH&&children!==MISSING_OWN_DATA_DESCRIPTOR&&children!==UNSAFE_OWN_DATA_DESCRIPTOR&&pushTocEntries(children.value,current.level+1,budget,stack)}return Object.freeze(items)}const TONE_FILL_TOKEN={accent:{token:"--lr-color-brand-quiet",fallback:"#ddf4ff"},success:{token:"--lr-color-success-quiet",fallback:"#dafbe1"},warning:{token:"--lr-color-warning-quiet",fallback:"#fff8c5"},danger:{token:"--lr-color-danger-quiet",fallback:"#ffebe9"},neutral:{token:"--lr-color-surface-raised",fallback:"#f6f8fa"}},SEARCH_MATCH_FILL_TOKEN={token:"--lr-color-warning",fallback:"#9a6700"},ACTIVE_HIGHLIGHT_STROKE_TOKEN={token:"--lr-focus-ring-color",fallback:DEFAULT_CANVAS_COLOR};class LyraEbookViewerBase extends LyraElement{}class LyraEbookViewer extends DocumentAnchorTarget(LyraEbookViewerBase){static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,documentPreviewEmpty:LYRA_DEFAULT_documentPreviewEmpty,documentPreviewResourceTooLarge:LYRA_DEFAULT_documentPreviewResourceTooLarge,documentPreviewTypeDocument:LYRA_DEFAULT_documentPreviewTypeDocument,documentPreviewUrlNotAllowed:LYRA_DEFAULT_documentPreviewUrlNotAllowed,ebookViewerLoadError:LYRA_DEFAULT_ebookViewerLoadError,ebookViewerMissingLibrary:LYRA_DEFAULT_ebookViewerMissingLibrary,ebookViewerNextChapter:LYRA_DEFAULT_ebookViewerNextChapter,ebookViewerPreviousChapter:LYRA_DEFAULT_ebookViewerPreviousChapter,ebookViewerRegionLabel:LYRA_DEFAULT_ebookViewerRegionLabel,loadingDocument:LYRA_DEFAULT_loadingDocument}}static{this.styles=[LyraElement.styles,styles,viewerPagerStyles,srOnly,viewerLoadingStyles]}constructor(){super(),this.src="",this.name="",this.maxHeight="",this.location="",this.anchorKinds=["cfi","text-quote"],this.ebookState={kind:"idle"},this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.mountRef=createRef(),this.generation=0,this.failedGeneration=-1,this.searchQuery="",this.lastSearchLocale="",this.searchGeneration=0,this.pendingSearchResetEvent=!1,this.anchorOperationGeneration=0,this.paintedHighlightCfis=[],this.announcements=new ViewerAnnouncementController(this),this.chapterButtonFocused=!1,this.previous=()=>{this.runRenditionNavigation("previous")},this.next=()=>{this.runRenditionNavigation("next")},new ThemeWatcher(this,()=>this.repaintAnnotations())}updated(changed){if(super.updated(changed),this.chapterButtonFocused&&this.ebookState.kind!=="ready"&&this.shadowRoot?.querySelector('[part="mount"]')?.focus(),this.chapterButtonFocused=!1,this.announcements.transition("load",this.ebookState.kind,this.ebookState.kind==="error"?this.ebookState.message:this.localize("loadingDocument")),changed.has("src")&&this.scheduleAfterUpdate(()=>{this.load()}),changed.has("src")&&this.pendingSearchResetEvent&&(this.pendingSearchResetEvent=!1,this.emitSearchChange()),changed.has("location")){const fromRelocated=this.relocatedLocation===this.location;this.relocatedLocation=void 0,!fromRelocated&&this.rendition&&this.location&&this.displayLocation(this.location)}(changed.has("highlights")||changed.has("activeHighlightId"))&&this.rendition&&this.repaintAnnotations();const locale=this.effectiveLocale;if(locale!==this.lastSearchLocale){const shouldRecompute=this.searchQuery!=="";this.lastSearchLocale=locale,shouldRecompute&&this.scheduleAfterUpdate(()=>{this.search(this.searchQuery)},"search")}}willUpdate(changed){super.willUpdate(changed);const active=shadowFocusTarget(this);this.chapterButtonFocused=active?.localName==="button"&&!active.disabled&&active.getAttribute("part")?.endsWith("-button")===!0,changed.has("src")&&(this.pendingSearchResetEvent||=this.hasSearchState(),this.resetSearchState())}connectedCallback(){super.connectedCallback(),this.announcements.connect(),this.hasUpdated&&this.src.trim()&&this.scheduleAfterUpdate(()=>{this.load()})}disconnectedCallback(){this.generation++,this.anchorOperationGeneration++,this.announcements.disconnect(),this.teardown(),this.ebookState={kind:"idle"},super.disconnectedCallback()}connectedMoveCallback(){}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}teardown(){const shouldEmitSearchReset=this.hasSearchState();this.destroyBook(this.book),this.book=void 0,this.rendition=void 0,this.resetSearchState(),this.paintedHighlightCfis=[],shouldEmitSearchReset&&this.isConnected&&this.emitSearchChange()}destroyBook(book){try{book?.destroy()}catch{}}isCurrentLoad(generation,ownerView){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView}isCurrentBookRendition(generation,ownerView,book,rendition){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView&&this.book===book&&this.rendition===rendition}failCurrentLoad(error,message=this.localize("ebookViewerLoadError")){this.failedGeneration!==this.generation&&(this.failedGeneration=this.generation,this.ebookState={kind:"error",message},this.emit("lr-render-error",{error}))}hasSearchState(){return this.searchQuery!==""||this.searchMatches.length>0||!this.searchMatchCountExact||this.searchActiveIndex!==-1}resetSearchState(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.searchAnnotationCfi=void 0}async load(){const generation=++this.generation,signal=this.beginAbortableLoad();if(this.teardown(),!this.src.trim()){this.ebookState={kind:"idle"};return}const fetchTarget=resolveOwnerFetchTarget(this,this.src);if(!fetchTarget){this.failWithLocalizedMessage(this.localize("documentPreviewUrlNotAllowed"));return}this.ebookState={kind:"loading"};let data,factory;try{if([data,factory]=await Promise.all([fetchTarget.view.fetch(fetchTarget.url,signal?{signal}:void 0).then(response=>{if(!response.ok)throw new Error(`${response.status} ${response.statusText}`);return readResponseArrayBuffer(response)}),getEpubJs()]),!this.isCurrentLoad(generation,fetchTarget.view)||(await assertEpubArchiveWithinLimits(data,void 0,void 0,{signal}),!this.isCurrentLoad(generation,fetchTarget.view)))return}catch(error){if(isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error,this.localize(isResourceLimitError(error)?"documentPreviewResourceTooLarge":"ebookViewerLoadError"));return}if(!factory){this.failWithLocalizedMessage(this.localize("ebookViewerMissingLibrary"));return}const mount=this.mountRef.value;if(!mount){this.failWithLocalizedMessage(this.localize("ebookViewerLoadError"));return}let candidateBook;try{const book=normalizeBook(factory(data));if(!book)throw new Error("EPUB peer returned an unusable book.");candidateBook=book,registerNetworkSilentChapters(book);const rawRendition=book.renderTo(mount,{width:"100%",height:"100%"});guardEpubUnloadListener({settings:inheritedDataValue(rawRendition,"settings"),requireManager:savedCallable(rawRendition,"requireManager")});const rendition=normalizeRendition(rawRendition);if(!rendition)throw new Error("EPUB peer returned an unusable rendition.");if(await book.ready,!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}if(book.getNavigation(),await rendition.display(this.location||void 0),!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}rendition.on("relocated",loc=>{if(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition))return;const start=inheritedDataValue(loc,"start"),cfi=inheritedDataValue(start,"cfi"),href=inheritedDataValue(start,"href");typeof cfi!="string"||cfi.trim()===""||!cfi||cfi===this.location||(this.relocatedLocation=cfi,this.location=cfi,this.emit("lr-location-change",{cfi,href:typeof href=="string"?href:""}))}),rendition.on("selected",(cfiRange,contents)=>{if(!(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition)||typeof cfiRange!="string"))try{const contentsWindow=inheritedDataValue(contents,"window"),selection=savedCallable(contentsWindow,"getSelection")?.(),range=this.selectedRange(selection);if(!range)return;const text=boundedSelectionText(range);if(!text)return;const rects=this.translateSelectionRects(boundedSelectionRects(range),contentsWindow);this.emit("lr-text-select",{text,anchor:{kind:"cfi",cfi:cfiRange},rects})}catch{}}),this.book=book,this.rendition=rendition,candidateBook=void 0,this.ebookState={kind:"ready"},this.repaintAnnotations()}catch(error){if(this.destroyBook(candidateBook),isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error)}}selectedRange(selection){const prototype=this.ownerDocument.defaultView?.Selection.prototype;if(prototype)try{const count2=Object.getOwnPropertyDescriptor(prototype,"rangeCount")?.get?.call(selection);if(typeof count2=="number")return count2>0?prototype.getRangeAt.call(selection,0):null}catch{}const count=inheritedDataValue(selection,"rangeCount"),getRangeAt=savedCallable(selection,"getRangeAt");return typeof count=="number"&&count>0&&getRangeAt?getRangeAt(0):null}failWithLocalizedMessage(message){const error=new LyraUserFacingError(message);this.failCurrentLoad(error,message)}reportRenditionFailure(error,rendition,generation,ownerView=this.ownerDocument.defaultView){!this.isConnected||generation!==this.generation||this.ownerDocument.defaultView!==ownerView||rendition!==this.rendition||this.failCurrentLoad(error)}translateSelectionRects(rects,sourceWindow){const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow||!sourceWindow)return[];const translated=[];for(const rect of rects){let x=Number(rect.x??rect.left),y=Number(rect.y??rect.top),width=Number(rect.width),height=Number(rect.height);if(![x,y,width,height].every(Number.isFinite))continue;let current=sourceWindow,valid=!0;for(;current&¤t!==ownerWindow;){if(!("frameElement"in current)){current=ownerWindow;break}let frameElement;try{frameElement=current.frameElement}catch{valid=!1;break}const frameWindow=frameElement?.ownerDocument.defaultView;if(!frameElement||!frameWindow||!(frameElement instanceof frameWindow.HTMLElement)){valid=!1;break}const frame=frameElement,frameRect=frame.getBoundingClientRect(),borderBoxWidth=frame.offsetWidth||frame.clientWidth,borderBoxHeight=frame.offsetHeight||frame.clientHeight,viewportWidth=current.innerWidth||frame.clientWidth,viewportHeight=current.innerHeight||frame.clientHeight;if(borderBoxWidth<=0||borderBoxHeight<=0||viewportWidth<=0||viewportHeight<=0){valid=!1;break}const borderScaleX=frameRect.width/borderBoxWidth,borderScaleY=frameRect.height/borderBoxHeight,contentScaleX=frame.clientWidth*borderScaleX/viewportWidth,contentScaleY=frame.clientHeight*borderScaleY/viewportHeight;x=frameRect.left+frame.clientLeft*borderScaleX+x*contentScaleX,y=frameRect.top+frame.clientTop*borderScaleY+y*contentScaleY,width*=contentScaleX,height*=contentScaleY,current=frame.ownerDocument.defaultView}!valid||current!==ownerWindow||translated.push(Object.freeze({x,y,width,height,top:y,right:x+width,bottom:y+height,left:x}))}return translated}displayLocation(location){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{Promise.resolve(rendition.display(location)).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}runRenditionNavigation(action){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{const task=action==="previous"?rendition.prev():rendition.next();Promise.resolve(task).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async getToc(){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!book||!ownerView)return[];try{await book.ready}catch{return[]}return!this.isCurrentLoad(generation,ownerView)||this.book!==book?[]:[...projectToc(inheritedDataValue(book.getNavigation(),"toc"))]}async scrollToAnchor(target){const operation=++this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView,book=this.book,rendition=this.rendition;try{return await Object.getPrototypeOf(LyraEbookViewer.prototype).performScrollToAnchor.call(this,target)}catch(error){return operation!==this.anchorOperationGeneration||!ownerView||!this.isCurrentLoad(generation,ownerView)||this.book!==book||this.rendition!==rendition||(rendition&&this.reportRenditionFailure(error,rendition,generation,ownerView),this.emit("lr-anchor-result",{found:!1})),!1}}async applyAnchor(anchor){const rendition=this.rendition,operation=this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!rendition||!ownerView)return!1;if(anchor.kind==="cfi")return operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(anchor.cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition);if(anchor.kind==="text-quote"){const cfi=await this.findTextQuoteCfi(anchor);return!cfi||operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition)}return!1}async findTextQuoteCfi(anchor){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,quote=anchor.quote.trim(),boundedQuery=boundedViewerSearchQuery(quote,this.effectiveLocale);if(!book||!ownerView||!boundedQuery.accepted||!boundedQuery.needle)return null;const fullContextScore=(anchor.prefix?.trim()?1:0)+(anchor.suffix?.trim()?1:0);let bestMatch=null,bestScore=-1;const work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);for(const item of spine.items){if(!work.consume(""))return bestMatch;let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;const{value:rawResults}=await awaitPeerResult(item.find(quote)),results=projectFindResults(rawResults,work);if(!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;for(const result of results.matches){if(!work.consume(""))return bestMatch;const score=fullContextScore===0?0:quoteContextScore(result.excerpt,quote,anchor.prefix,anchor.suffix);if(score===fullContextScore)return result.cfi;score>bestScore&&(bestMatch=result.cfi,bestScore=score)}}catch{continue}finally{if(loaded)try{item.unload()}catch{}}}return bestMatch}repaintHighlights(){const rendition=this.rendition;if(!rendition)return;const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,work=new ViewerSearchWorkBudget;for(const cfi of this.paintedHighlightCfis){if(!work.consume(cfi))break;rendition.annotations.remove(cfi,"highlight")}this.paintedHighlightCfis=[];let painted=0;const fillCache=new Map,resolveFill=pair=>{let value=fillCache.get(pair.token);return value===void 0&&(value=this.resolveHighlightFill(pair).fill,fillCache.set(pair.token,value)),value};for(const highlight of prioritizedHighlightCandidates(this.highlights,this.activeHighlightId)){if(highlight.anchor.kind!=="cfi")continue;if(painted>=MAX_PAINTED_HIGHLIGHTS)break;const cfi=highlight.anchor.cfi.trim();if(!cfi||cfi.length>VIEWER_SEARCH_QUERY_LIMIT||!work.consume(cfi))continue;const tone=highlight.tone??"accent",active=highlight.id===this.activeHighlightId,styles2={fill:resolveFill(TONE_FILL_TOKEN[tone])};if(active){const forcedColors=this.ownerDocument.defaultView?.matchMedia?.("(forced-colors: active)").matches??!1;styles2.stroke=forcedColors?"CanvasText":resolveFill(ACTIVE_HIGHLIGHT_STROKE_TOKEN),styles2["stroke-width"]="3",styles2["stroke-dasharray"]="2 1"}rendition.annotations.highlight(cfi,{id:highlight.id},()=>{!book||!ownerView||!this.isCurrentBookRendition(generation,ownerView,book,rendition)||this.emit("lr-highlight-activate",{highlightId:highlight.id})},active?`lr-hl-${tone} lr-ebook-highlight-active`:`lr-hl-${tone}`,styles2),this.paintedHighlightCfis.push(cfi),painted++}}repaintSearchAnnotation(){const rendition=this.rendition,cfi=this.searchAnnotationCfi;!rendition||!cfi||(rendition.annotations.remove(cfi,"highlight"),rendition.annotations.highlight(cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN)))}repaintAnnotations(){const rendition=this.rendition;if(rendition)try{this.repaintHighlights(),this.repaintSearchAnnotation()}catch(error){this.reportRenditionFailure(error,rendition,this.generation)}}async search(query){const generation=++this.searchGeneration,ownerView=this.ownerDocument.defaultView,boundedQuery=boundedViewerSearchQuery(query,this.effectiveLocale);if(this.searchQuery=query,this.lastSearchLocale=this.effectiveLocale,this.clearSearchAnnotation(),!boundedQuery.accepted)return this.searchMatches=[],this.searchMatchCountExact=!1,this.searchActiveIndex=-1,this.emitSearchChange(),0;if(!this.book||!ownerView||!boundedQuery.needle)return this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.emitSearchChange(),0;const matches=[];let matchCountExact=!0,matchCeilingExceeded=!1;const book=this.book,work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);spine.exact||(matchCountExact=!1);for(const item of spine.items){if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected)return this.searchMatches.length;if(!work.consume("")){matchCountExact=!1;break}let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;const{value:rawResults}=await awaitPeerResult(item.find(query.trim())),results=projectFindResults(rawResults,work);if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;results.exact||(matchCountExact=!1);for(const r of results.matches){if(!work.consume("")){matchCountExact=!1,matchCeilingExceeded=!0;break}if(matches.length===MAX_SEARCH_MATCHES){matchCountExact=!1,matchCeilingExceeded=!0;break}matches.push(r)}}catch{matchCountExact=!1;continue}finally{if(loaded)try{item.unload()}catch{matchCountExact=!1}}if(matchCeilingExceeded)break}return generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book?this.searchMatches.length:(this.searchMatches=matches,this.searchMatchCountExact=matchCountExact,this.searchActiveIndex=matches.length>0?0:-1,this.emitSearchChange(),this.searchActiveIndex>=0&&await this.showSearchMatch(this.searchActiveIndex,generation,ownerView),matches.length)}async searchNext(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex+1)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}async searchPrevious(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex-1+this.searchMatches.length)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}clearSearch(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.clearSearchAnnotation(),this.emit("lr-search-change",{query:"",matchCount:0,matchCountExact:!0,activeIndex:-1})}clearSearchAnnotation(){const cfi=this.searchAnnotationCfi;this.searchAnnotationCfi=void 0;const rendition=this.rendition,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!(!cfi||!rendition||!ownerView))try{rendition.annotations.remove(cfi,"highlight")}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async showSearchMatch(index,generation=this.searchGeneration,ownerView=this.ownerDocument.defaultView){const match=this.searchMatches[index],rendition=this.rendition;if(!match||!rendition||generation!==this.searchGeneration||!ownerView||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;this.clearSearchAnnotation();try{await rendition.display(match.cfi)}catch(error){return generation===this.searchGeneration&&rendition===this.rendition&&this.ownerDocument.defaultView===ownerView&&this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}if(generation!==this.searchGeneration||rendition!==this.rendition||this.searchMatches[index]!==match||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;try{rendition.annotations.highlight(match.cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN))}catch(error){return this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}return this.searchAnnotationCfi=match.cfi,!0}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:this.searchMatchCountExact,activeIndex:this.searchActiveIndex})}resolveHighlightFill({token,fallback}){return{fill:(this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(token).trim()??"")||fallback}}renderStatus(){return this.ebookState.kind==="loading"?renderViewerLoading(this.localize("loadingDocument")):this.ebookState.kind==="error"?html`<div part="error">${this.ebookState.message}</div>`:this.ebookState.kind==="idle"?html`<p class="status-note">${this.localize("documentPreviewEmpty",void 0,{type:this.localize("documentPreviewTypeDocument")})}</p>`:nothing}render(){const maxHeight=sanitizeCssLength(this.maxHeight),disabled=this.ebookState.kind!=="ready";return html`
|
|
2
2
|
<div
|
|
3
3
|
part="base"
|
|
4
4
|
aria-busy=${this.ebookState.kind==="loading"?"true":"false"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function isManagerClass(value){if(typeof value!="function")return!1;const prototype=Object.getOwnPropertyDescriptor(value,"prototype")?.value;if(typeof prototype!="object"||prototype===null)return!1;let current=prototype;for(let depth=0;current&&depth<8;depth+=1){const descriptor=Object.getOwnPropertyDescriptor(current,"addEventListeners");if(descriptor)return typeof descriptor.value=="function";current=Object.getPrototypeOf(current)}return!1}function guardEpubUnloadListener({settings,requireManager}){if(typeof settings!="object"||settings===null||!requireManager)return;const descriptor=Object.getOwnPropertyDescriptor(settings,"manager");if(!descriptor||!("value"in descriptor)||!descriptor.writable)return;const Manager=requireManager(descriptor.value);if(!isManagerClass(Manager))return;class UnloadFreeManager extends Manager{addEventListeners(...args){const ownListener=Object.hasOwn(window,"addEventListener"),previous=window.addEventListener;window.addEventListener=function(type,...rest){if(type!=="unload")return previous.call(this,type,...rest)};try{return super.addEventListeners(...args)}finally{ownListener?window.addEventListener=previous:delete window.addEventListener}}}Object.defineProperty(settings,"manager",{...descriptor,value:UnloadFreeManager})}export{guardEpubUnloadListener};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{loadDompurify}from"../../../internal/dompurify-loader.js";import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";function isPostalMimeApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"}const postalMime=createOptionalPeerLoader({load:()=>import("postal-mime"),isCapability:isPostalMimeApi,warningKey:"lyra-email-viewer-postal-mime-unavailable",warning:"<lr-email-viewer> could not load its optional postal-mime peer."});let depsPromise,resolvedDeps;async function loadEmailAndSanitizer(importPostalMime,importDompurify){const[PostalMime,DOMPurify]=await Promise.all([importPostalMime?postalMime.loadWith(importPostalMime):postalMime.get(),loadDompurify(importDompurify)]);return{PostalMime:PostalMime??void 0,DOMPurify:DOMPurify??void 0}}function loadEmailDeps(){return depsPromise??=loadEmailAndSanitizer().then(result=>((!result.PostalMime||!result.DOMPurify)&&(depsPromise=void 0),resolvedDeps=result,result)),depsPromise}function getEmailDepsIfLoaded(){return resolvedDeps}function clearEmailDepsCache(){depsPromise=void 0,resolvedDeps=void 0,postalMime.clear()}function __setEmailDepsForTesting(deps){depsPromise=deps===void 0?void 0:Promise.resolve(deps),resolvedDeps=deps}export{__setEmailDepsForTesting,clearEmailDepsCache,getEmailDepsIfLoaded,loadEmailAndSanitizer,loadEmailDeps};
|
|
1
|
+
import{loadDompurify}from"../../../internal/dompurify-loader.js";import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";function isPostalMimeApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"}const postalMime=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("postal-mime")}catch(e){throw e}})(),isCapability:isPostalMimeApi,warningKey:"lyra-email-viewer-postal-mime-unavailable",warning:"<lr-email-viewer> could not load its optional postal-mime peer."});let depsPromise,resolvedDeps;async function loadEmailAndSanitizer(importPostalMime,importDompurify){const[PostalMime,DOMPurify]=await Promise.all([importPostalMime?postalMime.loadWith(importPostalMime):postalMime.get(),loadDompurify(importDompurify)]);return{PostalMime:PostalMime??void 0,DOMPurify:DOMPurify??void 0}}function loadEmailDeps(){return depsPromise??=loadEmailAndSanitizer().then(result=>((!result.PostalMime||!result.DOMPurify)&&(depsPromise=void 0),resolvedDeps=result,result)),depsPromise}function getEmailDepsIfLoaded(){return resolvedDeps}function clearEmailDepsCache(){depsPromise=void 0,resolvedDeps=void 0,postalMime.clear()}function __setEmailDepsForTesting(deps){depsPromise=deps===void 0?void 0:Promise.resolve(deps),resolvedDeps=deps}export{__setEmailDepsForTesting,clearEmailDepsCache,getEmailDepsIfLoaded,loadEmailAndSanitizer,loadEmailDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadHtmlSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadHtmlSanitizer(){return override??loadDompurify()}function clearHtmlSanitizerCache(){override=void 0,clearDompurifyCache()}function __setHtmlSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setHtmlSanitizerForTesting,clearHtmlSanitizerCache,loadHtmlSanitizer,loadHtmlSanitizerDeps};
|
|
1
|
+
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadHtmlSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadHtmlSanitizer(){return override??loadDompurify()}function clearHtmlSanitizerCache(){override=void 0,clearDompurifyCache()}function __setHtmlSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setHtmlSanitizerForTesting,clearHtmlSanitizerCache,loadHtmlSanitizer,loadHtmlSanitizerDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{webgl2Available}from"../../../internal/engine-3d.js";import{tag}from"../../../internal/prefix.js";const modelEngineLoader=createEngine3dLoader({entry:"model",tag:tag("model-viewer"),load:()=>import("@aceshooting/lyra-3d/model")}),modelEngineEnvironment={available:document=>webgl2Available(()=>document.createElement("canvas"))};function supportsAsyncModelData(engine){return"setDataAsync"in engine&&typeof engine.setDataAsync=="function"}export{modelEngineEnvironment,modelEngineLoader,supportsAsyncModelData};
|
|
1
|
+
import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{webgl2Available}from"../../../internal/engine-3d.js";import{tag}from"../../../internal/prefix.js";const modelEngineLoader=createEngine3dLoader({entry:"model",tag:tag("model-viewer"),load:()=>(async()=>{try{return await import("@aceshooting/lyra-3d/model")}catch(e){throw e}})()}),modelEngineEnvironment={available:document=>webgl2Available(()=>document.createElement("canvas"))};function supportsAsyncModelData(engine){return"setDataAsync"in engine&&typeof engine.setDataAsync=="function"}export{modelEngineEnvironment,modelEngineLoader,supportsAsyncModelData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadNotebookSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadNotebookSanitizer(){return override??loadDompurify()}function clearNotebookSanitizerCache(){override=void 0,clearDompurifyCache()}function __setNotebookSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setNotebookSanitizerForTesting,clearNotebookSanitizerCache,loadNotebookSanitizer,loadNotebookSanitizerDeps};
|
|
1
|
+
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadNotebookSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadNotebookSanitizer(){return override??loadDompurify()}function clearNotebookSanitizerCache(){override=void 0,clearDompurifyCache()}function __setNotebookSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setNotebookSanitizerForTesting,clearNotebookSanitizerCache,loadNotebookSanitizer,loadNotebookSanitizerDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PDF_JS_WARNING_KEY="lyra-pdf-viewer-pdfjs-unavailable",PDF_JS_WARNING="<lr-pdf-viewer> could not load its optional pdfjs-dist peer.";function isPdfJsApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"getDocument"in value&&typeof value.getDocument=="function"&&"GlobalWorkerOptions"in value&&(typeof value.GlobalWorkerOptions=="object"||typeof value.GlobalWorkerOptions=="function")&&value.GlobalWorkerOptions!==null}const pdfjs=createOptionalPeerLoader({load:()=>import("pdfjs-dist"),isCapability:isPdfJsApi,warningKey:PDF_JS_WARNING_KEY,warning:PDF_JS_WARNING}),PDF_WORKER_MODULE_SPECIFIER="pdfjs-dist/build/pdf.worker.min.mjs",ALLOWED_WORKER_PROTOCOLS=["http:","https:","blob:","file:"];function defaultWorkerModuleResolver(specifier){const resolver=import.meta.resolve;if(!resolver)return null;try{return resolver(specifier)}catch{return null}}function safeWorkerModuleUrl(value){if(!value)return null;try{const url=new URL(value);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function safeAuthoredWorkerUrl(value){if(!value)return null;try{const url=new URL(value,typeof document>"u"?void 0:document.baseURI);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function configurePdfJsWorker(pdfjsLib,authoredWorkerSrc,resolveWorkerModule){if(pdfjsLib.GlobalWorkerOptions.workerSrc)return;const workerSrc=safeAuthoredWorkerUrl(authoredWorkerSrc)??safeWorkerModuleUrl(resolveWorkerModule(PDF_WORKER_MODULE_SPECIFIER));workerSrc&&(pdfjsLib.GlobalWorkerOptions.workerSrc=workerSrc)}async function loadPdfJsDeps(importPdfjs,resolveWorkerModule=defaultWorkerModuleResolver,workerSrc){const pdfjsLib=await pdfjs.loadWith(importPdfjs);return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,resolveWorkerModule),pdfjsLib}async function loadPdfJs(workerSrc){const pdfjsLib=await pdfjs.get();return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,defaultWorkerModuleResolver),pdfjsLib}function clearPdfJsCache(){pdfjs.clear()}export{clearPdfJsCache,loadPdfJs,loadPdfJsDeps};
|
|
1
|
+
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PDF_JS_WARNING_KEY="lyra-pdf-viewer-pdfjs-unavailable",PDF_JS_WARNING="<lr-pdf-viewer> could not load its optional pdfjs-dist peer.";function isPdfJsApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"getDocument"in value&&typeof value.getDocument=="function"&&"GlobalWorkerOptions"in value&&(typeof value.GlobalWorkerOptions=="object"||typeof value.GlobalWorkerOptions=="function")&&value.GlobalWorkerOptions!==null}const pdfjs=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("pdfjs-dist")}catch(e){throw e}})(),isCapability:isPdfJsApi,warningKey:PDF_JS_WARNING_KEY,warning:PDF_JS_WARNING}),PDF_WORKER_MODULE_SPECIFIER="pdfjs-dist/build/pdf.worker.min.mjs",ALLOWED_WORKER_PROTOCOLS=["http:","https:","blob:","file:"];function defaultWorkerModuleResolver(specifier){const resolver=import.meta.resolve;if(!resolver)return null;try{return resolver(specifier)}catch{return null}}function safeWorkerModuleUrl(value){if(!value)return null;try{const url=new URL(value);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function safeAuthoredWorkerUrl(value){if(!value)return null;try{const url=new URL(value,typeof document>"u"?void 0:document.baseURI);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function configurePdfJsWorker(pdfjsLib,authoredWorkerSrc,resolveWorkerModule){if(pdfjsLib.GlobalWorkerOptions.workerSrc)return;const workerSrc=safeAuthoredWorkerUrl(authoredWorkerSrc)??safeWorkerModuleUrl(resolveWorkerModule(PDF_WORKER_MODULE_SPECIFIER));workerSrc&&(pdfjsLib.GlobalWorkerOptions.workerSrc=workerSrc)}async function loadPdfJsDeps(importPdfjs,resolveWorkerModule=defaultWorkerModuleResolver,workerSrc){const pdfjsLib=await pdfjs.loadWith(importPdfjs);return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,resolveWorkerModule),pdfjsLib}async function loadPdfJs(workerSrc){const pdfjsLib=await pdfjs.get();return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,defaultWorkerModuleResolver),pdfjsLib}function clearPdfJsCache(){pdfjs.clear()}export{clearPdfJsCache,loadPdfJs,loadPdfJsDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PPTX_RENDERER_WARNING_KEY="lyra-pptx-viewer-renderer-unavailable",PPTX_RENDERER_WARNING="<lr-pptx-viewer> could not load its optional @aiden0z/pptx-renderer peer.",MAX_SAFE_PPTX_ZIP_LIMITS={maxEntries:4e3,maxEntryUncompressedBytes:32*1024*1024,maxTotalUncompressedBytes:256*1024*1024,maxMediaBytes:192*1024*1024,maxConcurrency:8};let override;function hasPptxOpenCapability(value){if(typeof value!="object"&&typeof value!="function"||value===null)return!1;const viewer=value.PptxViewer;if(typeof viewer!="object"&&typeof viewer!="function"||viewer===null||typeof viewer.open!="function")return!1;const limits=value.RECOMMENDED_ZIP_LIMITS;return typeof limits!="object"||limits===null?!1:Object.keys(MAX_SAFE_PPTX_ZIP_LIMITS).every(key=>{const candidate=limits[key];return Number.isSafeInteger(candidate)&&candidate>0&&candidate<=MAX_SAFE_PPTX_ZIP_LIMITS[key]})}function adaptPptxViewer(value){if(typeof value!="object"&&typeof value!="function"||value===null)return null;const candidate=value;if(!Number.isSafeInteger(candidate.slideCount)||candidate.slideCount<0||!Number.isSafeInteger(candidate.currentSlideIndex)||typeof candidate.goToSlide!="function"||typeof candidate.searchText!="function"||typeof candidate.highlightSearchResult!="function"||typeof candidate.renderThumbnailToContainer!="function"||typeof candidate.clearSearchHighlights!="function"||typeof candidate.destroy!="function"||typeof candidate.addEventListener!="function"||typeof candidate.removeEventListener!="function")return null;const viewer=candidate,listeners=new Set;let destroyed=!1;const emit=event=>{for(const listener of listeners)listener(event)},onSlideChange=event=>{const index=event.detail?.index;typeof index=="number"&&Number.isSafeInteger(index)&&index>=0&&index<viewer.slideCount&&emit(Object.freeze({kind:"slide-change",index}))},onSlideError=event=>{const detail=event.detail,page=typeof detail?.index=="number"&&Number.isSafeInteger(detail.index)&&detail.index>=0&&detail.index<viewer.slideCount?detail.index+1:void 0,normalized={kind:"diagnostic",code:"pptx-slide-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...page===void 0?{}:{page}};emit(Object.freeze(normalized))},onNodeError=event=>{const detail=event.detail,nodeId=typeof detail?.nodeId=="string"&&detail.nodeId.length<=1024?detail.nodeId:void 0,normalized={kind:"diagnostic",code:"pptx-node-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...nodeId===void 0?{}:{nodeId}};emit(Object.freeze(normalized))};return viewer.addEventListener("slidechange",onSlideChange),viewer.addEventListener("slideerror",onSlideError),viewer.addEventListener("nodeerror",onNodeError),Object.freeze({get slideCount(){return viewer.slideCount},get currentSlideIndex(){return viewer.currentSlideIndex},goToSlide:async index=>{await viewer.goToSlide(index)},searchText:(query,options)=>viewer.searchText(query,options),highlightSearchResult:async(result,options)=>viewer.highlightSearchResult(result,options),renderThumbnailToContainer(index,container,options){if(!Number.isSafeInteger(index)||index<0||index>=viewer.slideCount)return null;const width=options?.width;if(width!==void 0&&(!Number.isFinite(width)||width<=0))return null;const raw=viewer.renderThumbnailToContainer(index,container,options);if(!raw||typeof raw.dispose!="function"||typeof raw.ready?.then!="function")return null;let disposed=!1;return Object.freeze({ready:Promise.resolve(raw.ready),dispose(){disposed||(disposed=!0,raw.dispose())}})},clearSearchHighlights:()=>viewer.clearSearchHighlights(),subscribe(listener){return destroyed?()=>{}:(listeners.add(listener),()=>listeners.delete(listener))},destroy(){destroyed||(destroyed=!0,viewer.removeEventListener("slidechange",onSlideChange),viewer.removeEventListener("slideerror",onSlideError),viewer.removeEventListener("nodeerror",onNodeError),listeners.clear(),viewer.destroy())}})}const pptxRenderer=createOptionalPeerLoader({load:()=>import("@aiden0z/pptx-renderer"),isCapability:hasPptxOpenCapability,warningKey:PPTX_RENDERER_WARNING_KEY,warning:PPTX_RENDERER_WARNING});function loadPptxRenderer(importer){return pptxRenderer.loadWith(importer)}function getPptxRenderer(){return override??pptxRenderer.get()}function __setPptxRendererForTesting(module){override=module===void 0?void 0:Promise.resolve(module),pptxRenderer.clear()}export{__setPptxRendererForTesting,adaptPptxViewer,getPptxRenderer,loadPptxRenderer};
|
|
1
|
+
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PPTX_RENDERER_WARNING_KEY="lyra-pptx-viewer-renderer-unavailable",PPTX_RENDERER_WARNING="<lr-pptx-viewer> could not load its optional @aiden0z/pptx-renderer peer.",MAX_SAFE_PPTX_ZIP_LIMITS={maxEntries:4e3,maxEntryUncompressedBytes:32*1024*1024,maxTotalUncompressedBytes:256*1024*1024,maxMediaBytes:192*1024*1024,maxConcurrency:8};let override;function hasPptxOpenCapability(value){if(typeof value!="object"&&typeof value!="function"||value===null)return!1;const viewer=value.PptxViewer;if(typeof viewer!="object"&&typeof viewer!="function"||viewer===null||typeof viewer.open!="function")return!1;const limits=value.RECOMMENDED_ZIP_LIMITS;return typeof limits!="object"||limits===null?!1:Object.keys(MAX_SAFE_PPTX_ZIP_LIMITS).every(key=>{const candidate=limits[key];return Number.isSafeInteger(candidate)&&candidate>0&&candidate<=MAX_SAFE_PPTX_ZIP_LIMITS[key]})}function adaptPptxViewer(value){if(typeof value!="object"&&typeof value!="function"||value===null)return null;const candidate=value;if(!Number.isSafeInteger(candidate.slideCount)||candidate.slideCount<0||!Number.isSafeInteger(candidate.currentSlideIndex)||typeof candidate.goToSlide!="function"||typeof candidate.searchText!="function"||typeof candidate.highlightSearchResult!="function"||typeof candidate.renderThumbnailToContainer!="function"||typeof candidate.clearSearchHighlights!="function"||typeof candidate.destroy!="function"||typeof candidate.addEventListener!="function"||typeof candidate.removeEventListener!="function")return null;const viewer=candidate,listeners=new Set;let destroyed=!1;const emit=event=>{for(const listener of listeners)listener(event)},onSlideChange=event=>{const index=event.detail?.index;typeof index=="number"&&Number.isSafeInteger(index)&&index>=0&&index<viewer.slideCount&&emit(Object.freeze({kind:"slide-change",index}))},onSlideError=event=>{const detail=event.detail,page=typeof detail?.index=="number"&&Number.isSafeInteger(detail.index)&&detail.index>=0&&detail.index<viewer.slideCount?detail.index+1:void 0,normalized={kind:"diagnostic",code:"pptx-slide-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...page===void 0?{}:{page}};emit(Object.freeze(normalized))},onNodeError=event=>{const detail=event.detail,nodeId=typeof detail?.nodeId=="string"&&detail.nodeId.length<=1024?detail.nodeId:void 0,normalized={kind:"diagnostic",code:"pptx-node-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...nodeId===void 0?{}:{nodeId}};emit(Object.freeze(normalized))};return viewer.addEventListener("slidechange",onSlideChange),viewer.addEventListener("slideerror",onSlideError),viewer.addEventListener("nodeerror",onNodeError),Object.freeze({get slideCount(){return viewer.slideCount},get currentSlideIndex(){return viewer.currentSlideIndex},goToSlide:async index=>{await viewer.goToSlide(index)},searchText:(query,options)=>viewer.searchText(query,options),highlightSearchResult:async(result,options)=>viewer.highlightSearchResult(result,options),renderThumbnailToContainer(index,container,options){if(!Number.isSafeInteger(index)||index<0||index>=viewer.slideCount)return null;const width=options?.width;if(width!==void 0&&(!Number.isFinite(width)||width<=0))return null;const raw=viewer.renderThumbnailToContainer(index,container,options);if(!raw||typeof raw.dispose!="function"||typeof raw.ready?.then!="function")return null;let disposed=!1;return Object.freeze({ready:Promise.resolve(raw.ready),dispose(){disposed||(disposed=!0,raw.dispose())}})},clearSearchHighlights:()=>viewer.clearSearchHighlights(),subscribe(listener){return destroyed?()=>{}:(listeners.add(listener),()=>listeners.delete(listener))},destroy(){destroyed||(destroyed=!0,viewer.removeEventListener("slidechange",onSlideChange),viewer.removeEventListener("slideerror",onSlideError),viewer.removeEventListener("nodeerror",onNodeError),listeners.clear(),viewer.destroy())}})}const pptxRenderer=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("@aiden0z/pptx-renderer")}catch(e){throw e}})(),isCapability:hasPptxOpenCapability,warningKey:PPTX_RENDERER_WARNING_KEY,warning:PPTX_RENDERER_WARNING});function loadPptxRenderer(importer){return pptxRenderer.loadWith(importer)}function getPptxRenderer(){return override??pptxRenderer.get()}function __setPptxRendererForTesting(module){override=module===void 0?void 0:Promise.resolve(module),pptxRenderer.clear()}export{__setPptxRendererForTesting,adaptPptxViewer,getPptxRenderer,loadPptxRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const SPREADSHEET_WARNING_KEY="lyra-spreadsheet-viewer-xlsx-unavailable",SPREADSHEET_WARNING="<lr-spreadsheet-viewer> could not load its optional xlsx peer.";function isSheetJsApi(candidate){const api=candidate;return!!(api&&typeof api.read=="function"&&typeof api.utils?.sheet_to_json=="function")}const sheetJs=createOptionalPeerLoader({load:()=>import("xlsx"),isCapability:isSheetJsApi,warningKey:SPREADSHEET_WARNING_KEY,warning:SPREADSHEET_WARNING});function loadSheetJs(importXlsx){return sheetJs.loadWith(importXlsx)}function loadSheetJsCached(){return sheetJs.get()}function clearSheetJsCache(){sheetJs.clear()}export{clearSheetJsCache,loadSheetJs,loadSheetJsCached};
|
|
1
|
+
import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const SPREADSHEET_WARNING_KEY="lyra-spreadsheet-viewer-xlsx-unavailable",SPREADSHEET_WARNING="<lr-spreadsheet-viewer> could not load its optional xlsx peer.";function isSheetJsApi(candidate){const api=candidate;return!!(api&&typeof api.read=="function"&&typeof api.utils?.sheet_to_json=="function")}const sheetJs=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("xlsx")}catch(e){throw e}})(),isCapability:isSheetJsApi,warningKey:SPREADSHEET_WARNING_KEY,warning:SPREADSHEET_WARNING});function loadSheetJs(importXlsx){return sheetJs.loadWith(importXlsx)}function loadSheetJsCached(){return sheetJs.get()}function clearSheetJsCache(){sheetJs.clear()}export{clearSheetJsCache,loadSheetJs,loadSheetJsCached};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";function loadSvgSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadSvgSanitizer(){return loadDompurify()}function clearSvgSanitizerCache(){clearDompurifyCache()}export{clearSvgSanitizerCache,loadSvgSanitizer,loadSvgSanitizerDeps};
|
|
1
|
+
import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";function loadSvgSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadSvgSanitizer(){return loadDompurify()}function clearSvgSanitizerCache(){clearDompurifyCache()}export{clearSvgSanitizerCache,loadSvgSanitizer,loadSvgSanitizerDeps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createOptionalPeerLoader,isHtmlSanitizer}from"./optional-peer-capabilities.js";const dompurify=createOptionalPeerLoader({load:()=>import("dompurify"),isCapability:isHtmlSanitizer,warningKey:"lyra-dompurify-unavailable",warning:"A lyra-ui component could not load its optional dompurify peer."});function loadDompurify(importer){return importer?dompurify.loadWith(importer):dompurify.get()}function clearDompurifyCache(){dompurify.clear()}export{clearDompurifyCache,loadDompurify};
|
|
1
|
+
import{createOptionalPeerLoader,isHtmlSanitizer}from"./optional-peer-capabilities.js";const dompurify=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})(),isCapability:isHtmlSanitizer,warningKey:"lyra-dompurify-unavailable",warning:"A lyra-ui component could not load its optional dompurify peer."});function loadDompurify(importer){return importer?dompurify.loadWith(importer):dompurify.get()}function clearDompurifyCache(){dompurify.clear()}export{clearDompurifyCache,loadDompurify};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const localeLoaders=Object.freeze({am:()=>import("@aceshooting/lyra-translations/am.js"),ar:()=>import("@aceshooting/lyra-translations/ar.js"),bg:()=>import("@aceshooting/lyra-translations/bg.js"),bho:()=>import("@aceshooting/lyra-translations/bho.js"),bn:()=>import("@aceshooting/lyra-translations/bn.js"),ca:()=>import("@aceshooting/lyra-translations/ca.js"),cs:()=>import("@aceshooting/lyra-translations/cs.js"),da:()=>import("@aceshooting/lyra-translations/da.js"),de:()=>import("@aceshooting/lyra-translations/de.js"),"de-CH":()=>import("@aceshooting/lyra-translations/de-CH.js"),el:()=>import("@aceshooting/lyra-translations/el.js"),"en-GB":()=>import("@aceshooting/lyra-translations/en-GB.js"),es:()=>import("@aceshooting/lyra-translations/es.js"),"es-419":()=>import("@aceshooting/lyra-translations/es-419.js"),et:()=>import("@aceshooting/lyra-translations/et.js"),fa:()=>import("@aceshooting/lyra-translations/fa.js"),"fa-AF":()=>import("@aceshooting/lyra-translations/fa-AF.js"),fi:()=>import("@aceshooting/lyra-translations/fi.js"),fil:()=>import("@aceshooting/lyra-translations/tl.js"),fr:()=>import("@aceshooting/lyra-translations/fr.js"),"fr-CA":()=>import("@aceshooting/lyra-translations/fr-CA.js"),ga:()=>import("@aceshooting/lyra-translations/ga.js"),gu:()=>import("@aceshooting/lyra-translations/gu.js"),ha:()=>import("@aceshooting/lyra-translations/ha.js"),he:()=>import("@aceshooting/lyra-translations/he.js"),hi:()=>import("@aceshooting/lyra-translations/hi.js"),hr:()=>import("@aceshooting/lyra-translations/hr.js"),hu:()=>import("@aceshooting/lyra-translations/hu.js"),id:()=>import("@aceshooting/lyra-translations/id.js"),ig:()=>import("@aceshooting/lyra-translations/ig.js"),it:()=>import("@aceshooting/lyra-translations/it.js"),ja:()=>import("@aceshooting/lyra-translations/ja.js"),jv:()=>import("@aceshooting/lyra-translations/jv.js"),kk:()=>import("@aceshooting/lyra-translations/kk.js"),kn:()=>import("@aceshooting/lyra-translations/kn.js"),ko:()=>import("@aceshooting/lyra-translations/ko.js"),lah:()=>import("@aceshooting/lyra-translations/pnb.js"),ln:()=>import("@aceshooting/lyra-translations/ln.js"),lt:()=>import("@aceshooting/lyra-translations/lt.js"),lv:()=>import("@aceshooting/lyra-translations/lv.js"),ml:()=>import("@aceshooting/lyra-translations/ml.js"),mr:()=>import("@aceshooting/lyra-translations/mr.js"),ms:()=>import("@aceshooting/lyra-translations/ms.js"),mt:()=>import("@aceshooting/lyra-translations/mt.js"),my:()=>import("@aceshooting/lyra-translations/my.js"),nb:()=>import("@aceshooting/lyra-translations/nb.js"),ne:()=>import("@aceshooting/lyra-translations/ne.js"),nl:()=>import("@aceshooting/lyra-translations/nl.js"),nn:()=>import("@aceshooting/lyra-translations/nn.js"),om:()=>import("@aceshooting/lyra-translations/om.js"),or:()=>import("@aceshooting/lyra-translations/or.js"),pa:()=>import("@aceshooting/lyra-translations/pa.js"),pcm:()=>import("@aceshooting/lyra-translations/pcm.js"),pl:()=>import("@aceshooting/lyra-translations/pl.js"),ps:()=>import("@aceshooting/lyra-translations/ps.js"),"pt-BR":()=>import("@aceshooting/lyra-translations/pt-BR.js"),"pt-PT":()=>import("@aceshooting/lyra-translations/pt-PT.js"),ro:()=>import("@aceshooting/lyra-translations/ro.js"),ru:()=>import("@aceshooting/lyra-translations/ru.js"),sd:()=>import("@aceshooting/lyra-translations/sd.js"),sk:()=>import("@aceshooting/lyra-translations/sk.js"),sl:()=>import("@aceshooting/lyra-translations/sl.js"),sr:()=>import("@aceshooting/lyra-translations/sr.js"),"sr-Latn":()=>import("@aceshooting/lyra-translations/sr-Latn.js"),su:()=>import("@aceshooting/lyra-translations/su.js"),sv:()=>import("@aceshooting/lyra-translations/sv.js"),sw:()=>import("@aceshooting/lyra-translations/sw.js"),ta:()=>import("@aceshooting/lyra-translations/ta.js"),te:()=>import("@aceshooting/lyra-translations/te.js"),th:()=>import("@aceshooting/lyra-translations/th.js"),tr:()=>import("@aceshooting/lyra-translations/tr.js"),uk:()=>import("@aceshooting/lyra-translations/uk.js"),ur:()=>import("@aceshooting/lyra-translations/ur.js"),uz:()=>import("@aceshooting/lyra-translations/uz.js"),vi:()=>import("@aceshooting/lyra-translations/vi.js"),yo:()=>import("@aceshooting/lyra-translations/yo.js"),"zh-CN":()=>import("@aceshooting/lyra-translations/zh-CN.js"),"zh-HK":()=>import("@aceshooting/lyra-translations/zh-HK.js"),"zh-TW":()=>import("@aceshooting/lyra-translations/zh-TW.js"),zu:()=>import("@aceshooting/lyra-translations/zu.js")});export{localeLoaders};
|
|
1
|
+
const localeLoaders=Object.freeze({am:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/am.js")}catch(e){throw e}})(),ar:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ar.js")}catch(e){throw e}})(),bg:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/bg.js")}catch(e){throw e}})(),bho:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/bho.js")}catch(e){throw e}})(),bn:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/bn.js")}catch(e){throw e}})(),ca:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ca.js")}catch(e){throw e}})(),cs:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/cs.js")}catch(e){throw e}})(),da:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/da.js")}catch(e){throw e}})(),de:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/de.js")}catch(e){throw e}})(),"de-CH":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/de-CH.js")}catch(e){throw e}})(),el:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/el.js")}catch(e){throw e}})(),"en-GB":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/en-GB.js")}catch(e){throw e}})(),es:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/es.js")}catch(e){throw e}})(),"es-419":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/es-419.js")}catch(e){throw e}})(),et:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/et.js")}catch(e){throw e}})(),fa:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fa.js")}catch(e){throw e}})(),"fa-AF":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fa-AF.js")}catch(e){throw e}})(),fi:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fi.js")}catch(e){throw e}})(),fil:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/tl.js")}catch(e){throw e}})(),fr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fr.js")}catch(e){throw e}})(),"fr-CA":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fr-CA.js")}catch(e){throw e}})(),ga:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ga.js")}catch(e){throw e}})(),gu:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/gu.js")}catch(e){throw e}})(),ha:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ha.js")}catch(e){throw e}})(),he:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/he.js")}catch(e){throw e}})(),hi:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/hi.js")}catch(e){throw e}})(),hr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/hr.js")}catch(e){throw e}})(),hu:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/hu.js")}catch(e){throw e}})(),id:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/id.js")}catch(e){throw e}})(),ig:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ig.js")}catch(e){throw e}})(),it:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/it.js")}catch(e){throw e}})(),ja:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ja.js")}catch(e){throw e}})(),jv:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/jv.js")}catch(e){throw e}})(),kk:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/kk.js")}catch(e){throw e}})(),kn:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/kn.js")}catch(e){throw e}})(),ko:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ko.js")}catch(e){throw e}})(),lah:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pnb.js")}catch(e){throw e}})(),ln:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ln.js")}catch(e){throw e}})(),lt:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/lt.js")}catch(e){throw e}})(),lv:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/lv.js")}catch(e){throw e}})(),ml:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ml.js")}catch(e){throw e}})(),mr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/mr.js")}catch(e){throw e}})(),ms:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ms.js")}catch(e){throw e}})(),mt:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/mt.js")}catch(e){throw e}})(),my:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/my.js")}catch(e){throw e}})(),nb:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/nb.js")}catch(e){throw e}})(),ne:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ne.js")}catch(e){throw e}})(),nl:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/nl.js")}catch(e){throw e}})(),nn:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/nn.js")}catch(e){throw e}})(),om:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/om.js")}catch(e){throw e}})(),or:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/or.js")}catch(e){throw e}})(),pa:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pa.js")}catch(e){throw e}})(),pcm:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pcm.js")}catch(e){throw e}})(),pl:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pl.js")}catch(e){throw e}})(),ps:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ps.js")}catch(e){throw e}})(),"pt-BR":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pt-BR.js")}catch(e){throw e}})(),"pt-PT":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pt-PT.js")}catch(e){throw e}})(),ro:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ro.js")}catch(e){throw e}})(),ru:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ru.js")}catch(e){throw e}})(),sd:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sd.js")}catch(e){throw e}})(),sk:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sk.js")}catch(e){throw e}})(),sl:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sl.js")}catch(e){throw e}})(),sr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sr.js")}catch(e){throw e}})(),"sr-Latn":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sr-Latn.js")}catch(e){throw e}})(),su:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/su.js")}catch(e){throw e}})(),sv:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sv.js")}catch(e){throw e}})(),sw:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sw.js")}catch(e){throw e}})(),ta:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ta.js")}catch(e){throw e}})(),te:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/te.js")}catch(e){throw e}})(),th:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/th.js")}catch(e){throw e}})(),tr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/tr.js")}catch(e){throw e}})(),uk:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/uk.js")}catch(e){throw e}})(),ur:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ur.js")}catch(e){throw e}})(),uz:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/uz.js")}catch(e){throw e}})(),vi:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/vi.js")}catch(e){throw e}})(),yo:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/yo.js")}catch(e){throw e}})(),"zh-CN":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zh-CN.js")}catch(e){throw e}})(),"zh-HK":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zh-HK.js")}catch(e){throw e}})(),"zh-TW":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zh-TW.js")}catch(e){throw e}})(),zu:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zu.js")}catch(e){throw e}})()});export{localeLoaders};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const attachments=new WeakMap;function registerMapCustomLayers(host,attachment){return attachments.set(host,attachment),()=>{attachments.get(host)===attachment&&attachments.delete(host)}}function mapCustomLayerAttachment(host){return attachments.get(host)}export{mapCustomLayerAttachment,registerMapCustomLayers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mapCustomLayerAttachment}from"./map-custom-layer-attachment.js";import{isMapSceneLayerHandle,loadMapSceneLayerRuntime}from"./map-scene-layer-runtime.js";const text=value=>typeof value=="string"&&value.trim().length>0;function ownValue(record,key){const descriptor=Object.getOwnPropertyDescriptor(record,key);if(descriptor&&!("value"in descriptor))throw new TypeError(`Map custom layer ${key} must be a data property.`);return descriptor?.value}function admitLayer(layer){if(typeof layer!="object"||layer===null)throw new TypeError("A map custom layer must be an object.");const id=ownValue(layer,"id"),label=ownValue(layer,"label"),before=ownValue(layer,"before"),create=layer.create;if(!text(id)||!text(label)||typeof create!="function"||before!==void 0&&!text(before))throw new TypeError("A map custom layer needs a nonblank id and label, a create() function and an optional nonblank before.");return Object.freeze({id,label,...before===void 0?{}:{before},create:context=>Reflect.apply(create,layer,[context])})}function nativeCall(map,method,name,listener){const callable=Reflect.get(map,method);typeof callable=="function"&&Reflect.apply(callable,map,[name,listener])}function eventPoint(event){if(typeof event!="object"||event===null)return;const point=Reflect.get(event,"point");if(typeof point!="object"||point===null)return;const x=Reflect.get(point,"x"),y=Reflect.get(point,"y");return typeof x=="number"&&typeof y=="number"&&Number.isFinite(x)&&Number.isFinite(y)?[x,y]:void 0}function createMapCustomLayerController(element,input,options={}){const layer=admitLayer(input),attachment=mapCustomLayerAttachment(element);if(!attachment)throw new TypeError("addMapCustomLayer() requires a connected lr-map.");const onStateChange=options.onStateChange;let status=Object.freeze({state:"loading"}),removed=!1,visible=!0,attempt=0,engine,engineMap,abort,lease;function setStatus(state,code){if(!(removed&&state!=="removed")&&!(status.state===state&&status.code===code)){status=Object.freeze(code===void 0?{state}:{state,code});try{onStateChange?.(status)}catch{}}}const onClick=event=>{const target=engine,point=eventPoint(event);!target||!visible||removed||!point||target.pick(point).then(hit=>{!hit||target!==engine||removed||typeof event!="object"||event===null||lease?.activate({id:hit.id,layerId:layer.id,...hit.position?{position:hit.position}:{}},event)},()=>{})};function stop(){attempt++,abort?.abort(),abort=void 0;const previous=engine;engine=void 0;try{previous?.dispose()}catch{}if(engineMap)try{nativeCall(engineMap,"off","click",onClick)}catch{}engineMap=void 0}function start(map){stop();const ticket=attempt,controller=abort=new AbortController;engineMap=map,setStatus("loading");try{nativeCall(map,"on","click",onClick)}catch{}loadMapSceneLayerRuntime().then(runtime=>{if(removed||ticket!==attempt)return;let created;try{if(created=runtime.createSceneLayer(map,layer,{signal:controller.signal,onState:(state,code)=>{!removed&&ticket===attempt&&setStatus(state,code)},reducedMotion:()=>lease?.reducedMotion()??!1}),!isMapSceneLayerHandle(created))throw new TypeError("Map custom layers are unavailable")}catch{if(controller.abort(),isMapSceneLayerHandle(created))try{created.dispose()}catch{}ticket===attempt&&setStatus("unavailable","engine");return}if(removed||ticket!==attempt){created.dispose();return}engine=created,visible||created.setVisible(!1)},()=>{!removed&&ticket===attempt&&setStatus("unavailable","engine")})}function remove(){if(removed)return;stop(),removed=!0;const owned=lease;lease=void 0,owned?.release(),status=Object.freeze({state:"removed"});try{onStateChange?.(status)}catch{}}lease=attachment.acquire({styleReady(map){if(!removed){if(engineMap===map){engine?.styleReady();return}start(map)}},styleInvalidated(){removed||engine?.invalidateStyle()},mapRemoved(){removed||(stop(),setStatus("loading"))},released:remove});const initial=lease.nativeMap();return initial&&start(initial),Object.freeze({id:layer.id,get status(){return status},requestRender(){removed||engine?.requestFrame()},setVisible(value){visible=!!value,removed||engine?.setVisible(visible)},async pick(point){const target=engine;if(!target||removed)return null;const hit=await target.pick(point);return target===engine&&!removed?hit:null},remove})}export{createMapCustomLayerController};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type{LyraMapPosition}from'../components/media/map/map-scene-types.js';
|
|
2
|
+
/** A position resolved to meters above sea level, or why its terrain height is not known yet.*/
|
|
3
|
+
export type LyraMapResolvedPosition={readonly lngLat:readonly[number,number];readonly altitude:number;readonly status:'resolved';}|{readonly lngLat:readonly[number,number];readonly status:'terrain-pending'|'terrain-unavailable';};
|
|
4
|
+
/** CSS-pixel projection of one position; `visible` excludes clipped and horizon-occluded positions.*/
|
|
5
|
+
export interface LyraMapProjectedPosition{readonly point?:readonly[number,number];readonly visible:boolean;readonly status:'resolved'|'terrain-pending'|'terrain-unavailable'|'visibility-pending'|'clipped'|'occluded';}
|
|
6
|
+
/** A tile-local coordinate origin for one world copy; valid for the current view only.*/
|
|
7
|
+
export interface LyraMapGeographicOrigin{readonly tile:{readonly z:number;readonly x:number;readonly y:number;readonly wrap:number;};readonly key:string;}export type LyraMapGeographicUniform={readonly name:string;readonly type:'float';readonly value:number;}|{readonly name:string;readonly type:'vec4';readonly value:readonly[number,number,number,number];}|{readonly name:string;readonly type:'mat4';readonly value:readonly number[];};
|
|
8
|
+
/**
|
|
9
|
+
* GLSL ES 3.00 prelude and uniforms for one origin. Prefix your vertex body with `defines` and
|
|
10
|
+
* `vertexPrelude`, then call `lrProjectPosition(vec3)` with tile-local xy and meter z. On a globe,
|
|
11
|
+
* forward `lrHorizonPosition()` through a highp varying and discard fragments where
|
|
12
|
+
* `lrHorizonOccluded()` (from `fragmentPrelude`) returns true.
|
|
13
|
+
*/
|
|
14
|
+
export interface LyraMapGeographicShader{readonly key:string;readonly vertexPrelude:string;readonly fragmentPrelude:string;readonly defines:string;readonly positionEncoding:'tile-xy-meters-z';readonly projectFunction:'lrProjectPosition';readonly horizonPositionFunction:'lrHorizonPosition';readonly horizonOccludedFunction:'lrHorizonOccluded';readonly horizonMode:'none'|'sphere';readonly uniforms:readonly LyraMapGeographicUniform[];}
|
|
15
|
+
/** Geographic services that outlive one frame; terrain resolution reads the current view.*/
|
|
16
|
+
export interface LyraMapGeographicServices{readonly limits:Readonly<Record<string,number>>;resolve(position:LyraMapPosition):LyraMapResolvedPosition;
|
|
17
|
+
/** The tile origin nearest the current view for a position.*/
|
|
18
|
+
frameFor(position:LyraMapPosition):LyraMapGeographicOrigin;
|
|
19
|
+
/** Offsets a resolved position by east/north/up meters on the renderer sphere.*/
|
|
20
|
+
fromEnu(origin:Extract<LyraMapResolvedPosition,{status:'resolved';}>,point:readonly[east:number,north:number,up:number]):LyraMapPosition;}
|
|
21
|
+
/** Per-frame geographic transforms; they expire when the render callback returns.*/
|
|
22
|
+
export interface LyraMapGeographicFrame{resolve(position:LyraMapPosition):LyraMapResolvedPosition;project(position:LyraMapPosition):LyraMapProjectedPosition;
|
|
23
|
+
/** Tile-local `[x, y, meters]` for a resolved position in the origin's world copy.*/
|
|
24
|
+
encode(position:LyraMapResolvedPosition,origin:LyraMapGeographicOrigin):readonly[number,number,number];shader(origin:LyraMapGeographicOrigin):LyraMapGeographicShader;}
|
|
25
|
+
/** What a custom layer receives once per mount epoch.*/
|
|
26
|
+
export interface LyraMapCustomLayerContext{
|
|
27
|
+
/** The map's own context: never resize or destroy its canvas or lose the context.*/
|
|
28
|
+
readonly gl:WebGL2RenderingContext;
|
|
29
|
+
/** Aborted when this epoch ends (removal, style replacement, context loss).*/
|
|
30
|
+
readonly signal:AbortSignal;readonly geographic:LyraMapGeographicServices;requestRender():void;reportState(state:'ready'|'loading'|'unavailable',code?:'terrain'|'resource'):void;}
|
|
31
|
+
/** The shared camera for one frame: CSS size, device pixel ratio and geographic transforms.*/
|
|
32
|
+
export interface LyraMapCustomLayerFrame{
|
|
33
|
+
/** View revision; pass it back to reject stale picks.*/
|
|
34
|
+
readonly revision:number;
|
|
35
|
+
/** Monotonic rendering milliseconds.*/
|
|
36
|
+
readonly time:number;readonly width:number;readonly height:number;readonly pixelRatio:number;readonly reducedMotion:boolean;readonly geographic:LyraMapGeographicFrame;}export interface LyraMapCustomLayerPick{readonly id:string;readonly position?:LyraMapPosition;}export interface LyraMapCustomLayerInstance{
|
|
37
|
+
/** Runs before the main pass, for offscreen work.*/
|
|
38
|
+
prerender?(frame:LyraMapCustomLayerFrame):void;render(frame:LyraMapCustomLayerFrame):void;
|
|
39
|
+
/**
|
|
40
|
+
* Releases this instance's GL objects. Runs on removal, style replacement, context loss and map
|
|
41
|
+
* disconnection; after a loss `context.gl.isContextLost()` is true and the objects are already gone.
|
|
42
|
+
*/
|
|
43
|
+
dispose():void;
|
|
44
|
+
/** Hit-tests CSS pixel `point` for the frame `revision`; resolve null for no hit.*/
|
|
45
|
+
pick?(point:readonly[x:number,y:number],revision:number):Promise<LyraMapCustomLayerPick|null>;}
|
|
46
|
+
/** A trusted custom WebGL2 layer. `create()` runs once per mount epoch and returns a fresh instance.*/
|
|
47
|
+
export interface LyraMapCustomLayer{
|
|
48
|
+
/** Your identifier, reported as `layerId` when a pick activates.*/
|
|
49
|
+
readonly id:string;
|
|
50
|
+
/** Plain-text name.*/
|
|
51
|
+
readonly label:string;
|
|
52
|
+
/** An existing style layer id to render beneath.*/
|
|
53
|
+
readonly before?:string;create(context:LyraMapCustomLayerContext):LyraMapCustomLayerInstance;}
|
|
54
|
+
/** `removed` is final: `remove()` was called or the map disconnected.*/
|
|
55
|
+
export type LyraMapCustomLayerState='loading'|'ready'|'unavailable'|'removed';export type LyraMapCustomLayerCode='engine'|'render'|'invalid'|'context-lost'|'terrain'|'resource';export interface LyraMapCustomLayerStatus{readonly state:LyraMapCustomLayerState;readonly code?:LyraMapCustomLayerCode;}export interface LyraMapCustomLayerOptions{
|
|
56
|
+
/** Called after every state change.*/
|
|
57
|
+
readonly onStateChange?:(status:LyraMapCustomLayerStatus)=>void;}export interface LyraMapCustomLayerHandle{readonly id:string;
|
|
58
|
+
/** The latest status.*/
|
|
59
|
+
readonly status:LyraMapCustomLayerStatus;requestRender():void;setVisible(visible:boolean):void;
|
|
60
|
+
/** Asks the current instance; resolves null without an installed instance or for a stale view.*/
|
|
61
|
+
pick(point:readonly[x:number,y:number]):Promise<LyraMapCustomLayerPick|null>;
|
|
62
|
+
/** Idempotent. Disposes the instance and removes the native layer.*/
|
|
63
|
+
remove():void;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveOptionalPeerCapability}from"./optional-peer-capabilities.js";const handleMethods=["invalidateStyle","styleReady","requestFrame","setVisible","pick","dispose"];function isMapSceneLayerRuntime(value){return typeof value=="object"&&value!==null&&"createSceneLayer"in value&&typeof value.createSceneLayer=="function"}function isMapSceneLayerHandle(value){return typeof value=="object"&&value!==null&&handleMethods.every(name=>typeof Reflect.get(value,name)=="function")}const defaultImporter=()=>(async()=>{try{return await import("@aceshooting/lyra-map/scene")}catch(e){throw e}})();let importer=defaultImporter,pending;function loadMapSceneLayerRuntime(){if(pending)return pending;const attempt=importer().then(module=>{const runtime=resolveOptionalPeerCapability(module,isMapSceneLayerRuntime);if(!runtime)throw new TypeError("Map custom layers are unavailable");return runtime});return pending=attempt,attempt.catch(()=>{pending===attempt&&(pending=void 0)}),attempt}function __setMapSceneLayerImporterForTesting(next){importer=next??defaultImporter,pending=void 0}export{__setMapSceneLayerImporterForTesting,isMapSceneLayerHandle,loadMapSceneLayerRuntime};
|