@soonspacejs/plugin-poi-renderer 2.13.16 → 2.14.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/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import SoonSpace from 'soonspacejs';
2
- import type { PoiNode, PoiNodeInfo } from 'soonspacejs';
1
+ import { default as SoonSpace, PoiNode, PoiNodeInfo } from 'soonspacejs';
3
2
  import * as CSS from 'csstype';
4
3
  export type PoiNodeBaseOption = Omit<PoiNodeInfo, 'element'>;
5
4
  export interface PoiNodeCustomOptions extends PoiNodeBaseOption {
package/dist/index.esm.js CHANGED
@@ -1 +1,117 @@
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};
1
+ const m = {
2
+ width: "400px",
3
+ height: "300px",
4
+ backgroundColor: "black"
5
+ };
6
+ var f = /* @__PURE__ */ ((n) => (n.PANEL = "PANEL", n.VIDEO = "VIDEO", n.VIDEO_STREAM = "VIDEO_STREAM", n))(f || {});
7
+ class x {
8
+ constructor(t) {
9
+ this.ssp = t, this.poiIdSet = /* @__PURE__ */ new Set();
10
+ }
11
+ poiIdSet;
12
+ resetStyleName(t) {
13
+ const e = [...t];
14
+ for (const s in e)
15
+ e[s] !== e[s].toLowerCase() && (e[s] = `-${e[s].toLowerCase()}`);
16
+ return e.join("");
17
+ }
18
+ mergeElementStyle(t) {
19
+ let e = "";
20
+ for (const s in t)
21
+ e += `${this.resetStyleName(s)}: ${t[s]};`;
22
+ return e;
23
+ }
24
+ renderCustom(t) {
25
+ const { tagName: e, style: s = m, innerHTML: r } = t, o = document.createElement(e);
26
+ return o.style.cssText = this.mergeElementStyle(s), r && (o.innerHTML = r), this.ssp.createPoiNode({
27
+ ...t,
28
+ element: o
29
+ });
30
+ }
31
+ renderVideo(t) {
32
+ const {
33
+ src: e,
34
+ style: s = m,
35
+ isLoop: r = !0,
36
+ autoPlay: o = !0
37
+ } = t, l = document.createElement("video");
38
+ return l.style.cssText = this.mergeElementStyle(s), l.controls = !0, l.muted = !0, l.loop = r, l.autoplay = o, e && (l.src = e), this.ssp.createPoiNode({
39
+ ...t,
40
+ element: l
41
+ });
42
+ }
43
+ renderPanel(t) {
44
+ const { dataSource: e, rowStyle: s, labelStyle: r, valueStyle: o } = t, l = e.map(
45
+ (i) => `<div style="${this.mergeElementStyle(s || {})}">
46
+ <span style="${this.mergeElementStyle(r || {})}">${i.label}</span>
47
+ <span style="${this.mergeElementStyle(o || {})}">${i.value}</span>
48
+ </div>`
49
+ ).join("");
50
+ return this.renderCustom({
51
+ tagName: "div",
52
+ ...t,
53
+ innerHTML: l
54
+ });
55
+ }
56
+ batchRender(t) {
57
+ const { dataSource: e } = t;
58
+ this.poiIdSet.forEach((r) => {
59
+ this.ssp.removeObjectById(r);
60
+ }), this.poiIdSet.clear();
61
+ const s = (r) => {
62
+ const { id: o, pid: l, width: i, height: d, dataSource: g, fileUrl: S, style: E, visible: b } = r;
63
+ let c = this.ssp.getObjectById(o);
64
+ const h = b;
65
+ if (this.poiIdSet.add(o), r.contentType === "VIDEO")
66
+ c = this.renderVideo({
67
+ ...r,
68
+ src: S,
69
+ visible: h,
70
+ style: {
71
+ width: i + "px",
72
+ height: d + "px"
73
+ }
74
+ });
75
+ else if (r.contentType === "PANEL") {
76
+ const {
77
+ panel: { bodyStyle: a, rowStyle: y, labelStyle: p, valueStyle: u }
78
+ } = JSON.parse(E);
79
+ c = this.renderPanel({
80
+ ...r,
81
+ visible: h,
82
+ style: {
83
+ width: i + "px",
84
+ height: d + "px",
85
+ backgroundImage: `url(${S})`,
86
+ overflow: "auto",
87
+ ...a,
88
+ padding: a.padding + "px"
89
+ },
90
+ rowStyle: {
91
+ ...y,
92
+ gap: y.gap + "px"
93
+ },
94
+ labelStyle: {
95
+ ...p,
96
+ fontSize: p.fontSize + "px"
97
+ },
98
+ valueStyle: {
99
+ ...u,
100
+ fontSize: u.fontSize + "px"
101
+ },
102
+ dataSource: g
103
+ });
104
+ }
105
+ if (c && l) {
106
+ const a = this.ssp.getObjectById(l);
107
+ a && this.ssp.addObject(c, a);
108
+ }
109
+ };
110
+ e.forEach(s);
111
+ }
112
+ }
113
+ export {
114
+ m as DefaultStyle,
115
+ f as PoiContentTypeEnum,
116
+ x as default
117
+ };
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.16",
4
+ "version": "2.14.0",
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": "aaf0c46565c740277fad34bc3a3ba9fa61d48278",
16
+ "gitHead": "4c85e8b7b8ad24ccb9b42f3a1826bca377c42a6d",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.13.16"
18
+ "soonspacejs": "2.14.0"
19
19
  },
20
20
  "dependencies": {
21
21
  "csstype": "^3.1.2"