@soonspacejs/plugin-poi-renderer 2.13.5 → 2.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export interface PoiNodeBatchOptions {
45
45
  }
46
46
  export default class PatrolControlsPlugin {
47
47
  readonly ssp: SoonSpace;
48
+ poiIdSet: Set<string>;
48
49
  constructor(ssp: SoonSpace);
49
50
  private resetStyleName;
50
51
  private mergeElementStyle;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- const e={width:"400px",height:"300px",backgroundColor:"black"};var t;!function(e){e.PANEL="PANEL",e.VIDEO="VIDEO",e.VIDEO_STREAM="VIDEO_STREAM"}(t||(t={}));class s{constructor(e){this.ssp=e}resetStyleName(e){const t=[...e];for(const e in t)t[e]!==t[e].toLowerCase()&&(t[e]=`-${t[e].toLowerCase()}`);return t.join("")}mergeElementStyle(e){let t="";for(const s in e)t+=`${this.resetStyleName(s)}: ${e[s]};`;return t}renderCustom(t){const{tagName:s,style:n=e,innerHTML:i}=t,a=document.createElement(s);return a.style.cssText=this.mergeElementStyle(n),i&&(a.innerHTML=i),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:a}))}renderVideo(t){const{src:s,style:n=e,isLoop:i=!0,autoPlay:a=!0}=t,l=document.createElement("video");return l.style.cssText=this.mergeElementStyle(n),l.controls=!0,l.muted=!0,l.loop=i,l.autoplay=a,s&&(l.src=s),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:l}))}renderPanel(e){const{dataSource:t,rowStyle:s,labelStyle:n,valueStyle:i}=e,a=t.map((e=>`<div style="${this.mergeElementStyle(s||{})}">\n<span style="${this.mergeElementStyle(n||{})}">${e.label}</span>\n<span style="${this.mergeElementStyle(i||{})}">${e.value}</span>\n</div>`)).join("");return this.renderCustom(Object.assign(Object.assign({tagName:"div"},e),{innerHTML:a}))}batchRender(e){const{dataSource:s}=e,n=e=>{const{id:s,pid:n,width:i,height:a,dataSource:l,fileUrl:r,style:o,visible:c}=e;let d=this.ssp.getObjectById(s),g=c;if(d&&(g=d.visible,this.ssp.removeObjectById(s)),e.contentType===t.VIDEO)d=this.renderVideo(Object.assign(Object.assign({},e),{src:r,visible:g,style:{width:i+"px",height:a+"px"}}));else if(e.contentType===t.PANEL){const{panel:{bodyStyle:t,rowStyle:s,labelStyle:n,valueStyle:c}}=JSON.parse(o);d=this.renderPanel(Object.assign(Object.assign({},e),{visible:g,style:Object.assign(Object.assign({width:i+"px",height:a+"px",backgroundImage:`url(${r})`,overflow:"auto"},t),{padding:t.padding+"px"}),rowStyle:Object.assign(Object.assign({},s),{gap:s.gap+"px"}),labelStyle:Object.assign(Object.assign({},n),{fontSize:n.fontSize+"px"}),valueStyle:Object.assign(Object.assign({},c),{fontSize:c.fontSize+"px"}),dataSource:l}))}if(d&&n){const e=this.ssp.getObjectById(n);e&&this.ssp.addObject(d,e)}};s.forEach((e=>{n(e)}))}}export{e as DefaultStyle,t as PoiContentTypeEnum,s as default};
1
+ const e={width:"400px",height:"300px",backgroundColor:"black"};var t;!function(e){e.PANEL="PANEL",e.VIDEO="VIDEO",e.VIDEO_STREAM="VIDEO_STREAM"}(t||(t={}));class s{constructor(e){this.ssp=e,this.poiIdSet=new Set}resetStyleName(e){const t=[...e];for(const e in t)t[e]!==t[e].toLowerCase()&&(t[e]=`-${t[e].toLowerCase()}`);return t.join("")}mergeElementStyle(e){let t="";for(const s in e)t+=`${this.resetStyleName(s)}: ${e[s]};`;return t}renderCustom(t){const{tagName:s,style:n=e,innerHTML:i}=t,a=document.createElement(s);return a.style.cssText=this.mergeElementStyle(n),i&&(a.innerHTML=i),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:a}))}renderVideo(t){const{src:s,style:n=e,isLoop:i=!0,autoPlay:a=!0}=t,l=document.createElement("video");return l.style.cssText=this.mergeElementStyle(n),l.controls=!0,l.muted=!0,l.loop=i,l.autoplay=a,s&&(l.src=s),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:l}))}renderPanel(e){const{dataSource:t,rowStyle:s,labelStyle:n,valueStyle:i}=e,a=t.map((e=>`<div style="${this.mergeElementStyle(s||{})}">\n<span style="${this.mergeElementStyle(n||{})}">${e.label}</span>\n<span style="${this.mergeElementStyle(i||{})}">${e.value}</span>\n</div>`)).join("");return this.renderCustom(Object.assign(Object.assign({tagName:"div"},e),{innerHTML:a}))}batchRender(e){const{dataSource:s}=e;this.poiIdSet.forEach((e=>{this.ssp.removeObjectById(e)})),this.poiIdSet.clear();s.forEach((e=>{const{id:s,pid:n,width:i,height:a,dataSource:l,fileUrl:o,style:r,visible:c}=e;let d=this.ssp.getObjectById(s);const g=c;if(this.poiIdSet.add(s),e.contentType===t.VIDEO)d=this.renderVideo(Object.assign(Object.assign({},e),{src:o,visible:g,style:{width:i+"px",height:a+"px"}}));else if(e.contentType===t.PANEL){const{panel:{bodyStyle:t,rowStyle:s,labelStyle:n,valueStyle:c}}=JSON.parse(r);d=this.renderPanel(Object.assign(Object.assign({},e),{visible:g,style:Object.assign(Object.assign({width:i+"px",height:a+"px",backgroundImage:`url(${o})`,overflow:"auto"},t),{padding:t.padding+"px"}),rowStyle:Object.assign(Object.assign({},s),{gap:s.gap+"px"}),labelStyle:Object.assign(Object.assign({},n),{fontSize:n.fontSize+"px"}),valueStyle:Object.assign(Object.assign({},c),{fontSize:c.fontSize+"px"}),dataSource:l}))}if(d&&n){const e=this.ssp.getObjectById(n);e&&this.ssp.addObject(d,e)}}))}}export{e as DefaultStyle,t as PoiContentTypeEnum,s as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-poi-renderer",
3
3
  "pluginName": "PoiRendererPlugin",
4
- "version": "2.13.5",
4
+ "version": "2.13.6",
5
5
  "description": "Poi-renderer plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,9 +13,9 @@
13
13
  ],
14
14
  "author": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "e19da4dc04255f2374645aa083e0116668894874",
16
+ "gitHead": "6c1113b3e61e448be7ce9463ed22a75f507d9f67",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.13.5"
18
+ "soonspacejs": "2.13.6"
19
19
  },
20
20
  "dependencies": {
21
21
  "csstype": "^3.1.2"