@soonspacejs/plugin-poi-renderer 2.9.5 → 2.9.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
@@ -1,23 +1,53 @@
1
1
  import SoonSpace from 'soonspacejs';
2
- import type { PoiNodeInfo } from 'soonspacejs/types/Library';
2
+ import type { PoiNode, PoiNodeInfo } from 'soonspacejs/types/Library';
3
3
  import * as CSS from 'csstype';
4
- export interface PoiCustomOptions extends PoiNodeInfo {
4
+ export type PoiNodeBaseOption = Omit<PoiNodeInfo, 'element'>;
5
+ export interface PoiNodeCustomOptions extends PoiNodeBaseOption {
5
6
  tagName: keyof HTMLElementTagNameMap;
6
7
  style?: CSS.Properties;
7
8
  innerHTML?: string;
8
9
  }
9
- export interface PoiVideoOptions extends PoiNodeInfo {
10
- src: string;
10
+ export interface PoiNodeVideoOptions extends PoiNodeBaseOption {
11
+ src?: string;
11
12
  style?: CSS.Properties;
12
13
  }
13
- export type PoiImageOptions = PoiVideoOptions;
14
+ export interface PoiNodePanelDataSource {
15
+ label: string;
16
+ value: string;
17
+ }
18
+ export interface PoiNodePanelOptions extends PoiNodeBaseOption {
19
+ dataSource: PoiNodePanelDataSource[];
20
+ style?: CSS.Properties;
21
+ rowStyle?: CSS.Properties;
22
+ labelStyle?: CSS.Properties;
23
+ valueStyle?: CSS.Properties;
24
+ }
25
+ export type PoiImageOptions = PoiNodeVideoOptions;
14
26
  export declare const DefaultStyle: CSS.Properties;
27
+ export declare enum PoiContentTypeEnum {
28
+ PANEL = "PANEL",
29
+ VIDEO = "VIDEO",
30
+ VIDEO_STREAM = "VIDEO_STREAM"
31
+ }
32
+ export interface PoiNodeData extends PoiNodeBaseOption {
33
+ pid?: string;
34
+ width: number;
35
+ height: number;
36
+ dataSource: PoiNodePanelDataSource[];
37
+ fileUrl?: string;
38
+ contentType: PoiContentTypeEnum;
39
+ style: string;
40
+ }
41
+ export interface PoiNodeBatchOptions {
42
+ dataSource: PoiNodeData[];
43
+ }
15
44
  export default class PatrolControlsPlugin {
16
45
  readonly ssp: SoonSpace;
17
46
  constructor(ssp: SoonSpace);
18
47
  private resetStyleName;
19
48
  private mergeElementStyle;
20
- renderCustom(options: PoiCustomOptions): void;
21
- renderVideo(options: PoiVideoOptions): void;
22
- renderImage(options: PoiVideoOptions): void;
49
+ renderCustom(options: PoiNodeCustomOptions): PoiNode;
50
+ renderVideo(options: PoiNodeVideoOptions): PoiNode;
51
+ renderPanel(options: PoiNodePanelOptions): PoiNode;
52
+ batchRender(batchOptions: PoiNodeBatchOptions): void;
23
53
  }
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- const e={width:"400px",height:"300px",backgroundColor:"black"};class t{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,t){let s="";for(const e in t)s+=`${this.resetStyleName(e)}: ${t[e]};`;console.log("cssText",s),e.style.cssText=s}renderCustom(t){const{tagName:s,style:n=e,innerHTML:o}=t,r=document.createElement(s);this.mergeElementStyle(r,n),o&&(r.innerHTML=o),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:r}))}renderVideo(t){const{src:s,style:n=e}=t,o=document.createElement("video");o.controls=!0,o.src=s,this.mergeElementStyle(o,n),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:o}))}renderImage(t){const{src:s,style:n=e}=t,o=document.createElement("img");o.src=s,this.mergeElementStyle(o,n),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:o}))}}export{e as DefaultStyle,t 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}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:a}=t,i=document.createElement(s);return i.style.cssText=this.mergeElementStyle(n),a&&(i.innerHTML=a),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:i}))}renderVideo(t){const{src:s,style:n=e}=t,a=document.createElement("video");return a.style.cssText=this.mergeElementStyle(n),a.controls=!0,s&&(a.src=s),this.ssp.createPoiNode(Object.assign(Object.assign({},t),{element:a}))}renderPanel(e){const{dataSource:t,rowStyle:s,labelStyle:n,valueStyle:a}=e,i=t.map((e=>`<div style="${this.mergeElementStyle(s||{})}">\n<span style="${this.mergeElementStyle(n||{})}">${e.label}</span>\n<span style="${this.mergeElementStyle(a||{})}">${e.value}</span>\n</div>`)).join("");return this.renderCustom(Object.assign(Object.assign({tagName:"div"},e),{innerHTML:i}))}batchRender(e){const{dataSource:s}=e,n=e=>{const{id:s,pid:n,width:a,height:i,dataSource:l,fileUrl:r,style:o}=e;let c=this.ssp.getPoiNodeById(s);if(!c){if(e.contentType===t.VIDEO)c=this.renderVideo(Object.assign(Object.assign({},e),{src:r,style:{width:a+"px",height:i+"px"}}));else if(e.contentType===t.PANEL){const{panel:{bodyStyle:t,rowStyle:s,labelStyle:n,valueStyle:d}}=JSON.parse(o);c=this.renderPanel(Object.assign(Object.assign({},e),{style:Object.assign(Object.assign({width:a+"px",height:i+"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({},d),{fontSize:d.fontSize+"px"}),dataSource:l}))}if(c&&n){const e=this.ssp.getObjectById(n);e&&this.ssp.addObject(c,e)}}};s.forEach((e=>{n(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.9.5",
4
+ "version": "2.9.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": "29ad56babad46dfae6b0aba61e3a113706eaf672",
16
+ "gitHead": "3ab8f7a974691b6456ca4adf0430b6950c13e868",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.9.5"
18
+ "soonspacejs": "2.9.6"
19
19
  },
20
20
  "dependencies": {
21
21
  "csstype": "^3.1.2"