@sun-panel/micro-app 1.0.13 → 1.0.14

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.
@@ -1,4 +1,5 @@
1
- import { LitElement, TemplateResult } from 'lit';
1
+ import type { TemplateResult } from 'lit';
2
+ import { LitElement } from 'lit';
2
3
  /**
3
4
  * Sun Panel 基础元素抽象类
4
5
  * 提供了微应用开发的基础能力
@@ -1,6 +1,6 @@
1
+ import type { PropertyValueMap, TemplateResult } from 'lit';
2
+ import type { NetworkMode, PageInitializedParam, SpContextPage } from './types/common';
1
3
  import { SunPanelElement } from './SunPanelElement';
2
- import { TemplateResult, PropertyValueMap } from 'lit';
3
- import { SpContextPage, NetworkMode, PageInitializedParam } from './types/common';
4
4
  /**
5
5
  * Sun Panel 页面元素基类
6
6
  * 用于开发微应用中的页面组件,以窗口的形式加载
@@ -1,6 +1,6 @@
1
+ import type { PropertyValueMap, TemplateResult } from 'lit';
2
+ import type { NetworkMode, SpContextWidget, WidgetInfo } from './types/common';
1
3
  import { SunPanelElement } from './SunPanelElement';
2
- import { TemplateResult, PropertyValueMap } from 'lit';
3
- import { SpContextWidget, NetworkMode, WidgetInfo } from './types/common';
4
4
  /**
5
5
  * Sun Panel 小部件(卡片)元素基类
6
6
  * 用于开发微应用中的卡片组件
@@ -1,23 +1,22 @@
1
- !function(t){
1
+ !function(t){class e extends Error{constructor(t,e="unknown",s){super(t),this.name="SpNetworkRequestError",this.type=e,this.response=s}}class s extends Error{constructor(t,e,s){super(t),this.name="SpDataNodeError",this.code=e,this.response=s}}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- const e=globalThis,s=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),n=new WeakMap;let o=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(s&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=n.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&n.set(e,t))}return t}toString(){return this.cssText}};const r=s?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new o("string"==typeof t?t:t+"",void 0,i))(e)})(t):t,{is:h,defineProperty:a,getOwnPropertyDescriptor:d,getOwnPropertyNames:l,getOwnPropertySymbols:c,getPrototypeOf:p}=Object,u=globalThis,$=u.trustedTypes,_=$?$.emptyScript:"",g=u.reactiveElementPolyfillSupport,f=(t,e)=>t,A={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},m=(t,e)=>!h(t,e),y={attribute:!0,type:String,converter:A,reflect:!1,useDefault:!1,hasChanged:m};
6
+ */const i=globalThis,n=i.ShadowRoot&&(void 0===i.ShadyCSS||i.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o=Symbol(),r=new WeakMap;let h=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(n&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=r.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&r.set(e,t))}return t}toString(){return this.cssText}};const a=n?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new h("string"==typeof t?t:t+"",void 0,o))(e)})(t):t,{is:d,defineProperty:l,getOwnPropertyDescriptor:c,getOwnPropertyNames:p,getOwnPropertySymbols:u,getPrototypeOf:$}=Object,_=globalThis,g=_.trustedTypes,f=g?g.emptyScript:"",A=_.reactiveElementPolyfillSupport,m=(t,e)=>t,y={toAttribute(t,e){switch(e){case Boolean:t=t?f:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},v=(t,e)=>!d(t,e),E={attribute:!0,type:String,converter:y,reflect:!1,useDefault:!1,hasChanged:v};
8
7
  /**
9
8
  * @license
10
9
  * Copyright 2017 Google LLC
11
10
  * SPDX-License-Identifier: BSD-3-Clause
12
- */Symbol.metadata??=Symbol("metadata"),u.litPropertyMetadata??=new WeakMap;let v=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&a(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=d(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y}static _$Ei(){if(this.hasOwnProperty(f("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(f("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(f("properties"))){const t=this.properties,e=[...l(t),...c(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,i)=>{if(s)t.adoptedStyleSheets=i.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const s of i){const i=document.createElement("style"),n=e.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=s.cssText,t.appendChild(i)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:A).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:A;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??m)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[f("elementProperties")]=new Map,v[f("finalized")]=new Map,g?.({ReactiveElement:v}),(u.reactiveElementVersions??=[]).push("2.1.2");
11
+ */Symbol.metadata??=Symbol("metadata"),_.litPropertyMetadata??=new WeakMap;let C=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=E){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&l(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=c(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??E}static _$Ei(){if(this.hasOwnProperty(m("elementProperties")))return;const t=$(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(m("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(m("properties"))){const t=this.properties,e=[...p(t),...u(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(n)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const s of e){const e=document.createElement("style"),n=i.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:y).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:y;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??v)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[m("elementProperties")]=new Map,C[m("finalized")]=new Map,A?.({ReactiveElement:C}),(_.reactiveElementVersions??=[]).push("2.1.2");
13
12
  /**
14
13
  * @license
15
14
  * Copyright 2017 Google LLC
16
15
  * SPDX-License-Identifier: BSD-3-Clause
17
16
  */
18
- const E=globalThis,C=t=>t,b=E.trustedTypes,w=b?b.createPolicy("lit-html",{createHTML:t=>t}):void 0,S="$lit$",M=`lit$${Math.random().toFixed(9).slice(2)}$`,x="?"+M,P=`<${x}>`,k=document,U=()=>k.createComment(""),O=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,R="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,L=/>/g,I=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),z=/'/g,D=/"/g,j=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),W=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),V=new WeakMap,F=k.createTreeWalker(k,129);function J(t,e){if(!N(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=H;for(let e=0;e<s;e++){const s=t[e];let h,a,d=-1,l=0;for(;l<s.length&&(r.lastIndex=l,a=r.exec(s),null!==a);)l=r.lastIndex,r===H?"!--"===a[1]?r=T:void 0!==a[1]?r=L:void 0!==a[2]?(j.test(a[2])&&(n=RegExp("</"+a[2],"g")),r=I):void 0!==a[3]&&(r=I):r===I?">"===a[0]?(r=n??H,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,h=a[1],r=void 0===a[3]?I:'"'===a[3]?D:z):r===D||r===z?r=I:r===T||r===L?r=H:(r=I,n=void 0);const c=r===I&&t[e+1].startsWith("/>")?" ":"";o+=r===H?s+P:d>=0?(i.push(h),s.slice(0,d)+S+s.slice(d)+M+c):s+M+(-2===d?e:c)}return[J(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class Z{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[a,d]=K(t,e);if(this.el=Z.createElement(a,s),F.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=F.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(S)){const e=d[o++],s=i.getAttribute(t).split(M),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?tt:"?"===r[1]?et:"@"===r[1]?st:Y}),i.removeAttribute(t)}else t.startsWith(M)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(j.test(i.tagName)){const t=i.textContent.split(M),e=t.length-1;if(e>0){i.textContent=b?b.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],U()),F.nextNode(),h.push({type:2,index:++n});i.append(t[e],U())}}}else if(8===i.nodeType)if(i.data===x)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(M,t+1));)h.push({type:7,index:n}),t+=M.length-1}n++}}static createElement(t,e){const s=k.createElement("template");return s.innerHTML=t,s}}function G(t,e,s=t,i){if(e===W)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=O(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=G(t,n._$AS(t,e.values),n,i)),e}class Q{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??k).importNode(e,!0);F.currentNode=i;let n=F.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new X(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new it(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=F.nextNode(),o++)}return F.currentNode=k,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=G(this,t,e),O(t)?t===q||null==t||""===t?(this._$AH!==q&&this._$AR(),this._$AH=q):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>N(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&O(this._$AH)?this._$AA.nextSibling.data=t:this.T(k.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Z.createElement(J(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new Q(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=V.get(t.strings);return void 0===e&&V.set(t.strings,e=new Z(t)),e}k(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new X(this.O(U()),this.O(U()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=C(t).nextSibling;C(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=q,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=q}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=G(this,t,e,0),o=!O(t)||t!==this._$AH&&t!==W,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=G(this,i[s+r],e,r),h===W&&(h=this._$AH[r]),o||=!O(h)||h!==this._$AH[r],h===q?t=q:t!==q&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tt extends Y{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===q?void 0:t}}class et extends Y{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==q)}}class st extends Y{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=G(this,t,e,0)??q)===W)return;const s=this._$AH,i=t===q&&s!==q||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==q&&(s===q||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class it{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){G(this,t)}}const nt=E.litHtmlPolyfillSupport;nt?.(Z,X),(E.litHtmlVersions??=[]).push("3.3.2");const ot=globalThis;
17
+ const b=globalThis,w=t=>t,S=b.trustedTypes,M=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,x="$lit$",P=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+P,U=`<${k}>`,O=document,N=()=>O.createComment(""),R=t=>null===t||"object"!=typeof t&&"function"!=typeof t,H=Array.isArray,T="[ \t\n\f\r]",L=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,z=/>/g,D=RegExp(`>|${T}(?:([^\\s"'>=/]+)(${T}*=${T}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,B=/"/g,W=/^(?:script|style|textarea|title)$/i,q=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),V=Symbol.for("lit-noChange"),F=Symbol.for("lit-nothing"),J=new WeakMap,K=O.createTreeWalker(O,129);function Z(t,e){if(!H(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==M?M.createHTML(e):e}const G=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=L;for(let e=0;e<s;e++){const s=t[e];let h,a,d=-1,l=0;for(;l<s.length&&(r.lastIndex=l,a=r.exec(s),null!==a);)l=r.lastIndex,r===L?"!--"===a[1]?r=I:void 0!==a[1]?r=z:void 0!==a[2]?(W.test(a[2])&&(n=RegExp("</"+a[2],"g")),r=D):void 0!==a[3]&&(r=D):r===D?">"===a[0]?(r=n??L,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,h=a[1],r=void 0===a[3]?D:'"'===a[3]?B:j):r===B||r===j?r=D:r===I||r===z?r=L:(r=D,n=void 0);const c=r===D&&t[e+1].startsWith("/>")?" ":"";o+=r===L?s+U:d>=0?(i.push(h),s.slice(0,d)+x+s.slice(d)+P+c):s+P+(-2===d?e:c)}return[Z(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class Q{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[a,d]=G(t,e);if(this.el=Q.createElement(a,s),K.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=K.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(x)){const e=d[o++],s=i.getAttribute(t).split(P),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?st:"?"===r[1]?it:"@"===r[1]?nt:et}),i.removeAttribute(t)}else t.startsWith(P)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(W.test(i.tagName)){const t=i.textContent.split(P),e=t.length-1;if(e>0){i.textContent=S?S.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],N()),K.nextNode(),h.push({type:2,index:++n});i.append(t[e],N())}}}else if(8===i.nodeType)if(i.data===k)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(P,t+1));)h.push({type:7,index:n}),t+=P.length-1}n++}}static createElement(t,e){const s=O.createElement("template");return s.innerHTML=t,s}}function X(t,e,s=t,i){if(e===V)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=R(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=X(t,n._$AS(t,e.values),n,i)),e}class Y{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??O).importNode(e,!0);K.currentNode=i;let n=K.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new tt(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new ot(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=K.nextNode(),o++)}return K.currentNode=O,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class tt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=F,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=X(this,t,e),R(t)?t===F||null==t||""===t?(this._$AH!==F&&this._$AR(),this._$AH=F):t!==this._$AH&&t!==V&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>H(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==F&&R(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Q.createElement(Z(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new Y(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=J.get(t.strings);return void 0===e&&J.set(t.strings,e=new Q(t)),e}k(t){H(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new tt(this.O(N()),this.O(N()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=w(t).nextSibling;w(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class et{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=F,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=F}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=X(this,t,e,0),o=!R(t)||t!==this._$AH&&t!==V,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=X(this,i[s+r],e,r),h===V&&(h=this._$AH[r]),o||=!R(h)||h!==this._$AH[r],h===F?t=F:t!==F&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===F?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class st extends et{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===F?void 0:t}}class it extends et{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==F)}}class nt extends et{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=X(this,t,e,0)??F)===V)return;const s=this._$AH,i=t===F&&s!==F||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==F&&(s===F||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class ot{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){X(this,t)}}const rt=b.litHtmlPolyfillSupport;rt?.(Q,tt),(b.litHtmlVersions??=[]).push("3.3.2");const ht=globalThis;
19
18
  /**
20
19
  * @license
21
20
  * Copyright 2017 Google LLC
22
21
  * SPDX-License-Identifier: BSD-3-Clause
23
- */class rt extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new X(e.insertBefore(U(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}}rt._$litElement$=!0,rt.finalized=!0,ot.litElementHydrateSupport?.({LitElement:rt});const ht=ot.litElementPolyfillSupport;ht?.({LitElement:rt}),(ot.litElementVersions??=[]).push("4.2.2");class at extends rt{constructor(){super(),this._initialized=!1,this._eventListeners=new Map}initializeMicroApp(){this._initialized||(this._setupEventListeners(),this._initialized=!0)}connectedCallback(){super.connectedCallback(),this.initializeMicroApp(),this.onConnected()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupEventListeners(),this.onDisconnected()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.onAttributeChanged(t,e,s)}_setupEventListeners(){}_cleanupEventListeners(){const t=Array.from(this._eventListeners.entries());for(const[e,s]of t)s.forEach(t=>{window.removeEventListener(e,t)});this._eventListeners.clear()}addEventListener(t,e,s){super.addEventListener(t,e,s)}dispatchCustomEvent(t,e){const s=new CustomEvent(t,{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}onConnected(){}onDisconnected(){}onAttributeChanged(t,e,s){}render(){return B``}}class dt extends at{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,widgetInfo:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.widgetInfo!==e.widgetInfo&&this.onWidgetInfoChanged(s.widgetInfo,e.widgetInfo),s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized()}onInitialized(){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}onWidgetInfoChanged(t,e){}render(){return B``}}dt.properties={spCtx:{type:Object,attribute:!1}};class lt extends at{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,background:"",widgetInfo:{},customParam:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized({widgetInfo:this.spCtx.widgetInfo,customParam:this.spCtx.customParam})}onInitialized(t){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}render(){return B``}}lt.properties={spCtx:{type:Object,attribute:!1}};class ct extends Error{constructor(t,e="unknown",s){super(t),this.name="SpNetworkRequestError",this.type=e,this.response=s}}class pt extends Error{constructor(t,e,s){super(t),this.name="SpDataNodeError",this.code=e,this.response=s}}t.SpDataNodeError=pt,t.SpNetworkRequestError=ct,t.SunPanelElement=at,t.SunPanelPageElement=lt,t.SunPanelWidgetElement=dt,t.VERSION='"1.0.13"'}(this.SunPanelMicroApp=this.SunPanelMicroApp||{});
22
+ */class at extends C{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new tt(e.insertBefore(N(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}}at._$litElement$=!0,at.finalized=!0,ht.litElementHydrateSupport?.({LitElement:at});const dt=ht.litElementPolyfillSupport;dt?.({LitElement:at}),(ht.litElementVersions??=[]).push("4.2.2");class lt extends at{constructor(){super(),this._initialized=!1,this._eventListeners=new Map}initializeMicroApp(){this._initialized||(this._setupEventListeners(),this._initialized=!0)}connectedCallback(){super.connectedCallback(),this.initializeMicroApp(),this.onConnected()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupEventListeners(),this.onDisconnected()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.onAttributeChanged(t,e,s)}_setupEventListeners(){}_cleanupEventListeners(){const t=Array.from(this._eventListeners.entries());for(const[e,s]of t)s.forEach(t=>{window.removeEventListener(e,t)});this._eventListeners.clear()}addEventListener(t,e,s){super.addEventListener(t,e,s)}dispatchCustomEvent(t,e){const s=new CustomEvent(t,{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}onConnected(){}onDisconnected(){}onAttributeChanged(t,e,s){}render(){return q``}}class ct extends lt{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,background:"",widgetInfo:{},customParam:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized({widgetInfo:this.spCtx.widgetInfo,customParam:this.spCtx.customParam})}onInitialized(t){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}render(){return q``}}ct.properties={spCtx:{type:Object,attribute:!1}};class pt extends lt{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,widgetInfo:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.widgetInfo!==e.widgetInfo&&this.onWidgetInfoChanged(s.widgetInfo,e.widgetInfo),s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized()}onInitialized(){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}onWidgetInfoChanged(t,e){}render(){return q``}}pt.properties={spCtx:{type:Object,attribute:!1}};t.SpDataNodeError=s,t.SpNetworkRequestError=e,t.SunPanelElement=lt,t.SunPanelPageElement=ct,t.SunPanelWidgetElement=pt,t.VERSION='"1.0.14"'}(this.SunPanelMicroApp=this.SunPanelMicroApp||{});
package/dist/index.d.ts CHANGED
@@ -12,16 +12,16 @@
12
12
  * }
13
13
  * ```
14
14
  */
15
+ export { SpDataNodeError, SpNetworkRequestError, } from './errors.js';
15
16
  export { SunPanelElement } from './SunPanelElement.js';
16
- export { SunPanelWidgetElement } from './SunPanelWidgetElement.js';
17
17
  export { SunPanelPageElement } from './SunPanelPageElement.js';
18
- export type { SpAPI, RequestOptions, TemplateReplacementRule, WindowConfig, OpenWindowOptions, WindowInitializedParam, } from './types/api.js';
19
- export { SpNetworkRequestError, SpDataNodeError, } from './errors.js';
20
- export type { SpContext, SpContextWidget, SpContextPage, WidgetInfo, PageInitializedParam, ChangedProperties, NetworkMode, RoleType, GridSizeType, BackgroundType, } from './types/common.js';
18
+ export { SunPanelWidgetElement } from './SunPanelWidgetElement.js';
19
+ export type { OpenWindowOptions, RequestOptions, SpAPI, TemplateReplacementRule, WindowConfig, WindowInitializedParam, } from './types/api.js';
20
+ export type { BackgroundType, ChangedProperties, GridSizeType, NetworkMode, PageInitializedParam, RoleType, SpContext, SpContextPage, SpContextWidget, WidgetInfo, } from './types/common.js';
21
21
  /** 应用主题类型 */
22
22
  export type Theme = 'light' | 'dark';
23
23
  /** 库版本号 */
24
- export declare const VERSION = "1.0.13";
24
+ export declare const VERSION = "1.0.14";
25
25
  /**
26
26
  * HTMLElement 扩展属性
27
27
  *
package/dist/index.esm.js CHANGED
@@ -1,22 +1,22 @@
1
+ class t extends Error{constructor(t,e="unknown",s){super(t),this.name="SpNetworkRequestError",this.type=e,this.response=s}}class e extends Error{constructor(t,e,s){super(t),this.name="SpDataNodeError",this.code=e,this.response=s}}
1
2
  /**
2
3
  * @license
3
4
  * Copyright 2019 Google LLC
4
5
  * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;let n=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=i.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&i.set(s,t))}return t}toString(){return this.cssText}};const o=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:r,defineProperty:h,getOwnPropertyDescriptor:a,getOwnPropertyNames:d,getOwnPropertySymbols:c,getPrototypeOf:l}=Object,p=globalThis,u=p.trustedTypes,$=u?u.emptyScript:"",_=p.reactiveElementPolyfillSupport,g=(t,e)=>t,f={toAttribute(t,e){switch(e){case Boolean:t=t?$:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},A=(t,e)=>!r(t,e),m={attribute:!0,type:String,converter:f,reflect:!1,useDefault:!1,hasChanged:A};
6
+ */const s=globalThis,i=s.ShadowRoot&&(void 0===s.ShadyCSS||s.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;let r=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&o.set(e,t))}return t}toString(){return this.cssText}};const h=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:a,defineProperty:d,getOwnPropertyDescriptor:c,getOwnPropertyNames:l,getOwnPropertySymbols:p,getPrototypeOf:u}=Object,$=globalThis,_=$.trustedTypes,g=_?_.emptyScript:"",f=$.reactiveElementPolyfillSupport,A=(t,e)=>t,m={toAttribute(t,e){switch(e){case Boolean:t=t?g:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!a(t,e),v={attribute:!0,type:String,converter:m,reflect:!1,useDefault:!1,hasChanged:y};
7
7
  /**
8
8
  * @license
9
9
  * Copyright 2017 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
- */Symbol.metadata??=Symbol("metadata"),p.litPropertyMetadata??=new WeakMap;let y=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=m){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&h(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=a(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??m}static _$Ei(){if(this.hasOwnProperty(g("elementProperties")))return;const t=l(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(g("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(g("properties"))){const t=this.properties,e=[...d(t),...c(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(o(t))}else void 0!==t&&e.push(o(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const s=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((s,i)=>{if(e)s.adoptedStyleSheets=i.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of i){const i=document.createElement("style"),n=t.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}})(s,this.constructor.elementStyles),s}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:f).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:f;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??A)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[g("elementProperties")]=new Map,y[g("finalized")]=new Map,_?.({ReactiveElement:y}),(p.reactiveElementVersions??=[]).push("2.1.2");
11
+ */Symbol.metadata??=Symbol("metadata"),$.litPropertyMetadata??=new WeakMap;let C=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=v){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&d(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=c(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??v}static _$Ei(){if(this.hasOwnProperty(A("elementProperties")))return;const t=u(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(A("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(A("properties"))){const t=this.properties,e=[...l(t),...p(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(h(t))}else void 0!==t&&e.push(h(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(i)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),n=s.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:m).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:m;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??y)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[A("elementProperties")]=new Map,C[A("finalized")]=new Map,f?.({ReactiveElement:C}),($.reactiveElementVersions??=[]).push("2.1.2");
12
12
  /**
13
13
  * @license
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- const v=globalThis,C=t=>t,E=v.trustedTypes,b=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,w="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,x="?"+S,M=`<${x}>`,k=document,P=()=>k.createComment(""),U=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,N="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,R=/-->/g,T=/>/g,L=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),I=/'/g,z=/"/g,D=/^(?:script|style|textarea|title)$/i,j=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),B=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),q=new WeakMap,V=k.createTreeWalker(k,129);function F(t,e){if(!O(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==b?b.createHTML(e):e}const J=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=H;for(let e=0;e<s;e++){const s=t[e];let h,a,d=-1,c=0;for(;c<s.length&&(r.lastIndex=c,a=r.exec(s),null!==a);)c=r.lastIndex,r===H?"!--"===a[1]?r=R:void 0!==a[1]?r=T:void 0!==a[2]?(D.test(a[2])&&(n=RegExp("</"+a[2],"g")),r=L):void 0!==a[3]&&(r=L):r===L?">"===a[0]?(r=n??H,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,h=a[1],r=void 0===a[3]?L:'"'===a[3]?z:I):r===z||r===I?r=L:r===R||r===T?r=H:(r=L,n=void 0);const l=r===L&&t[e+1].startsWith("/>")?" ":"";o+=r===H?s+M:d>=0?(i.push(h),s.slice(0,d)+w+s.slice(d)+S+l):s+S+(-2===d?e:l)}return[F(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class K{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[a,d]=J(t,e);if(this.el=K.createElement(a,s),V.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=V.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(w)){const e=d[o++],s=i.getAttribute(t).split(S),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?Y:"?"===r[1]?tt:"@"===r[1]?et:X}),i.removeAttribute(t)}else t.startsWith(S)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(D.test(i.tagName)){const t=i.textContent.split(S),e=t.length-1;if(e>0){i.textContent=E?E.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],P()),V.nextNode(),h.push({type:2,index:++n});i.append(t[e],P())}}}else if(8===i.nodeType)if(i.data===x)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(S,t+1));)h.push({type:7,index:n}),t+=S.length-1}n++}}static createElement(t,e){const s=k.createElement("template");return s.innerHTML=t,s}}function Z(t,e,s=t,i){if(e===B)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=U(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Z(t,n._$AS(t,e.values),n,i)),e}class G{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??k).importNode(e,!0);V.currentNode=i;let n=V.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new Q(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new st(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=V.nextNode(),o++)}return V.currentNode=k,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class Q{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),U(t)?t===W||null==t||""===t?(this._$AH!==W&&this._$AR(),this._$AH=W):t!==this._$AH&&t!==B&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>O(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==W&&U(this._$AH)?this._$AA.nextSibling.data=t:this.T(k.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=K.createElement(F(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new G(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=q.get(t.strings);return void 0===e&&q.set(t.strings,e=new K(t)),e}k(t){O(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new Q(this.O(P()),this.O(P()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=C(t).nextSibling;C(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class X{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=W,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=W}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Z(this,t,e,0),o=!U(t)||t!==this._$AH&&t!==B,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=Z(this,i[s+r],e,r),h===B&&(h=this._$AH[r]),o||=!U(h)||h!==this._$AH[r],h===W?t=W:t!==W&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Y extends X{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===W?void 0:t}}class tt extends X{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==W)}}class et extends X{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??W)===B)return;const s=this._$AH,i=t===W&&s!==W||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==W&&(s===W||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class st{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const it=v.litHtmlPolyfillSupport;it?.(K,Q),(v.litHtmlVersions??=[]).push("3.3.2");const nt=globalThis;
17
+ const E=globalThis,b=t=>t,w=E.trustedTypes,S=w?w.createPolicy("lit-html",{createHTML:t=>t}):void 0,x="$lit$",M=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+M,P=`<${k}>`,U=document,O=()=>U.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,H=Array.isArray,R="[ \t\n\f\r]",T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,I=/>/g,z=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,j=/"/g,B=/^(?:script|style|textarea|title)$/i,W=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),q=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),F=new WeakMap,J=U.createTreeWalker(U,129);function K(t,e){if(!H(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const Z=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=T;for(let e=0;e<s;e++){const s=t[e];let h,a,d=-1,c=0;for(;c<s.length&&(r.lastIndex=c,a=r.exec(s),null!==a);)c=r.lastIndex,r===T?"!--"===a[1]?r=L:void 0!==a[1]?r=I:void 0!==a[2]?(B.test(a[2])&&(n=RegExp("</"+a[2],"g")),r=z):void 0!==a[3]&&(r=z):r===z?">"===a[0]?(r=n??T,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,h=a[1],r=void 0===a[3]?z:'"'===a[3]?j:D):r===j||r===D?r=z:r===L||r===I?r=T:(r=z,n=void 0);const l=r===z&&t[e+1].startsWith("/>")?" ":"";o+=r===T?s+P:d>=0?(i.push(h),s.slice(0,d)+x+s.slice(d)+M+l):s+M+(-2===d?e:l)}return[K(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class G{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[a,d]=Z(t,e);if(this.el=G.createElement(a,s),J.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=J.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(x)){const e=d[o++],s=i.getAttribute(t).split(M),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?et:"?"===r[1]?st:"@"===r[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(M)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(B.test(i.tagName)){const t=i.textContent.split(M),e=t.length-1;if(e>0){i.textContent=w?w.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],O()),J.nextNode(),h.push({type:2,index:++n});i.append(t[e],O())}}}else if(8===i.nodeType)if(i.data===k)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(M,t+1));)h.push({type:7,index:n}),t+=M.length-1}n++}}static createElement(t,e){const s=U.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,i){if(e===q)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=N(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Q(t,n._$AS(t,e.values),n,i)),e}class X{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??U).importNode(e,!0);J.currentNode=i;let n=J.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new Y(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new nt(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=J.nextNode(),o++)}return J.currentNode=U,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class Y{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Q(this,t,e),N(t)?t===V||null==t||""===t?(this._$AH!==V&&this._$AR(),this._$AH=V):t!==this._$AH&&t!==q&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>H(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==V&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(U.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(K(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new X(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=F.get(t.strings);return void 0===e&&F.set(t.strings,e=new G(t)),e}k(t){H(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new Y(this.O(O()),this.O(O()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=b(t).nextSibling;b(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=V,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=V}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Q(this,t,e,0),o=!N(t)||t!==this._$AH&&t!==q,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=Q(this,i[s+r],e,r),h===q&&(h=this._$AH[r]),o||=!N(h)||h!==this._$AH[r],h===V?t=V:t!==V&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===V?void 0:t}}class st extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==V)}}class it extends tt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===q)return;const s=this._$AH,i=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==V&&(s===V||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Q(this,t)}}const ot=E.litHtmlPolyfillSupport;ot?.(G,Y),(E.litHtmlVersions??=[]).push("3.3.2");const rt=globalThis;
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
- */class ot extends y{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new Q(e.insertBefore(P(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return B}}ot._$litElement$=!0,ot.finalized=!0,nt.litElementHydrateSupport?.({LitElement:ot});const rt=nt.litElementPolyfillSupport;rt?.({LitElement:ot}),(nt.litElementVersions??=[]).push("4.2.2");class ht extends ot{constructor(){super(),this._initialized=!1,this._eventListeners=new Map}initializeMicroApp(){this._initialized||(this._setupEventListeners(),this._initialized=!0)}connectedCallback(){super.connectedCallback(),this.initializeMicroApp(),this.onConnected()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupEventListeners(),this.onDisconnected()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.onAttributeChanged(t,e,s)}_setupEventListeners(){}_cleanupEventListeners(){const t=Array.from(this._eventListeners.entries());for(const[e,s]of t)s.forEach(t=>{window.removeEventListener(e,t)});this._eventListeners.clear()}addEventListener(t,e,s){super.addEventListener(t,e,s)}dispatchCustomEvent(t,e){const s=new CustomEvent(t,{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}onConnected(){}onDisconnected(){}onAttributeChanged(t,e,s){}render(){return j``}}class at extends ht{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,widgetInfo:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.widgetInfo!==e.widgetInfo&&this.onWidgetInfoChanged(s.widgetInfo,e.widgetInfo),s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized()}onInitialized(){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}onWidgetInfoChanged(t,e){}render(){return j``}}at.properties={spCtx:{type:Object,attribute:!1}};class dt extends ht{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,background:"",widgetInfo:{},customParam:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized({widgetInfo:this.spCtx.widgetInfo,customParam:this.spCtx.customParam})}onInitialized(t){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}render(){return j``}}dt.properties={spCtx:{type:Object,attribute:!1}};class ct extends Error{constructor(t,e="unknown",s){super(t),this.name="SpNetworkRequestError",this.type=e,this.response=s}}class lt extends Error{constructor(t,e,s){super(t),this.name="SpDataNodeError",this.code=e,this.response=s}}const pt='"1.0.13"';export{lt as SpDataNodeError,ct as SpNetworkRequestError,ht as SunPanelElement,dt as SunPanelPageElement,at as SunPanelWidgetElement,pt as VERSION};
22
+ */class ht extends C{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new Y(e.insertBefore(O(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return q}}ht._$litElement$=!0,ht.finalized=!0,rt.litElementHydrateSupport?.({LitElement:ht});const at=rt.litElementPolyfillSupport;at?.({LitElement:ht}),(rt.litElementVersions??=[]).push("4.2.2");class dt extends ht{constructor(){super(),this._initialized=!1,this._eventListeners=new Map}initializeMicroApp(){this._initialized||(this._setupEventListeners(),this._initialized=!0)}connectedCallback(){super.connectedCallback(),this.initializeMicroApp(),this.onConnected()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupEventListeners(),this.onDisconnected()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.onAttributeChanged(t,e,s)}_setupEventListeners(){}_cleanupEventListeners(){const t=Array.from(this._eventListeners.entries());for(const[e,s]of t)s.forEach(t=>{window.removeEventListener(e,t)});this._eventListeners.clear()}addEventListener(t,e,s){super.addEventListener(t,e,s)}dispatchCustomEvent(t,e){const s=new CustomEvent(t,{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}onConnected(){}onDisconnected(){}onAttributeChanged(t,e,s){}render(){return W``}}class ct extends dt{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,background:"",widgetInfo:{},customParam:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized({widgetInfo:this.spCtx.widgetInfo,customParam:this.spCtx.customParam})}onInitialized(t){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}render(){return W``}}ct.properties={spCtx:{type:Object,attribute:!1}};class lt extends dt{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,widgetInfo:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.widgetInfo!==e.widgetInfo&&this.onWidgetInfoChanged(s.widgetInfo,e.widgetInfo),s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized()}onInitialized(){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}onWidgetInfoChanged(t,e){}render(){return W``}}lt.properties={spCtx:{type:Object,attribute:!1}};const pt='"1.0.14"';export{e as SpDataNodeError,t as SpNetworkRequestError,dt as SunPanelElement,ct as SunPanelPageElement,lt as SunPanelWidgetElement,pt as VERSION};
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
+ class t extends Error{constructor(t,e="unknown",s){super(t),this.name="SpNetworkRequestError",this.type=e,this.response=s}}class e extends Error{constructor(t,e,s){super(t),this.name="SpDataNodeError",this.code=e,this.response=s}}
1
2
  /**
2
3
  * @license
3
4
  * Copyright 2019 Google LLC
4
5
  * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;let n=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=i.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&i.set(s,t))}return t}toString(){return this.cssText}};const o=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:r,defineProperty:h,getOwnPropertyDescriptor:a,getOwnPropertyNames:d,getOwnPropertySymbols:l,getPrototypeOf:c}=Object,p=globalThis,u=p.trustedTypes,$=u?u.emptyScript:"",_=p.reactiveElementPolyfillSupport,g=(t,e)=>t,f={toAttribute(t,e){switch(e){case Boolean:t=t?$:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},A=(t,e)=>!r(t,e),m={attribute:!0,type:String,converter:f,reflect:!1,useDefault:!1,hasChanged:A};
6
+ */const s=globalThis,i=s.ShadowRoot&&(void 0===s.ShadyCSS||s.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;let r=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&o.set(e,t))}return t}toString(){return this.cssText}};const h=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:a,defineProperty:d,getOwnPropertyDescriptor:l,getOwnPropertyNames:c,getOwnPropertySymbols:p,getPrototypeOf:u}=Object,$=globalThis,_=$.trustedTypes,g=_?_.emptyScript:"",f=$.reactiveElementPolyfillSupport,A=(t,e)=>t,m={toAttribute(t,e){switch(e){case Boolean:t=t?g:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!a(t,e),v={attribute:!0,type:String,converter:m,reflect:!1,useDefault:!1,hasChanged:y};
7
7
  /**
8
8
  * @license
9
9
  * Copyright 2017 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
- */Symbol.metadata??=Symbol("metadata"),p.litPropertyMetadata??=new WeakMap;let y=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=m){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&h(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=a(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??m}static _$Ei(){if(this.hasOwnProperty(g("elementProperties")))return;const t=c(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(g("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(g("properties"))){const t=this.properties,e=[...d(t),...l(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(o(t))}else void 0!==t&&e.push(o(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const s=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((s,i)=>{if(e)s.adoptedStyleSheets=i.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of i){const i=document.createElement("style"),n=t.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}})(s,this.constructor.elementStyles),s}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:f).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:f;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??A)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[g("elementProperties")]=new Map,y[g("finalized")]=new Map,_?.({ReactiveElement:y}),(p.reactiveElementVersions??=[]).push("2.1.2");
11
+ */Symbol.metadata??=Symbol("metadata"),$.litPropertyMetadata??=new WeakMap;let E=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=v){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&d(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??v}static _$Ei(){if(this.hasOwnProperty(A("elementProperties")))return;const t=u(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(A("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(A("properties"))){const t=this.properties,e=[...c(t),...p(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(h(t))}else void 0!==t&&e.push(h(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(i)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),n=s.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:m).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:m;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??y)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};E.elementStyles=[],E.shadowRootOptions={mode:"open"},E[A("elementProperties")]=new Map,E[A("finalized")]=new Map,f?.({ReactiveElement:E}),($.reactiveElementVersions??=[]).push("2.1.2");
12
12
  /**
13
13
  * @license
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- const v=globalThis,E=t=>t,C=v.trustedTypes,b=C?C.createPolicy("lit-html",{createHTML:t=>t}):void 0,w="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,x="?"+S,M=`<${x}>`,P=document,k=()=>P.createComment(""),U=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,N="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,H=/-->/g,T=/>/g,L=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),I=/'/g,z=/"/g,D=/^(?:script|style|textarea|title)$/i,j=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),B=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),q=new WeakMap,V=P.createTreeWalker(P,129);function F(t,e){if(!O(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==b?b.createHTML(e):e}const J=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=R;for(let e=0;e<s;e++){const s=t[e];let h,a,d=-1,l=0;for(;l<s.length&&(r.lastIndex=l,a=r.exec(s),null!==a);)l=r.lastIndex,r===R?"!--"===a[1]?r=H:void 0!==a[1]?r=T:void 0!==a[2]?(D.test(a[2])&&(n=RegExp("</"+a[2],"g")),r=L):void 0!==a[3]&&(r=L):r===L?">"===a[0]?(r=n??R,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,h=a[1],r=void 0===a[3]?L:'"'===a[3]?z:I):r===z||r===I?r=L:r===H||r===T?r=R:(r=L,n=void 0);const c=r===L&&t[e+1].startsWith("/>")?" ":"";o+=r===R?s+M:d>=0?(i.push(h),s.slice(0,d)+w+s.slice(d)+S+c):s+S+(-2===d?e:c)}return[F(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class K{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[a,d]=J(t,e);if(this.el=K.createElement(a,s),V.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=V.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(w)){const e=d[o++],s=i.getAttribute(t).split(S),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?Y:"?"===r[1]?tt:"@"===r[1]?et:X}),i.removeAttribute(t)}else t.startsWith(S)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(D.test(i.tagName)){const t=i.textContent.split(S),e=t.length-1;if(e>0){i.textContent=C?C.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],k()),V.nextNode(),h.push({type:2,index:++n});i.append(t[e],k())}}}else if(8===i.nodeType)if(i.data===x)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(S,t+1));)h.push({type:7,index:n}),t+=S.length-1}n++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Z(t,e,s=t,i){if(e===B)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=U(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Z(t,n._$AS(t,e.values),n,i)),e}class G{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??P).importNode(e,!0);V.currentNode=i;let n=V.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new Q(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new st(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=V.nextNode(),o++)}return V.currentNode=P,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class Q{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),U(t)?t===W||null==t||""===t?(this._$AH!==W&&this._$AR(),this._$AH=W):t!==this._$AH&&t!==B&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>O(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==W&&U(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=K.createElement(F(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new G(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=q.get(t.strings);return void 0===e&&q.set(t.strings,e=new K(t)),e}k(t){O(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new Q(this.O(k()),this.O(k()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=E(t).nextSibling;E(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class X{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=W,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=W}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Z(this,t,e,0),o=!U(t)||t!==this._$AH&&t!==B,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=Z(this,i[s+r],e,r),h===B&&(h=this._$AH[r]),o||=!U(h)||h!==this._$AH[r],h===W?t=W:t!==W&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Y extends X{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===W?void 0:t}}class tt extends X{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==W)}}class et extends X{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??W)===B)return;const s=this._$AH,i=t===W&&s!==W||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==W&&(s===W||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class st{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const it=v.litHtmlPolyfillSupport;it?.(K,Q),(v.litHtmlVersions??=[]).push("3.3.2");const nt=globalThis;
17
+ const C=globalThis,b=t=>t,w=C.trustedTypes,S=w?w.createPolicy("lit-html",{createHTML:t=>t}):void 0,x="$lit$",M=`lit$${Math.random().toFixed(9).slice(2)}$`,P="?"+M,k=`<${P}>`,U=document,O=()=>U.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,R=Array.isArray,H="[ \t\n\f\r]",T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,I=/>/g,z=RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,j=/"/g,B=/^(?:script|style|textarea|title)$/i,W=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),q=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),F=new WeakMap,J=U.createTreeWalker(U,129);function K(t,e){if(!R(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const Z=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=T;for(let e=0;e<s;e++){const s=t[e];let h,a,d=-1,l=0;for(;l<s.length&&(r.lastIndex=l,a=r.exec(s),null!==a);)l=r.lastIndex,r===T?"!--"===a[1]?r=L:void 0!==a[1]?r=I:void 0!==a[2]?(B.test(a[2])&&(n=RegExp("</"+a[2],"g")),r=z):void 0!==a[3]&&(r=z):r===z?">"===a[0]?(r=n??T,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,h=a[1],r=void 0===a[3]?z:'"'===a[3]?j:D):r===j||r===D?r=z:r===L||r===I?r=T:(r=z,n=void 0);const c=r===z&&t[e+1].startsWith("/>")?" ":"";o+=r===T?s+k:d>=0?(i.push(h),s.slice(0,d)+x+s.slice(d)+M+c):s+M+(-2===d?e:c)}return[K(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class G{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[a,d]=Z(t,e);if(this.el=G.createElement(a,s),J.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=J.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(x)){const e=d[o++],s=i.getAttribute(t).split(M),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?et:"?"===r[1]?st:"@"===r[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(M)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(B.test(i.tagName)){const t=i.textContent.split(M),e=t.length-1;if(e>0){i.textContent=w?w.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],O()),J.nextNode(),h.push({type:2,index:++n});i.append(t[e],O())}}}else if(8===i.nodeType)if(i.data===P)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(M,t+1));)h.push({type:7,index:n}),t+=M.length-1}n++}}static createElement(t,e){const s=U.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,i){if(e===q)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=N(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Q(t,n._$AS(t,e.values),n,i)),e}class X{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??U).importNode(e,!0);J.currentNode=i;let n=J.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new Y(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new nt(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=J.nextNode(),o++)}return J.currentNode=U,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class Y{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Q(this,t,e),N(t)?t===V||null==t||""===t?(this._$AH!==V&&this._$AR(),this._$AH=V):t!==this._$AH&&t!==q&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>R(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==V&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(U.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(K(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new X(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=F.get(t.strings);return void 0===e&&F.set(t.strings,e=new G(t)),e}k(t){R(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new Y(this.O(O()),this.O(O()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=b(t).nextSibling;b(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=V,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=V}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Q(this,t,e,0),o=!N(t)||t!==this._$AH&&t!==q,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=Q(this,i[s+r],e,r),h===q&&(h=this._$AH[r]),o||=!N(h)||h!==this._$AH[r],h===V?t=V:t!==V&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===V?void 0:t}}class st extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==V)}}class it extends tt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===q)return;const s=this._$AH,i=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==V&&(s===V||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Q(this,t)}}const ot=C.litHtmlPolyfillSupport;ot?.(G,Y),(C.litHtmlVersions??=[]).push("3.3.2");const rt=globalThis;
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
- */class ot extends y{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new Q(e.insertBefore(k(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return B}}ot._$litElement$=!0,ot.finalized=!0,nt.litElementHydrateSupport?.({LitElement:ot});const rt=nt.litElementPolyfillSupport;rt?.({LitElement:ot}),(nt.litElementVersions??=[]).push("4.2.2");class ht extends ot{constructor(){super(),this._initialized=!1,this._eventListeners=new Map}initializeMicroApp(){this._initialized||(this._setupEventListeners(),this._initialized=!0)}connectedCallback(){super.connectedCallback(),this.initializeMicroApp(),this.onConnected()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupEventListeners(),this.onDisconnected()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.onAttributeChanged(t,e,s)}_setupEventListeners(){}_cleanupEventListeners(){const t=Array.from(this._eventListeners.entries());for(const[e,s]of t)s.forEach(t=>{window.removeEventListener(e,t)});this._eventListeners.clear()}addEventListener(t,e,s){super.addEventListener(t,e,s)}dispatchCustomEvent(t,e){const s=new CustomEvent(t,{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}onConnected(){}onDisconnected(){}onAttributeChanged(t,e,s){}render(){return j``}}class at extends ht{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,widgetInfo:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.widgetInfo!==e.widgetInfo&&this.onWidgetInfoChanged(s.widgetInfo,e.widgetInfo),s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized()}onInitialized(){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}onWidgetInfoChanged(t,e){}render(){return j``}}at.properties={spCtx:{type:Object,attribute:!1}};class dt extends ht{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,background:"",widgetInfo:{},customParam:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized({widgetInfo:this.spCtx.widgetInfo,customParam:this.spCtx.customParam})}onInitialized(t){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}render(){return j``}}dt.properties={spCtx:{type:Object,attribute:!1}};class lt extends Error{constructor(t,e="unknown",s){super(t),this.name="SpNetworkRequestError",this.type=e,this.response=s}}class ct extends Error{constructor(t,e,s){super(t),this.name="SpDataNodeError",this.code=e,this.response=s}}exports.SpDataNodeError=ct,exports.SpNetworkRequestError=lt,exports.SunPanelElement=ht,exports.SunPanelPageElement=dt,exports.SunPanelWidgetElement=at,exports.VERSION='"1.0.13"';
22
+ */class ht extends E{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new Y(e.insertBefore(O(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return q}}ht._$litElement$=!0,ht.finalized=!0,rt.litElementHydrateSupport?.({LitElement:ht});const at=rt.litElementPolyfillSupport;at?.({LitElement:ht}),(rt.litElementVersions??=[]).push("4.2.2");class dt extends ht{constructor(){super(),this._initialized=!1,this._eventListeners=new Map}initializeMicroApp(){this._initialized||(this._setupEventListeners(),this._initialized=!0)}connectedCallback(){super.connectedCallback(),this.initializeMicroApp(),this.onConnected()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupEventListeners(),this.onDisconnected()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.onAttributeChanged(t,e,s)}_setupEventListeners(){}_cleanupEventListeners(){const t=Array.from(this._eventListeners.entries());for(const[e,s]of t)s.forEach(t=>{window.removeEventListener(e,t)});this._eventListeners.clear()}addEventListener(t,e,s){super.addEventListener(t,e,s)}dispatchCustomEvent(t,e){const s=new CustomEvent(t,{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}onConnected(){}onDisconnected(){}onAttributeChanged(t,e,s){}render(){return W``}}class lt extends dt{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,background:"",widgetInfo:{},customParam:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized({widgetInfo:this.spCtx.widgetInfo,customParam:this.spCtx.customParam})}onInitialized(t){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}render(){return W``}}lt.properties={spCtx:{type:Object,attribute:!1}};class ct extends dt{constructor(){super(),this.spCtx={api:{},darkMode:!1,language:"zh-CN",networkMode:"wan",staticPath:"",role:0,widgetInfo:{}}}updateContext(t){if(!t||"object"!=typeof t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>void 0!==e));this.spCtx={...this.spCtx,...e}}firstUpdated(t){super.firstUpdated?.(t),this.onFirstRendered()}updated(t){if(super.updated(t),t.has("spCtx")){const e=t.get("spCtx")||{},s=this.spCtx;s.widgetInfo!==e.widgetInfo&&this.onWidgetInfoChanged(s.widgetInfo,e.widgetInfo),s.darkMode!==e.darkMode&&this.onDarkModeChanged(s.darkMode,e.darkMode),s.language!==e.language&&this.onLanguageChanged(s.language,e.language),s.networkMode!==e.networkMode&&this.onNetworkModeChanged(s.networkMode,e.networkMode)}}onConnected(){super.onConnected(),this.onInitialized()}onInitialized(){}onFirstRendered(){}onDarkModeChanged(t,e){}onLanguageChanged(t,e){}onNetworkModeChanged(t,e){}onWidgetInfoChanged(t,e){}render(){return W``}}ct.properties={spCtx:{type:Object,attribute:!1}};exports.SpDataNodeError=e,exports.SpNetworkRequestError=t,exports.SunPanelElement=dt,exports.SunPanelPageElement=lt,exports.SunPanelWidgetElement=ct,exports.VERSION='"1.0.14"';
@@ -1,4 +1,4 @@
1
- import { WidgetInfo } from './common.js'
1
+ import type { WidgetInfo } from './common.js'
2
2
 
3
3
  /**
4
4
  * 微应用 API 类型定义
@@ -7,18 +7,45 @@ import { WidgetInfo } from './common.js'
7
7
  // ========== 请求类型 ==========
8
8
 
9
9
  export interface RequestOptions {
10
- targetUrl: string
10
+ /**
11
+ * @deprecated Use request.targetUrl instead
12
+ */
13
+ targetUrl?: string
14
+ /**
15
+ * @deprecated Use request.method instead
16
+ */
11
17
  method?: string
18
+ /**
19
+ * @deprecated Use request.headers instead
20
+ */
12
21
  headers?: Record<string, string>
22
+ /**
23
+ * @deprecated Use request.body instead
24
+ */
13
25
  body?: string
14
- templateReplacements: TemplateReplacementRule[]
26
+ /**
27
+ * Request parameters (recommended)
28
+ */
29
+ request?: {
30
+ targetUrl: string
31
+ method?: string
32
+ headers?: Record<string, string>
33
+ body?: string
34
+ }
35
+ templateReplacements?: TemplateReplacementRule[]
36
+ cookieDataNodeKey?: string // Cookie storage data node, format: "nodeName.key"
15
37
  }
16
38
 
17
39
  // ========== 模板替换规则 ==========
18
40
  export interface TemplateReplacementRule {
19
- placeholder: string // 要替换的字符,用户自定义,如 "{{token}}"
20
- fields: string[] // 替换参数,可选:targetUrl, method, headers, body
21
- dataNode: string // 数据节点路径,如 "config.token"
41
+ placeholder: string // Placeholder to replace, e.g. "{{token}}"
42
+ fields: string[] // Fields to replace: targetUrl, method, headers, body
43
+
44
+ /**
45
+ * @deprecated Use dataNodeKey instead
46
+ */
47
+ dataNode?: string // Data node path, e.g. "config.token"
48
+ dataNodeKey?: string // Data node key, e.g. "config.token"
22
49
  }
23
50
 
24
51
  // ========== 微应用 API 接口 ==========
@@ -84,7 +111,7 @@ export interface SpAPI {
84
111
  // 小部件
85
112
  widget: {
86
113
  save: <T = any>(data: WidgetInfo) => Promise<T>
87
- },
114
+ }
88
115
  }
89
116
 
90
117
  // ========== 窗口相关类型 ==========
@@ -117,5 +144,3 @@ export interface WindowInitializedParam {
117
144
  windowConfig?: WindowConfig
118
145
  customParam?: any
119
146
  }
120
-
121
-
@@ -1,15 +1,15 @@
1
- import { SpAPI } from './api';
1
+ import type { SpAPI } from './api'
2
2
  /**
3
3
  * 通用类型定义
4
4
  */
5
5
 
6
6
  export interface SpContext {
7
- api: SpAPI;
8
- darkMode: boolean;
9
- language: string;
10
- networkMode: string;
11
- staticPath: string;
12
- role: number;
7
+ api: SpAPI
8
+ darkMode: boolean
9
+ language: string
10
+ networkMode: string
11
+ staticPath: string
12
+ role: number
13
13
  // size: { width: number; height: number };
14
14
  // [key: string]: any;
15
15
  }
@@ -22,17 +22,16 @@ export interface PageInitializedParam {
22
22
  export interface SpContextWidget extends SpContext {
23
23
  // itemInfo: ItemInfo;
24
24
  // background: string;
25
- widgetInfo: WidgetInfo;
25
+ widgetInfo: WidgetInfo
26
26
  // gridSizeType: GridSizeType;
27
27
  }
28
28
 
29
29
  export interface SpContextPage extends SpContext {
30
- background: string;
31
- widgetInfo: WidgetInfo;
32
- customParam: any;
30
+ background: string
31
+ widgetInfo: WidgetInfo
32
+ customParam: any
33
33
  }
34
34
 
35
-
36
35
  // 小部件配置
37
36
  export interface WidgetInfo {
38
37
  widgetId: string // 小部件ID
@@ -42,7 +41,6 @@ export interface WidgetInfo {
42
41
  title: string
43
42
  }
44
43
 
45
-
46
44
  // export interface ItemInfo {
47
45
  // id: number
48
46
  // onlyName: string
@@ -62,12 +60,12 @@ export interface WidgetInfo {
62
60
  // }
63
61
 
64
62
  // LitElement 使用的属性变更类型
65
- export type ChangedProperties = Map<string, any>;
63
+ export type ChangedProperties = Map<string, any>
66
64
 
67
- export type GridSizeType = number;
65
+ export type GridSizeType = number
68
66
 
69
- export type BackgroundType = string;
67
+ export type BackgroundType = string
70
68
 
71
- export type NetworkMode = 'wan' | 'lan' | 'auto';
69
+ export type NetworkMode = 'wan' | 'lan' | 'auto'
72
70
 
73
- export type RoleType = 0 | 1 | 2; // 0:公开模式 1:私有模式 2:管理员模式
71
+ export type RoleType = 0 | 1 | 2 // 0:公开模式 1:私有模式 2:管理员模式
package/package.json CHANGED
@@ -1,25 +1,17 @@
1
1
  {
2
2
  "name": "@sun-panel/micro-app",
3
- "version": "1.0.13",
3
+ "type": "module",
4
+ "version": "1.0.14",
4
5
  "description": "Sun Panel Micro App - A Lit-based framework for developing micro applications with built-in event binding and validation support",
5
- "main": "dist/index.js",
6
- "module": "dist/index.esm.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/index.esm.js",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- }
6
+ "author": "Sun Panel Team",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/sun-panel/micro-app#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/sun-panel/micro-app.git"
14
12
  },
15
- "scripts": {
16
- "build": "rm -rf dist && rollup -c && tsc -p tsconfig.types.json && cp -r src/types dist/ && sed -i '' \"s/__VERSION__/$npm_package_version/g\" dist/index.d.ts",
17
- "dev": "rollup -c rollup.dev.config.js -w",
18
- "lint": "eslint src --ext .js,.ts",
19
- "test": "jest",
20
- "test:watch": "jest --watch",
21
- "prepublishOnly": "npm run build",
22
- "validate": "npm run build && npm run test"
13
+ "bugs": {
14
+ "url": "https://github.com/sun-panel/micro-app/issues"
23
15
  },
24
16
  "keywords": [
25
17
  "sun-panel",
@@ -29,28 +21,40 @@
29
21
  "typescript",
30
22
  "sdk"
31
23
  ],
32
- "author": "Sun Panel Team",
33
- "license": "MIT",
34
- "repository": {
35
- "type": "git",
36
- "url": "https://github.com/sun-panel/micro-app.git"
37
- },
38
- "bugs": {
39
- "url": "https://github.com/sun-panel/micro-app/issues"
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.esm.js",
28
+ "require": "./dist/index.js"
29
+ }
40
30
  },
41
- "homepage": "https://github.com/sun-panel/micro-app#readme",
42
- "type": "module",
31
+ "main": "dist/index.js",
32
+ "module": "dist/index.esm.js",
33
+ "types": "dist/index.d.ts",
43
34
  "files": [
44
- "dist/",
45
- "README.md",
46
35
  "LICENSE",
36
+ "README.md",
47
37
  "TYPES_LICENSE.md",
38
+ "dist/",
48
39
  "src/types/"
49
40
  ],
41
+ "engines": {
42
+ "node": ">=16.0.0"
43
+ },
44
+ "scripts": {
45
+ "build": "rm -rf dist && rollup -c && tsc -p tsconfig.types.json && cp -r src/types dist/ && sed -i '' \"s/__VERSION__/$npm_package_version/g\" dist/index.d.ts",
46
+ "dev": "rollup -c rollup.dev.config.js -w",
47
+ "lint": "eslint src --ext .js,.ts",
48
+ "test": "jest",
49
+ "test:watch": "jest --watch",
50
+ "prepublishOnly": "npm run build",
51
+ "validate": "npm run build && npm run test"
52
+ },
50
53
  "dependencies": {
51
54
  "lit": "^3.0.0"
52
55
  },
53
56
  "devDependencies": {
57
+ "@antfu/eslint-config": "^2.27.3",
54
58
  "@rollup/plugin-commonjs": "^25.0.8",
55
59
  "@rollup/plugin-node-resolve": "^15.3.1",
56
60
  "@rollup/plugin-replace": "^6.0.3",
@@ -70,8 +74,5 @@
70
74
  "ts-jest": "^29.0.0",
71
75
  "tslib": "^2.8.1",
72
76
  "typescript": "^5.0.0"
73
- },
74
- "engines": {
75
- "node": ">=16.0.0"
76
77
  }
77
- }
78
+ }
@@ -1,4 +1,4 @@
1
- import { WidgetInfo } from './common.js'
1
+ import type { WidgetInfo } from './common.js'
2
2
 
3
3
  /**
4
4
  * 微应用 API 类型定义
@@ -7,18 +7,45 @@ import { WidgetInfo } from './common.js'
7
7
  // ========== 请求类型 ==========
8
8
 
9
9
  export interface RequestOptions {
10
- targetUrl: string
10
+ /**
11
+ * @deprecated Use request.targetUrl instead
12
+ */
13
+ targetUrl?: string
14
+ /**
15
+ * @deprecated Use request.method instead
16
+ */
11
17
  method?: string
18
+ /**
19
+ * @deprecated Use request.headers instead
20
+ */
12
21
  headers?: Record<string, string>
22
+ /**
23
+ * @deprecated Use request.body instead
24
+ */
13
25
  body?: string
14
- templateReplacements: TemplateReplacementRule[]
26
+ /**
27
+ * Request parameters (recommended)
28
+ */
29
+ request?: {
30
+ targetUrl: string
31
+ method?: string
32
+ headers?: Record<string, string>
33
+ body?: string
34
+ }
35
+ templateReplacements?: TemplateReplacementRule[]
36
+ cookieDataNodeKey?: string // Cookie storage data node, format: "nodeName.key"
15
37
  }
16
38
 
17
39
  // ========== 模板替换规则 ==========
18
40
  export interface TemplateReplacementRule {
19
- placeholder: string // 要替换的字符,用户自定义,如 "{{token}}"
20
- fields: string[] // 替换参数,可选:targetUrl, method, headers, body
21
- dataNode: string // 数据节点路径,如 "config.token"
41
+ placeholder: string // Placeholder to replace, e.g. "{{token}}"
42
+ fields: string[] // Fields to replace: targetUrl, method, headers, body
43
+
44
+ /**
45
+ * @deprecated Use dataNodeKey instead
46
+ */
47
+ dataNode?: string // Data node path, e.g. "config.token"
48
+ dataNodeKey?: string // Data node key, e.g. "config.token"
22
49
  }
23
50
 
24
51
  // ========== 微应用 API 接口 ==========
@@ -84,7 +111,7 @@ export interface SpAPI {
84
111
  // 小部件
85
112
  widget: {
86
113
  save: <T = any>(data: WidgetInfo) => Promise<T>
87
- },
114
+ }
88
115
  }
89
116
 
90
117
  // ========== 窗口相关类型 ==========
@@ -117,5 +144,3 @@ export interface WindowInitializedParam {
117
144
  windowConfig?: WindowConfig
118
145
  customParam?: any
119
146
  }
120
-
121
-
@@ -1,15 +1,15 @@
1
- import { SpAPI } from './api';
1
+ import type { SpAPI } from './api'
2
2
  /**
3
3
  * 通用类型定义
4
4
  */
5
5
 
6
6
  export interface SpContext {
7
- api: SpAPI;
8
- darkMode: boolean;
9
- language: string;
10
- networkMode: string;
11
- staticPath: string;
12
- role: number;
7
+ api: SpAPI
8
+ darkMode: boolean
9
+ language: string
10
+ networkMode: string
11
+ staticPath: string
12
+ role: number
13
13
  // size: { width: number; height: number };
14
14
  // [key: string]: any;
15
15
  }
@@ -22,17 +22,16 @@ export interface PageInitializedParam {
22
22
  export interface SpContextWidget extends SpContext {
23
23
  // itemInfo: ItemInfo;
24
24
  // background: string;
25
- widgetInfo: WidgetInfo;
25
+ widgetInfo: WidgetInfo
26
26
  // gridSizeType: GridSizeType;
27
27
  }
28
28
 
29
29
  export interface SpContextPage extends SpContext {
30
- background: string;
31
- widgetInfo: WidgetInfo;
32
- customParam: any;
30
+ background: string
31
+ widgetInfo: WidgetInfo
32
+ customParam: any
33
33
  }
34
34
 
35
-
36
35
  // 小部件配置
37
36
  export interface WidgetInfo {
38
37
  widgetId: string // 小部件ID
@@ -42,7 +41,6 @@ export interface WidgetInfo {
42
41
  title: string
43
42
  }
44
43
 
45
-
46
44
  // export interface ItemInfo {
47
45
  // id: number
48
46
  // onlyName: string
@@ -62,12 +60,12 @@ export interface WidgetInfo {
62
60
  // }
63
61
 
64
62
  // LitElement 使用的属性变更类型
65
- export type ChangedProperties = Map<string, any>;
63
+ export type ChangedProperties = Map<string, any>
66
64
 
67
- export type GridSizeType = number;
65
+ export type GridSizeType = number
68
66
 
69
- export type BackgroundType = string;
67
+ export type BackgroundType = string
70
68
 
71
- export type NetworkMode = 'wan' | 'lan' | 'auto';
69
+ export type NetworkMode = 'wan' | 'lan' | 'auto'
72
70
 
73
- export type RoleType = 0 | 1 | 2; // 0:公开模式 1:私有模式 2:管理员模式
71
+ export type RoleType = 0 | 1 | 2 // 0:公开模式 1:私有模式 2:管理员模式
@@ -1,64 +0,0 @@
1
- /**
2
- * 验证相关类型定义
3
- */
4
- /**
5
- * 验证规则接口
6
- */
7
- export interface ValidationRule {
8
- required?: boolean;
9
- type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'date' | 'email' | 'url';
10
- minLength?: number;
11
- maxLength?: number;
12
- min?: number;
13
- max?: number;
14
- pattern?: RegExp;
15
- validator?: (value: any) => boolean | string | Promise<boolean | string>;
16
- message?: string;
17
- }
18
- /**
19
- * 验证错误项接口
20
- */
21
- export interface ValidationErrorItem {
22
- field: string;
23
- message: string;
24
- value?: any;
25
- }
26
- /**
27
- * 验证错误类
28
- */
29
- export declare class ValidationError extends Error {
30
- errors: ValidationErrorItem[];
31
- constructor(errors: ValidationErrorItem[]);
32
- }
33
- /**
34
- * 验证器类
35
- */
36
- export declare class Validator {
37
- /**
38
- * 验证单个值
39
- */
40
- static validateField(value: any, rules: ValidationRule, fieldName?: string): Promise<ValidationErrorItem[]>;
41
- /**
42
- * 验证对象
43
- */
44
- static validateObject(obj: Record<string, any>, rules: Record<string, ValidationRule>): Promise<ValidationErrorItem[]>;
45
- /**
46
- * 验证数组
47
- */
48
- static validateArray(arr: any[], rules: ValidationRule): Promise<ValidationErrorItem[]>;
49
- }
50
- /**
51
- * 表单验证器类
52
- */
53
- export declare class FormValidator {
54
- private rules;
55
- constructor(rules: Record<string, ValidationRule>);
56
- /**
57
- * 验证表单数据
58
- */
59
- validate(data: Record<string, any>): Promise<ValidationErrorItem[]>;
60
- /**
61
- * 验证并抛出错误
62
- */
63
- validateOrThrow(data: Record<string, any>): Promise<void>;
64
- }