@lytjs/renderer 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom.cjs +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/miniapp.cjs +22 -16
- package/dist/miniapp.mjs +22 -16
- package/dist/native.cjs +1 -1
- package/dist/native.mjs +1 -1
- package/dist/ssr.cjs +1 -1
- package/dist/ssr.mjs +1 -1
- package/dist/types/dom/dom-ops.d.ts.map +1 -1
- package/dist/types/dom/dom-renderer.d.ts.map +1 -1
- package/dist/types/dom/patch-events.d.ts.map +1 -1
- package/dist/types/dom/patch-props.d.ts.map +1 -1
- package/dist/types/miniapp/api-adapter.d.ts +514 -0
- package/dist/types/miniapp/api-adapter.d.ts.map +1 -0
- package/dist/types/miniapp/index.d.ts +15 -2
- package/dist/types/miniapp/index.d.ts.map +1 -1
- package/dist/types/miniapp/miniapp-compiler.d.ts.map +1 -1
- package/dist/types/miniapp/miniapp-event-bridge.d.ts.map +1 -1
- package/dist/types/miniapp/miniapp-lifecycle.d.ts +1 -1
- package/dist/types/miniapp/miniapp-lifecycle.d.ts.map +1 -1
- package/dist/types/miniapp/miniapp-renderer.d.ts.map +1 -1
- package/dist/types/miniapp/miniapp-utils.d.ts.map +1 -1
- package/dist/types/miniapp/style-compiler.d.ts +193 -0
- package/dist/types/miniapp/style-compiler.d.ts.map +1 -0
- package/dist/types/native/native-renderer.d.ts.map +1 -1
- package/dist/types/ssr/hydration.d.ts.map +1 -1
- package/dist/types/ssr/ssr-renderer.d.ts.map +1 -1
- package/dist/types/vapor/vapor-reactive.d.ts.map +1 -1
- package/dist/vapor.cjs +1 -1
- package/dist/vapor.mjs +1 -1
- package/package.json +4 -4
package/dist/miniapp.cjs
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var ue=(s,e)=>{for(var t in e)k(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of de(e))!fe.call(s,n)&&n!==t&&k(s,n,{get:()=>e[n],enumerable:!(r=le(e,n))||r.enumerable});return s};var ge=s=>me(k({},"__esModule",{value:!0}),s);var Pe={};ue(Pe,{Comment:()=>H,Fragment:()=>O,MiniAppCompiler:()=>$,MiniAppEventBridge:()=>P,MiniAppLifecycleAdapter:()=>S,MiniAppRenderer:()=>b,PatchFlags:()=>N,ShapeFlags:()=>g,Text:()=>V,camelToKebab:()=>m.camelToKebab,createRenderer:()=>Y,createWxsModule:()=>oe,escapeHtml:()=>se,generateComponentJson:()=>T,generatePageJson:()=>C,isNativeTag:()=>ae,kebabToCamel:()=>m.kebabToCamel,miniAppRenderer:()=>ne,normalizeProps:()=>L,parseClassObject:()=>ie,parseStyleObject:()=>re});module.exports=ge(Pe);var X=require("@lytjs/vdom");var g=(o=>(o[o.ELEMENT=1]="ELEMENT",o[o.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",o[o.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",o[o.TEXT_CHILDREN=8]="TEXT_CHILDREN",o[o.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",o[o.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",o))(g||{}),N=(d=>(d[d.TEXT=1]="TEXT",d[d.CLASS=2]="CLASS",d[d.STYLE=4]="STYLE",d[d.PROPS=8]="PROPS",d[d.FULL_PROPS=16]="FULL_PROPS",d[d.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",d[d.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",d[d.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",d[d.NEED_PATCH=256]="NEED_PATCH",d[d.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",d[d.HOISTED=-1]="HOISTED",d[d.BAIL=-2]="BAIL",d))(N||{}),O=Symbol("Fragment"),V=Symbol("Text"),H=Symbol("Comment");function h(s){return s.type===O}function _(s){return s.type===V}function x(s){return s.type===H}function z(s,e){return s.type===e.type&&s.key===e.key}function j(s){return Array.isArray(s.dynamicChildren)}function K(s,e,t,r){if(t==="class")s.setClass(e,r);else if(t==="style")s.setStyle(e,r);else if(t.startsWith("on")||t.startsWith("@")){let n=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();s.addEventListener(e,n,r)}else t==="key"||t==="ref"||s.setAttribute(e,t,r)}function D(s,e,t,r,n){if(t==="class")s.setClass(e,r);else if(t==="style")s.setStyle(e,r||{});else if(t.startsWith("on")||t.startsWith("@")){let i=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();n&&s.removeEventListener(e,i,n),r&&s.addEventListener(e,i,r)}else s.setAttribute(e,t,r)}function I(s,e,t,r){for(let n in r){if(n==="key"||n==="ref")continue;let i=t[n],o=r[n];o!==i&&D(s,e,n,o,i)}for(let n in t)if(!(n==="key"||n==="ref")&&!(n in r))if(n==="class")s.setClass(e,"");else if(n==="style")s.setStyle(e,{});else if(n.startsWith("on")||n.startsWith("@")){let i=n.startsWith("@")?n.slice(1).toLowerCase():n.slice(2).toLowerCase();s.removeEventListener(e,i,t[n])}else s.removeAttribute(e,n)}function B(s,e,t,r,n,i){let{shapeFlag:o}=t;if(h(t)){ye(s,e,t,r,n,i);return}if(_(t)){let a=s.createText(t.children);t.el=a,s.insert(r,a,n);return}if(x(t)){let a=s.createComment(t.children);t.el=a,s.insert(r,a,n);return}if(o&1){he(s,e,t,r,n,i);return}if(o&6){be(e,t,r,n,i);return}}function he(s,e,t,r,n,i){let o=t.type,a=s.createElement(o);if(t.el=a,t.props)for(let l in t.props){let f=t.props[l];K(s,a,l,f)}let{shapeFlag:c,children:p}=t;c&8?a.textContent=p:c&16&&w(e,p,a,null,i),s.insert(r,a,n)}function w(s,e,t,r,n){for(let i=0;i<e.length;i++)s(null,e[i],t,r,n)}function ye(s,e,t,r,n,i){let{children:o}=t,a=s.createComment("");s.insert(r,a,n),Array.isArray(o)&&o.length>0&&w(e,o,r,a,i),t.el=a,t.anchor=a}function be(s,e,t,r,n){let i=e.component;i&&i.update&&i.update(),i&&i.subTree&&(s(null,i.subTree,t,r,i),e.el=i.subTree.el)}function J(s,e,t,r){let{shapeFlag:n,children:i}=t;if(h(t)){if(Array.isArray(i))for(let o=0;o<i.length;o++)e(i[o],r);t.anchor&&t.anchor.parentNode&&s.remove(t.anchor);return}if(n&6){t.component&&t.component.subTree&&e(t.component.subTree,r);return}t.el&&s.remove(t.el)}function A(s,e){for(let t=0;t<e.length;t++)s(e[t])}var M=require("@lytjs/vdom");function E(s,e,t,r,n,i=null,o=null){if(r==null){t&&e(t,n);return}if(t===null){B(s,F(s,e),r,n,i,o);return}if(j(r)&&j(t)){xe(s,e,t,r,n,o);return}if(!z(t,r)){e(t,n),B(s,F(s,e),r,n,i,o);return}r.el=t.el,r.anchor=t.anchor;let{shapeFlag:a}=r;if(h(r)){_e(s,e,t,r,n,i,o);return}if(_(r)){r.children!==t.children&&(r.el.nodeValue=r.children);return}if(x(r)){r.children!==t.children&&(r.el.nodeValue=r.children);return}if(a&1){ve(s,e,t,r,o);return}if(a&6){we(t,r,o);return}}function F(s,e){return(t,r,n,i,o)=>{E(s,e,t,r,n,i,o)}}function ve(s,e,t,r,n=null){let i=r.el=t.el,o=t.props||{},a=r.props||{},{patchFlag:c,dynamicProps:p}=r;if(c&&c>0){if(c&1&&t.children!==r.children&&(i.textContent=r.children),c&2&&o.class!==a.class&&s.setClass(i,a.class),c&4&&o.style!==a.style&&s.setStyle(i,a.style||{}),c&8&&p)for(let l=0;l<p.length;l++){let f=p[l],d=o[f],v=a[f];v!==d&&D(s,i,f,v,d)}c&16&&I(s,i,o,a)}else I(s,i,o,a);(!c||!(c&1))&&W(s,e,t,r,i,null,n)}function W(s,e,t,r,n,i,o){let a=t.shapeFlag,c=r.shapeFlag,p=t.children,l=r.children;if(c&8){a&16&&A(e,p),p!==l&&(n.textContent=l);return}if(c&16){a&16?Ne(s,e,p,l,n,i,o):(a&8&&(n.textContent=""),w(F(s,e),l,n,i,o));return}l==null&&(a&8?n.textContent="":a&16&&A(e,p))}function Ne(s,e,t,r,n,i,o){r.every(c=>c.key!==null&&c.key!==void 0)&&t.every(c=>c.key!==null&&c.key!==void 0)?(0,M.patchKeyedChildren)(t,r,n,i,o,null,!1):(0,M.patchUnkeyedChildren)(t,r,n,i,o,null,!1)}function _e(s,e,t,r,n,i,o){let a=t.children,c=r.children;Array.isArray(c)&&c.length>0?(W(s,e,t,r,n,i,o),r.el=c[0].el,r.anchor=c[c.length-1].el?s.nextSibling(c[c.length-1].el):i):Array.isArray(a)&&a.length>0&&c===null?(A(e,a),r.el=t.el,r.anchor=t.anchor):(r.el=t.el,r.anchor=t.anchor)}function xe(s,e,t,r,n,i){let o=t.dynamicChildren,a=r.dynamicChildren;for(let c=0;c<a.length;c++)E(s,e,o[c],a[c],n,null,i)}function we(s,e,t){e.component=s.component,e.el=s.el,e.component&&e.component.update&&e.component.update()}function Y(s){function e(n,i){J(s,e,n,i)}(0,X.registerDOMOperations)({insert(n,i,o){s.insert(i,n,o)},createElement(n){return s.createElement(n)},createText(n){return s.createText(n)},setText(n,i){n.nodeValue=i},setElementText(n,i){n.textContent=i},remove(n){s.remove(n)},createComment(n){return s.createComment(n)},mount(n,i,o,a,c,p,l){r(null,n,i,o,a)},patch(n,i,o,a,c,p,l,f){r(n,i,o,a,c)},unmount(n,i,o,a){e(n)},move(n,i,o){s.insert(i,n.el,o)}});function r(n,i,o,a,c){E(s,e,n,i,o,a,c)}return{mount(n,i){i.nodeType===1&&(i.textContent=""),r(null,n,i,null,null)},patch(n,i,o){var a;r(n,i,o||((a=n.el)==null?void 0:a.parentNode),null,null)},unmount(n,i){e(n,i)}}}var R={div:"view",span:"text",p:"text",h1:"text",h2:"text",h3:"text",h4:"text",h5:"text",h6:"text",img:"image",input:"input",textarea:"textarea",button:"button",scroll:"scroll-view",list:"view",a:"navigator",ul:"view",ol:"view",li:"view",form:"form",header:"view",footer:"view",nav:"view",main:"view",section:"view",article:"view",aside:"view"},u={click:"tap",input:"input",change:"change",submit:"submit",focus:"focus",blur:"blur",touchstart:"touchstart",touchend:"touchend",touchmove:"touchmove",scroll:"scroll",longpress:"longpress"};function G(s,e,t){if(!(!s||!e)){if(e._parent){let r=e._parent,n=r.children.indexOf(e);n!==-1&&r.children.splice(n,1)}if(e._parent=s,t){let r=s.children.indexOf(t);r!==-1?s.children.splice(r,0,e):s.children.push(e)}else s.children.push(e)}}function Z(s){if(!s||!s._parent)return;let e=s._parent,t=e.children.indexOf(s);t!==-1&&e.children.splice(t,1),s._parent=void 0}function q(s,e,t){if(!s||!e||!t)return;let r=s.children.indexOf(e);r!==-1&&(e._parent=void 0,t._parent=s,s.children[r]=t)}function Q(s){var e;return(e=s==null?void 0:s._parent)!=null?e:null}function ee(s){if(!s||!s._parent)return null;let e=s._parent.children,t=e.indexOf(s);return t!==-1&&t+1<e.length?e[t+1]:null}function te(s){Promise.resolve().then(()=>s())}var Ae={if:{attr:"if"},else:{attr:"else"},each:{attr:"for",prefix:""},bind:{attr:"model:"},on:{attr:"bind",prefix:""},ref:{attr:""},slot:{attr:"slot"},class:{attr:"class"},style:{attr:"style"},show:{attr:"hidden"}},y={wechat:{if:"wx:if",else:"wx:else",for:"wx:for",forKey:"wx:key",bind:"bind",catch:"catch"},alipay:{if:"a:if",else:"a:else",for:"a:for",forKey:"a:key",bind:"on",catch:"catchEvent"},bytedance:{if:"tt:if",else:"tt:else",for:"tt:for",forKey:"tt:key",bind:"bind",catch:"catch"}},b=class{createElement(e){return{tag:R[e]||e,attrs:{},children:[],bindEvents:{},modelBindings:{}}}createText(e){return{tag:"__text__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}createComment(e){return{tag:"__comment__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}setAttribute(e,t,r){if(e){if(t.startsWith("lyt:")){let n=t.slice(4);this._applyDirective(e,n,r);return}if(t==="v-if"||t==="if"){e.wxIf=String(r);return}if(t==="v-else"||t==="else"){e.attrs["wx:else"]="";return}if(t==="v-for"||t==="each"){let n=String(r),i=n.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);i?(e.wxFor=i[4]||i[3],e.wxForKey=i[1]||i[3]):e.wxFor=n;return}if(t.startsWith("on")&&typeof r=="function"){let n=t.slice(2).toLowerCase(),i=u[n]||n;e.bindEvents[i]=r.name||"handleEvent";return}if(t==="v-model"||t==="model"){e.modelBindings.value=String(r);return}if(t==="class"||t==="className"){e.attrs.class=String(r);return}if(t==="style"){typeof r=="object"&&r!==null?e.attrs.style=this._styleObjectToString(r):e.attrs.style=String(r);return}if(t==="href"&&e.tag==="navigator"){e.attrs.url=String(r);return}e.attrs[t]=String(r)}}removeAttribute(e,t){if(e)if(t==="v-if"||t==="if")delete e.wxIf;else if(t==="v-for"||t==="each")delete e.wxFor,delete e.wxForKey;else if(t.startsWith("on")){let r=t.slice(2).toLowerCase(),n=u[r]||r;delete e.bindEvents[n]}else delete e.attrs[t]}setStyle(e,t){if(!e)return;let r=this._styleObjectToString(t);e.attrs.style=r}setClass(e,t){if(e){if(typeof t=="string")e.attrs.class=t;else if(typeof t=="object"&&t!==null){let r=[];for(let[n,i]of Object.entries(t))i&&r.push(n);e.attrs.class=r.join(" ")}}}insert(e,t,r){G(e,t,r)}remove(e){Z(e)}replace(e,t,r){q(e,t,r)}addEventListener(e,t,r,n){if(!e)return;let i=u[t]||t;e.bindEvents[i]=r.name||"handleEvent"}removeEventListener(e,t,r){if(!e)return;let n=u[t]||t;delete e.bindEvents[n]}nextTick(e){te(e)}parentNode(e){return Q(e)}nextSibling(e){return ee(e)}setText(e,t){e&&e.tag==="__text__"&&(e.text=t)}patchProp(e,t,r,n){if(e){if(n==null){this.removeAttribute(e,t);return}if(t==="style")this.setStyle(e,n);else if(t==="class"||t==="className")this.setClass(e,n);else if(t.startsWith("on")&&typeof n=="function"){let i=t.slice(2).toLowerCase(),o=u[i]||i;e.bindEvents[o]=n.name||"handleEvent"}else this.setAttribute(e,t,n)}}querySelector(e){return null}renderToMiniAppTree(e){if(!e)return this.createComment("empty vnode");if(typeof e=="string")return this.createText(e);if(e.type===Symbol.for("lyt.comment")||e.type==="comment")return this.createComment(e.children||"");if(e.type===Symbol.for("lyt.text")||e.type==="text")return this.createText(e.children||"");if(e.type===Symbol.for("lyt.fragment")||e.type==="fragment"){let t=this.createElement("__fragment__");if(Array.isArray(e.children))for(let r of e.children)this.insert(t,this.renderToMiniAppTree(r));return t}if(typeof e.type=="string"){let t=this.createElement(e.type);if(e.props)for(let[r,n]of Object.entries(e.props))r==="key"||r==="ref"||this.setAttribute(t,r,n);if(e.children){if(typeof e.children=="string")this.insert(t,this.createText(e.children));else if(Array.isArray(e.children))for(let r of e.children)this.insert(t,this.renderToMiniAppTree(r))}return t}if(typeof e.type=="object"||typeof e.type=="function"){let t=this.createElement("div");if(Array.isArray(e.children))for(let r of e.children)this.insert(t,this.renderToMiniAppTree(r));return t}return this.createComment("unknown vnode type")}serializeToWXML(e,t=0){return this._serializeToTemplate(e,t,"wechat")}serializeToAXML(e,t=0){return this._serializeToTemplate(e,t,"alipay")}serializeToTTML(e,t=0){return this._serializeToTemplate(e,t,"bytedance")}getPlatformTemplate(e,t){return this._serializeToTemplate(e,0,t)}mapDirective(e,t,r="wechat"){let n=y[r]||y.wechat,i=Ae[e];if(!i)return"";switch(e){case"if":return`${n.if}="{{${t}}}"`;case"else":return`${n.else}`;case"each":{let o=t.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);if(o){let a=o[1]||o[3],c=o[4]||o[3];return`${n.for}="{{${c}}}" ${n.forKey}="{{${a}}}"`}return`${n.for}="{{${t}}}"`}case"show":return`hidden="{{!${t}}}"`;default:return`${i.attr}="${t}"`}}mapEvent(e,t="wechat"){let r=y[t]||y.wechat,n=u[e]||e;return r.bind==="on"?`on${n.charAt(0).toUpperCase()}${n.slice(1)}`:`${r.bind}${n}`}_applyDirective(e,t,r){switch(t){case"if":e.wxIf=String(r);break;case"else":e.attrs["wx:else"]="";break;case"each":{let n=String(r),i=n.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);i?(e.wxFor=i[4]||i[3],e.wxForKey=i[1]||i[3]):e.wxFor=n;break}case"show":e.attrs.hidden=String(r);break;default:e.attrs[t]=String(r)}}_styleObjectToString(e){return Object.entries(e).map(([t,r])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${r}`).join("; ")}_serializeToTemplate(e,t,r){let n=" ".repeat(t),i=y[r]||y.wechat;if(e.tag==="__text__")return`${n}${e.text||""}`;if(e.tag==="__comment__")return`${n}<!-- ${e.text||""} -->`;if(e.tag==="__fragment__")return e.children.map(l=>this._serializeToTemplate(l,t,r)).join(`
|
|
2
|
-
`);let
|
|
3
|
-
`);return`${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
1
|
+
"use strict";var D=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var Se=(s,e)=>{for(var t in e)D(s,t,{get:e[t],enumerable:!0})},Me=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ae(e))!Te.call(s,r)&&r!==t&&D(s,r,{get:()=>e[r],enumerable:!(n=Re(e,r))||n.enumerable});return s};var Ne=s=>Me(D({},"__esModule",{value:!0}),s);var We={};Se(We,{Comment:()=>B,Fragment:()=>F,GlobalStateManager:()=>R,MiniAppApiAdapter:()=>v,MiniAppCompiler:()=>O,MiniAppEventBridge:()=>I,MiniAppLifecycleAdapter:()=>V,MiniAppRenderer:()=>w,MiniAppStyleCompiler:()=>x,PatchFlags:()=>A,ShapeFlags:()=>h,Text:()=>H,camelToKebab:()=>m.camelToKebab,compileMiniAppStyle:()=>ye,createApiAdapter:()=>ve,createGlobalState:()=>xe,createMiniAppRenderer:()=>pe,createRenderer:()=>re,createWxsModule:()=>ge,escapeHtml:()=>me,generateComponentJson:()=>L,generatePageJson:()=>P,getApiAdapter:()=>_e,isNativeTag:()=>he,kebabToCamel:()=>m.kebabToCamel,miniAppRenderer:()=>de,miniAppStyleCompiler:()=>W,normalizeProps:()=>$,parseClassObject:()=>fe,parseStyleObject:()=>ue});module.exports=Ne(We);var ne=require("@lytjs/vdom");var h=(i=>(i[i.ELEMENT=1]="ELEMENT",i[i.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",i[i.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",i[i.TEXT_CHILDREN=8]="TEXT_CHILDREN",i[i.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",i[i.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",i))(h||{}),A=(d=>(d[d.TEXT=1]="TEXT",d[d.CLASS=2]="CLASS",d[d.STYLE=4]="STYLE",d[d.PROPS=8]="PROPS",d[d.FULL_PROPS=16]="FULL_PROPS",d[d.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",d[d.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",d[d.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",d[d.NEED_PATCH=256]="NEED_PATCH",d[d.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",d[d.HOISTED=-1]="HOISTED",d[d.BAIL=-2]="BAIL",d))(A||{}),F=Symbol("Fragment"),H=Symbol("Text"),B=Symbol("Comment");function y(s){return s.type===F}function T(s){return s.type===H}function S(s){return s.type===B}function Z(s,e){return s.type===e.type&&s.key===e.key}function U(s){return Array.isArray(s.dynamicChildren)}function Q(s,e,t,n){if(t==="class")s.setClass(e,n);else if(t==="style")s.setStyle(e,n);else if(t.startsWith("on")||t.startsWith("@")){let r=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();s.addEventListener(e,r,n)}else t==="key"||t==="ref"||s.setAttribute(e,t,n)}function z(s,e,t,n,r){if(t==="class")s.setClass(e,n);else if(t==="style")s.setStyle(e,n||{});else if(t.startsWith("on")||t.startsWith("@")){let o=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();r&&s.removeEventListener(e,o,r),n&&s.addEventListener(e,o,n)}else s.setAttribute(e,t,n)}function K(s,e,t,n){for(let r in n){if(r==="key"||r==="ref")continue;let o=t[r],i=n[r];i!==o&&z(s,e,r,i,o)}for(let r in t)if(!(r==="key"||r==="ref")&&!(r in n))if(r==="class")s.setClass(e,"");else if(r==="style")s.setStyle(e,{});else if(r.startsWith("on")||r.startsWith("@")){let o=r.startsWith("@")?r.slice(1).toLowerCase():r.slice(2).toLowerCase();s.removeEventListener(e,o,t[r])}else s.removeAttribute(e,r)}function G(s,e,t,n,r,o){let{shapeFlag:i}=t;if(y(t)){Ce(s,e,t,n,r,o);return}if(T(t)){let a=s.createText(t.children);t.el=a,s.insert(n,a,r);return}if(S(t)){let a=s.createComment(t.children);t.el=a,s.insert(n,a,r);return}if(i&1){ke(s,e,t,n,r,o);return}if(i&6){Ee(e,t,n,r,o);return}}function ke(s,e,t,n,r,o){let i=t.type,a=s.createElement(i);if(t.el=a,t.props)for(let p in t.props){let u=t.props[p];Q(s,a,p,u)}let{shapeFlag:c,children:l}=t;c&8?a.textContent=l:c&16&&M(e,l,a,null,o),s.insert(n,a,r)}function M(s,e,t,n,r){for(let o=0;o<e.length;o++)s(null,e[o],t,n,r)}function Ce(s,e,t,n,r,o){let{children:i}=t,a=s.createComment("");s.insert(n,a,r),Array.isArray(i)&&i.length>0&&M(e,i,n,a,o),t.el=a,t.anchor=a}function Ee(s,e,t,n,r){let o=e.component;o&&o.update&&o.update(),o&&o.subTree&&(s(null,o.subTree,t,n,o),e.el=o.subTree.el)}function ee(s,e,t,n){let{shapeFlag:r,children:o}=t;if(y(t)){if(Array.isArray(o))for(let i=0;i<o.length;i++)e(o[i],n);t.anchor&&t.anchor.parentNode&&s.remove(t.anchor);return}if(r&6){t.component&&t.component.subTree&&e(t.component.subTree,n);return}t.el&&s.remove(t.el)}function N(s,e){for(let t=0;t<e.length;t++)s(e[t])}var k=require("@lytjs/vdom");function C(s,e,t,n,r,o=null,i=null){if(n==null){t&&e(t,r);return}if(t===null){G(s,J(s,e),n,r,o,i);return}if(U(n)&&U(t)){Oe(s,e,t,n,r,i);return}if(!Z(t,n)){e(t,r),G(s,J(s,e),n,r,o,i);return}n.el=t.el,n.anchor=t.anchor;let{shapeFlag:a}=n;if(y(n)){$e(s,e,t,n,r,o,i);return}if(T(n)){n.children!==t.children&&(n.el.nodeValue=n.children);return}if(S(n)){n.children!==t.children&&(n.el.nodeValue=n.children);return}if(a&1){Pe(s,e,t,n,i);return}if(a&6){Ie(t,n,i);return}}function J(s,e){return(t,n,r,o,i)=>{C(s,e,t,n,r,o,i)}}function Pe(s,e,t,n,r=null){let o=n.el=t.el,i=t.props||{},a=n.props||{},{patchFlag:c,dynamicProps:l}=n;if(c&&c>0){if(c&1&&t.children!==n.children&&(o.textContent=n.children),c&2&&i.class!==a.class&&s.setClass(o,a.class),c&4&&i.style!==a.style&&s.setStyle(o,a.style||{}),c&8&&l)for(let p=0;p<l.length;p++){let u=l[p],d=i[u],f=a[u];f!==d&&z(s,o,u,f,d)}c&16&&K(s,o,i,a)}else K(s,o,i,a);(!c||!(c&1))&&te(s,e,t,n,o,null,r)}function te(s,e,t,n,r,o,i){let a=t.shapeFlag,c=n.shapeFlag,l=t.children,p=n.children;if(c&8){a&16&&N(e,l),l!==p&&(r.textContent=p);return}if(c&16){a&16?Le(s,e,l,p,r,o,i):(a&8&&(r.textContent=""),M(J(s,e),p,r,o,i));return}p==null&&(a&8?r.textContent="":a&16&&N(e,l))}function Le(s,e,t,n,r,o,i){n.every(c=>c.key!==null&&c.key!==void 0)&&t.every(c=>c.key!==null&&c.key!==void 0)?(0,k.patchKeyedChildren)(t,n,r,o,i,null,!1):(0,k.patchUnkeyedChildren)(t,n,r,o,i,null,!1)}function $e(s,e,t,n,r,o,i){let a=t.children,c=n.children;Array.isArray(c)&&c.length>0?(te(s,e,t,n,r,o,i),n.el=c[0].el,n.anchor=c[c.length-1].el?s.nextSibling(c[c.length-1].el):o):Array.isArray(a)&&a.length>0&&c===null?(N(e,a),n.el=t.el,n.anchor=t.anchor):(n.el=t.el,n.anchor=t.anchor)}function Oe(s,e,t,n,r,o){let i=t.dynamicChildren,a=n.dynamicChildren;for(let c=0;c<a.length;c++)C(s,e,i[c],a[c],r,null,o)}function Ie(s,e,t){e.component=s.component,e.el=s.el,e.component&&e.component.update&&e.component.update()}function re(s){function e(r,o){ee(s,e,r,o)}(0,ne.registerDOMOperations)({insert(r,o,i){s.insert(o,r,i)},createElement(r){return s.createElement(r)},createText(r){return s.createText(r)},setText(r,o){r.nodeValue=o},setElementText(r,o){r.textContent=o},remove(r){s.remove(r)},createComment(r){return s.createComment(r)},mount(r,o,i,a,c,l,p){n(null,r,o,i,a)},patch(r,o,i,a,c,l,p,u){n(r,o,i,a,c)},unmount(r,o,i,a){e(r)},move(r,o,i){s.insert(o,r.el,i)}});function n(r,o,i,a,c){C(s,e,r,o,i,a,c)}return{mount(r,o){o.nodeType===1&&(o.textContent=""),n(null,r,o,null,null)},patch(r,o,i){var a;n(r,o,i||((a=r.el)==null?void 0:a.parentNode),null,null)},unmount(r,o){e(r,o)}}}var E={div:"view",span:"text",p:"text",h1:"text",h2:"text",h3:"text",h4:"text",h5:"text",h6:"text",img:"image",input:"input",textarea:"textarea",button:"button",scroll:"scroll-view",list:"view",a:"navigator",ul:"view",ol:"view",li:"view",form:"form",header:"view",footer:"view",nav:"view",main:"view",section:"view",article:"view",aside:"view"},g={click:"tap",input:"input",change:"change",submit:"submit",focus:"focus",blur:"blur",touchstart:"touchstart",touchend:"touchend",touchmove:"touchmove",scroll:"scroll",longpress:"longpress"};function oe(s,e,t){if(!(!s||!e)){if(e._parent){let n=e._parent,r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)}if(e._parent=s,t){let n=s.children.indexOf(t);n!==-1?s.children.splice(n,0,e):s.children.push(e)}else s.children.push(e)}}function ie(s){if(!s||!s._parent)return;let e=s._parent,t=e.children.indexOf(s);t!==-1&&e.children.splice(t,1),s._parent=void 0}function se(s,e,t){if(!s||!e||!t)return;let n=s.children.indexOf(e);n!==-1&&(e._parent=void 0,t._parent=s,s.children[n]=t)}function ae(s){var e;return(e=s==null?void 0:s._parent)!=null?e:null}function ce(s){if(!s||!s._parent)return null;let e=s._parent.children,t=e.indexOf(s);return t!==-1&&t+1<e.length?e[t+1]:null}function le(s){Promise.resolve().then(()=>s())}var Ve={if:{attr:"if"},else:{attr:"else"},each:{attr:"for",prefix:""},bind:{attr:"model:"},on:{attr:"bind",prefix:""},ref:{attr:""},slot:{attr:"slot"},class:{attr:"class"},style:{attr:"style"},show:{attr:"hidden"}},b={wechat:{if:"wx:if",else:"wx:else",for:"wx:for",forKey:"wx:key",bind:"bind",catch:"catch"},alipay:{if:"a:if",else:"a:else",for:"a:for",forKey:"a:key",bind:"on",catch:"catchEvent"},bytedance:{if:"tt:if",else:"tt:else",for:"tt:for",forKey:"tt:key",bind:"bind",catch:"catch"}},w=class{createElement(e){return{tag:E[e]||e,attrs:{},children:[],bindEvents:{},modelBindings:{}}}createText(e){return{tag:"__text__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}createComment(e){return{tag:"__comment__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}setAttribute(e,t,n){if(e){if(t.startsWith("lyt:")){let r=t.slice(4);this._applyDirective(e,r,n);return}if(t==="v-if"||t==="if"){e.wxIf=String(n);return}if(t==="v-else"||t==="else"){e.attrs["wx:else"]="";return}if(t==="v-for"||t==="each"){let r=String(n),o=r.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);o?(e.wxFor=o[4]||o[3],e.wxForKey=o[1]||o[3]):e.wxFor=r;return}if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),o=g[r]||r;e.bindEvents[o]=n.name||"handleEvent";return}if(t==="v-model"||t==="model"){e.modelBindings.value=String(n);return}if(t==="class"||t==="className"){e.attrs.class=String(n);return}if(t==="style"){typeof n=="object"&&n!==null?e.attrs.style=this._styleObjectToString(n):e.attrs.style=String(n);return}if(t==="href"&&e.tag==="navigator"){e.attrs.url=String(n);return}e.attrs[t]=String(n)}}removeAttribute(e,t){if(e)if(t==="v-if"||t==="if")delete e.wxIf;else if(t==="v-for"||t==="each")delete e.wxFor,delete e.wxForKey;else if(t.startsWith("on")){let n=t.slice(2).toLowerCase(),r=g[n]||n;delete e.bindEvents[r]}else delete e.attrs[t]}setStyle(e,t){if(!e)return;let n=this._styleObjectToString(t);e.attrs.style=n}setClass(e,t){if(e){if(typeof t=="string")e.attrs.class=t;else if(typeof t=="object"&&t!==null){let n=[];for(let[r,o]of Object.entries(t))o&&n.push(r);e.attrs.class=n.join(" ")}}}insert(e,t,n){oe(e,t,n)}remove(e){ie(e)}replace(e,t,n){se(e,t,n)}addEventListener(e,t,n,r){if(!e)return;let o=g[t]||t;e.bindEvents[o]=n.name||"handleEvent"}removeEventListener(e,t,n){if(!e)return;let r=g[t]||t;delete e.bindEvents[r]}nextTick(e){le(e)}parentNode(e){return ae(e)}nextSibling(e){return ce(e)}setText(e,t){e&&e.tag==="__text__"&&(e.text=t)}patchProp(e,t,n,r){if(e){if(r==null){this.removeAttribute(e,t);return}if(t==="style")this.setStyle(e,r);else if(t==="class"||t==="className")this.setClass(e,r);else if(t.startsWith("on")&&typeof r=="function"){let o=t.slice(2).toLowerCase(),i=g[o]||o;e.bindEvents[i]=r.name||"handleEvent"}else this.setAttribute(e,t,r)}}querySelector(e){return null}renderToMiniAppTree(e){if(!e)return this.createComment("empty vnode");if(typeof e=="string")return this.createText(e);if(e.type===Symbol.for("lyt.comment")||e.type==="comment")return this.createComment(e.children||"");if(e.type===Symbol.for("lyt.text")||e.type==="text")return this.createText(e.children||"");if(e.type===Symbol.for("lyt.fragment")||e.type==="fragment"){let t=this.createElement("__fragment__");if(Array.isArray(e.children))for(let n of e.children)this.insert(t,this.renderToMiniAppTree(n));return t}if(typeof e.type=="string"){let t=this.createElement(e.type);if(e.props)for(let[n,r]of Object.entries(e.props))n==="key"||n==="ref"||this.setAttribute(t,n,r);if(e.children){if(typeof e.children=="string")this.insert(t,this.createText(e.children));else if(Array.isArray(e.children))for(let n of e.children)this.insert(t,this.renderToMiniAppTree(n))}return t}if(typeof e.type=="object"||typeof e.type=="function"){let t=this.createElement("div");if(Array.isArray(e.children))for(let n of e.children)this.insert(t,this.renderToMiniAppTree(n));return t}return this.createComment("unknown vnode type")}serializeToWXML(e,t=0){return this._serializeToTemplate(e,t,"wechat")}serializeToAXML(e,t=0){return this._serializeToTemplate(e,t,"alipay")}serializeToTTML(e,t=0){return this._serializeToTemplate(e,t,"bytedance")}getPlatformTemplate(e,t){return this._serializeToTemplate(e,0,t)}mapDirective(e,t,n="wechat"){let r=b[n]||b.wechat,o=Ve[e];if(!o)return"";switch(e){case"if":return`${r.if}="{{${t}}}"`;case"else":return`${r.else}`;case"each":{let i=t.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);if(i){let a=i[1]||i[3],c=i[4]||i[3];return`${r.for}="{{${c}}}" ${r.forKey}="{{${a}}}"`}return`${r.for}="{{${t}}}"`}case"show":return`hidden="{{!${t}}}"`;default:return`${o.attr}="${t}"`}}mapEvent(e,t="wechat"){let n=b[t]||b.wechat,r=g[e]||e;return n.bind==="on"?`on${r.charAt(0).toUpperCase()}${r.slice(1)}`:`${n.bind}${r}`}_applyDirective(e,t,n){switch(t){case"if":e.wxIf=String(n);break;case"else":e.attrs["wx:else"]="";break;case"each":{let r=String(n),o=r.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);o?(e.wxFor=o[4]||o[3],e.wxForKey=o[1]||o[3]):e.wxFor=r;break}case"show":e.attrs.hidden=String(n);break;default:e.attrs[t]=String(n)}}_styleObjectToString(e){return Object.entries(e).map(([t,n])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${n}`).join("; ")}_serializeToTemplate(e,t,n){let r=" ".repeat(t),o=b[n]||b.wechat;if(e.tag==="__text__")return`${r}${e.text||""}`;if(e.tag==="__comment__")return`${r}<!-- ${e.text||""} -->`;if(e.tag==="__fragment__")return e.children.map(p=>this._serializeToTemplate(p,t,n)).join(`
|
|
2
|
+
`);let i=[];for(let[p,u]of Object.entries(e.attrs)){if(p==="wx:else"){i.push(o.else);continue}i.push(`${p}="${u}"`)}e.wxIf&&i.unshift(`${o.if}="{{${e.wxIf}}}"`),e.wxFor&&(i.unshift(`${o.for}="{{${e.wxFor}}}"`),e.wxForKey&&i.unshift(`${o.forKey}="{{${e.wxForKey}}}"`));for(let[p,u]of Object.entries(e.bindEvents)){let d=o.bind==="on"?`on${p.charAt(0).toUpperCase()}${p.slice(1)}`:`${o.bind}${p}`;i.push(`${d}="${u}"`)}for(let[p,u]of Object.entries(e.modelBindings))i.push(`model:${p}="{{${u}}}"`);let a=i.length>0?" "+i.join(" "):"",c=new Set(["image","input"]);if(e.children.length===0&&c.has(e.tag))return`${r}<${e.tag}${a} />`;if(e.children.length===0)return`${r}<${e.tag}${a}></${e.tag}>`;let l=e.children.map(p=>this._serializeToTemplate(p,t+1,n)).join(`
|
|
3
|
+
`);return`${r}<${e.tag}${a}>
|
|
4
|
+
${l}
|
|
5
|
+
${r}</${e.tag}>`}};function pe(){return new w}var de=new w;var m=require("@lytjs/common");function ue(s){return Object.entries(s).map(([e,t])=>`${(0,m.camelToKebab)(e)}: ${t}`).join("; ")}function fe(s){return typeof s=="string"?s:typeof s=="object"&&s!==null?Object.entries(s).filter(([,e])=>!!e).map(([e])=>e).join(" "):""}function P(s){let e={};return s.navigationBarTitleText!==void 0&&(e.navigationBarTitleText=s.navigationBarTitleText),s.enablePullDownRefresh!==void 0&&(e.enablePullDownRefresh=s.enablePullDownRefresh),s.backgroundColor!==void 0&&(e.backgroundColor=s.backgroundColor),s.backgroundTextStyle!==void 0&&(e.backgroundTextStyle=s.backgroundTextStyle),s.navigationBarBackgroundColor!==void 0&&(e.navigationBarBackgroundColor=s.navigationBarBackgroundColor),s.navigationBarTextStyle!==void 0&&(e.navigationBarTextStyle=s.navigationBarTextStyle),s.usingComponents&&Object.keys(s.usingComponents).length>0&&(e.usingComponents=s.usingComponents),JSON.stringify(e,null,2)}function L(s){let e={component:s.component!==!1};return s.usingComponents&&Object.keys(s.usingComponents).length>0&&(e.usingComponents=s.usingComponents),JSON.stringify(e,null,2)}function $(s){let e={},t=[];for(let[n,r]of Object.entries(s))if(typeof r=="function")e[n]={type:r.name};else if(typeof r=="object"&&r!==null){let o={};if(r.type!==void 0&&(o.type=r.type),r.default!==void 0&&(o.value=r.default),r.value!==void 0&&(o.value=r.value),r.optional!==void 0&&(o.optionalTypes=r.optional),e[n]=o,r.observer){let i=typeof r.observer=="string"?r.observer:`_${n}Observer`;t.push(`${n}: function(${n}) { this.${i}(${n}); }`)}}else e[n]={type:String,value:r};return{properties:e,observers:t}}function ge(s){let e=[],t=/function\s+(\w+)\s*\(/g,n;for(;(n=t.exec(s))!==null;)e.push(n[1]);let r=[],o=/(?:const|let|var)\s+(\w+)\s*=/g;for(;(n=o.exec(s))!==null;)r.push(n[1]);let i=[];for(let c of e)i.push(` ${c}: ${c}`);for(let c of r)i.push(` ${c}: ${c}`);return`${i.length>0?`module.exports = {
|
|
6
|
+
${i.join(`,
|
|
7
7
|
`)}
|
|
8
8
|
};`:"module.exports = {};"}
|
|
9
9
|
|
|
10
10
|
// Original code:
|
|
11
|
-
${s}`}var
|
|
11
|
+
${s}`}var je={"&":"&","<":"<",">":">",'"':""","'":"'"},De=/[&<>"']/g;function me(s){return s.replace(De,e=>je[e]||e)}var Fe=new Set(["view","scroll-view","swiper","swiper-item","movable-view","movable-area","cover-view","cover-image","text","rich-text","progress","button","form","input","textarea","checkbox","checkbox-group","radio","radio-group","switch","slider","picker","picker-view","picker-view-column","navigator","audio","image","video","camera","live-player","live-pusher","map","canvas","ad","official-account","open-data","web-view","page-container","aria-component"]);function he(s){return Fe.has(s.toLowerCase())}var He={wechat:{if:"wx:if",elif:"wx:elif",else:"wx:else",for:"wx:for",forItem:"wx:for-item",forIndex:"wx:for-index",forKey:"wx:key",bind:"bind",catch:"catch",model:"model",slot:"slot"},alipay:{if:"a:if",elif:"a:elif",else:"a:else",for:"a:for",forItem:"a:for-item",forIndex:"a:for-index",forKey:"a:key",bind:"on",catch:"catchEvent",model:"model",slot:"slot"},bytedance:{if:"tt:if",elif:"tt:elif",else:"tt:else",for:"tt:for",forItem:"tt:for-item",forIndex:"tt:for-index",forKey:"tt:key",bind:"bind",catch:"catch",model:"model",slot:"slot"}},Be={click:"tap",dblclick:"tap",input:"input",change:"change",submit:"submit",focus:"focus",blur:"blur",touchstart:"touchstart",touchend:"touchend",touchmove:"touchmove",scroll:"scroll",longpress:"longpress",keydown:"confirm",keyup:"confirm",keypress:"confirm"},O=class{compile(e,t){let{template:n,style:r,script:o}=this._extractTags(e),i=this._extractData(o);return{template:this._transformTemplate(n,t),style:r,script:o,data:i}}compilePage(e,t){let n=this.compile(e.template,t),r={...n.data,...e.data||{}},o={...e.methods||{}},i=this._generatePageJs(r,o,e,t),a=P({});return{wxml:n.template,wxss:n.style,js:i,json:a}}compileComponent(e,t){let n=this.compile(e.template,t),r={...n.data,...e.data||{}},o={...e.methods||{}},i={},a=[];if(e.props)if(Array.isArray(e.props))for(let p of e.props)i[p]={type:null};else{let p=$(e.props);i=p.properties,a=p.observers}let c=this._generateComponentJs(i,r,o,a,t),l=L({component:!0});return{wxml:n.template,wxss:n.style,js:c,json:l}}_transformTemplate(e,t){let n=He[t],r=e;return r=this._transformTags(r),r=this._transformConditional(r,n),r=this._transformIteration(r,n),r=this._transformEvents(r,t,n),r=this._transformModelBindings(r,n),r=this._transformSlots(r,n),r=this._transformRefs(r),r=this._transformShow(r),r=this._transformAttributeBindings(r),r=this._cleanupLytDirectives(r),r}_transformTags(e){let t=/<\/?([a-zA-Z][a-zA-Z0-9-]*)/g;return e.replace(t,(n,r)=>{let o=r.toLowerCase(),i=E[o];return i?n.replace(r,i):n})}_transformConditional(e,t){let n=e.replace(/lyt:if="([^"]*)"/g,(r,o)=>`${t.if}="{{${o}}}"`);return n=n.replace(/v-if="([^"]*)"/g,(r,o)=>`${t.if}="{{${o}}}"`),n=n.replace(/lyt:elif="([^"]*)"/g,(r,o)=>`${t.elif}="{{${o}}}"`),n=n.replace(/v-else-if="([^"]*)"/g,(r,o)=>`${t.elif}="{{${o}}}"`),n=n.replace(/\blyt:else\b/g,t.else),n=n.replace(/\bv-else\b/g,t.else),n}_transformIteration(e,t){let n=o=>{let i=o.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);if(i){let a=i[1]||i[3],c=i[2],l=i[4].trim(),p=`${t.for}="{{${l}}}" ${t.forItem}="${a}" ${t.forKey}="${a}"`;return c&&(p+=` ${t.forIndex}="${c}"`),p}return`${t.for}="{{${o.trim()}}}"`},r=e.replace(/lyt:each="([^"]*)"/g,(o,i)=>n(i));return r=r.replace(/v-for="([^"]*)"/g,(o,i)=>n(i)),r}_transformEvents(e,t,n){let r=/@(\w+)(?:\.(\w+))*="([^"]*)"/g;return e.replace(r,(o,i,a,c)=>{let l=Be[i.toLowerCase()]||i.toLowerCase();return a==="stop"||a==="prevent"?t==="alipay"?`catchEvent${this._capitalize(l)}="${c}"`:`${n.catch}${l}="${c}"`:a==="capture"?`capture-bind:${l}="${c}"`:t==="alipay"?`on${this._capitalize(l)}="${c}"`:`${n.bind}${l}="${c}"`})}_transformModelBindings(e,t){let n=e.replace(/:value="([^"]*)"/g,(r,o)=>`${t.model}:value="{{${o}}}"`);return n=n.replace(/v-model="([^"]*)"/g,(r,o)=>`${t.model}:value="{{${o}}}"`),n=n.replace(/:checked="([^"]*)"/g,(r,o)=>`${t.model}:checked="{{${o}}}"`),n}_transformSlots(e,t){return e}_transformRefs(e){return e.replace(/\bref="([^"]*)"/g,'id="$1"')}_transformShow(e){let t=e.replace(/lyt:show="([^"]*)"/g,(n,r)=>`hidden="{{!${r}}}"`);return t=t.replace(/v-show="([^"]*)"/g,(n,r)=>`hidden="{{!${r}}}"`),t}_transformAttributeBindings(e){let t=/:([a-zA-Z][a-zA-Z0-9-]*)="([^"]*)"/g;return e.replace(t,(n,r,o)=>r==="value"||r==="checked"?n:`${r}="{{${o}}}"`)}_cleanupLytDirectives(e){return e.replace(/\s*lyt:[a-zA-Z-]+(?:="[^"]*")?/g,"")}_extractTags(e){let t=e,n="",r="",o=e.match(/<style[^>]*>([\s\S]*?)<\/style>/i);o&&(n=o[1].trim(),t=t.replace(o[0],""));let i=e.match(/<script[^>]*>([\s\S]*?)<\/script>/i);return i&&(r=i[1].trim(),t=t.replace(i[0],"")),t=t.trim(),{template:t,style:n,script:r}}_extractData(e){let t={};if(!e)return t;let n=e.match(/data\s*:\s*(\{[\s\S]*?\})(?:\s*[,}])/);if(n)try{let o=n[1];this._parseSimpleObject(o,t)}catch(o){}let r=e.match(/data\s*\(\s*\)\s*\{[\s\S]*?return\s*(\{[\s\S]*?\})\s*;?\s*\}/);if(r)try{let o=r[1];this._parseSimpleObject(o,t)}catch(o){}return t}_parseSimpleObject(e,t){let n=e.replace(/^\s*\{/,"").replace(/\}\s*$/,"").trim();if(!n)return;let r=n.split(/\n|,/);for(let o of r){let i=o.trim();if(!i)continue;let a=i.match(/^(\w+)\s*:\s*(.+)$/);if(a){let c=a[1],l=a[2].trim().replace(/[,;]\s*$/,"");l==="true"?t[c]=!0:l==="false"?t[c]=!1:l==="null"?t[c]=null:l==="undefined"?t[c]=void 0:/^'[^']*'$/.test(l)||/^"[^"]*"$/.test(l)?t[c]=l.slice(1,-1):/^-?\d+$/.test(l)?t[c]=parseInt(l,10):/^-?\d+\.\d+$/.test(l)?t[c]=parseFloat(l):(/^\[/.test(l)||/^\{/.test(l),t[c]=l)}}}_generatePageJs(e,t,n,r){let o=[];o.push("// Auto-generated by MiniAppCompiler"),o.push(`// Platform: ${r}`),o.push(""),o.push("Page({"),o.push(" data: "+JSON.stringify(e,null,4).split(`
|
|
12
12
|
`).map((a,c)=>c===0?a:" "+a).join(`
|
|
13
|
-
`)+","),
|
|
14
|
-
`))
|
|
15
|
-
`)}_generateComponentJs(e,t,r,
|
|
16
|
-
`).map((c,
|
|
17
|
-
`)+","),
|
|
18
|
-
`).map((c,
|
|
19
|
-
`)+","),
|
|
20
|
-
`))
|
|
21
|
-
`)}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}_extractParamNames(e){let t=e.match(/(?:function\s*\w*\s*|\w+\s*=>\s*(?:\([^)]*\)|([^)]*)))\s*\(?([^)]*)\)?/);if(t&&t[2])return t[2].split(",").map(i=>i.trim()).filter(Boolean);let r=e.match(/\(([^)]*)\)\s*=>/);if(r)return r[1].split(",").map(i=>i.trim()).filter(Boolean);let n=e.match(/(\w+)\s*=>/);return n?[n[1].trim()]:[]}};var ce={click:{wechat:"tap",alipay:"tap",bytedance:"tap"},dblclick:{wechat:"tap",alipay:"tap",bytedance:"tap"},input:{wechat:"input",alipay:"input",bytedance:"input"},change:{wechat:"change",alipay:"change",bytedance:"change"},submit:{wechat:"submit",alipay:"submit",bytedance:"submit"},focus:{wechat:"focus",alipay:"focus",bytedance:"focus"},blur:{wechat:"blur",alipay:"blur",bytedance:"blur"},touchstart:{wechat:"touchstart",alipay:"touchStart",bytedance:"touchstart"},touchend:{wechat:"touchend",alipay:"touchEnd",bytedance:"touchend"},touchmove:{wechat:"touchmove",alipay:"touchMove",bytedance:"touchmove"},touchcancel:{wechat:"touchcancel",alipay:"touchCancel",bytedance:"touchcancel"},scroll:{wechat:"scroll",alipay:"scroll",bytedance:"scroll"},longpress:{wechat:"longpress",alipay:"longTap",bytedance:"longpress"},keydown:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keyup:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keypress:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"}},Le={wechat:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"},alipay:{bind:"on",catch:"catchEvent",captureBind:"capture-bind:",captureCatch:"capture-catch:"},bytedance:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"}},P=class{constructor(e,t){this._customEventListeners={};this._platform=e,this._componentInstance=t,this._bubblingEnabled=!0,this._capturingEnabled=!0}normalizeEvent(e,t){let r=t||this._platform,n=e.toLowerCase(),i=ce[n];return i?i[r]:r==="alipay"?e.charAt(0).toLowerCase()+e.slice(1):n}getBindName(e,t){let r=this.normalizeEvent(e),n=Le[this._platform];return t!=null&&t.capture?`${n.captureBind}${r}`:t!=null&&t.stop?this._platform==="alipay"?`${n.catch}${this._capitalize(r)}`:`${n.catch}${r}`:this._platform==="alipay"?`${n.bind}${this._capitalize(r)}`:`${n.bind}${r}`}parseEventArgs(e,t){let r=t||this._platform,n=e[0]||{},i={type:n.type||"",timeStamp:n.timeStamp||Date.now(),target:this._normalizeTarget(n.target||{}),currentTarget:this._normalizeTarget(n.currentTarget||{}),detail:n.detail||{},bubbles:n.bubbles!==!1,cancelable:n.cancelable!==!1,defaultPrevented:!1,propagationStopped:!1},o=n.detail||{};return r==="wechat"||r==="alipay"&&!o.value&&n.value!==void 0&&(i.detail.value=n.value),{nativeEvent:i,detail:o}}_normalizeTarget(e){return{id:e.id||"",dataset:e.dataset||{}}}createDataBinder(e){let t=this;return{get(){if(!t._componentInstance)return;let r=t._componentInstance.data||{};return t._getNestedValue(r,e)},set(r){t._componentInstance&&(typeof t._componentInstance.setData=="function"?t._componentInstance.setData({[e]:r}):t._setNestedValue(t._componentInstance.data||{},e,r))}}}_getNestedValue(e,t){let r=t.split("."),n=e;for(let i of r){if(n==null)return;n=n[i]}return n}_setNestedValue(e,t,r){let n=t.split("."),i=e;for(let o=0;o<n.length-1;o++){let a=n[o];i[a]==null&&(i[a]={}),i=i[a]}i[n[n.length-1]]=r}createBridgeHandler(e){let t={},r=this;for(let[n]of Object.entries(ce)){let i=this.getBindName(n),o=this.normalizeEvent(n);t[i]=function(a,...c){let p=r.parseEventArgs([a,...c]);return r._bubblingEnabled&&r._emitCustomEvent(e,n,p.detail,p.nativeEvent),p},t[o]=t[i]}return t.handleEvent=function(n){return r.parseEventArgs([n])},t}on(e,t){this._customEventListeners[e]||(this._customEventListeners[e]=[]),this._customEventListeners[e].push(t)}off(e,t){if(this._customEventListeners[e])if(t){let r=this._customEventListeners[e].indexOf(t);r!==-1&&this._customEventListeners[e].splice(r,1)}else delete this._customEventListeners[e]}_emitCustomEvent(e,t,r,n){let i=this._customEventListeners[t];if(!(!i||i.length===0)){for(let o of i)try{o(r,n)}catch(a){}this._componentInstance&&typeof this._componentInstance.triggerEvent=="function"&&this._componentInstance.triggerEvent(t,r,{bubbles:(n==null?void 0:n.bubbles)!==!1,composed:!0,capturePhase:!1})}}$emit(e,t){this._emitCustomEvent("__self__",e,t||{})}enableBubbling(){this._bubblingEnabled=!0}disableBubbling(){this._bubblingEnabled=!1}enableCapturing(){this._capturingEnabled=!0}disableCapturing(){this._capturingEnabled=!1}isBubblingEnabled(){return this._bubblingEnabled}isCapturingEnabled(){return this._capturingEnabled}setComponentInstance(e){this._componentInstance=e}getComponentInstance(){return this._componentInstance}getPlatform(){return this._platform}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}};var U={setup:{lytHook:"setup",platformHook:"data + attached",description:"setup() \u8FD4\u56DE\u503C\u4F5C\u4E3A data\uFF0C\u903B\u8F91\u5728 attached() \u4E2D\u6267\u884C",hasDirectMapping:!1},onBeforeMount:{lytHook:"onBeforeMount",platformHook:"created / onLoad",description:"\u9875\u9762\u4F7F\u7528 onLoad\uFF0C\u7EC4\u4EF6\u4F7F\u7528 created",hasDirectMapping:!0},onMounted:{lytHook:"onMounted",platformHook:"ready",description:"\u9875\u9762\u548C\u7EC4\u4EF6\u5747\u4F7F\u7528 ready",hasDirectMapping:!0},onUpdated:{lytHook:"onUpdated",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u901A\u8FC7 observers \u6216 setData \u56DE\u8C03\u6A21\u62DF",hasDirectMapping:!1},onBeforeUnmount:{lytHook:"onBeforeUnmount",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u5728 detached \u4E2D\u624B\u52A8\u5904\u7406",hasDirectMapping:!1},onUnmounted:{lytHook:"onUnmounted",platformHook:"detached / onUnload",description:"\u7EC4\u4EF6\u4F7F\u7528 detached\uFF0C\u9875\u9762\u4F7F\u7528 onUnload",hasDirectMapping:!0},onErrorCaptured:{lytHook:"onErrorCaptured",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u5C0F\u7A0B\u5E8F\u65E0\u76F4\u63A5\u5BF9\u5E94\uFF0C\u53EF\u5728\u65B9\u6CD5\u4E2D try-catch",hasDirectMapping:!1},onLoad:{lytHook:"onLoad",platformHook:"onLoad",description:"\u9875\u9762\u52A0\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onShow:{lytHook:"onShow",platformHook:"onShow",description:"\u9875\u9762\u663E\u793A\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onReady:{lytHook:"onReady",platformHook:"onReady",description:"\u9875\u9762\u521D\u6B21\u6E32\u67D3\u5B8C\u6210\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onHide:{lytHook:"onHide",platformHook:"onHide",description:"\u9875\u9762\u9690\u85CF\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onUnload:{lytHook:"onUnload",platformHook:"onUnload",description:"\u9875\u9762\u5378\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},created:{lytHook:"created",platformHook:"created",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u521B\u5EFA\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},attached:{lytHook:"attached",platformHook:"attached",description:"\u7EC4\u4EF6\u8FDB\u5165\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},ready:{lytHook:"ready",platformHook:"ready",description:"\u7EC4\u4EF6\u5E03\u5C40\u5B8C\u6210\u540E\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},moved:{lytHook:"moved",platformHook:"moved",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u88AB\u79FB\u52A8\u5230\u8282\u70B9\u6811\u53E6\u4E00\u4E2A\u4F4D\u7F6E\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},detached:{lytHook:"detached",platformHook:"detached",description:"\u7EC4\u4EF6\u79BB\u5F00\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0}},$e={onBeforeMount:"onLoad",onMounted:"onReady",onUnmounted:"onUnload",onShow:"onShow",onHide:"onHide",onReady:"onReady",onLoad:"onLoad",onUnload:"onUnload"},pe={onBeforeMount:"created",onMounted:"ready",onUnmounted:"detached",onReady:"ready",created:"created",attached:"attached",moved:"moved",detached:"detached"},S=class{constructor(e){this._platform=e}mapLifecycle(e,t){let r=U[e];return r?r.platformHook:e}getLifecycleMapping(e){return U[e]||null}getAllMappings(){return Object.values(U)}createPageLifecycle(e){let t={};for(let[r,n]of Object.entries(e)){if(typeof n!="function")continue;let i=$e[r];if(i)if(t[i]){let o=t[i];t[i]=function(...a){o.apply(this,a),n.apply(this,a)}}else t[i]=n;else t[r]=n}return t}createComponentLifecycle(e){let t={},r={},n=null;for(let[i,o]of Object.entries(e)){if(typeof o!="function")continue;if(i==="setup"){let c=o.call({});c&&typeof c=="object"&&(n=c);continue}let a=pe[i];if(a)if(r[a]){let c=r[a];r[a]=function(...p){c.apply(this,p),o.apply(this,p)}}else r[a]=o;else t.methods||(t.methods={}),t.methods[i]=o}return Object.keys(r).length>0&&(t.lifetimes=r),n&&(t.data=n),t}wrapComponent(e,t){let r=t||this._platform,n={};if(e.setup&&typeof e.setup=="function"){let a=e.setup.call({});a&&typeof a=="object"?n.data={...a||{},...e.data||{}}:n.data=e.data||{}}else n.data=e.data||{};if(e.props){if(Array.isArray(e.props)){let a={};for(let c of e.props)a[c]={type:null};n.properties=a}else if(typeof e.props=="object"){let a={};for(let[c,p]of Object.entries(e.props))if(typeof p=="function")a[c]={type:p.name};else if(typeof p=="object"&&p!==null){let l={};p.type&&(l.type=p.type),p.default!==void 0&&(l.value=p.default),p.value!==void 0&&(l.value=p.value),a[c]=l}else a[c]={type:null,value:p};n.properties=a}}let i={},o=["onBeforeMount","onMounted","onUpdated","onUnmounted","onBeforeUnmount","onErrorCaptured","created","attached","ready","moved","detached"];for(let a of o)if(e[a]&&typeof e[a]=="function"){let c=pe[a];c&&(i[c]=e[a])}if(Object.keys(i).length>0&&(n.lifetimes=i),e.methods&&typeof e.methods=="object"?n.methods={...e.methods}:n.methods={},e.computed&&typeof e.computed=="object"){let a={};for(let[c,p]of Object.entries(e.computed))if(typeof p=="function")try{let l=p.call(n.data);n.data[c]=l}catch(l){}}if(e.watch&&typeof e.watch=="object"){n.observers||(n.observers={});for(let[a,c]of Object.entries(e.watch))if(typeof c=="function")n.observers[a]=c;else if(Array.isArray(c)){let p=c.filter(l=>typeof l=="function");p.length>0&&(n.observers[a]=function(...l){for(let f of p)f.apply(this,l)})}}return e.observers&&typeof e.observers=="object"&&(n.observers||(n.observers={}),Object.assign(n.observers,e.observers)),(e.onLoad||e.onShow||e.onHide||e.onPullDownRefresh||e.onReachBottom||e.onShareAppMessage)&&(e.onLoad&&(n.onLoad=e.onLoad),e.onShow&&(n.onShow=e.onShow),e.onHide&&(n.onHide=e.onHide),e.onPullDownRefresh&&(n.onPullDownRefresh=e.onPullDownRefresh),e.onReachBottom&&(n.onReachBottom=e.onReachBottom),e.onShareAppMessage&&(n.onShareAppMessage=e.onShareAppMessage)),n}getPlatform(){return this._platform}setPlatform(e){this._platform=e}getPlatformLifecycleDifferences(e){let t=e||this._platform;return t==="alipay"?{created:"created\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"didMount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didMount \u66FF\u4EE3 ready\uFF09",detached:"didUnmount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didUnmount \u66FF\u4EE3 detached\uFF09",onLoad:"onLoad\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09"}:t==="bytedance"?{created:"created\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"ready\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",detached:"detached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",onLoad:"onLoad\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09"}:{created:"created",attached:"attached",ready:"ready",moved:"moved",detached:"detached",onLoad:"onLoad",onShow:"onShow",onReady:"onReady",onHide:"onHide",onUnload:"onUnload"}}};
|
|
13
|
+
`)+","),n.onLoad&&(o.push(""),o.push(" onLoad(options) {"),o.push(" // Lyt.js onBeforeMount -> onLoad"),o.push(" },")),n.onShow&&(o.push(""),o.push(" onShow() {"),o.push(" // Lyt.js onShow"),o.push(" },")),n.onReady&&(o.push(""),o.push(" onReady() {"),o.push(" // Lyt.js onMounted -> onReady"),o.push(" },"));let i=Object.entries(t);if(i.length>0){o.push("");for(let[a,c]of i){let l=c.toString(),p=l.match(/(?:function\s*\w*\s*\(|=>\s*\{?\s*)([\s\S]*)/),u=p?p[1].trim().replace(/^\{|\}$/g,"").trim():"";if(o.push(` ${a}(${this._extractParamNames(l).join(", ")}) {`),u)for(let d of u.split(`
|
|
14
|
+
`))o.push(` ${d}`);o.push(" },")}}return o.push("});"),o.join(`
|
|
15
|
+
`)}_generateComponentJs(e,t,n,r,o){let i=[];if(i.push("// Auto-generated by MiniAppCompiler"),i.push(`// Platform: ${o}`),i.push(""),i.push("Component({"),Object.keys(e).length>0&&i.push(" properties: "+JSON.stringify(e,null,4).split(`
|
|
16
|
+
`).map((c,l)=>l===0?c:" "+c).join(`
|
|
17
|
+
`)+","),i.push(" data: "+JSON.stringify(t,null,4).split(`
|
|
18
|
+
`).map((c,l)=>l===0?c:" "+c).join(`
|
|
19
|
+
`)+","),r.length>0){i.push(""),i.push(" observers: {");for(let c of r)i.push(` ${c},`);i.push(" },")}i.push(""),i.push(" lifetimes: {"),i.push(" attached() {"),i.push(" // Lyt.js setup -> attached"),i.push(" },"),i.push(" ready() {"),i.push(" // Lyt.js onMounted -> ready"),i.push(" },"),i.push(" detached() {"),i.push(" // Lyt.js onUnmounted -> detached"),i.push(" },"),i.push(" },");let a=Object.entries(n);if(a.length>0){i.push(""),i.push(" methods: {");for(let[c,l]of a){let p=l.toString(),u=p.match(/(?:function\s*\w*\s*\(|=>\s*\{?\s*)([\s\S]*)/),d=u?u[1].trim().replace(/^\{|\}$/g,"").trim():"";if(i.push(` ${c}(${this._extractParamNames(p).join(", ")}) {`),d)for(let f of d.split(`
|
|
20
|
+
`))i.push(` ${f}`);i.push(" },")}i.push(" },")}return i.push("});"),i.join(`
|
|
21
|
+
`)}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}_extractParamNames(e){let t=e.match(/(?:function\s*\w*\s*|\w+\s*=>\s*(?:\([^)]*\)|([^)]*)))\s*\(?([^)]*)\)?/);if(t&&t[2])return t[2].split(",").map(o=>o.trim()).filter(Boolean);let n=e.match(/\(([^)]*)\)\s*=>/);if(n)return n[1].split(",").map(o=>o.trim()).filter(Boolean);let r=e.match(/(\w+)\s*=>/);return r?[r[1].trim()]:[]}};var Ue=/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]+))?\s*\)/g,ze=new Set(["position: fixed","position: sticky","z-index","overflow: overlay","backdrop-filter","-webkit-backdrop-filter","mask-image","-webkit-mask-image","clip-path","filter: drop-shadow","writing-mode","text-orientation"]),Ke=new Set([":active",":hover"]),x=class{constructor(){this._scopeIdCounter=0}compile(e,t={}){let{scoped:n=!1,scopeId:r,pxToRpx:o=!1,rpxRatio:i=2,transformCssVariables:a=!0,cssVariables:c={},platform:l="wechat"}=t,p=r||this._generateScopeId(),u={cssVariablesTransformed:0,pxTransformed:0,scopedSelectorsAdded:0},d=e;if(d=this._removeComments(d),a&&Object.keys(c).length>0){let{code:f,count:_}=this._transformCssVariables(d,c);d=f,u.cssVariablesTransformed=_}if(o){let{code:f,count:_}=this._transformPxToRpx(d,i);d=f,u.pxTransformed=_}if(d=this._handleUnsupportedPseudoSelectors(d),d=this._handleUnsupportedProperties(d,l),n){let{code:f,count:_}=this._applyScoped(d,p);d=f,u.scopedSelectorsAdded=_}return d=this._handleImports(d),d=this._cleanup(d),{code:d,scopeId:p,stats:u}}compileScoped(e,t,n={}){return this.compile(e,{...n,scoped:!0,scopeId:t})}transformCssVariables(e,t){let{code:n}=this._transformCssVariables(e,t);return n}transformPxToRpx(e,t=2){let{code:n}=this._transformPxToRpx(e,t);return n}_generateScopeId(){return`data-v-${(++this._scopeIdCounter).toString(16).padStart(8,"0")}`}_removeComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}_transformCssVariables(e,t){let n=0;return{code:e.replace(Ue,(o,i,a)=>{let c=t[i];return c!==void 0?(n++,c):a!==void 0?(n++,a.trim()):o}),count:n}}_transformPxToRpx(e,t){let n=0,r=/\b(\d+(?:\.\d+)?)px\b/g;return{code:e.replace(r,(i,a)=>{let c=parseFloat(a);return c===0?"0px":(n++,`${Math.round(c*t)}rpx`)}),count:n}}_handleUnsupportedPseudoSelectors(e){let t=/([^{}@]+)(:not\([^)]*\)|:nth-child\([^)]*\)|:first-child|:last-child|:nth-of-type\([^)]*\)|:only-child|:only-of-type|:empty|:checked|:disabled|:enabled|:focus|:visited|:link|:before|:after|::before|::after)([^{]*)\{/g;return e.replace(t,(n,r,o,i)=>{let a=o.split("(")[0].trim();return Ke.has(a)?n:`${r}${i}{`})}_handleUnsupportedProperties(e,t){let n=e.split(`
|
|
22
|
+
`),r=[];for(let o of n){let i=o.trim(),a=!1;for(let c of ze)if(i.includes(c)){a=!0;break}a||r.push(o)}return r.join(`
|
|
23
|
+
`)}_applyScoped(e,t){let n=0,r=!1,o=0,i=e.split(`
|
|
24
|
+
`),a=[];for(let c of i){let l=c.trim();if(l.startsWith("@media")){r=!0,a.push(c);continue}if(o+=(l.match(/{/g)||[]).length,o-=(l.match(/}/g)||[]).length,r&&o<=0){r=!1,a.push(c);continue}if(l.startsWith("@keyframes")||l.startsWith("@font-face")){a.push(c);continue}if(!l||l==="{"||l==="}"){a.push(c);continue}if(l.endsWith("{")&&!l.startsWith("@")){let p=l.slice(0,-1).trim(),u=this._addScopeToSelector(p,t);a.push(` ${u} {`),n++}else a.push(c)}return{code:a.join(`
|
|
25
|
+
`),count:n}}_addScopeToSelector(e,t){return e.split(",").map(o=>o.trim()).map(o=>{let i=o.lastIndexOf("["),a=o.lastIndexOf("(");return i>a&&i!==-1?o.slice(0,i)+`[${t}]`+o.slice(i):`${o}[${t}]`}).join(", ")}_handleImports(e){return e.replace(/@import\s+['"]([^'"]+)['"]\s*;/g,(t,n)=>n.startsWith("http://")||n.startsWith("https://")?`/* Remote @import removed: ${n} */`:t)}_cleanup(e){return e.replace(/\n{3,}/g,`
|
|
26
|
+
|
|
27
|
+
`).trim()}},W=new x;function ye(s,e){return W.compile(s,e)}var be={click:{wechat:"tap",alipay:"tap",bytedance:"tap"},dblclick:{wechat:"tap",alipay:"tap",bytedance:"tap"},input:{wechat:"input",alipay:"input",bytedance:"input"},change:{wechat:"change",alipay:"change",bytedance:"change"},submit:{wechat:"submit",alipay:"submit",bytedance:"submit"},focus:{wechat:"focus",alipay:"focus",bytedance:"focus"},blur:{wechat:"blur",alipay:"blur",bytedance:"blur"},touchstart:{wechat:"touchstart",alipay:"touchStart",bytedance:"touchstart"},touchend:{wechat:"touchend",alipay:"touchEnd",bytedance:"touchend"},touchmove:{wechat:"touchmove",alipay:"touchMove",bytedance:"touchmove"},touchcancel:{wechat:"touchcancel",alipay:"touchCancel",bytedance:"touchcancel"},scroll:{wechat:"scroll",alipay:"scroll",bytedance:"scroll"},longpress:{wechat:"longpress",alipay:"longTap",bytedance:"longpress"},keydown:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keyup:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keypress:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"}},Ge={wechat:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"},alipay:{bind:"on",catch:"catchEvent",captureBind:"capture-bind:",captureCatch:"capture-catch:"},bytedance:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"}},I=class{constructor(e,t){this._customEventListeners={};this._platform=e,this._componentInstance=t,this._bubblingEnabled=!0,this._capturingEnabled=!0}normalizeEvent(e,t){let n=t||this._platform,r=e.toLowerCase(),o=be[r];return o?o[n]:n==="alipay"?e.charAt(0).toLowerCase()+e.slice(1):r}getBindName(e,t){let n=this.normalizeEvent(e),r=Ge[this._platform];return t!=null&&t.capture?`${r.captureBind}${n}`:t!=null&&t.stop?this._platform==="alipay"?`${r.catch}${this._capitalize(n)}`:`${r.catch}${n}`:this._platform==="alipay"?`${r.bind}${this._capitalize(n)}`:`${r.bind}${n}`}parseEventArgs(e,t){let n=t||this._platform,r=e[0]||{},o={type:r.type||"",timeStamp:r.timeStamp||Date.now(),target:this._normalizeTarget(r.target||{}),currentTarget:this._normalizeTarget(r.currentTarget||{}),detail:r.detail||{},bubbles:r.bubbles!==!1,cancelable:r.cancelable!==!1,defaultPrevented:!1,propagationStopped:!1},i=r.detail||{};return n==="wechat"||n==="alipay"&&!i.value&&r.value!==void 0&&(o.detail.value=r.value),{nativeEvent:o,detail:i}}_normalizeTarget(e){return{id:e.id||"",dataset:e.dataset||{}}}createDataBinder(e){let t=this;return{get(){if(!t._componentInstance)return;let n=t._componentInstance.data||{};return t._getNestedValue(n,e)},set(n){t._componentInstance&&(typeof t._componentInstance.setData=="function"?t._componentInstance.setData({[e]:n}):t._setNestedValue(t._componentInstance.data||{},e,n))}}}_getNestedValue(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null)return;r=r[o]}return r}_setNestedValue(e,t,n){let r=t.split("."),o=e;for(let i=0;i<r.length-1;i++){let a=r[i];o[a]==null&&(o[a]={}),o=o[a]}o[r[r.length-1]]=n}createBridgeHandler(e){let t={},n=this;for(let[r]of Object.entries(be)){let o=this.getBindName(r),i=this.normalizeEvent(r);t[o]=function(a,...c){let l=n.parseEventArgs([a,...c]);return n._bubblingEnabled&&n._emitCustomEvent(e,r,l.detail,l.nativeEvent),l},t[i]=t[o]}return t.handleEvent=function(r){return n.parseEventArgs([r])},t}on(e,t){this._customEventListeners[e]||(this._customEventListeners[e]=[]),this._customEventListeners[e].push(t)}off(e,t){if(this._customEventListeners[e])if(t){let n=this._customEventListeners[e].indexOf(t);n!==-1&&this._customEventListeners[e].splice(n,1)}else delete this._customEventListeners[e]}_emitCustomEvent(e,t,n,r){let o=this._customEventListeners[t];if(!(!o||o.length===0)){for(let i of o)try{i(n,r)}catch(a){}this._componentInstance&&typeof this._componentInstance.triggerEvent=="function"&&this._componentInstance.triggerEvent(t,n,{bubbles:(r==null?void 0:r.bubbles)!==!1,composed:!0,capturePhase:!1})}}$emit(e,t){this._emitCustomEvent("__self__",e,t||{})}enableBubbling(){this._bubblingEnabled=!0}disableBubbling(){this._bubblingEnabled=!1}enableCapturing(){this._capturingEnabled=!0}disableCapturing(){this._capturingEnabled=!1}isBubblingEnabled(){return this._bubblingEnabled}isCapturingEnabled(){return this._capturingEnabled}setComponentInstance(e){this._componentInstance=e}getComponentInstance(){return this._componentInstance}getPlatform(){return this._platform}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}};var X={setup:{lytHook:"setup",platformHook:"data + attached",description:"setup() \u8FD4\u56DE\u503C\u4F5C\u4E3A data\uFF0C\u903B\u8F91\u5728 attached() \u4E2D\u6267\u884C",hasDirectMapping:!1},onBeforeMount:{lytHook:"onBeforeMount",platformHook:"created / onLoad",description:"\u9875\u9762\u4F7F\u7528 onLoad\uFF0C\u7EC4\u4EF6\u4F7F\u7528 created",hasDirectMapping:!0},onMounted:{lytHook:"onMounted",platformHook:"ready",description:"\u9875\u9762\u548C\u7EC4\u4EF6\u5747\u4F7F\u7528 ready",hasDirectMapping:!0},onUpdated:{lytHook:"onUpdated",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u901A\u8FC7 observers \u6216 setData \u56DE\u8C03\u6A21\u62DF",hasDirectMapping:!1},onBeforeUnmount:{lytHook:"onBeforeUnmount",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u5728 detached \u4E2D\u624B\u52A8\u5904\u7406",hasDirectMapping:!1},onUnmounted:{lytHook:"onUnmounted",platformHook:"detached / onUnload",description:"\u7EC4\u4EF6\u4F7F\u7528 detached\uFF0C\u9875\u9762\u4F7F\u7528 onUnload",hasDirectMapping:!0},onErrorCaptured:{lytHook:"onErrorCaptured",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u5C0F\u7A0B\u5E8F\u65E0\u76F4\u63A5\u5BF9\u5E94\uFF0C\u53EF\u5728\u65B9\u6CD5\u4E2D try-catch",hasDirectMapping:!1},onLoad:{lytHook:"onLoad",platformHook:"onLoad",description:"\u9875\u9762\u52A0\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onShow:{lytHook:"onShow",platformHook:"onShow",description:"\u9875\u9762\u663E\u793A\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onReady:{lytHook:"onReady",platformHook:"onReady",description:"\u9875\u9762\u521D\u6B21\u6E32\u67D3\u5B8C\u6210\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onHide:{lytHook:"onHide",platformHook:"onHide",description:"\u9875\u9762\u9690\u85CF\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onUnload:{lytHook:"onUnload",platformHook:"onUnload",description:"\u9875\u9762\u5378\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},created:{lytHook:"created",platformHook:"created",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u521B\u5EFA\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},attached:{lytHook:"attached",platformHook:"attached",description:"\u7EC4\u4EF6\u8FDB\u5165\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},ready:{lytHook:"ready",platformHook:"ready",description:"\u7EC4\u4EF6\u5E03\u5C40\u5B8C\u6210\u540E\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},moved:{lytHook:"moved",platformHook:"moved",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u88AB\u79FB\u52A8\u5230\u8282\u70B9\u6811\u53E6\u4E00\u4E2A\u4F4D\u7F6E\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},detached:{lytHook:"detached",platformHook:"detached",description:"\u7EC4\u4EF6\u79BB\u5F00\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0}},Je={onBeforeMount:"onLoad",onMounted:"onReady",onUnmounted:"onUnload",onShow:"onShow",onHide:"onHide",onReady:"onReady",onLoad:"onLoad",onUnload:"onUnload"},we={onBeforeMount:"created",onMounted:"ready",onUnmounted:"detached",onReady:"ready",created:"created",attached:"attached",moved:"moved",detached:"detached"},V=class{constructor(e){this._platform=e}mapLifecycle(e,t){let n=X[e];return n?n.platformHook:e}getLifecycleMapping(e){return X[e]||null}getAllMappings(){return Object.values(X)}createPageLifecycle(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r!="function")continue;let o=Je[n];if(o)if(t[o]){let i=t[o];t[o]=function(...a){i.apply(this,a),r.apply(this,a)}}else t[o]=r;else t[n]=r}return t}createComponentLifecycle(e){let t={},n={},r=null;for(let[o,i]of Object.entries(e)){if(typeof i!="function")continue;if(o==="setup"){let c=i.call({});c&&typeof c=="object"&&(r=c);continue}let a=we[o];if(a)if(n[a]){let c=n[a];n[a]=function(...l){c.apply(this,l),i.apply(this,l)}}else n[a]=i;else t.methods||(t.methods={}),t.methods[o]=i}return Object.keys(n).length>0&&(t.lifetimes=n),r&&(t.data=r),t}wrapComponent(e,t){let n=t||this._platform,r={};if(e.setup&&typeof e.setup=="function"){let a=e.setup.call({});a&&typeof a=="object"?r.data={...a||{},...e.data||{}}:r.data=e.data||{}}else r.data=e.data||{};if(e.props){if(Array.isArray(e.props)){let a={};for(let c of e.props)a[c]={type:null};r.properties=a}else if(typeof e.props=="object"){let a={};for(let[c,l]of Object.entries(e.props))if(typeof l=="function")a[c]={type:l.name};else if(typeof l=="object"&&l!==null){let p={};l.type&&(p.type=l.type),l.default!==void 0&&(p.value=l.default),l.value!==void 0&&(p.value=l.value),a[c]=p}else a[c]={type:null,value:l};r.properties=a}}let o={},i=["onBeforeMount","onMounted","onUpdated","onUnmounted","onBeforeUnmount","onErrorCaptured","created","attached","ready","moved","detached"];for(let a of i)if(e[a]&&typeof e[a]=="function"){let c=we[a];c&&(o[c]=e[a])}if(Object.keys(o).length>0&&(r.lifetimes=o),e.methods&&typeof e.methods=="object"?r.methods={...e.methods}:r.methods={},e.computed&&typeof e.computed=="object"){let a={};for(let[c,l]of Object.entries(e.computed))if(typeof l=="function")try{let p=l.call(r.data);r.data[c]=p}catch(p){}}if(e.watch&&typeof e.watch=="object"){r.observers||(r.observers={});for(let[a,c]of Object.entries(e.watch))if(typeof c=="function")r.observers[a]=c;else if(Array.isArray(c)){let l=c.filter(p=>typeof p=="function");l.length>0&&(r.observers[a]=function(...p){for(let u of l)u.apply(this,p)})}}return e.observers&&typeof e.observers=="object"&&(r.observers||(r.observers={}),Object.assign(r.observers,e.observers)),(e.onLoad||e.onShow||e.onHide||e.onPullDownRefresh||e.onReachBottom||e.onShareAppMessage)&&(e.onLoad&&(r.onLoad=e.onLoad),e.onShow&&(r.onShow=e.onShow),e.onHide&&(r.onHide=e.onHide),e.onPullDownRefresh&&(r.onPullDownRefresh=e.onPullDownRefresh),e.onReachBottom&&(r.onReachBottom=e.onReachBottom),e.onShareAppMessage&&(r.onShareAppMessage=e.onShareAppMessage)),r}getPlatform(){return this._platform}setPlatform(e){this._platform=e}getPlatformLifecycleDifferences(e){let t=e||this._platform;return t==="alipay"?{created:"created\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"didMount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didMount \u66FF\u4EE3 ready\uFF09",detached:"didUnmount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didUnmount \u66FF\u4EE3 detached\uFF09",onLoad:"onLoad\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09"}:t==="bytedance"?{created:"created\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"ready\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",detached:"detached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",onLoad:"onLoad\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09"}:{created:"created",attached:"attached",ready:"ready",moved:"moved",detached:"detached",onLoad:"onLoad",onShow:"onShow",onReady:"onReady",onHide:"onHide",onUnload:"onUnload"}}};var v=class{constructor(e,t){this._platform=e,this._wx=t,this._storageAdapter=new Y(t),this._routerAdapter=new q(t)}async fetch(e,t){return new Promise((n,r)=>{let o={url:e,method:(t==null?void 0:t.method)||"GET",dataType:(t==null?void 0:t.responseType)||"json",responseType:(t==null?void 0:t.responseType)==="arraybuffer"?"arraybuffer":"text"};t!=null&&t.headers&&(o.header=t.headers),(t==null?void 0:t.data)!==void 0&&(o.data=t.data),t!=null&&t.timeout&&(o.timeout=t.timeout),this._wx.request({...o,success:i=>{n({statusCode:i.statusCode,headers:i.header||{},data:i.data,duration:i.duration||0,url:e})},fail:i=>{r(new Error(`[MiniApp API] Request failed: ${i.errMsg||JSON.stringify(i)}`))}})})}async get(e,t){return(await this.fetch(e,{url:e,method:"GET",headers:t})).data}async post(e,t,n){return(await this.fetch(e,{url:e,method:"POST",data:t,headers:n})).data}async put(e,t,n){return(await this.fetch(e,{url:e,method:"PUT",data:t,headers:n})).data}async delete(e,t){return(await this.fetch(e,{url:e,method:"DELETE",headers:t})).data}get storage(){return this._storageAdapter}get router(){return this._routerAdapter}showToast(e,t){this._wx.showToast({title:e,icon:(t==null?void 0:t.icon)||"none",duration:(t==null?void 0:t.duration)||1500,mask:(t==null?void 0:t.mask)||!1})}hideToast(){this._wx.hideToast()}showLoading(e="\u52A0\u8F7D\u4E2D...",t=!1){this._wx.showLoading({title:e,mask:t})}hideLoading(){this._wx.hideLoading()}showModal(e){return new Promise(t=>{this._wx.showModal({title:e.title||"\u63D0\u793A",content:e.content,showCancel:e.showCancel!==!1,cancelText:e.cancelText||"\u53D6\u6D88",confirmText:e.confirmText||"\u786E\u5B9A",success:n=>{t(n.confirm===!0)},fail:()=>{t(!1)}})})}getSystemInfo(){return this._wx.getSystemInfoSync()}getSystemInfoAsync(){return new Promise((e,t)=>{this._wx.getSystemInfo({success:n=>e(n),fail:n=>t(n)})})}setClipboardData(e){return new Promise((t,n)=>{this._wx.setClipboardData({data:e,success:()=>t(),fail:r=>n(r)})})}getClipboardData(){return new Promise((e,t)=>{this._wx.getClipboardData({success:n=>e(n.data),fail:n=>t(n)})})}startPullDownRefresh(){return new Promise((e,t)=>{this._wx.startPullDownRefresh({success:()=>e(),fail:n=>t(n)})})}stopPullDownRefresh(){this._wx.stopPullDownRefresh()}getPlatform(){return this._platform}getWx(){return this._wx}},Y=class{constructor(e){this._wx=e}getItem(e){try{let t=this._wx.getStorageSync(e);return t===""||t===void 0||t===null?null:typeof t=="string"?t:JSON.stringify(t)}catch(t){return null}}setItem(e,t){try{try{let n=JSON.parse(t);this._wx.setStorageSync(e,n)}catch(n){this._wx.setStorageSync(e,t)}}catch(n){}}removeItem(e){try{this._wx.removeStorageSync(e)}catch(t){}}clear(){try{this._wx.clearStorageSync()}catch(e){}}keys(){try{return this._wx.getStorageInfoSync().keys||[]}catch(e){return[]}}getInfo(){try{let e=this._wx.getStorageInfoSync();return{currentSize:e.currentSize||0,limitSize:e.limitSize||10240}}catch(e){return{currentSize:0,limitSize:10240}}}async getItemAsync(e){return new Promise(t=>{this._wx.getStorage({key:e,success:n=>{let r=n.data;t(r==null?null:typeof r=="string"?r:JSON.stringify(r))},fail:()=>t(null)})})}async setItemAsync(e,t){return new Promise((n,r)=>{let o=t;try{o=JSON.parse(t)}catch(i){}this._wx.setStorage({key:e,data:o,success:()=>n(),fail:i=>r(i)})})}async removeItemAsync(e){return new Promise(t=>{this._wx.removeStorage({key:e,success:()=>t(),fail:()=>t()})})}async clearAsync(){return new Promise(e=>{this._wx.clearStorage({success:()=>e(),fail:()=>e()})})}},q=class{constructor(e){this._wx=e}push(e,t){let n=this._buildUrl(e,t==null?void 0:t.query);this._wx.navigateTo({url:n,success:t!=null&&t.animationType?()=>{}:void 0,fail:r=>{}})}replace(e,t){let n=this._buildUrl(e,t==null?void 0:t.query);this._wx.redirectTo({url:n,fail:r=>{}})}replaceAll(e){this._wx.reLaunch({url:e,fail:t=>{}})}switchTab(e){this._wx.switchTab({url:e,fail:t=>{}})}back(e=1){this._wx.navigateBack({delta:e,fail:t=>{}})}_buildUrl(e,t){if(!t||Object.keys(t).length===0)return e;let n=Object.entries(t).map(([r,o])=>`${encodeURIComponent(r)}=${encodeURIComponent(o)}`).join("&");return`${e}?${n}`}},R=class{constructor(e={},t,n="__lyt_global_state__"){if(this._wx=t||null,this._persistKey=n,this._listeners={},this._wx)try{let r=this._wx.getStorageSync(n);r&&typeof r=="object"?this._state={...e,...r}:this._state={...e}}catch(r){this._state={...e}}else this._state={...e}}get(e){return this._state[e]}set(e,t){let n=this._state[e];this._state[e]=t,this._notify(e,t,n),this._persist()}setMultiple(e){let t={};for(let n of Object.keys(e))t[n]=this._state[n],this._state[n]=e[n];for(let n of Object.keys(e))this._notify(n,e[n],t[n]);this._persist()}on(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),()=>{let n=this._listeners[e];if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}getAll(){return{...this._state}}clear(){let e={...this._state};this._state={};for(let t of Object.keys(e))this._notify(t,void 0,e[t]);this._persist()}_notify(e,t,n){let r=this._listeners[e];if(r)for(let o of r)try{o(t,n)}catch(i){}}_persist(){if(this._wx)try{this._wx.setStorageSync(this._persistKey,this._state)}catch(e){}}},j=null;function ve(s,e){return new v(s,e)}function _e(s,e="wechat"){if(!j&&s&&(j=new v(e,s)),!j)throw new Error("[MiniApp API Adapter] \u672A\u521D\u59CB\u5316\u3002\u8BF7\u5148\u8C03\u7528 createApiAdapter() \u6216\u4F20\u5165 wx \u5BF9\u8C61\u3002");return j}function xe(s,e,t){return new R(s,e,t)}
|
package/dist/miniapp.mjs
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import{registerDOMOperations as le}from"@lytjs/vdom";var h=(o=>(o[o.ELEMENT=1]="ELEMENT",o[o.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",o[o.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",o[o.TEXT_CHILDREN=8]="TEXT_CHILDREN",o[o.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",o[o.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",o))(h||{}),M=(d=>(d[d.TEXT=1]="TEXT",d[d.CLASS=2]="CLASS",d[d.STYLE=4]="STYLE",d[d.PROPS=8]="PROPS",d[d.FULL_PROPS=16]="FULL_PROPS",d[d.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",d[d.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",d[d.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",d[d.NEED_PATCH=256]="NEED_PATCH",d[d.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",d[d.HOISTED=-1]="HOISTED",d[d.BAIL=-2]="BAIL",d))(M||{}),j=Symbol("Fragment"),D=Symbol("Text"),I=Symbol("Comment");function m(s){return s.type===j}function b(s){return s.type===D}function v(s){return s.type===I}function B(s,e){return s.type===e.type&&s.key===e.key}function E(s){return Array.isArray(s.dynamicChildren)}function F(s,e,t,r){if(t==="class")s.setClass(e,r);else if(t==="style")s.setStyle(e,r);else if(t.startsWith("on")||t.startsWith("@")){let n=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();s.addEventListener(e,n,r)}else t==="key"||t==="ref"||s.setAttribute(e,t,r)}function R(s,e,t,r,n){if(t==="class")s.setClass(e,r);else if(t==="style")s.setStyle(e,r||{});else if(t.startsWith("on")||t.startsWith("@")){let i=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();n&&s.removeEventListener(e,i,n),r&&s.addEventListener(e,i,r)}else s.setAttribute(e,t,r)}function C(s,e,t,r){for(let n in r){if(n==="key"||n==="ref")continue;let i=t[n],o=r[n];o!==i&&R(s,e,n,o,i)}for(let n in t)if(!(n==="key"||n==="ref")&&!(n in r))if(n==="class")s.setClass(e,"");else if(n==="style")s.setStyle(e,{});else if(n.startsWith("on")||n.startsWith("@")){let i=n.startsWith("@")?n.slice(1).toLowerCase():n.slice(2).toLowerCase();s.removeEventListener(e,i,t[n])}else s.removeAttribute(e,n)}function T(s,e,t,r,n,i){let{shapeFlag:o}=t;if(m(t)){te(s,e,t,r,n,i);return}if(b(t)){let a=s.createText(t.children);t.el=a,s.insert(r,a,n);return}if(v(t)){let a=s.createComment(t.children);t.el=a,s.insert(r,a,n);return}if(o&1){ee(s,e,t,r,n,i);return}if(o&6){ne(e,t,r,n,i);return}}function ee(s,e,t,r,n,i){let o=t.type,a=s.createElement(o);if(t.el=a,t.props)for(let l in t.props){let f=t.props[l];F(s,a,l,f)}let{shapeFlag:c,children:p}=t;c&8?a.textContent=p:c&16&&N(e,p,a,null,i),s.insert(r,a,n)}function N(s,e,t,r,n){for(let i=0;i<e.length;i++)s(null,e[i],t,r,n)}function te(s,e,t,r,n,i){let{children:o}=t,a=s.createComment("");s.insert(r,a,n),Array.isArray(o)&&o.length>0&&N(e,o,r,a,i),t.el=a,t.anchor=a}function ne(s,e,t,r,n){let i=e.component;i&&i.update&&i.update(),i&&i.subTree&&(s(null,i.subTree,t,r,i),e.el=i.subTree.el)}function U(s,e,t,r){let{shapeFlag:n,children:i}=t;if(m(t)){if(Array.isArray(i))for(let o=0;o<i.length;o++)e(i[o],r);t.anchor&&t.anchor.parentNode&&s.remove(t.anchor);return}if(n&6){t.component&&t.component.subTree&&e(t.component.subTree,r);return}t.el&&s.remove(t.el)}function _(s,e){for(let t=0;t<e.length;t++)s(e[t])}import{patchKeyedChildren as re,patchUnkeyedChildren as ie}from"@lytjs/vdom";function x(s,e,t,r,n,i=null,o=null){if(r==null){t&&e(t,n);return}if(t===null){T(s,L(s,e),r,n,i,o);return}if(E(r)&&E(t)){ce(s,e,t,r,n,o);return}if(!B(t,r)){e(t,n),T(s,L(s,e),r,n,i,o);return}r.el=t.el,r.anchor=t.anchor;let{shapeFlag:a}=r;if(m(r)){ae(s,e,t,r,n,i,o);return}if(b(r)){r.children!==t.children&&(r.el.nodeValue=r.children);return}if(v(r)){r.children!==t.children&&(r.el.nodeValue=r.children);return}if(a&1){oe(s,e,t,r,o);return}if(a&6){pe(t,r,o);return}}function L(s,e){return(t,r,n,i,o)=>{x(s,e,t,r,n,i,o)}}function oe(s,e,t,r,n=null){let i=r.el=t.el,o=t.props||{},a=r.props||{},{patchFlag:c,dynamicProps:p}=r;if(c&&c>0){if(c&1&&t.children!==r.children&&(i.textContent=r.children),c&2&&o.class!==a.class&&s.setClass(i,a.class),c&4&&o.style!==a.style&&s.setStyle(i,a.style||{}),c&8&&p)for(let l=0;l<p.length;l++){let f=p[l],d=o[f],y=a[f];y!==d&&R(s,i,f,y,d)}c&16&&C(s,i,o,a)}else C(s,i,o,a);(!c||!(c&1))&&z(s,e,t,r,i,null,n)}function z(s,e,t,r,n,i,o){let a=t.shapeFlag,c=r.shapeFlag,p=t.children,l=r.children;if(c&8){a&16&&_(e,p),p!==l&&(n.textContent=l);return}if(c&16){a&16?se(s,e,p,l,n,i,o):(a&8&&(n.textContent=""),N(L(s,e),l,n,i,o));return}l==null&&(a&8?n.textContent="":a&16&&_(e,p))}function se(s,e,t,r,n,i,o){r.every(c=>c.key!==null&&c.key!==void 0)&&t.every(c=>c.key!==null&&c.key!==void 0)?re(t,r,n,i,o,null,!1):ie(t,r,n,i,o,null,!1)}function ae(s,e,t,r,n,i,o){let a=t.children,c=r.children;Array.isArray(c)&&c.length>0?(z(s,e,t,r,n,i,o),r.el=c[0].el,r.anchor=c[c.length-1].el?s.nextSibling(c[c.length-1].el):i):Array.isArray(a)&&a.length>0&&c===null?(_(e,a),r.el=t.el,r.anchor=t.anchor):(r.el=t.el,r.anchor=t.anchor)}function ce(s,e,t,r,n,i){let o=t.dynamicChildren,a=r.dynamicChildren;for(let c=0;c<a.length;c++)x(s,e,o[c],a[c],n,null,i)}function pe(s,e,t){e.component=s.component,e.el=s.el,e.component&&e.component.update&&e.component.update()}function de(s){function e(n,i){U(s,e,n,i)}le({insert(n,i,o){s.insert(i,n,o)},createElement(n){return s.createElement(n)},createText(n){return s.createText(n)},setText(n,i){n.nodeValue=i},setElementText(n,i){n.textContent=i},remove(n){s.remove(n)},createComment(n){return s.createComment(n)},mount(n,i,o,a,c,p,l){r(null,n,i,o,a)},patch(n,i,o,a,c,p,l,f){r(n,i,o,a,c)},unmount(n,i,o,a){e(n)},move(n,i,o){s.insert(i,n.el,o)}});function r(n,i,o,a,c){x(s,e,n,i,o,a,c)}return{mount(n,i){i.nodeType===1&&(i.textContent=""),r(null,n,i,null,null)},patch(n,i,o){var a;r(n,i,o||((a=n.el)==null?void 0:a.parentNode),null,null)},unmount(n,i){e(n,i)}}}var w={div:"view",span:"text",p:"text",h1:"text",h2:"text",h3:"text",h4:"text",h5:"text",h6:"text",img:"image",input:"input",textarea:"textarea",button:"button",scroll:"scroll-view",list:"view",a:"navigator",ul:"view",ol:"view",li:"view",form:"form",header:"view",footer:"view",nav:"view",main:"view",section:"view",article:"view",aside:"view"},u={click:"tap",input:"input",change:"change",submit:"submit",focus:"focus",blur:"blur",touchstart:"touchstart",touchend:"touchend",touchmove:"touchmove",scroll:"scroll",longpress:"longpress"};function K(s,e,t){if(!(!s||!e)){if(e._parent){let r=e._parent,n=r.children.indexOf(e);n!==-1&&r.children.splice(n,1)}if(e._parent=s,t){let r=s.children.indexOf(t);r!==-1?s.children.splice(r,0,e):s.children.push(e)}else s.children.push(e)}}function J(s){if(!s||!s._parent)return;let e=s._parent,t=e.children.indexOf(s);t!==-1&&e.children.splice(t,1),s._parent=void 0}function W(s,e,t){if(!s||!e||!t)return;let r=s.children.indexOf(e);r!==-1&&(e._parent=void 0,t._parent=s,s.children[r]=t)}function X(s){var e;return(e=s==null?void 0:s._parent)!=null?e:null}function Y(s){if(!s||!s._parent)return null;let e=s._parent.children,t=e.indexOf(s);return t!==-1&&t+1<e.length?e[t+1]:null}function G(s){Promise.resolve().then(()=>s())}var fe={if:{attr:"if"},else:{attr:"else"},each:{attr:"for",prefix:""},bind:{attr:"model:"},on:{attr:"bind",prefix:""},ref:{attr:""},slot:{attr:"slot"},class:{attr:"class"},style:{attr:"style"},show:{attr:"hidden"}},g={wechat:{if:"wx:if",else:"wx:else",for:"wx:for",forKey:"wx:key",bind:"bind",catch:"catch"},alipay:{if:"a:if",else:"a:else",for:"a:for",forKey:"a:key",bind:"on",catch:"catchEvent"},bytedance:{if:"tt:if",else:"tt:else",for:"tt:for",forKey:"tt:key",bind:"bind",catch:"catch"}},A=class{createElement(e){return{tag:w[e]||e,attrs:{},children:[],bindEvents:{},modelBindings:{}}}createText(e){return{tag:"__text__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}createComment(e){return{tag:"__comment__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}setAttribute(e,t,r){if(e){if(t.startsWith("lyt:")){let n=t.slice(4);this._applyDirective(e,n,r);return}if(t==="v-if"||t==="if"){e.wxIf=String(r);return}if(t==="v-else"||t==="else"){e.attrs["wx:else"]="";return}if(t==="v-for"||t==="each"){let n=String(r),i=n.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);i?(e.wxFor=i[4]||i[3],e.wxForKey=i[1]||i[3]):e.wxFor=n;return}if(t.startsWith("on")&&typeof r=="function"){let n=t.slice(2).toLowerCase(),i=u[n]||n;e.bindEvents[i]=r.name||"handleEvent";return}if(t==="v-model"||t==="model"){e.modelBindings.value=String(r);return}if(t==="class"||t==="className"){e.attrs.class=String(r);return}if(t==="style"){typeof r=="object"&&r!==null?e.attrs.style=this._styleObjectToString(r):e.attrs.style=String(r);return}if(t==="href"&&e.tag==="navigator"){e.attrs.url=String(r);return}e.attrs[t]=String(r)}}removeAttribute(e,t){if(e)if(t==="v-if"||t==="if")delete e.wxIf;else if(t==="v-for"||t==="each")delete e.wxFor,delete e.wxForKey;else if(t.startsWith("on")){let r=t.slice(2).toLowerCase(),n=u[r]||r;delete e.bindEvents[n]}else delete e.attrs[t]}setStyle(e,t){if(!e)return;let r=this._styleObjectToString(t);e.attrs.style=r}setClass(e,t){if(e){if(typeof t=="string")e.attrs.class=t;else if(typeof t=="object"&&t!==null){let r=[];for(let[n,i]of Object.entries(t))i&&r.push(n);e.attrs.class=r.join(" ")}}}insert(e,t,r){K(e,t,r)}remove(e){J(e)}replace(e,t,r){W(e,t,r)}addEventListener(e,t,r,n){if(!e)return;let i=u[t]||t;e.bindEvents[i]=r.name||"handleEvent"}removeEventListener(e,t,r){if(!e)return;let n=u[t]||t;delete e.bindEvents[n]}nextTick(e){G(e)}parentNode(e){return X(e)}nextSibling(e){return Y(e)}setText(e,t){e&&e.tag==="__text__"&&(e.text=t)}patchProp(e,t,r,n){if(e){if(n==null){this.removeAttribute(e,t);return}if(t==="style")this.setStyle(e,n);else if(t==="class"||t==="className")this.setClass(e,n);else if(t.startsWith("on")&&typeof n=="function"){let i=t.slice(2).toLowerCase(),o=u[i]||i;e.bindEvents[o]=n.name||"handleEvent"}else this.setAttribute(e,t,n)}}querySelector(e){return null}renderToMiniAppTree(e){if(!e)return this.createComment("empty vnode");if(typeof e=="string")return this.createText(e);if(e.type===Symbol.for("lyt.comment")||e.type==="comment")return this.createComment(e.children||"");if(e.type===Symbol.for("lyt.text")||e.type==="text")return this.createText(e.children||"");if(e.type===Symbol.for("lyt.fragment")||e.type==="fragment"){let t=this.createElement("__fragment__");if(Array.isArray(e.children))for(let r of e.children)this.insert(t,this.renderToMiniAppTree(r));return t}if(typeof e.type=="string"){let t=this.createElement(e.type);if(e.props)for(let[r,n]of Object.entries(e.props))r==="key"||r==="ref"||this.setAttribute(t,r,n);if(e.children){if(typeof e.children=="string")this.insert(t,this.createText(e.children));else if(Array.isArray(e.children))for(let r of e.children)this.insert(t,this.renderToMiniAppTree(r))}return t}if(typeof e.type=="object"||typeof e.type=="function"){let t=this.createElement("div");if(Array.isArray(e.children))for(let r of e.children)this.insert(t,this.renderToMiniAppTree(r));return t}return this.createComment("unknown vnode type")}serializeToWXML(e,t=0){return this._serializeToTemplate(e,t,"wechat")}serializeToAXML(e,t=0){return this._serializeToTemplate(e,t,"alipay")}serializeToTTML(e,t=0){return this._serializeToTemplate(e,t,"bytedance")}getPlatformTemplate(e,t){return this._serializeToTemplate(e,0,t)}mapDirective(e,t,r="wechat"){let n=g[r]||g.wechat,i=fe[e];if(!i)return"";switch(e){case"if":return`${n.if}="{{${t}}}"`;case"else":return`${n.else}`;case"each":{let o=t.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);if(o){let a=o[1]||o[3],c=o[4]||o[3];return`${n.for}="{{${c}}}" ${n.forKey}="{{${a}}}"`}return`${n.for}="{{${t}}}"`}case"show":return`hidden="{{!${t}}}"`;default:return`${i.attr}="${t}"`}}mapEvent(e,t="wechat"){let r=g[t]||g.wechat,n=u[e]||e;return r.bind==="on"?`on${n.charAt(0).toUpperCase()}${n.slice(1)}`:`${r.bind}${n}`}_applyDirective(e,t,r){switch(t){case"if":e.wxIf=String(r);break;case"else":e.attrs["wx:else"]="";break;case"each":{let n=String(r),i=n.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);i?(e.wxFor=i[4]||i[3],e.wxForKey=i[1]||i[3]):e.wxFor=n;break}case"show":e.attrs.hidden=String(r);break;default:e.attrs[t]=String(r)}}_styleObjectToString(e){return Object.entries(e).map(([t,r])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${r}`).join("; ")}_serializeToTemplate(e,t,r){let n=" ".repeat(t),i=g[r]||g.wechat;if(e.tag==="__text__")return`${n}${e.text||""}`;if(e.tag==="__comment__")return`${n}<!-- ${e.text||""} -->`;if(e.tag==="__fragment__")return e.children.map(l=>this._serializeToTemplate(l,t,r)).join(`
|
|
2
|
-
`);let
|
|
3
|
-
`);return`${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
1
|
+
import{registerDOMOperations as be}from"@lytjs/vdom";var b=(i=>(i[i.ELEMENT=1]="ELEMENT",i[i.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",i[i.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",i[i.TEXT_CHILDREN=8]="TEXT_CHILDREN",i[i.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",i[i.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",i))(b||{}),C=(d=>(d[d.TEXT=1]="TEXT",d[d.CLASS=2]="CLASS",d[d.STYLE=4]="STYLE",d[d.PROPS=8]="PROPS",d[d.FULL_PROPS=16]="FULL_PROPS",d[d.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",d[d.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",d[d.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",d[d.NEED_PATCH=256]="NEED_PATCH",d[d.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",d[d.HOISTED=-1]="HOISTED",d[d.BAIL=-2]="BAIL",d))(C||{}),K=Symbol("Fragment"),G=Symbol("Text"),J=Symbol("Comment");function m(s){return s.type===K}function _(s){return s.type===G}function x(s){return s.type===J}function W(s,e){return s.type===e.type&&s.key===e.key}function E(s){return Array.isArray(s.dynamicChildren)}function X(s,e,t,n){if(t==="class")s.setClass(e,n);else if(t==="style")s.setStyle(e,n);else if(t.startsWith("on")||t.startsWith("@")){let r=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();s.addEventListener(e,r,n)}else t==="key"||t==="ref"||s.setAttribute(e,t,n)}function P(s,e,t,n,r){if(t==="class")s.setClass(e,n);else if(t==="style")s.setStyle(e,n||{});else if(t.startsWith("on")||t.startsWith("@")){let o=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();r&&s.removeEventListener(e,o,r),n&&s.addEventListener(e,o,n)}else s.setAttribute(e,t,n)}function L(s,e,t,n){for(let r in n){if(r==="key"||r==="ref")continue;let o=t[r],i=n[r];i!==o&&P(s,e,r,i,o)}for(let r in t)if(!(r==="key"||r==="ref")&&!(r in n))if(r==="class")s.setClass(e,"");else if(r==="style")s.setStyle(e,{});else if(r.startsWith("on")||r.startsWith("@")){let o=r.startsWith("@")?r.slice(1).toLowerCase():r.slice(2).toLowerCase();s.removeEventListener(e,o,t[r])}else s.removeAttribute(e,r)}function $(s,e,t,n,r,o){let{shapeFlag:i}=t;if(m(t)){le(s,e,t,n,r,o);return}if(_(t)){let a=s.createText(t.children);t.el=a,s.insert(n,a,r);return}if(x(t)){let a=s.createComment(t.children);t.el=a,s.insert(n,a,r);return}if(i&1){ce(s,e,t,n,r,o);return}if(i&6){pe(e,t,n,r,o);return}}function ce(s,e,t,n,r,o){let i=t.type,a=s.createElement(i);if(t.el=a,t.props)for(let p in t.props){let u=t.props[p];X(s,a,p,u)}let{shapeFlag:c,children:l}=t;c&8?a.textContent=l:c&16&&R(e,l,a,null,o),s.insert(n,a,r)}function R(s,e,t,n,r){for(let o=0;o<e.length;o++)s(null,e[o],t,n,r)}function le(s,e,t,n,r,o){let{children:i}=t,a=s.createComment("");s.insert(n,a,r),Array.isArray(i)&&i.length>0&&R(e,i,n,a,o),t.el=a,t.anchor=a}function pe(s,e,t,n,r){let o=e.component;o&&o.update&&o.update(),o&&o.subTree&&(s(null,o.subTree,t,n,o),e.el=o.subTree.el)}function Y(s,e,t,n){let{shapeFlag:r,children:o}=t;if(m(t)){if(Array.isArray(o))for(let i=0;i<o.length;i++)e(o[i],n);t.anchor&&t.anchor.parentNode&&s.remove(t.anchor);return}if(r&6){t.component&&t.component.subTree&&e(t.component.subTree,n);return}t.el&&s.remove(t.el)}function A(s,e){for(let t=0;t<e.length;t++)s(e[t])}import{patchKeyedChildren as de,patchUnkeyedChildren as ue}from"@lytjs/vdom";function T(s,e,t,n,r,o=null,i=null){if(n==null){t&&e(t,r);return}if(t===null){$(s,O(s,e),n,r,o,i);return}if(E(n)&&E(t)){he(s,e,t,n,r,i);return}if(!W(t,n)){e(t,r),$(s,O(s,e),n,r,o,i);return}n.el=t.el,n.anchor=t.anchor;let{shapeFlag:a}=n;if(m(n)){me(s,e,t,n,r,o,i);return}if(_(n)){n.children!==t.children&&(n.el.nodeValue=n.children);return}if(x(n)){n.children!==t.children&&(n.el.nodeValue=n.children);return}if(a&1){fe(s,e,t,n,i);return}if(a&6){ye(t,n,i);return}}function O(s,e){return(t,n,r,o,i)=>{T(s,e,t,n,r,o,i)}}function fe(s,e,t,n,r=null){let o=n.el=t.el,i=t.props||{},a=n.props||{},{patchFlag:c,dynamicProps:l}=n;if(c&&c>0){if(c&1&&t.children!==n.children&&(o.textContent=n.children),c&2&&i.class!==a.class&&s.setClass(o,a.class),c&4&&i.style!==a.style&&s.setStyle(o,a.style||{}),c&8&&l)for(let p=0;p<l.length;p++){let u=l[p],d=i[u],f=a[u];f!==d&&P(s,o,u,f,d)}c&16&&L(s,o,i,a)}else L(s,o,i,a);(!c||!(c&1))&&q(s,e,t,n,o,null,r)}function q(s,e,t,n,r,o,i){let a=t.shapeFlag,c=n.shapeFlag,l=t.children,p=n.children;if(c&8){a&16&&A(e,l),l!==p&&(r.textContent=p);return}if(c&16){a&16?ge(s,e,l,p,r,o,i):(a&8&&(r.textContent=""),R(O(s,e),p,r,o,i));return}p==null&&(a&8?r.textContent="":a&16&&A(e,l))}function ge(s,e,t,n,r,o,i){n.every(c=>c.key!==null&&c.key!==void 0)&&t.every(c=>c.key!==null&&c.key!==void 0)?de(t,n,r,o,i,null,!1):ue(t,n,r,o,i,null,!1)}function me(s,e,t,n,r,o,i){let a=t.children,c=n.children;Array.isArray(c)&&c.length>0?(q(s,e,t,n,r,o,i),n.el=c[0].el,n.anchor=c[c.length-1].el?s.nextSibling(c[c.length-1].el):o):Array.isArray(a)&&a.length>0&&c===null?(A(e,a),n.el=t.el,n.anchor=t.anchor):(n.el=t.el,n.anchor=t.anchor)}function he(s,e,t,n,r,o){let i=t.dynamicChildren,a=n.dynamicChildren;for(let c=0;c<a.length;c++)T(s,e,i[c],a[c],r,null,o)}function ye(s,e,t){e.component=s.component,e.el=s.el,e.component&&e.component.update&&e.component.update()}function we(s){function e(r,o){Y(s,e,r,o)}be({insert(r,o,i){s.insert(o,r,i)},createElement(r){return s.createElement(r)},createText(r){return s.createText(r)},setText(r,o){r.nodeValue=o},setElementText(r,o){r.textContent=o},remove(r){s.remove(r)},createComment(r){return s.createComment(r)},mount(r,o,i,a,c,l,p){n(null,r,o,i,a)},patch(r,o,i,a,c,l,p,u){n(r,o,i,a,c)},unmount(r,o,i,a){e(r)},move(r,o,i){s.insert(o,r.el,i)}});function n(r,o,i,a,c){T(s,e,r,o,i,a,c)}return{mount(r,o){o.nodeType===1&&(o.textContent=""),n(null,r,o,null,null)},patch(r,o,i){var a;n(r,o,i||((a=r.el)==null?void 0:a.parentNode),null,null)},unmount(r,o){e(r,o)}}}var S={div:"view",span:"text",p:"text",h1:"text",h2:"text",h3:"text",h4:"text",h5:"text",h6:"text",img:"image",input:"input",textarea:"textarea",button:"button",scroll:"scroll-view",list:"view",a:"navigator",ul:"view",ol:"view",li:"view",form:"form",header:"view",footer:"view",nav:"view",main:"view",section:"view",article:"view",aside:"view"},g={click:"tap",input:"input",change:"change",submit:"submit",focus:"focus",blur:"blur",touchstart:"touchstart",touchend:"touchend",touchmove:"touchmove",scroll:"scroll",longpress:"longpress"};function Z(s,e,t){if(!(!s||!e)){if(e._parent){let n=e._parent,r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)}if(e._parent=s,t){let n=s.children.indexOf(t);n!==-1?s.children.splice(n,0,e):s.children.push(e)}else s.children.push(e)}}function Q(s){if(!s||!s._parent)return;let e=s._parent,t=e.children.indexOf(s);t!==-1&&e.children.splice(t,1),s._parent=void 0}function ee(s,e,t){if(!s||!e||!t)return;let n=s.children.indexOf(e);n!==-1&&(e._parent=void 0,t._parent=s,s.children[n]=t)}function te(s){var e;return(e=s==null?void 0:s._parent)!=null?e:null}function ne(s){if(!s||!s._parent)return null;let e=s._parent.children,t=e.indexOf(s);return t!==-1&&t+1<e.length?e[t+1]:null}function re(s){Promise.resolve().then(()=>s())}var ve={if:{attr:"if"},else:{attr:"else"},each:{attr:"for",prefix:""},bind:{attr:"model:"},on:{attr:"bind",prefix:""},ref:{attr:""},slot:{attr:"slot"},class:{attr:"class"},style:{attr:"style"},show:{attr:"hidden"}},h={wechat:{if:"wx:if",else:"wx:else",for:"wx:for",forKey:"wx:key",bind:"bind",catch:"catch"},alipay:{if:"a:if",else:"a:else",for:"a:for",forKey:"a:key",bind:"on",catch:"catchEvent"},bytedance:{if:"tt:if",else:"tt:else",for:"tt:for",forKey:"tt:key",bind:"bind",catch:"catch"}},w=class{createElement(e){return{tag:S[e]||e,attrs:{},children:[],bindEvents:{},modelBindings:{}}}createText(e){return{tag:"__text__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}createComment(e){return{tag:"__comment__",attrs:{},children:[],text:e,bindEvents:{},modelBindings:{}}}setAttribute(e,t,n){if(e){if(t.startsWith("lyt:")){let r=t.slice(4);this._applyDirective(e,r,n);return}if(t==="v-if"||t==="if"){e.wxIf=String(n);return}if(t==="v-else"||t==="else"){e.attrs["wx:else"]="";return}if(t==="v-for"||t==="each"){let r=String(n),o=r.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);o?(e.wxFor=o[4]||o[3],e.wxForKey=o[1]||o[3]):e.wxFor=r;return}if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),o=g[r]||r;e.bindEvents[o]=n.name||"handleEvent";return}if(t==="v-model"||t==="model"){e.modelBindings.value=String(n);return}if(t==="class"||t==="className"){e.attrs.class=String(n);return}if(t==="style"){typeof n=="object"&&n!==null?e.attrs.style=this._styleObjectToString(n):e.attrs.style=String(n);return}if(t==="href"&&e.tag==="navigator"){e.attrs.url=String(n);return}e.attrs[t]=String(n)}}removeAttribute(e,t){if(e)if(t==="v-if"||t==="if")delete e.wxIf;else if(t==="v-for"||t==="each")delete e.wxFor,delete e.wxForKey;else if(t.startsWith("on")){let n=t.slice(2).toLowerCase(),r=g[n]||n;delete e.bindEvents[r]}else delete e.attrs[t]}setStyle(e,t){if(!e)return;let n=this._styleObjectToString(t);e.attrs.style=n}setClass(e,t){if(e){if(typeof t=="string")e.attrs.class=t;else if(typeof t=="object"&&t!==null){let n=[];for(let[r,o]of Object.entries(t))o&&n.push(r);e.attrs.class=n.join(" ")}}}insert(e,t,n){Z(e,t,n)}remove(e){Q(e)}replace(e,t,n){ee(e,t,n)}addEventListener(e,t,n,r){if(!e)return;let o=g[t]||t;e.bindEvents[o]=n.name||"handleEvent"}removeEventListener(e,t,n){if(!e)return;let r=g[t]||t;delete e.bindEvents[r]}nextTick(e){re(e)}parentNode(e){return te(e)}nextSibling(e){return ne(e)}setText(e,t){e&&e.tag==="__text__"&&(e.text=t)}patchProp(e,t,n,r){if(e){if(r==null){this.removeAttribute(e,t);return}if(t==="style")this.setStyle(e,r);else if(t==="class"||t==="className")this.setClass(e,r);else if(t.startsWith("on")&&typeof r=="function"){let o=t.slice(2).toLowerCase(),i=g[o]||o;e.bindEvents[i]=r.name||"handleEvent"}else this.setAttribute(e,t,r)}}querySelector(e){return null}renderToMiniAppTree(e){if(!e)return this.createComment("empty vnode");if(typeof e=="string")return this.createText(e);if(e.type===Symbol.for("lyt.comment")||e.type==="comment")return this.createComment(e.children||"");if(e.type===Symbol.for("lyt.text")||e.type==="text")return this.createText(e.children||"");if(e.type===Symbol.for("lyt.fragment")||e.type==="fragment"){let t=this.createElement("__fragment__");if(Array.isArray(e.children))for(let n of e.children)this.insert(t,this.renderToMiniAppTree(n));return t}if(typeof e.type=="string"){let t=this.createElement(e.type);if(e.props)for(let[n,r]of Object.entries(e.props))n==="key"||n==="ref"||this.setAttribute(t,n,r);if(e.children){if(typeof e.children=="string")this.insert(t,this.createText(e.children));else if(Array.isArray(e.children))for(let n of e.children)this.insert(t,this.renderToMiniAppTree(n))}return t}if(typeof e.type=="object"||typeof e.type=="function"){let t=this.createElement("div");if(Array.isArray(e.children))for(let n of e.children)this.insert(t,this.renderToMiniAppTree(n));return t}return this.createComment("unknown vnode type")}serializeToWXML(e,t=0){return this._serializeToTemplate(e,t,"wechat")}serializeToAXML(e,t=0){return this._serializeToTemplate(e,t,"alipay")}serializeToTTML(e,t=0){return this._serializeToTemplate(e,t,"bytedance")}getPlatformTemplate(e,t){return this._serializeToTemplate(e,0,t)}mapDirective(e,t,n="wechat"){let r=h[n]||h.wechat,o=ve[e];if(!o)return"";switch(e){case"if":return`${r.if}="{{${t}}}"`;case"else":return`${r.else}`;case"each":{let i=t.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);if(i){let a=i[1]||i[3],c=i[4]||i[3];return`${r.for}="{{${c}}}" ${r.forKey}="{{${a}}}"`}return`${r.for}="{{${t}}}"`}case"show":return`hidden="{{!${t}}}"`;default:return`${o.attr}="${t}"`}}mapEvent(e,t="wechat"){let n=h[t]||h.wechat,r=g[e]||e;return n.bind==="on"?`on${r.charAt(0).toUpperCase()}${r.slice(1)}`:`${n.bind}${r}`}_applyDirective(e,t,n){switch(t){case"if":e.wxIf=String(n);break;case"else":e.attrs["wx:else"]="";break;case"each":{let r=String(n),o=r.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);o?(e.wxFor=o[4]||o[3],e.wxForKey=o[1]||o[3]):e.wxFor=r;break}case"show":e.attrs.hidden=String(n);break;default:e.attrs[t]=String(n)}}_styleObjectToString(e){return Object.entries(e).map(([t,n])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${n}`).join("; ")}_serializeToTemplate(e,t,n){let r=" ".repeat(t),o=h[n]||h.wechat;if(e.tag==="__text__")return`${r}${e.text||""}`;if(e.tag==="__comment__")return`${r}<!-- ${e.text||""} -->`;if(e.tag==="__fragment__")return e.children.map(p=>this._serializeToTemplate(p,t,n)).join(`
|
|
2
|
+
`);let i=[];for(let[p,u]of Object.entries(e.attrs)){if(p==="wx:else"){i.push(o.else);continue}i.push(`${p}="${u}"`)}e.wxIf&&i.unshift(`${o.if}="{{${e.wxIf}}}"`),e.wxFor&&(i.unshift(`${o.for}="{{${e.wxFor}}}"`),e.wxForKey&&i.unshift(`${o.forKey}="{{${e.wxForKey}}}"`));for(let[p,u]of Object.entries(e.bindEvents)){let d=o.bind==="on"?`on${p.charAt(0).toUpperCase()}${p.slice(1)}`:`${o.bind}${p}`;i.push(`${d}="${u}"`)}for(let[p,u]of Object.entries(e.modelBindings))i.push(`model:${p}="{{${u}}}"`);let a=i.length>0?" "+i.join(" "):"",c=new Set(["image","input"]);if(e.children.length===0&&c.has(e.tag))return`${r}<${e.tag}${a} />`;if(e.children.length===0)return`${r}<${e.tag}${a}></${e.tag}>`;let l=e.children.map(p=>this._serializeToTemplate(p,t+1,n)).join(`
|
|
3
|
+
`);return`${r}<${e.tag}${a}>
|
|
4
|
+
${l}
|
|
5
|
+
${r}</${e.tag}>`}};function _e(){return new w}var xe=new w;import{camelToKebab as oe,kebabToCamel as Re}from"@lytjs/common";function Ae(s){return Object.entries(s).map(([e,t])=>`${oe(e)}: ${t}`).join("; ")}function Te(s){return typeof s=="string"?s:typeof s=="object"&&s!==null?Object.entries(s).filter(([,e])=>!!e).map(([e])=>e).join(" "):""}function I(s){let e={};return s.navigationBarTitleText!==void 0&&(e.navigationBarTitleText=s.navigationBarTitleText),s.enablePullDownRefresh!==void 0&&(e.enablePullDownRefresh=s.enablePullDownRefresh),s.backgroundColor!==void 0&&(e.backgroundColor=s.backgroundColor),s.backgroundTextStyle!==void 0&&(e.backgroundTextStyle=s.backgroundTextStyle),s.navigationBarBackgroundColor!==void 0&&(e.navigationBarBackgroundColor=s.navigationBarBackgroundColor),s.navigationBarTextStyle!==void 0&&(e.navigationBarTextStyle=s.navigationBarTextStyle),s.usingComponents&&Object.keys(s.usingComponents).length>0&&(e.usingComponents=s.usingComponents),JSON.stringify(e,null,2)}function V(s){let e={component:s.component!==!1};return s.usingComponents&&Object.keys(s.usingComponents).length>0&&(e.usingComponents=s.usingComponents),JSON.stringify(e,null,2)}function j(s){let e={},t=[];for(let[n,r]of Object.entries(s))if(typeof r=="function")e[n]={type:r.name};else if(typeof r=="object"&&r!==null){let o={};if(r.type!==void 0&&(o.type=r.type),r.default!==void 0&&(o.value=r.default),r.value!==void 0&&(o.value=r.value),r.optional!==void 0&&(o.optionalTypes=r.optional),e[n]=o,r.observer){let i=typeof r.observer=="string"?r.observer:`_${n}Observer`;t.push(`${n}: function(${n}) { this.${i}(${n}); }`)}}else e[n]={type:String,value:r};return{properties:e,observers:t}}function Se(s){let e=[],t=/function\s+(\w+)\s*\(/g,n;for(;(n=t.exec(s))!==null;)e.push(n[1]);let r=[],o=/(?:const|let|var)\s+(\w+)\s*=/g;for(;(n=o.exec(s))!==null;)r.push(n[1]);let i=[];for(let c of e)i.push(` ${c}: ${c}`);for(let c of r)i.push(` ${c}: ${c}`);return`${i.length>0?`module.exports = {
|
|
6
|
+
${i.join(`,
|
|
7
7
|
`)}
|
|
8
8
|
};`:"module.exports = {};"}
|
|
9
9
|
|
|
10
10
|
// Original code:
|
|
11
|
-
${s}`}var
|
|
11
|
+
${s}`}var Me={"&":"&","<":"<",">":">",'"':""","'":"'"},Ne=/[&<>"']/g;function ke(s){return s.replace(Ne,e=>Me[e]||e)}var Ce=new Set(["view","scroll-view","swiper","swiper-item","movable-view","movable-area","cover-view","cover-image","text","rich-text","progress","button","form","input","textarea","checkbox","checkbox-group","radio","radio-group","switch","slider","picker","picker-view","picker-view-column","navigator","audio","image","video","camera","live-player","live-pusher","map","canvas","ad","official-account","open-data","web-view","page-container","aria-component"]);function Ee(s){return Ce.has(s.toLowerCase())}var Pe={wechat:{if:"wx:if",elif:"wx:elif",else:"wx:else",for:"wx:for",forItem:"wx:for-item",forIndex:"wx:for-index",forKey:"wx:key",bind:"bind",catch:"catch",model:"model",slot:"slot"},alipay:{if:"a:if",elif:"a:elif",else:"a:else",for:"a:for",forItem:"a:for-item",forIndex:"a:for-index",forKey:"a:key",bind:"on",catch:"catchEvent",model:"model",slot:"slot"},bytedance:{if:"tt:if",elif:"tt:elif",else:"tt:else",for:"tt:for",forItem:"tt:for-item",forIndex:"tt:for-index",forKey:"tt:key",bind:"bind",catch:"catch",model:"model",slot:"slot"}},Le={click:"tap",dblclick:"tap",input:"input",change:"change",submit:"submit",focus:"focus",blur:"blur",touchstart:"touchstart",touchend:"touchend",touchmove:"touchmove",scroll:"scroll",longpress:"longpress",keydown:"confirm",keyup:"confirm",keypress:"confirm"},D=class{compile(e,t){let{template:n,style:r,script:o}=this._extractTags(e),i=this._extractData(o);return{template:this._transformTemplate(n,t),style:r,script:o,data:i}}compilePage(e,t){let n=this.compile(e.template,t),r={...n.data,...e.data||{}},o={...e.methods||{}},i=this._generatePageJs(r,o,e,t),a=I({});return{wxml:n.template,wxss:n.style,js:i,json:a}}compileComponent(e,t){let n=this.compile(e.template,t),r={...n.data,...e.data||{}},o={...e.methods||{}},i={},a=[];if(e.props)if(Array.isArray(e.props))for(let p of e.props)i[p]={type:null};else{let p=j(e.props);i=p.properties,a=p.observers}let c=this._generateComponentJs(i,r,o,a,t),l=V({component:!0});return{wxml:n.template,wxss:n.style,js:c,json:l}}_transformTemplate(e,t){let n=Pe[t],r=e;return r=this._transformTags(r),r=this._transformConditional(r,n),r=this._transformIteration(r,n),r=this._transformEvents(r,t,n),r=this._transformModelBindings(r,n),r=this._transformSlots(r,n),r=this._transformRefs(r),r=this._transformShow(r),r=this._transformAttributeBindings(r),r=this._cleanupLytDirectives(r),r}_transformTags(e){let t=/<\/?([a-zA-Z][a-zA-Z0-9-]*)/g;return e.replace(t,(n,r)=>{let o=r.toLowerCase(),i=S[o];return i?n.replace(r,i):n})}_transformConditional(e,t){let n=e.replace(/lyt:if="([^"]*)"/g,(r,o)=>`${t.if}="{{${o}}}"`);return n=n.replace(/v-if="([^"]*)"/g,(r,o)=>`${t.if}="{{${o}}}"`),n=n.replace(/lyt:elif="([^"]*)"/g,(r,o)=>`${t.elif}="{{${o}}}"`),n=n.replace(/v-else-if="([^"]*)"/g,(r,o)=>`${t.elif}="{{${o}}}"`),n=n.replace(/\blyt:else\b/g,t.else),n=n.replace(/\bv-else\b/g,t.else),n}_transformIteration(e,t){let n=o=>{let i=o.match(/(?:\((\w+),\s*(\w+)\)|(\w+))\s+in\s+(.+)/);if(i){let a=i[1]||i[3],c=i[2],l=i[4].trim(),p=`${t.for}="{{${l}}}" ${t.forItem}="${a}" ${t.forKey}="${a}"`;return c&&(p+=` ${t.forIndex}="${c}"`),p}return`${t.for}="{{${o.trim()}}}"`},r=e.replace(/lyt:each="([^"]*)"/g,(o,i)=>n(i));return r=r.replace(/v-for="([^"]*)"/g,(o,i)=>n(i)),r}_transformEvents(e,t,n){let r=/@(\w+)(?:\.(\w+))*="([^"]*)"/g;return e.replace(r,(o,i,a,c)=>{let l=Le[i.toLowerCase()]||i.toLowerCase();return a==="stop"||a==="prevent"?t==="alipay"?`catchEvent${this._capitalize(l)}="${c}"`:`${n.catch}${l}="${c}"`:a==="capture"?`capture-bind:${l}="${c}"`:t==="alipay"?`on${this._capitalize(l)}="${c}"`:`${n.bind}${l}="${c}"`})}_transformModelBindings(e,t){let n=e.replace(/:value="([^"]*)"/g,(r,o)=>`${t.model}:value="{{${o}}}"`);return n=n.replace(/v-model="([^"]*)"/g,(r,o)=>`${t.model}:value="{{${o}}}"`),n=n.replace(/:checked="([^"]*)"/g,(r,o)=>`${t.model}:checked="{{${o}}}"`),n}_transformSlots(e,t){return e}_transformRefs(e){return e.replace(/\bref="([^"]*)"/g,'id="$1"')}_transformShow(e){let t=e.replace(/lyt:show="([^"]*)"/g,(n,r)=>`hidden="{{!${r}}}"`);return t=t.replace(/v-show="([^"]*)"/g,(n,r)=>`hidden="{{!${r}}}"`),t}_transformAttributeBindings(e){let t=/:([a-zA-Z][a-zA-Z0-9-]*)="([^"]*)"/g;return e.replace(t,(n,r,o)=>r==="value"||r==="checked"?n:`${r}="{{${o}}}"`)}_cleanupLytDirectives(e){return e.replace(/\s*lyt:[a-zA-Z-]+(?:="[^"]*")?/g,"")}_extractTags(e){let t=e,n="",r="",o=e.match(/<style[^>]*>([\s\S]*?)<\/style>/i);o&&(n=o[1].trim(),t=t.replace(o[0],""));let i=e.match(/<script[^>]*>([\s\S]*?)<\/script>/i);return i&&(r=i[1].trim(),t=t.replace(i[0],"")),t=t.trim(),{template:t,style:n,script:r}}_extractData(e){let t={};if(!e)return t;let n=e.match(/data\s*:\s*(\{[\s\S]*?\})(?:\s*[,}])/);if(n)try{let o=n[1];this._parseSimpleObject(o,t)}catch(o){}let r=e.match(/data\s*\(\s*\)\s*\{[\s\S]*?return\s*(\{[\s\S]*?\})\s*;?\s*\}/);if(r)try{let o=r[1];this._parseSimpleObject(o,t)}catch(o){}return t}_parseSimpleObject(e,t){let n=e.replace(/^\s*\{/,"").replace(/\}\s*$/,"").trim();if(!n)return;let r=n.split(/\n|,/);for(let o of r){let i=o.trim();if(!i)continue;let a=i.match(/^(\w+)\s*:\s*(.+)$/);if(a){let c=a[1],l=a[2].trim().replace(/[,;]\s*$/,"");l==="true"?t[c]=!0:l==="false"?t[c]=!1:l==="null"?t[c]=null:l==="undefined"?t[c]=void 0:/^'[^']*'$/.test(l)||/^"[^"]*"$/.test(l)?t[c]=l.slice(1,-1):/^-?\d+$/.test(l)?t[c]=parseInt(l,10):/^-?\d+\.\d+$/.test(l)?t[c]=parseFloat(l):(/^\[/.test(l)||/^\{/.test(l),t[c]=l)}}}_generatePageJs(e,t,n,r){let o=[];o.push("// Auto-generated by MiniAppCompiler"),o.push(`// Platform: ${r}`),o.push(""),o.push("Page({"),o.push(" data: "+JSON.stringify(e,null,4).split(`
|
|
12
12
|
`).map((a,c)=>c===0?a:" "+a).join(`
|
|
13
|
-
`)+","),
|
|
14
|
-
`))
|
|
15
|
-
`)}_generateComponentJs(e,t,r,
|
|
16
|
-
`).map((c,
|
|
17
|
-
`)+","),
|
|
18
|
-
`).map((c,
|
|
19
|
-
`)+","),
|
|
20
|
-
`))
|
|
21
|
-
`)}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}_extractParamNames(e){let t=e.match(/(?:function\s*\w*\s*|\w+\s*=>\s*(?:\([^)]*\)|([^)]*)))\s*\(?([^)]*)\)?/);if(t&&t[2])return t[2].split(",").map(i=>i.trim()).filter(Boolean);let r=e.match(/\(([^)]*)\)\s*=>/);if(r)return r[1].split(",").map(i=>i.trim()).filter(Boolean);let n=e.match(/(\w+)\s*=>/);return n?[n[1].trim()]:[]}};var q={click:{wechat:"tap",alipay:"tap",bytedance:"tap"},dblclick:{wechat:"tap",alipay:"tap",bytedance:"tap"},input:{wechat:"input",alipay:"input",bytedance:"input"},change:{wechat:"change",alipay:"change",bytedance:"change"},submit:{wechat:"submit",alipay:"submit",bytedance:"submit"},focus:{wechat:"focus",alipay:"focus",bytedance:"focus"},blur:{wechat:"blur",alipay:"blur",bytedance:"blur"},touchstart:{wechat:"touchstart",alipay:"touchStart",bytedance:"touchstart"},touchend:{wechat:"touchend",alipay:"touchEnd",bytedance:"touchend"},touchmove:{wechat:"touchmove",alipay:"touchMove",bytedance:"touchmove"},touchcancel:{wechat:"touchcancel",alipay:"touchCancel",bytedance:"touchcancel"},scroll:{wechat:"scroll",alipay:"scroll",bytedance:"scroll"},longpress:{wechat:"longpress",alipay:"longTap",bytedance:"longpress"},keydown:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keyup:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keypress:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"}},Me={wechat:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"},alipay:{bind:"on",catch:"catchEvent",captureBind:"capture-bind:",captureCatch:"capture-catch:"},bytedance:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"}},O=class{constructor(e,t){this._customEventListeners={};this._platform=e,this._componentInstance=t,this._bubblingEnabled=!0,this._capturingEnabled=!0}normalizeEvent(e,t){let r=t||this._platform,n=e.toLowerCase(),i=q[n];return i?i[r]:r==="alipay"?e.charAt(0).toLowerCase()+e.slice(1):n}getBindName(e,t){let r=this.normalizeEvent(e),n=Me[this._platform];return t!=null&&t.capture?`${n.captureBind}${r}`:t!=null&&t.stop?this._platform==="alipay"?`${n.catch}${this._capitalize(r)}`:`${n.catch}${r}`:this._platform==="alipay"?`${n.bind}${this._capitalize(r)}`:`${n.bind}${r}`}parseEventArgs(e,t){let r=t||this._platform,n=e[0]||{},i={type:n.type||"",timeStamp:n.timeStamp||Date.now(),target:this._normalizeTarget(n.target||{}),currentTarget:this._normalizeTarget(n.currentTarget||{}),detail:n.detail||{},bubbles:n.bubbles!==!1,cancelable:n.cancelable!==!1,defaultPrevented:!1,propagationStopped:!1},o=n.detail||{};return r==="wechat"||r==="alipay"&&!o.value&&n.value!==void 0&&(i.detail.value=n.value),{nativeEvent:i,detail:o}}_normalizeTarget(e){return{id:e.id||"",dataset:e.dataset||{}}}createDataBinder(e){let t=this;return{get(){if(!t._componentInstance)return;let r=t._componentInstance.data||{};return t._getNestedValue(r,e)},set(r){t._componentInstance&&(typeof t._componentInstance.setData=="function"?t._componentInstance.setData({[e]:r}):t._setNestedValue(t._componentInstance.data||{},e,r))}}}_getNestedValue(e,t){let r=t.split("."),n=e;for(let i of r){if(n==null)return;n=n[i]}return n}_setNestedValue(e,t,r){let n=t.split("."),i=e;for(let o=0;o<n.length-1;o++){let a=n[o];i[a]==null&&(i[a]={}),i=i[a]}i[n[n.length-1]]=r}createBridgeHandler(e){let t={},r=this;for(let[n]of Object.entries(q)){let i=this.getBindName(n),o=this.normalizeEvent(n);t[i]=function(a,...c){let p=r.parseEventArgs([a,...c]);return r._bubblingEnabled&&r._emitCustomEvent(e,n,p.detail,p.nativeEvent),p},t[o]=t[i]}return t.handleEvent=function(n){return r.parseEventArgs([n])},t}on(e,t){this._customEventListeners[e]||(this._customEventListeners[e]=[]),this._customEventListeners[e].push(t)}off(e,t){if(this._customEventListeners[e])if(t){let r=this._customEventListeners[e].indexOf(t);r!==-1&&this._customEventListeners[e].splice(r,1)}else delete this._customEventListeners[e]}_emitCustomEvent(e,t,r,n){let i=this._customEventListeners[t];if(!(!i||i.length===0)){for(let o of i)try{o(r,n)}catch(a){}this._componentInstance&&typeof this._componentInstance.triggerEvent=="function"&&this._componentInstance.triggerEvent(t,r,{bubbles:(n==null?void 0:n.bubbles)!==!1,composed:!0,capturePhase:!1})}}$emit(e,t){this._emitCustomEvent("__self__",e,t||{})}enableBubbling(){this._bubblingEnabled=!0}disableBubbling(){this._bubblingEnabled=!1}enableCapturing(){this._capturingEnabled=!0}disableCapturing(){this._capturingEnabled=!1}isBubblingEnabled(){return this._bubblingEnabled}isCapturingEnabled(){return this._capturingEnabled}setComponentInstance(e){this._componentInstance=e}getComponentInstance(){return this._componentInstance}getPlatform(){return this._platform}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}};var V={setup:{lytHook:"setup",platformHook:"data + attached",description:"setup() \u8FD4\u56DE\u503C\u4F5C\u4E3A data\uFF0C\u903B\u8F91\u5728 attached() \u4E2D\u6267\u884C",hasDirectMapping:!1},onBeforeMount:{lytHook:"onBeforeMount",platformHook:"created / onLoad",description:"\u9875\u9762\u4F7F\u7528 onLoad\uFF0C\u7EC4\u4EF6\u4F7F\u7528 created",hasDirectMapping:!0},onMounted:{lytHook:"onMounted",platformHook:"ready",description:"\u9875\u9762\u548C\u7EC4\u4EF6\u5747\u4F7F\u7528 ready",hasDirectMapping:!0},onUpdated:{lytHook:"onUpdated",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u901A\u8FC7 observers \u6216 setData \u56DE\u8C03\u6A21\u62DF",hasDirectMapping:!1},onBeforeUnmount:{lytHook:"onBeforeUnmount",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u5728 detached \u4E2D\u624B\u52A8\u5904\u7406",hasDirectMapping:!1},onUnmounted:{lytHook:"onUnmounted",platformHook:"detached / onUnload",description:"\u7EC4\u4EF6\u4F7F\u7528 detached\uFF0C\u9875\u9762\u4F7F\u7528 onUnload",hasDirectMapping:!0},onErrorCaptured:{lytHook:"onErrorCaptured",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u5C0F\u7A0B\u5E8F\u65E0\u76F4\u63A5\u5BF9\u5E94\uFF0C\u53EF\u5728\u65B9\u6CD5\u4E2D try-catch",hasDirectMapping:!1},onLoad:{lytHook:"onLoad",platformHook:"onLoad",description:"\u9875\u9762\u52A0\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onShow:{lytHook:"onShow",platformHook:"onShow",description:"\u9875\u9762\u663E\u793A\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onReady:{lytHook:"onReady",platformHook:"onReady",description:"\u9875\u9762\u521D\u6B21\u6E32\u67D3\u5B8C\u6210\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onHide:{lytHook:"onHide",platformHook:"onHide",description:"\u9875\u9762\u9690\u85CF\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onUnload:{lytHook:"onUnload",platformHook:"onUnload",description:"\u9875\u9762\u5378\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},created:{lytHook:"created",platformHook:"created",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u521B\u5EFA\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},attached:{lytHook:"attached",platformHook:"attached",description:"\u7EC4\u4EF6\u8FDB\u5165\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},ready:{lytHook:"ready",platformHook:"ready",description:"\u7EC4\u4EF6\u5E03\u5C40\u5B8C\u6210\u540E\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},moved:{lytHook:"moved",platformHook:"moved",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u88AB\u79FB\u52A8\u5230\u8282\u70B9\u6811\u53E6\u4E00\u4E2A\u4F4D\u7F6E\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},detached:{lytHook:"detached",platformHook:"detached",description:"\u7EC4\u4EF6\u79BB\u5F00\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0}},Ee={onBeforeMount:"onLoad",onMounted:"onReady",onUnmounted:"onUnload",onShow:"onShow",onHide:"onHide",onReady:"onReady",onLoad:"onLoad",onUnload:"onUnload"},Q={onBeforeMount:"created",onMounted:"ready",onUnmounted:"detached",onReady:"ready",created:"created",attached:"attached",moved:"moved",detached:"detached"},H=class{constructor(e){this._platform=e}mapLifecycle(e,t){let r=V[e];return r?r.platformHook:e}getLifecycleMapping(e){return V[e]||null}getAllMappings(){return Object.values(V)}createPageLifecycle(e){let t={};for(let[r,n]of Object.entries(e)){if(typeof n!="function")continue;let i=Ee[r];if(i)if(t[i]){let o=t[i];t[i]=function(...a){o.apply(this,a),n.apply(this,a)}}else t[i]=n;else t[r]=n}return t}createComponentLifecycle(e){let t={},r={},n=null;for(let[i,o]of Object.entries(e)){if(typeof o!="function")continue;if(i==="setup"){let c=o.call({});c&&typeof c=="object"&&(n=c);continue}let a=Q[i];if(a)if(r[a]){let c=r[a];r[a]=function(...p){c.apply(this,p),o.apply(this,p)}}else r[a]=o;else t.methods||(t.methods={}),t.methods[i]=o}return Object.keys(r).length>0&&(t.lifetimes=r),n&&(t.data=n),t}wrapComponent(e,t){let r=t||this._platform,n={};if(e.setup&&typeof e.setup=="function"){let a=e.setup.call({});a&&typeof a=="object"?n.data={...a||{},...e.data||{}}:n.data=e.data||{}}else n.data=e.data||{};if(e.props){if(Array.isArray(e.props)){let a={};for(let c of e.props)a[c]={type:null};n.properties=a}else if(typeof e.props=="object"){let a={};for(let[c,p]of Object.entries(e.props))if(typeof p=="function")a[c]={type:p.name};else if(typeof p=="object"&&p!==null){let l={};p.type&&(l.type=p.type),p.default!==void 0&&(l.value=p.default),p.value!==void 0&&(l.value=p.value),a[c]=l}else a[c]={type:null,value:p};n.properties=a}}let i={},o=["onBeforeMount","onMounted","onUpdated","onUnmounted","onBeforeUnmount","onErrorCaptured","created","attached","ready","moved","detached"];for(let a of o)if(e[a]&&typeof e[a]=="function"){let c=Q[a];c&&(i[c]=e[a])}if(Object.keys(i).length>0&&(n.lifetimes=i),e.methods&&typeof e.methods=="object"?n.methods={...e.methods}:n.methods={},e.computed&&typeof e.computed=="object"){let a={};for(let[c,p]of Object.entries(e.computed))if(typeof p=="function")try{let l=p.call(n.data);n.data[c]=l}catch(l){}}if(e.watch&&typeof e.watch=="object"){n.observers||(n.observers={});for(let[a,c]of Object.entries(e.watch))if(typeof c=="function")n.observers[a]=c;else if(Array.isArray(c)){let p=c.filter(l=>typeof l=="function");p.length>0&&(n.observers[a]=function(...l){for(let f of p)f.apply(this,l)})}}return e.observers&&typeof e.observers=="object"&&(n.observers||(n.observers={}),Object.assign(n.observers,e.observers)),(e.onLoad||e.onShow||e.onHide||e.onPullDownRefresh||e.onReachBottom||e.onShareAppMessage)&&(e.onLoad&&(n.onLoad=e.onLoad),e.onShow&&(n.onShow=e.onShow),e.onHide&&(n.onHide=e.onHide),e.onPullDownRefresh&&(n.onPullDownRefresh=e.onPullDownRefresh),e.onReachBottom&&(n.onReachBottom=e.onReachBottom),e.onShareAppMessage&&(n.onShareAppMessage=e.onShareAppMessage)),n}getPlatform(){return this._platform}setPlatform(e){this._platform=e}getPlatformLifecycleDifferences(e){let t=e||this._platform;return t==="alipay"?{created:"created\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"didMount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didMount \u66FF\u4EE3 ready\uFF09",detached:"didUnmount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didUnmount \u66FF\u4EE3 detached\uFF09",onLoad:"onLoad\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09"}:t==="bytedance"?{created:"created\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"ready\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",detached:"detached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",onLoad:"onLoad\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09"}:{created:"created",attached:"attached",ready:"ready",moved:"moved",detached:"detached",onLoad:"onLoad",onShow:"onShow",onReady:"onReady",onHide:"onHide",onUnload:"onUnload"}}};export{I as Comment,j as Fragment,k as MiniAppCompiler,O as MiniAppEventBridge,H as MiniAppLifecycleAdapter,A as MiniAppRenderer,M as PatchFlags,h as ShapeFlags,D as Text,Z as camelToKebab,de as createRenderer,ye as createWxsModule,Ne as escapeHtml,P as generateComponentJson,$ as generatePageJson,xe as isNativeTag,me as kebabToCamel,ue as miniAppRenderer,S as normalizeProps,he as parseClassObject,ge as parseStyleObject};
|
|
13
|
+
`)+","),n.onLoad&&(o.push(""),o.push(" onLoad(options) {"),o.push(" // Lyt.js onBeforeMount -> onLoad"),o.push(" },")),n.onShow&&(o.push(""),o.push(" onShow() {"),o.push(" // Lyt.js onShow"),o.push(" },")),n.onReady&&(o.push(""),o.push(" onReady() {"),o.push(" // Lyt.js onMounted -> onReady"),o.push(" },"));let i=Object.entries(t);if(i.length>0){o.push("");for(let[a,c]of i){let l=c.toString(),p=l.match(/(?:function\s*\w*\s*\(|=>\s*\{?\s*)([\s\S]*)/),u=p?p[1].trim().replace(/^\{|\}$/g,"").trim():"";if(o.push(` ${a}(${this._extractParamNames(l).join(", ")}) {`),u)for(let d of u.split(`
|
|
14
|
+
`))o.push(` ${d}`);o.push(" },")}}return o.push("});"),o.join(`
|
|
15
|
+
`)}_generateComponentJs(e,t,n,r,o){let i=[];if(i.push("// Auto-generated by MiniAppCompiler"),i.push(`// Platform: ${o}`),i.push(""),i.push("Component({"),Object.keys(e).length>0&&i.push(" properties: "+JSON.stringify(e,null,4).split(`
|
|
16
|
+
`).map((c,l)=>l===0?c:" "+c).join(`
|
|
17
|
+
`)+","),i.push(" data: "+JSON.stringify(t,null,4).split(`
|
|
18
|
+
`).map((c,l)=>l===0?c:" "+c).join(`
|
|
19
|
+
`)+","),r.length>0){i.push(""),i.push(" observers: {");for(let c of r)i.push(` ${c},`);i.push(" },")}i.push(""),i.push(" lifetimes: {"),i.push(" attached() {"),i.push(" // Lyt.js setup -> attached"),i.push(" },"),i.push(" ready() {"),i.push(" // Lyt.js onMounted -> ready"),i.push(" },"),i.push(" detached() {"),i.push(" // Lyt.js onUnmounted -> detached"),i.push(" },"),i.push(" },");let a=Object.entries(n);if(a.length>0){i.push(""),i.push(" methods: {");for(let[c,l]of a){let p=l.toString(),u=p.match(/(?:function\s*\w*\s*\(|=>\s*\{?\s*)([\s\S]*)/),d=u?u[1].trim().replace(/^\{|\}$/g,"").trim():"";if(i.push(` ${c}(${this._extractParamNames(p).join(", ")}) {`),d)for(let f of d.split(`
|
|
20
|
+
`))i.push(` ${f}`);i.push(" },")}i.push(" },")}return i.push("});"),i.join(`
|
|
21
|
+
`)}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}_extractParamNames(e){let t=e.match(/(?:function\s*\w*\s*|\w+\s*=>\s*(?:\([^)]*\)|([^)]*)))\s*\(?([^)]*)\)?/);if(t&&t[2])return t[2].split(",").map(o=>o.trim()).filter(Boolean);let n=e.match(/\(([^)]*)\)\s*=>/);if(n)return n[1].split(",").map(o=>o.trim()).filter(Boolean);let r=e.match(/(\w+)\s*=>/);return r?[r[1].trim()]:[]}};var $e=/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]+))?\s*\)/g,Oe=new Set(["position: fixed","position: sticky","z-index","overflow: overlay","backdrop-filter","-webkit-backdrop-filter","mask-image","-webkit-mask-image","clip-path","filter: drop-shadow","writing-mode","text-orientation"]),Ie=new Set([":active",":hover"]),M=class{constructor(){this._scopeIdCounter=0}compile(e,t={}){let{scoped:n=!1,scopeId:r,pxToRpx:o=!1,rpxRatio:i=2,transformCssVariables:a=!0,cssVariables:c={},platform:l="wechat"}=t,p=r||this._generateScopeId(),u={cssVariablesTransformed:0,pxTransformed:0,scopedSelectorsAdded:0},d=e;if(d=this._removeComments(d),a&&Object.keys(c).length>0){let{code:f,count:y}=this._transformCssVariables(d,c);d=f,u.cssVariablesTransformed=y}if(o){let{code:f,count:y}=this._transformPxToRpx(d,i);d=f,u.pxTransformed=y}if(d=this._handleUnsupportedPseudoSelectors(d),d=this._handleUnsupportedProperties(d,l),n){let{code:f,count:y}=this._applyScoped(d,p);d=f,u.scopedSelectorsAdded=y}return d=this._handleImports(d),d=this._cleanup(d),{code:d,scopeId:p,stats:u}}compileScoped(e,t,n={}){return this.compile(e,{...n,scoped:!0,scopeId:t})}transformCssVariables(e,t){let{code:n}=this._transformCssVariables(e,t);return n}transformPxToRpx(e,t=2){let{code:n}=this._transformPxToRpx(e,t);return n}_generateScopeId(){return`data-v-${(++this._scopeIdCounter).toString(16).padStart(8,"0")}`}_removeComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}_transformCssVariables(e,t){let n=0;return{code:e.replace($e,(o,i,a)=>{let c=t[i];return c!==void 0?(n++,c):a!==void 0?(n++,a.trim()):o}),count:n}}_transformPxToRpx(e,t){let n=0,r=/\b(\d+(?:\.\d+)?)px\b/g;return{code:e.replace(r,(i,a)=>{let c=parseFloat(a);return c===0?"0px":(n++,`${Math.round(c*t)}rpx`)}),count:n}}_handleUnsupportedPseudoSelectors(e){let t=/([^{}@]+)(:not\([^)]*\)|:nth-child\([^)]*\)|:first-child|:last-child|:nth-of-type\([^)]*\)|:only-child|:only-of-type|:empty|:checked|:disabled|:enabled|:focus|:visited|:link|:before|:after|::before|::after)([^{]*)\{/g;return e.replace(t,(n,r,o,i)=>{let a=o.split("(")[0].trim();return Ie.has(a)?n:`${r}${i}{`})}_handleUnsupportedProperties(e,t){let n=e.split(`
|
|
22
|
+
`),r=[];for(let o of n){let i=o.trim(),a=!1;for(let c of Oe)if(i.includes(c)){a=!0;break}a||r.push(o)}return r.join(`
|
|
23
|
+
`)}_applyScoped(e,t){let n=0,r=!1,o=0,i=e.split(`
|
|
24
|
+
`),a=[];for(let c of i){let l=c.trim();if(l.startsWith("@media")){r=!0,a.push(c);continue}if(o+=(l.match(/{/g)||[]).length,o-=(l.match(/}/g)||[]).length,r&&o<=0){r=!1,a.push(c);continue}if(l.startsWith("@keyframes")||l.startsWith("@font-face")){a.push(c);continue}if(!l||l==="{"||l==="}"){a.push(c);continue}if(l.endsWith("{")&&!l.startsWith("@")){let p=l.slice(0,-1).trim(),u=this._addScopeToSelector(p,t);a.push(` ${u} {`),n++}else a.push(c)}return{code:a.join(`
|
|
25
|
+
`),count:n}}_addScopeToSelector(e,t){return e.split(",").map(o=>o.trim()).map(o=>{let i=o.lastIndexOf("["),a=o.lastIndexOf("(");return i>a&&i!==-1?o.slice(0,i)+`[${t}]`+o.slice(i):`${o}[${t}]`}).join(", ")}_handleImports(e){return e.replace(/@import\s+['"]([^'"]+)['"]\s*;/g,(t,n)=>n.startsWith("http://")||n.startsWith("https://")?`/* Remote @import removed: ${n} */`:t)}_cleanup(e){return e.replace(/\n{3,}/g,`
|
|
26
|
+
|
|
27
|
+
`).trim()}},ie=new M;function Ve(s,e){return ie.compile(s,e)}var se={click:{wechat:"tap",alipay:"tap",bytedance:"tap"},dblclick:{wechat:"tap",alipay:"tap",bytedance:"tap"},input:{wechat:"input",alipay:"input",bytedance:"input"},change:{wechat:"change",alipay:"change",bytedance:"change"},submit:{wechat:"submit",alipay:"submit",bytedance:"submit"},focus:{wechat:"focus",alipay:"focus",bytedance:"focus"},blur:{wechat:"blur",alipay:"blur",bytedance:"blur"},touchstart:{wechat:"touchstart",alipay:"touchStart",bytedance:"touchstart"},touchend:{wechat:"touchend",alipay:"touchEnd",bytedance:"touchend"},touchmove:{wechat:"touchmove",alipay:"touchMove",bytedance:"touchmove"},touchcancel:{wechat:"touchcancel",alipay:"touchCancel",bytedance:"touchcancel"},scroll:{wechat:"scroll",alipay:"scroll",bytedance:"scroll"},longpress:{wechat:"longpress",alipay:"longTap",bytedance:"longpress"},keydown:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keyup:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"},keypress:{wechat:"confirm",alipay:"confirm",bytedance:"confirm"}},je={wechat:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"},alipay:{bind:"on",catch:"catchEvent",captureBind:"capture-bind:",captureCatch:"capture-catch:"},bytedance:{bind:"bind",catch:"catch",captureBind:"capture-bind:",captureCatch:"capture-catch:"}},F=class{constructor(e,t){this._customEventListeners={};this._platform=e,this._componentInstance=t,this._bubblingEnabled=!0,this._capturingEnabled=!0}normalizeEvent(e,t){let n=t||this._platform,r=e.toLowerCase(),o=se[r];return o?o[n]:n==="alipay"?e.charAt(0).toLowerCase()+e.slice(1):r}getBindName(e,t){let n=this.normalizeEvent(e),r=je[this._platform];return t!=null&&t.capture?`${r.captureBind}${n}`:t!=null&&t.stop?this._platform==="alipay"?`${r.catch}${this._capitalize(n)}`:`${r.catch}${n}`:this._platform==="alipay"?`${r.bind}${this._capitalize(n)}`:`${r.bind}${n}`}parseEventArgs(e,t){let n=t||this._platform,r=e[0]||{},o={type:r.type||"",timeStamp:r.timeStamp||Date.now(),target:this._normalizeTarget(r.target||{}),currentTarget:this._normalizeTarget(r.currentTarget||{}),detail:r.detail||{},bubbles:r.bubbles!==!1,cancelable:r.cancelable!==!1,defaultPrevented:!1,propagationStopped:!1},i=r.detail||{};return n==="wechat"||n==="alipay"&&!i.value&&r.value!==void 0&&(o.detail.value=r.value),{nativeEvent:o,detail:i}}_normalizeTarget(e){return{id:e.id||"",dataset:e.dataset||{}}}createDataBinder(e){let t=this;return{get(){if(!t._componentInstance)return;let n=t._componentInstance.data||{};return t._getNestedValue(n,e)},set(n){t._componentInstance&&(typeof t._componentInstance.setData=="function"?t._componentInstance.setData({[e]:n}):t._setNestedValue(t._componentInstance.data||{},e,n))}}}_getNestedValue(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null)return;r=r[o]}return r}_setNestedValue(e,t,n){let r=t.split("."),o=e;for(let i=0;i<r.length-1;i++){let a=r[i];o[a]==null&&(o[a]={}),o=o[a]}o[r[r.length-1]]=n}createBridgeHandler(e){let t={},n=this;for(let[r]of Object.entries(se)){let o=this.getBindName(r),i=this.normalizeEvent(r);t[o]=function(a,...c){let l=n.parseEventArgs([a,...c]);return n._bubblingEnabled&&n._emitCustomEvent(e,r,l.detail,l.nativeEvent),l},t[i]=t[o]}return t.handleEvent=function(r){return n.parseEventArgs([r])},t}on(e,t){this._customEventListeners[e]||(this._customEventListeners[e]=[]),this._customEventListeners[e].push(t)}off(e,t){if(this._customEventListeners[e])if(t){let n=this._customEventListeners[e].indexOf(t);n!==-1&&this._customEventListeners[e].splice(n,1)}else delete this._customEventListeners[e]}_emitCustomEvent(e,t,n,r){let o=this._customEventListeners[t];if(!(!o||o.length===0)){for(let i of o)try{i(n,r)}catch(a){}this._componentInstance&&typeof this._componentInstance.triggerEvent=="function"&&this._componentInstance.triggerEvent(t,n,{bubbles:(r==null?void 0:r.bubbles)!==!1,composed:!0,capturePhase:!1})}}$emit(e,t){this._emitCustomEvent("__self__",e,t||{})}enableBubbling(){this._bubblingEnabled=!0}disableBubbling(){this._bubblingEnabled=!1}enableCapturing(){this._capturingEnabled=!0}disableCapturing(){this._capturingEnabled=!1}isBubblingEnabled(){return this._bubblingEnabled}isCapturingEnabled(){return this._capturingEnabled}setComponentInstance(e){this._componentInstance=e}getComponentInstance(){return this._componentInstance}getPlatform(){return this._platform}_capitalize(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}};var H={setup:{lytHook:"setup",platformHook:"data + attached",description:"setup() \u8FD4\u56DE\u503C\u4F5C\u4E3A data\uFF0C\u903B\u8F91\u5728 attached() \u4E2D\u6267\u884C",hasDirectMapping:!1},onBeforeMount:{lytHook:"onBeforeMount",platformHook:"created / onLoad",description:"\u9875\u9762\u4F7F\u7528 onLoad\uFF0C\u7EC4\u4EF6\u4F7F\u7528 created",hasDirectMapping:!0},onMounted:{lytHook:"onMounted",platformHook:"ready",description:"\u9875\u9762\u548C\u7EC4\u4EF6\u5747\u4F7F\u7528 ready",hasDirectMapping:!0},onUpdated:{lytHook:"onUpdated",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u901A\u8FC7 observers \u6216 setData \u56DE\u8C03\u6A21\u62DF",hasDirectMapping:!1},onBeforeUnmount:{lytHook:"onBeforeUnmount",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u53EF\u5728 detached \u4E2D\u624B\u52A8\u5904\u7406",hasDirectMapping:!1},onUnmounted:{lytHook:"onUnmounted",platformHook:"detached / onUnload",description:"\u7EC4\u4EF6\u4F7F\u7528 detached\uFF0C\u9875\u9762\u4F7F\u7528 onUnload",hasDirectMapping:!0},onErrorCaptured:{lytHook:"onErrorCaptured",platformHook:"(\u65E0\u76F4\u63A5\u5BF9\u5E94)",description:"\u5C0F\u7A0B\u5E8F\u65E0\u76F4\u63A5\u5BF9\u5E94\uFF0C\u53EF\u5728\u65B9\u6CD5\u4E2D try-catch",hasDirectMapping:!1},onLoad:{lytHook:"onLoad",platformHook:"onLoad",description:"\u9875\u9762\u52A0\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onShow:{lytHook:"onShow",platformHook:"onShow",description:"\u9875\u9762\u663E\u793A\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onReady:{lytHook:"onReady",platformHook:"onReady",description:"\u9875\u9762\u521D\u6B21\u6E32\u67D3\u5B8C\u6210\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onHide:{lytHook:"onHide",platformHook:"onHide",description:"\u9875\u9762\u9690\u85CF\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},onUnload:{lytHook:"onUnload",platformHook:"onUnload",description:"\u9875\u9762\u5378\u8F7D\u65F6\u89E6\u53D1\uFF08\u4EC5\u9875\u9762\uFF09",hasDirectMapping:!0},created:{lytHook:"created",platformHook:"created",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u521B\u5EFA\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},attached:{lytHook:"attached",platformHook:"attached",description:"\u7EC4\u4EF6\u8FDB\u5165\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},ready:{lytHook:"ready",platformHook:"ready",description:"\u7EC4\u4EF6\u5E03\u5C40\u5B8C\u6210\u540E\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},moved:{lytHook:"moved",platformHook:"moved",description:"\u7EC4\u4EF6\u5B9E\u4F8B\u88AB\u79FB\u52A8\u5230\u8282\u70B9\u6811\u53E6\u4E00\u4E2A\u4F4D\u7F6E\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0},detached:{lytHook:"detached",platformHook:"detached",description:"\u7EC4\u4EF6\u79BB\u5F00\u9875\u9762\u8282\u70B9\u6811\u65F6\u89E6\u53D1\uFF08\u4EC5\u7EC4\u4EF6\uFF09",hasDirectMapping:!0}},De={onBeforeMount:"onLoad",onMounted:"onReady",onUnmounted:"onUnload",onShow:"onShow",onHide:"onHide",onReady:"onReady",onLoad:"onLoad",onUnload:"onUnload"},ae={onBeforeMount:"created",onMounted:"ready",onUnmounted:"detached",onReady:"ready",created:"created",attached:"attached",moved:"moved",detached:"detached"},B=class{constructor(e){this._platform=e}mapLifecycle(e,t){let n=H[e];return n?n.platformHook:e}getLifecycleMapping(e){return H[e]||null}getAllMappings(){return Object.values(H)}createPageLifecycle(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r!="function")continue;let o=De[n];if(o)if(t[o]){let i=t[o];t[o]=function(...a){i.apply(this,a),r.apply(this,a)}}else t[o]=r;else t[n]=r}return t}createComponentLifecycle(e){let t={},n={},r=null;for(let[o,i]of Object.entries(e)){if(typeof i!="function")continue;if(o==="setup"){let c=i.call({});c&&typeof c=="object"&&(r=c);continue}let a=ae[o];if(a)if(n[a]){let c=n[a];n[a]=function(...l){c.apply(this,l),i.apply(this,l)}}else n[a]=i;else t.methods||(t.methods={}),t.methods[o]=i}return Object.keys(n).length>0&&(t.lifetimes=n),r&&(t.data=r),t}wrapComponent(e,t){let n=t||this._platform,r={};if(e.setup&&typeof e.setup=="function"){let a=e.setup.call({});a&&typeof a=="object"?r.data={...a||{},...e.data||{}}:r.data=e.data||{}}else r.data=e.data||{};if(e.props){if(Array.isArray(e.props)){let a={};for(let c of e.props)a[c]={type:null};r.properties=a}else if(typeof e.props=="object"){let a={};for(let[c,l]of Object.entries(e.props))if(typeof l=="function")a[c]={type:l.name};else if(typeof l=="object"&&l!==null){let p={};l.type&&(p.type=l.type),l.default!==void 0&&(p.value=l.default),l.value!==void 0&&(p.value=l.value),a[c]=p}else a[c]={type:null,value:l};r.properties=a}}let o={},i=["onBeforeMount","onMounted","onUpdated","onUnmounted","onBeforeUnmount","onErrorCaptured","created","attached","ready","moved","detached"];for(let a of i)if(e[a]&&typeof e[a]=="function"){let c=ae[a];c&&(o[c]=e[a])}if(Object.keys(o).length>0&&(r.lifetimes=o),e.methods&&typeof e.methods=="object"?r.methods={...e.methods}:r.methods={},e.computed&&typeof e.computed=="object"){let a={};for(let[c,l]of Object.entries(e.computed))if(typeof l=="function")try{let p=l.call(r.data);r.data[c]=p}catch(p){}}if(e.watch&&typeof e.watch=="object"){r.observers||(r.observers={});for(let[a,c]of Object.entries(e.watch))if(typeof c=="function")r.observers[a]=c;else if(Array.isArray(c)){let l=c.filter(p=>typeof p=="function");l.length>0&&(r.observers[a]=function(...p){for(let u of l)u.apply(this,p)})}}return e.observers&&typeof e.observers=="object"&&(r.observers||(r.observers={}),Object.assign(r.observers,e.observers)),(e.onLoad||e.onShow||e.onHide||e.onPullDownRefresh||e.onReachBottom||e.onShareAppMessage)&&(e.onLoad&&(r.onLoad=e.onLoad),e.onShow&&(r.onShow=e.onShow),e.onHide&&(r.onHide=e.onHide),e.onPullDownRefresh&&(r.onPullDownRefresh=e.onPullDownRefresh),e.onReachBottom&&(r.onReachBottom=e.onReachBottom),e.onShareAppMessage&&(r.onShareAppMessage=e.onShareAppMessage)),r}getPlatform(){return this._platform}setPlatform(e){this._platform=e}getPlatformLifecycleDifferences(e){let t=e||this._platform;return t==="alipay"?{created:"created\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"didMount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didMount \u66FF\u4EE3 ready\uFF09",detached:"didUnmount\uFF08\u652F\u4ED8\u5B9D\u7EC4\u4EF6\u4F7F\u7528 didUnmount \u66FF\u4EE3 detached\uFF09",onLoad:"onLoad\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u652F\u4ED8\u5B9D\u9875\u9762\u652F\u6301\uFF09"}:t==="bytedance"?{created:"created\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",attached:"attached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",ready:"ready\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",detached:"detached\uFF08\u5B57\u8282\u8DF3\u52A8\u7EC4\u4EF6\u652F\u6301\uFF09",onLoad:"onLoad\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onReady:"onReady\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09",onUnload:"onUnload\uFF08\u5B57\u8282\u8DF3\u52A8\u9875\u9762\u652F\u6301\uFF09"}:{created:"created",attached:"attached",ready:"ready",moved:"moved",detached:"detached",onLoad:"onLoad",onShow:"onShow",onReady:"onReady",onHide:"onHide",onUnload:"onUnload"}}};var v=class{constructor(e,t){this._platform=e,this._wx=t,this._storageAdapter=new U(t),this._routerAdapter=new z(t)}async fetch(e,t){return new Promise((n,r)=>{let o={url:e,method:(t==null?void 0:t.method)||"GET",dataType:(t==null?void 0:t.responseType)||"json",responseType:(t==null?void 0:t.responseType)==="arraybuffer"?"arraybuffer":"text"};t!=null&&t.headers&&(o.header=t.headers),(t==null?void 0:t.data)!==void 0&&(o.data=t.data),t!=null&&t.timeout&&(o.timeout=t.timeout),this._wx.request({...o,success:i=>{n({statusCode:i.statusCode,headers:i.header||{},data:i.data,duration:i.duration||0,url:e})},fail:i=>{r(new Error(`[MiniApp API] Request failed: ${i.errMsg||JSON.stringify(i)}`))}})})}async get(e,t){return(await this.fetch(e,{url:e,method:"GET",headers:t})).data}async post(e,t,n){return(await this.fetch(e,{url:e,method:"POST",data:t,headers:n})).data}async put(e,t,n){return(await this.fetch(e,{url:e,method:"PUT",data:t,headers:n})).data}async delete(e,t){return(await this.fetch(e,{url:e,method:"DELETE",headers:t})).data}get storage(){return this._storageAdapter}get router(){return this._routerAdapter}showToast(e,t){this._wx.showToast({title:e,icon:(t==null?void 0:t.icon)||"none",duration:(t==null?void 0:t.duration)||1500,mask:(t==null?void 0:t.mask)||!1})}hideToast(){this._wx.hideToast()}showLoading(e="\u52A0\u8F7D\u4E2D...",t=!1){this._wx.showLoading({title:e,mask:t})}hideLoading(){this._wx.hideLoading()}showModal(e){return new Promise(t=>{this._wx.showModal({title:e.title||"\u63D0\u793A",content:e.content,showCancel:e.showCancel!==!1,cancelText:e.cancelText||"\u53D6\u6D88",confirmText:e.confirmText||"\u786E\u5B9A",success:n=>{t(n.confirm===!0)},fail:()=>{t(!1)}})})}getSystemInfo(){return this._wx.getSystemInfoSync()}getSystemInfoAsync(){return new Promise((e,t)=>{this._wx.getSystemInfo({success:n=>e(n),fail:n=>t(n)})})}setClipboardData(e){return new Promise((t,n)=>{this._wx.setClipboardData({data:e,success:()=>t(),fail:r=>n(r)})})}getClipboardData(){return new Promise((e,t)=>{this._wx.getClipboardData({success:n=>e(n.data),fail:n=>t(n)})})}startPullDownRefresh(){return new Promise((e,t)=>{this._wx.startPullDownRefresh({success:()=>e(),fail:n=>t(n)})})}stopPullDownRefresh(){this._wx.stopPullDownRefresh()}getPlatform(){return this._platform}getWx(){return this._wx}},U=class{constructor(e){this._wx=e}getItem(e){try{let t=this._wx.getStorageSync(e);return t===""||t===void 0||t===null?null:typeof t=="string"?t:JSON.stringify(t)}catch(t){return null}}setItem(e,t){try{try{let n=JSON.parse(t);this._wx.setStorageSync(e,n)}catch(n){this._wx.setStorageSync(e,t)}}catch(n){}}removeItem(e){try{this._wx.removeStorageSync(e)}catch(t){}}clear(){try{this._wx.clearStorageSync()}catch(e){}}keys(){try{return this._wx.getStorageInfoSync().keys||[]}catch(e){return[]}}getInfo(){try{let e=this._wx.getStorageInfoSync();return{currentSize:e.currentSize||0,limitSize:e.limitSize||10240}}catch(e){return{currentSize:0,limitSize:10240}}}async getItemAsync(e){return new Promise(t=>{this._wx.getStorage({key:e,success:n=>{let r=n.data;t(r==null?null:typeof r=="string"?r:JSON.stringify(r))},fail:()=>t(null)})})}async setItemAsync(e,t){return new Promise((n,r)=>{let o=t;try{o=JSON.parse(t)}catch(i){}this._wx.setStorage({key:e,data:o,success:()=>n(),fail:i=>r(i)})})}async removeItemAsync(e){return new Promise(t=>{this._wx.removeStorage({key:e,success:()=>t(),fail:()=>t()})})}async clearAsync(){return new Promise(e=>{this._wx.clearStorage({success:()=>e(),fail:()=>e()})})}},z=class{constructor(e){this._wx=e}push(e,t){let n=this._buildUrl(e,t==null?void 0:t.query);this._wx.navigateTo({url:n,success:t!=null&&t.animationType?()=>{}:void 0,fail:r=>{}})}replace(e,t){let n=this._buildUrl(e,t==null?void 0:t.query);this._wx.redirectTo({url:n,fail:r=>{}})}replaceAll(e){this._wx.reLaunch({url:e,fail:t=>{}})}switchTab(e){this._wx.switchTab({url:e,fail:t=>{}})}back(e=1){this._wx.navigateBack({delta:e,fail:t=>{}})}_buildUrl(e,t){if(!t||Object.keys(t).length===0)return e;let n=Object.entries(t).map(([r,o])=>`${encodeURIComponent(r)}=${encodeURIComponent(o)}`).join("&");return`${e}?${n}`}},k=class{constructor(e={},t,n="__lyt_global_state__"){if(this._wx=t||null,this._persistKey=n,this._listeners={},this._wx)try{let r=this._wx.getStorageSync(n);r&&typeof r=="object"?this._state={...e,...r}:this._state={...e}}catch(r){this._state={...e}}else this._state={...e}}get(e){return this._state[e]}set(e,t){let n=this._state[e];this._state[e]=t,this._notify(e,t,n),this._persist()}setMultiple(e){let t={};for(let n of Object.keys(e))t[n]=this._state[n],this._state[n]=e[n];for(let n of Object.keys(e))this._notify(n,e[n],t[n]);this._persist()}on(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),()=>{let n=this._listeners[e];if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}getAll(){return{...this._state}}clear(){let e={...this._state};this._state={};for(let t of Object.keys(e))this._notify(t,void 0,e[t]);this._persist()}_notify(e,t,n){let r=this._listeners[e];if(r)for(let o of r)try{o(t,n)}catch(i){}}_persist(){if(this._wx)try{this._wx.setStorageSync(this._persistKey,this._state)}catch(e){}}},N=null;function Fe(s,e){return new v(s,e)}function He(s,e="wechat"){if(!N&&s&&(N=new v(e,s)),!N)throw new Error("[MiniApp API Adapter] \u672A\u521D\u59CB\u5316\u3002\u8BF7\u5148\u8C03\u7528 createApiAdapter() \u6216\u4F20\u5165 wx \u5BF9\u8C61\u3002");return N}function Be(s,e,t){return new k(s,e,t)}export{J as Comment,K as Fragment,k as GlobalStateManager,v as MiniAppApiAdapter,D as MiniAppCompiler,F as MiniAppEventBridge,B as MiniAppLifecycleAdapter,w as MiniAppRenderer,M as MiniAppStyleCompiler,C as PatchFlags,b as ShapeFlags,G as Text,oe as camelToKebab,Ve as compileMiniAppStyle,Fe as createApiAdapter,Be as createGlobalState,_e as createMiniAppRenderer,we as createRenderer,Se as createWxsModule,ke as escapeHtml,V as generateComponentJson,I as generatePageJson,He as getApiAdapter,Ee as isNativeTag,Re as kebabToCamel,xe as miniAppRenderer,ie as miniAppStyleCompiler,j as normalizeProps,Te as parseClassObject,Ae as parseStyleObject};
|