glass-easel-miniprogram-adapter 0.14.1 → 0.15.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/glass_easel_miniprogram_adapter.d.ts +13 -3
- package/dist/glass_easel_miniprogram_adapter.es.js +1 -1
- package/dist/glass_easel_miniprogram_adapter.es.js.map +1 -1
- package/dist/glass_easel_miniprogram_adapter.js +1 -1
- package/dist/glass_easel_miniprogram_adapter.js.map +1 -1
- package/package.json +4 -4
- package/src/behavior.ts +20 -1
- package/src/component.ts +2 -0
- package/src/space.ts +7 -1
- package/tests/space.test.ts +22 -0
|
@@ -123,6 +123,8 @@ declare class MediaQueryObserver {
|
|
|
123
123
|
type DataList$6 = typeUtils.DataList;
|
|
124
124
|
type PropertyList$6 = typeUtils.PropertyList;
|
|
125
125
|
type MethodList$5 = typeUtils.MethodList;
|
|
126
|
+
type Empty$4 = typeUtils.Empty;
|
|
127
|
+
type PropertyValues<TProperty extends PropertyList$6> = typeUtils.PropertyValues<TProperty>;
|
|
126
128
|
type AllData<TData extends DataList$6, TProperty extends PropertyList$6> = typeUtils.DataWithPropertyValues<TData, TProperty>;
|
|
127
129
|
type ExportType<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport, UExtraThisFields extends DataList$6> = [UComponentExport] extends [never] ? Component<UData, UProperty, UMethod, UComponentExport, UExtraThisFields> : UComponentExport;
|
|
128
130
|
declare const determineComponentExports: (parent: GeneralBehavior[], selfExport: ((source: GeneralComponent | null) => any) | undefined) => ((source: GeneralComponent | null) => any) | undefined;
|
|
@@ -289,9 +291,10 @@ declare const component_ComponentCaller: typeof ComponentCaller;
|
|
|
289
291
|
type component_ComponentProto<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport, TExtraThisFields extends DataList$6> = ComponentProto<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>;
|
|
290
292
|
declare const component_ComponentProto: typeof ComponentProto;
|
|
291
293
|
type component_GeneralComponent = GeneralComponent;
|
|
294
|
+
type component_PropertyValues<TProperty extends PropertyList$6> = PropertyValues<TProperty>;
|
|
292
295
|
declare const component_determineComponentExports: typeof determineComponentExports;
|
|
293
296
|
declare namespace component {
|
|
294
|
-
export { type component_AllData as AllData, type component_Component as Component, component_ComponentCaller as ComponentCaller, component_ComponentProto as ComponentProto, type component_GeneralComponent as GeneralComponent, component_determineComponentExports as determineComponentExports };
|
|
297
|
+
export { type component_AllData as AllData, type component_Component as Component, component_ComponentCaller as ComponentCaller, component_ComponentProto as ComponentProto, type Empty$4 as Empty, type component_GeneralComponent as GeneralComponent, type component_PropertyValues as PropertyValues, component_determineComponentExports as determineComponentExports };
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
type ResolveBehaviorBuilder<B, TChainingFilter extends ChainingFilterType$4> = typeUtils.IsNever<TChainingFilter> extends false ? TChainingFilter extends ChainingFilterType$4 ? Omit<B, TChainingFilter['remove']> & TChainingFilter['add'] : B : B;
|
|
@@ -447,7 +450,13 @@ type DefinitionFilter = (target: GeneralComponentDefinition, childFilters: (((ta
|
|
|
447
450
|
type GeneralBehavior = Behavior<Record<string, any>, Record<string, any>, Record<string, any>, any, any, Record<string, any>>;
|
|
448
451
|
declare class Behavior<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4, TChainingFilter extends ChainingFilterType$3, TComponentExport, TExtraThisFields extends DataList$4> {
|
|
449
452
|
}
|
|
453
|
+
type ComponentFieldTypes<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4> = {
|
|
454
|
+
propertyValues: PropertyValues<TProperty>;
|
|
455
|
+
dataWithProperties: AllData<TData, TProperty>;
|
|
456
|
+
methods: TMethod;
|
|
457
|
+
};
|
|
450
458
|
declare class ComponentType<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4, TComponentExport, TExtraThisFields extends DataList$4> {
|
|
459
|
+
protected readonly _$fieldTypes: ComponentFieldTypes<TData, TProperty, TMethod>;
|
|
451
460
|
}
|
|
452
461
|
type GeneralComponentType = ComponentType<Record<string, any>, Record<string, any>, Record<string, any>, any, Record<string, any>>;
|
|
453
462
|
declare class TraitBehavior<TIn extends {
|
|
@@ -460,6 +469,7 @@ declare class TraitBehavior<TIn extends {
|
|
|
460
469
|
|
|
461
470
|
type behavior_Behavior<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4, TChainingFilter extends ChainingFilterType$3, TComponentExport, TExtraThisFields extends DataList$4> = Behavior<TData, TProperty, TMethod, TChainingFilter, TComponentExport, TExtraThisFields>;
|
|
462
471
|
declare const behavior_Behavior: typeof Behavior;
|
|
472
|
+
type behavior_ComponentFieldTypes<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4> = ComponentFieldTypes<TData, TProperty, TMethod>;
|
|
463
473
|
type behavior_ComponentType<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4, TComponentExport, TExtraThisFields extends DataList$4> = ComponentType<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>;
|
|
464
474
|
declare const behavior_ComponentType: typeof ComponentType;
|
|
465
475
|
type behavior_DefinitionFilter = DefinitionFilter;
|
|
@@ -472,7 +482,7 @@ type behavior_TraitBehavior<TIn extends {
|
|
|
472
482
|
} = TIn> = TraitBehavior<TIn, TOut>;
|
|
473
483
|
declare const behavior_TraitBehavior: typeof TraitBehavior;
|
|
474
484
|
declare namespace behavior {
|
|
475
|
-
export { behavior_Behavior as Behavior, behavior_ComponentType as ComponentType, type behavior_DefinitionFilter as DefinitionFilter, type behavior_GeneralBehavior as GeneralBehavior, type behavior_GeneralComponentType as GeneralComponentType, behavior_TraitBehavior as TraitBehavior };
|
|
485
|
+
export { behavior_Behavior as Behavior, type behavior_ComponentFieldTypes as ComponentFieldTypes, behavior_ComponentType as ComponentType, type behavior_DefinitionFilter as DefinitionFilter, type behavior_GeneralBehavior as GeneralBehavior, type behavior_GeneralComponentType as GeneralComponentType, behavior_TraitBehavior as TraitBehavior };
|
|
476
486
|
}
|
|
477
487
|
|
|
478
488
|
type Empty$3 = typeUtils.Empty;
|
|
@@ -699,7 +709,7 @@ declare namespace index {
|
|
|
699
709
|
interface PageConstructor {
|
|
700
710
|
<TData extends DataList, TNewExtraFields extends {
|
|
701
711
|
[k: PropertyKey]: any;
|
|
702
|
-
}>(definition: PageDefinition<TData, TNewExtraFields> & ThisType<Component<TData, Empty, TNewExtraFields, never, Empty>>):
|
|
712
|
+
}>(definition: PageDefinition<TData, TNewExtraFields> & ThisType<Component<TData, Empty, TNewExtraFields, never, Empty>>): ComponentType<TData, Empty, TNewExtraFields, never, Empty>;
|
|
703
713
|
}
|
|
704
714
|
interface ComponentConstructor {
|
|
705
715
|
(): DefaultComponentBuilder;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as e from"glass-easel";import{typeUtils as t}from"glass-easel";export{e as glassEasel};class i{constructor(e,t){this._$env=e,this._$=t}registerStyleSheetContent(e,t){this._$.registerStyleSheetContent(e,t)}createRoot(e,t,i,s){if(this._$env!==t._$env)throw new Error("The code space is not in the same environment as the backend");return new o(this._$,e,t,i,s)}}class o{constructor(t,i,o,s,r){if(this._$comp=o.getComponentSpace().createComponentByUrl(i,s,r||null,t),o.isMainSpace()){const e=o.getStyleSheet("app");if(void 0!==e){const i=o._$styleIsolationMap[this._$comp.is];"isolated"!==i&&"apply-shared"!==i&&"shared"!==i||t.appendStyleSheetPath(e,o._$sharedStyleScope)}}const n=i=>{const{styleScope:o}=i.getComponentOptions(),s=i.behavior.ownerSpace.__wxCodeSpace,r=null==s?void 0:s.getStyleSheet(i.is);void 0!==r&&t.appendStyleSheetPath(r,null!=o?o:e.StyleScopeManager.globalScope())};this._$comp.getRootBehavior().getComponentDependencies().forEach(n),n(this._$comp.getComponentDefinition())}get(){return this._$comp.getMethodCaller()}getComponent(){return this._$comp}attach(t,i){e.Element.replaceDocumentElement(this._$comp,t,i)}release(){e.Element.pretendDetached(this._$comp),this._$comp.destroyBackendElement()}}const s=(e,t)=>{let i=!1,o=e.length;const s=new Array(o);e.forEach(((e,r)=>{e((e=>{s[r]=e,o-=1,0===o&&i&&t(s)}))})),i=!0,0===o&&setTimeout((()=>{t(s)}),0)};class r{constructor(e,t,i,o){this._$sq=e,this._$comp=t,this._$sel=i,this._$single=o}fields(e,t=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,e,t),this._$sq}boundingClientRect(e=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,{id:!0,dataset:!0,rect:!0,size:!0},e),this._$sq}scrollOffset(e=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,{id:!0,dataset:!0,scrollOffset:!0},e),this._$sq}context(e=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,{context:!0},e),this._$sq}}class n{constructor(e){this._$comp=e,this._$queue=[]}in(e){return this._$comp=e,this}select(e){return new r(this,this._$comp,e,!0)}selectAll(e){return new r(this,this._$comp,e,!1)}selectViewport(){return new r(this,this._$comp,null,!0)}_$push(e,t,i,o,s){this._$queue.push({component:t,selector:e,single:i,fields:o,cb:s})}exec(t=(()=>{})){const i=this._$queue;s(i.map((t=>i=>{const{component:o,selector:r,single:n,fields:a,cb:l}=t;if(null===r){const e={};s([t=>{const i=o._$.getBackendContext(),s=i?i.getWindowWidth():0,r=i?i.getWindowHeight():0;if(a.id&&(e.id=""),a.dataset&&(e.dataset={}),a.mark&&(e.mark={}),a.rect&&(e.left=0,e.top=0,e.right=s,e.bottom=r),a.size&&(e.width=s,e.height=r),a.scrollOffset){let i=o._$.general();for(;i.ownerShadowRoot;)i=i.ownerShadowRoot.getHostNode();i.getBoundingClientRect((({left:i,top:o,width:s,height:r})=>{e.scrollLeft=i,e.scrollTop=o,e.scrollWidth=s,e.scrollHeight=r,t(void 0)}))}else t(void 0)}],(()=>{l(e),i(e)}))}else{const t=(t,i)=>{const o={};a.id&&(o.id=t.id),a.dataset&&(o.dataset=t.dataset),a.mark&&(o.mark=t.collectMarks()),s([e=>{a.rect||a.size?t.getBoundingClientRect((t=>{a.rect&&(o.left=t.left,o.top=t.top,o.right=t.left+t.width,o.bottom=t.top+t.height),a.size&&(o.width=t.width,o.height=t.height),e(void 0)})):e(void 0)},e=>{a.scrollOffset?t.getScrollOffset((t=>{o.scrollLeft=t.scrollLeft,o.scrollTop=t.scrollTop,o.scrollWidth=t.scrollWidth,o.scrollHeight=t.scrollHeight,e(void 0)})):e(void 0)},e=>{a.context?t.getContext((t=>{o.context=t,e(void 0)})):e(void 0)}],(()=>{a.properties&&e.Component.isComponent(t)&&a.properties.forEach((i=>{if(e.Component.hasProperty(t,i)){const s=t.getComponentOptions().propertyPassingDeepCopy,r=t.data[i];s===e.DeepCopyKind.None?o[i]=r:s===e.DeepCopyKind.Simple?o[i]=e.dataUtils.simpleDeepCopy(r):s===e.DeepCopyKind.SimpleWithRecursion&&(o[i]=e.dataUtils.deepCopy(r,!0))}})),i(o)}))};if(n){const e=o._$.getShadowRoot().querySelector(r);e?t(e,(e=>{l(e),i(e)})):setTimeout((()=>{l(null),i(null)}),0)}else{const e=o._$.getShadowRoot().querySelectorAll(r);s(e.map((e=>i=>{t(e,(e=>{i(e)}))})),(e=>{l(e),i(e)}))}}})),t)}}const a={left:0,top:0,right:0,bottom:0};class l{constructor(e,t,i,o){this._$selector=null,this._$margins=null,this._$observers=[],this._$comp=e,this._$thresholds=t,this._$initialRatio=i,this._$observeAll=o}relativeTo(e,t){return this._$selector=e,this._$margins=null!=t?t:a,this}relativeToViewport(e){return this._$selector=null,this._$margins=null!=e?e:a,this}observe(e,t){const i=this._$comp._$.getShadowRoot();let o,s;if(i)if(this._$observeAll)o=i.querySelectorAll(e);else{const t=i.querySelector(e);o=null===t?[]:[t]}else o=[];if(null!==this._$selector&&i){const e=i.querySelector(this._$selector);null===e||(s=e)}else s=null;if(!this._$margins)throw new Error("`relativeTo` or `relativeToViewport` should be called before observe");const{left:r,top:n,right:a,bottom:l}={left:(h=this._$margins).left||0,top:h.top||0,right:h.right||0,bottom:h.bottom||0};var h;const c=`${n}px ${a}px ${l}px ${r}px`;o.forEach((e=>{let i=this._$initialRatio;const o=e.createIntersectionObserver(s,c,this._$thresholds,(e=>{if(null!==i){let t=0;for(;t<this._$thresholds.length;t+=1){const o=this._$thresholds[t];if(i!==e.intersectionRatio&&(i-o)*(e.intersectionRatio-o)<=0)break}if(i=null,t<this._$thresholds.length)return}t(e)}));null===o||this._$observers.push(o)}))}disconnect(){const e=this._$observers;this._$observers=[],e.forEach((e=>e.disconnect()))}}class h{constructor(e){this._$observer=null,this._$comp=e}observe(e,t){var i,o;this._$observer&&this._$observer.disconnect(),this._$observer=(null===(o=null===(i=this._$comp._$.getBackendContext())||void 0===i?void 0:i.createMediaQueryObserver)||void 0===o?void 0:o.call(i,e,t))||null}disconnect(){this._$observer&&this._$observer.disconnect(),this._$observer=null}}const c=(e,t,i)=>{var o;const s=t.asInstanceOf(i._$);if(null===s)return;const r=s.getRootBehavior().ownerSpace,n=s.getMethodCaller(),a=n instanceof u?n:null,l=e._$.getRootBehavior().ownerSpace,h=r!==l?null:a,c=null===(o=null==a?void 0:a._$export)||void 0===o?void 0:o.call(a,r!==l?null:e);return void 0===c?h:c},p=(t,i)=>{var o;if(e.Component.isComponent(i)){const e=i.getRootBehavior().ownerSpace,s=i.getMethodCaller(),r=s instanceof u?s:null,n=t._$.getRootBehavior().ownerSpace,a=e!==n?null:r,l=null===(o=null==r?void 0:r._$export)||void 0===o?void 0:o.call(r,e!==n?null:t);return void 0===l?a:l}},d=(e,t)=>{if(void 0!==t)return t;const i=e.findLast((e=>void 0!==e._$export));return void 0!==i?i._$export:void 0};class u{get is(){return this._$.is}set is(e){Object.defineProperty(this,"is",{value:e,writable:!0,enumerable:!0,configurable:!0})}get id(){return this._$.id}set id(e){Object.defineProperty(this,"id",{value:e,writable:!0,enumerable:!0,configurable:!0})}get dataset(){return this._$.dataset}set dataset(e){Object.defineProperty(this,"dataset",{value:e,writable:!0,enumerable:!0,configurable:!0})}get data(){return this._$.data}set data(e){Object.defineProperty(this,"data",{value:e,writable:!0,enumerable:!0,configurable:!0})}get properties(){return this._$.data}set properties(e){Object.defineProperty(this,"properties",{value:e,writable:!0,enumerable:!0,configurable:!0})}groupSetData(t){e.safeCallback("GroupSetData Callback",t,this,[],this._$)}setData(t,i){this._$.setData(t),i&&e.triggerRender(this._$,(()=>{e.safeCallback("SetData Callback",i,this,[],this._$)}))}updateData(e){this._$.updateData(e)}replaceDataOnPath(e,t){this._$.replaceDataOnPath(e,t)}spliceArrayDataOnPath(e,t,i,o){this._$.spliceArrayDataOnPath(e,t,i,o)}applyDataUpdates(){this._$.applyDataUpdates()}groupUpdates(t){return this._$.groupUpdates((()=>e.safeCallback("GroupUpdates Callback",t,this,[],this._$)))}hasBehavior(e){return this._$.hasBehavior(e._$)}traitBehavior(e){return this._$.traitBehavior(e._$)}triggerEvent(e,t,i){return this._$.triggerEvent(e,t,i)}createSelectorQuery(){return new n(this)}createIntersectionObserver(e){return new l(this,(null==e?void 0:e.thresholds)||[0],(null==e?void 0:e.initialRatio)||0,(null==e?void 0:e.observeAll)||!1)}createMediaQueryObserver(){return new h(this)}selectComponent(e,t){var i,o;const s=this._$.getShadowRoot().querySelector(e);return null===s?null:t?null!==(i=c(this,s,t))&&void 0!==i?i:null:null!==(o=p(this,s))&&void 0!==o?o:null}selectAllComponents(e,t){const i=this._$.getShadowRoot().querySelectorAll(e),o=[];return i.forEach((e=>{const i=t?c(this,e,t):p(this,e);void 0!==i&&o.push(i)})),o}selectOwnerComponent(e){var t,i,o;const s=null===(t=this._$.ownerShadowRoot)||void 0===t?void 0:t.getHostNode();return void 0===s?null:e?null!==(i=c(this,s,e))&&void 0!==i?i:null:null!==(o=p(this,s))&&void 0!==o?o:null}getRelationNodes(e){return this._$.getRelationNodes(e).map((e=>e.getMethodCaller()))}general(){return this}asInstanceOf(e){return this._$.asInstanceOf(e._$)?this:null}}class _{constructor(e,t,i){this.proto=Object.create(u.prototype),Object.assign(this.proto,e),this.proto._$export=d(t,i)}derive(){return Object.create(this.proto)}}var $=Object.freeze({__proto__:null,ComponentCaller:u,ComponentProto:_,determineComponentExports:d});class g{constructor(e,t,i,o,s){if(this._$=e,this._$chainingFilter=o,this._$export=d(t,s),void 0!==i){const e=t.map((e=>{var t;return null!==(t=e._$boundDefinitionFilter)&&void 0!==t?t:null}));this._$boundDefinitionFilter=t=>{i(t,e)}}}}class v{constructor(e){this._$=e}}class m{constructor(e){this._$=e}}var f=Object.freeze({__proto__:null,Behavior:g,ComponentType:v,TraitBehavior:m});class S{constructor(){this._$parents=[]}implement(e,t){return this._$.implement(e._$,t),this}externalClasses(e){return this._$.externalClasses(e),this}export(e){return this._$export=e,this}behavior(e){return this._$parents.push(e),this._$=this._$.behavior(e._$),e._$chainingFilter?e._$chainingFilter(this):this}data(e){return this._$.data(e),this}staticData(e){return this._$.staticData(e),this}property(e,t){return this._$.property(e,t),this}methods(e){return this._$.methods(e),this}observer(e,t,i=!1){return this._$.observer(e,t,i),this}lifetime(e,t,i=!1){return this._$.lifetime(e,t,i),this}pageLifetime(e,t,i=!1){return this._$.pageLifetime(e,t,i),this}relation(e,t){const i=t.target instanceof g||t.target instanceof v||t.target instanceof m?t.target._$:t.target;return this._$.relation(e,{target:i,type:t.type,linked:t.linked,linkChanged:t.linkChanged,unlinked:t.unlinked,linkFailed:t.linkFailed}),this}init(t){return this._$.init((function({data:i,setData:o,implement:s,relation:r,observer:n,lifetime:a,pageLifetime:l,method:h,listener:c}){const p=this,d=t.call(p,{self:p,data:i,setData:(t,i)=>{o(t),i&&e.triggerRender(p._$,(()=>{i()}))},implement:(e,t)=>{s(e._$,t)},relation:e=>{const t=e.target instanceof g||e.target instanceof v||e.target instanceof m?e.target._$:e.target;return r({target:t,type:e.type,linked:e.linked,linkChanged:e.linkChanged,unlinked:e.unlinked,linkFailed:e.linkFailed})},observer:n,lifetime:a,pageLifetime:l,method:h,listener:c});if(d){const t=Object.keys(d);for(let i=0;i<t.length;i+=1){const o=t[i],s=d[o];e.Component.isTaggedMethod(s)&&(p[o]=s)}}return d})),this}definition(e){var t;null===(t=e.behaviors)||void 0===t||t.forEach((t=>{var i;return null===(i=t._$boundDefinitionFilter)||void 0===i?void 0:i.call(t,e)}));const i=this._$,{behaviors:o,properties:s,data:r,observers:n,methods:a,created:l,attached:h,ready:c,moved:p,detached:d,lifetimes:u,pageLifetimes:_,relations:$,externalClasses:f,export:S}=e;if(null==o||o.forEach((e=>{this._$parents.push(e),i.behavior(e._$)})),void 0!==r&&("function"==typeof r?i.data(r):i.staticData(r)),void 0!==s){const e=Object.keys(s);for(let t=0;t<e.length;t+=1){const o=e[t];i.property(o,s[o])}}if(void 0!==n)if(Array.isArray(n))for(let e=0;e<n.length;e+=1){const{fields:t,observer:o}=n[e];i.observer(t||"**",o)}else{const e=Object.keys(n);for(let t=0;t<e.length;t+=1){const o=e[t],s=n[o];i.observer(o,s)}}if(a&&i.methods(a),l&&void 0===(null==u?void 0:u.created)&&i.lifetime("created",l,!0),h&&void 0===(null==u?void 0:u.attached)&&i.lifetime("attached",h,!0),c&&void 0===(null==u?void 0:u.ready)&&i.lifetime("ready",c,!0),p&&void 0===(null==u?void 0:u.moved)&&i.lifetime("moved",p,!0),d&&void 0===(null==u?void 0:u.detached)&&i.lifetime("detached",d,!0),u){const e=Object.keys(u);for(let t=0;t<e.length;t+=1){const o=e[t],s=u[o];i.lifetime(o,s,!0)}}if(_){const e=Object.keys(_);for(let t=0;t<e.length;t+=1){const o=e[t],s=_[o];i.pageLifetime(o,s,!0)}}if($){const e=Object.keys($);for(let t=0;t<e.length;t+=1){const o=e[t],s=$[o],r=s.target instanceof g||s.target instanceof v||s.target instanceof m?s.target._$:s.target;i.relation(o,{target:r,type:s.type,linked:s.linked,linkChanged:s.linkChanged,unlinked:s.unlinked,linkFailed:s.linkFailed})}}return f&&i.externalClasses(f),S&&(this._$export=S),this}}class y extends S{static create(e){const t=new y;return t._$codeSpace=e,t._$=e.getComponentSpace().defineWithMethodCaller(),t}chainingFilter(e){return this._$chainingFilter=e,this}behavior(e){return super.behavior(e)}export(e){return super.export(e)}data(e){return super.data(e)}staticData(e){return super.staticData(e)}property(e,t){return super.property(e,t)}methods(e){return super.methods(e)}init(e){return super.init(e)}definition(e){return super.definition(e),e.definitionFilter&&(this._$definitionFilter=e.definitionFilter),this}register(){return new g(this._$.registerBehavior(),this._$parents,this._$definitionFilter,this._$chainingFilter,this._$export)}extraThisFieldsType(){return this}}class b extends S{static create(e,t,i){const o=new b,s=e._$overallBehavior;return o._$codeSpace=e,o._$=e.getComponentSpace().defineWithMethodCaller(t||""),o._$is=t||"",o._$alias=i,o._$.methodCallerInit((function(){const e=this;let t=o._$proto;if(void 0===t){const i=e.getComponentDefinition().behavior.getMethods();t=o._$proto=new _(i,o._$parents,o._$export)}const i=t.derive();return i._$=e,i})),s&&o._$.behavior(s),o}options(e){return this._$options=e,this}behavior(e){return super.behavior(e)}export(e){return super.export(e)}data(e){return super.data(e)}staticData(e){return super.staticData(e)}property(e,t){return super.property(e,t)}methods(e){return super.methods(e)}init(e){return super.init(e)}definition(e){return super.definition(e),e.options&&this.options(e.options),this}pageDefinition(t){const i=Object.create(null),o={methods:{}},s=Object.keys(t);for(let e=0;e<s.length;e+=1){const r=s[e];"data"===r?o.data=t.data:"function"==typeof t[r]?o.methods[r]=t[r]:"methods"===r?i.methods=t.methods:o[r]=t[r]}this.definition(o);const r=Object.keys(o);for(let e=0;e<r.length;e+=1){const t=r[e];"data"!==t&&"methods"!==t&&"behaviors"!==t&&(i[t]=o[t])}return this._$.init((function(){Object.assign(this,e.dataUtils.simpleDeepCopy(i))})),this}register(){var e;const t=this._$is,i=this._$codeSpace,[o,s]=i.prepareComponentOptions(t,this._$options);this._$.options(o);const r=i.getComponentStaticConfig(t),n=null==r?void 0:r.usingComponents,a=null==r?void 0:r.componentGenerics,l=null==r?void 0:r.componentPlaceholder;n&&this._$.usingComponents(n),a&&this._$.generics(a),l&&this._$.placeholders(l);const h=i.getCompiledTemplate(t);h&&this._$.template(h),i._$styleIsolationMap[t]=s;const c=this._$.registerComponent();return null===(e=this._$alias)||void 0===e||e.forEach((e=>{this._$codeSpace.getComponentSpace().exportComponent(e,this._$is)})),new v(c)}extraThisFieldsType(){return this}}var C=Object.freeze({__proto__:null,BehaviorBuilder:y,ComponentBuilder:b});const w=()=>Math.floor(4294967296*(1+Math.random())).toString(16).slice(1);class O{constructor(t,i,o,s){this._$overallBehavior=null,this._$env=t,this._$isMainSpace=i,this.space=new e.ComponentSpace("",null==s?void 0:s.space,null==s?void 0:s.space.styleScopeManager),this.space.__wxCodeSpace=this,this.styleScopeManager=this.space.styleScopeManager,this.staticConfigMap=Object.create(null),this.styleSheetMap=Object.create(null),this.compiledTemplateMap=Object.create(null),this.waitingAliasMap=Object.create(null),Object.keys(o).forEach((e=>{const t=o[e];this.waitingAliasMap[t]?this.waitingAliasMap[t].push(e):this.waitingAliasMap[t]=[e]})),this._$sharedStyleScope=this.styleScopeManager.register(""),this.space.setSharedStyleScope(this._$sharedStyleScope),this._$styleIsolationMap=Object.create(null)}isMainSpace(){return this._$isMainSpace}getComponentSpace(){return this.space}setOverallBehavior(e){this._$overallBehavior=e}importCodeSpace(e,t,i=!1){const o=this._$env.getCodeSpace(e);if(!o)throw new Error(`There is no space "${e}" in the environment`);t&&this.space.importSpace(`plugin://${t}`,o.space,!1),i&&this.space.importSpace(`plugin-private://${e}`,o.space,!0)}addStyleSheet(e,t,i){this.styleSheetMap[e]={url:t,styleScopeName:i}}getStyleSheet(e){var t;return null===(t=this.styleSheetMap[e])||void 0===t?void 0:t.url}getStyleScopeName(e){var t;return null===(t=this.styleSheetMap[e])||void 0===t?void 0:t.styleScopeName}addCompiledTemplate(e,t){this.compiledTemplateMap[e]=t}getCompiledTemplate(e){return this.compiledTemplateMap[e]}addComponentStaticConfig(e,t){this.staticConfigMap[e]=t}getComponentStaticConfig(e){return this.staticConfigMap[e]}prepareComponentOptions(e,t){const i=this.staticConfigMap[e],o=null==i?void 0:i.pureDataPattern,s=o?new RegExp(o):null==t?void 0:t.pureDataPattern,r=null==i?void 0:i.addGlobalClass;let n,a,l=null==i?void 0:i.styleIsolation;void 0===l&&(l=(null==i?void 0:i.component)?r?"apply-shared":"isolated":"shared"),"apply-shared"===l||"page-apply-shared"===l?(n=this.styleScopeManager.register(this.getStyleScopeName(e)||`__${w()}`),a=this._$sharedStyleScope):n="shared"!==l&&"page-shared"!==l||!this._$isMainSpace?this.styleScopeManager.register(this.getStyleScopeName(e)||`__${w()}`):this._$sharedStyleScope;return[{idPrefixGenerator:w,multipleSlots:null==t?void 0:t.multipleSlots,dynamicSlots:null==t?void 0:t.dynamicSlots,pureDataPattern:s,virtualHost:null==t?void 0:t.virtualHost,styleScope:n,extraStyleScope:a,dataDeepCopy:null==t?void 0:t.dataDeepCopy,propertyPassingDeepCopy:null==t?void 0:t.propertyPassingDeepCopy,propertyEarlyInit:null==t?void 0:t.propertyEarlyInit},l]}globalComponentEnv(e,t,i){return this.componentEnv(t,(({Page:t,Component:o,Behavior:s})=>{const r=e.Page,n=e.Component,a=e.Behavior;e.Page=t,e.Component=o,e.Behavior=s;const l=i();return e.Page=r,e.Component=n,e.Behavior=a,l}))}componentEnv(e,t){const i=this;function o(e){return void 0!==e?i.behavior().definition(e).register():i.behavior()}return o.trait=i.traitBehavior.bind(i),t({Page:function(t){return i.component(e).pageDefinition(t).register()},Component:function(t){return void 0!==t?i.component(e).definition(t).register():i.component(e)},Behavior:o})}component(e){return b.create(this,e,this.waitingAliasMap[e])}behavior(){return y.create(this)}traitBehavior(e){return new m(void 0===e?this.space.defineTraitBehavior():this.space.defineTraitBehavior(e))}}class k{constructor(){this.codeSpaceMap=Object.create(null),this.globalCodeSpace=new O(this,!1,{})}getGlobalCodeSpace(){return this.globalCodeSpace}associateBackend(t){const o=null!=t?t:new e.CurrentWindowBackendContext;return new i(this,o)}createCodeSpace(e,t,i=Object.create(null)){const o=new O(this,t,i,this.globalCodeSpace);return this.codeSpaceMap[e]=o,o}getCodeSpace(e){return this.codeSpaceMap[e]}}var M;!function(e){e.Isolated="isolated",e.ApplyShared="apply-shared",e.Shared="shared",e.PageIsolated="page-isolated",e.PageApplyShared="page-apply-shared",e.PageShared="page-shared"}(M||(M={}));var x=Object.freeze({__proto__:null,get StyleIsolation(){return M},utils:t});export{i as AssociatedBackend,O as CodeSpace,k as MiniProgramEnv,o as Root,f as behavior,C as builder,$ as component,x as types};
|
|
1
|
+
import*as e from"glass-easel";import{typeUtils as t}from"glass-easel";export{e as glassEasel};class i{constructor(e,t){this._$env=e,this._$=t}registerStyleSheetContent(e,t){this._$.registerStyleSheetContent(e,t)}createRoot(e,t,i,s){if(this._$env!==t._$env)throw new Error("The code space is not in the same environment as the backend");return new o(this._$,e,t,i,s)}}class o{constructor(t,i,o,s,r){if(this._$comp=o.getComponentSpace().createComponentByUrl(i,s,r||null,t),o.isMainSpace()){const e=o.getStyleSheet("app");if(void 0!==e){const i=o._$styleIsolationMap[this._$comp.is];"isolated"!==i&&"apply-shared"!==i&&"shared"!==i||t.appendStyleSheetPath(e,o._$sharedStyleScope)}}const n=i=>{const{styleScope:o}=i.getComponentOptions(),s=i.behavior.ownerSpace.__wxCodeSpace,r=null==s?void 0:s.getStyleSheet(i.is);void 0!==r&&t.appendStyleSheetPath(r,null!=o?o:e.StyleScopeManager.globalScope())};this._$comp.getRootBehavior().getComponentDependencies().forEach(n),n(this._$comp.getComponentDefinition())}get(){return this._$comp.getMethodCaller()}getComponent(){return this._$comp}attach(t,i){e.Element.replaceDocumentElement(this._$comp,t,i)}release(){e.Element.pretendDetached(this._$comp),this._$comp.destroyBackendElement()}}const s=(e,t)=>{let i=!1,o=e.length;const s=new Array(o);e.forEach(((e,r)=>{e((e=>{s[r]=e,o-=1,0===o&&i&&t(s)}))})),i=!0,0===o&&setTimeout((()=>{t(s)}),0)};class r{constructor(e,t,i,o){this._$sq=e,this._$comp=t,this._$sel=i,this._$single=o}fields(e,t=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,e,t),this._$sq}boundingClientRect(e=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,{id:!0,dataset:!0,rect:!0,size:!0},e),this._$sq}scrollOffset(e=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,{id:!0,dataset:!0,scrollOffset:!0},e),this._$sq}context(e=(()=>{})){return this._$sq._$push(this._$sel,this._$comp,this._$single,{context:!0},e),this._$sq}}class n{constructor(e){this._$comp=e,this._$queue=[]}in(e){return this._$comp=e,this}select(e){return new r(this,this._$comp,e,!0)}selectAll(e){return new r(this,this._$comp,e,!1)}selectViewport(){return new r(this,this._$comp,null,!0)}_$push(e,t,i,o,s){this._$queue.push({component:t,selector:e,single:i,fields:o,cb:s})}exec(t=(()=>{})){const i=this._$queue;s(i.map((t=>i=>{const{component:o,selector:r,single:n,fields:a,cb:l}=t;if(null===r){const e={};s([t=>{const i=o._$.getBackendContext(),s=i?i.getWindowWidth():0,r=i?i.getWindowHeight():0;if(a.id&&(e.id=""),a.dataset&&(e.dataset={}),a.mark&&(e.mark={}),a.rect&&(e.left=0,e.top=0,e.right=s,e.bottom=r),a.size&&(e.width=s,e.height=r),a.scrollOffset){let i=o._$.general();for(;i.ownerShadowRoot;)i=i.ownerShadowRoot.getHostNode();i.getBoundingClientRect((({left:i,top:o,width:s,height:r})=>{e.scrollLeft=i,e.scrollTop=o,e.scrollWidth=s,e.scrollHeight=r,t(void 0)}))}else t(void 0)}],(()=>{l(e),i(e)}))}else{const t=(t,i)=>{const o={};a.id&&(o.id=t.id),a.dataset&&(o.dataset=t.dataset),a.mark&&(o.mark=t.collectMarks()),s([e=>{a.rect||a.size?t.getBoundingClientRect((t=>{a.rect&&(o.left=t.left,o.top=t.top,o.right=t.left+t.width,o.bottom=t.top+t.height),a.size&&(o.width=t.width,o.height=t.height),e(void 0)})):e(void 0)},e=>{a.scrollOffset?t.getScrollOffset((t=>{o.scrollLeft=t.scrollLeft,o.scrollTop=t.scrollTop,o.scrollWidth=t.scrollWidth,o.scrollHeight=t.scrollHeight,e(void 0)})):e(void 0)},e=>{a.context?t.getContext((t=>{o.context=t,e(void 0)})):e(void 0)}],(()=>{a.properties&&e.Component.isComponent(t)&&a.properties.forEach((i=>{if(e.Component.hasProperty(t,i)){const s=t.getComponentOptions().propertyPassingDeepCopy,r=t.data[i];s===e.DeepCopyKind.None?o[i]=r:s===e.DeepCopyKind.Simple?o[i]=e.dataUtils.simpleDeepCopy(r):s===e.DeepCopyKind.SimpleWithRecursion&&(o[i]=e.dataUtils.deepCopy(r,!0))}})),i(o)}))};if(n){const e=o._$.getShadowRoot().querySelector(r);e?t(e,(e=>{l(e),i(e)})):setTimeout((()=>{l(null),i(null)}),0)}else{const e=o._$.getShadowRoot().querySelectorAll(r);s(e.map((e=>i=>{t(e,(e=>{i(e)}))})),(e=>{l(e),i(e)}))}}})),t)}}const a={left:0,top:0,right:0,bottom:0};class l{constructor(e,t,i,o){this._$selector=null,this._$margins=null,this._$observers=[],this._$comp=e,this._$thresholds=t,this._$initialRatio=i,this._$observeAll=o}relativeTo(e,t){return this._$selector=e,this._$margins=null!=t?t:a,this}relativeToViewport(e){return this._$selector=null,this._$margins=null!=e?e:a,this}observe(e,t){const i=this._$comp._$.getShadowRoot();let o,s;if(i)if(this._$observeAll)o=i.querySelectorAll(e);else{const t=i.querySelector(e);o=null===t?[]:[t]}else o=[];if(null!==this._$selector&&i){const e=i.querySelector(this._$selector);null===e||(s=e)}else s=null;if(!this._$margins)throw new Error("`relativeTo` or `relativeToViewport` should be called before observe");const{left:r,top:n,right:a,bottom:l}={left:(h=this._$margins).left||0,top:h.top||0,right:h.right||0,bottom:h.bottom||0};var h;const c=`${n}px ${a}px ${l}px ${r}px`;o.forEach((e=>{let i=this._$initialRatio;const o=e.createIntersectionObserver(s,c,this._$thresholds,(e=>{if(null!==i){let t=0;for(;t<this._$thresholds.length;t+=1){const o=this._$thresholds[t];if(i!==e.intersectionRatio&&(i-o)*(e.intersectionRatio-o)<=0)break}if(i=null,t<this._$thresholds.length)return}t(e)}));null===o||this._$observers.push(o)}))}disconnect(){const e=this._$observers;this._$observers=[],e.forEach((e=>e.disconnect()))}}class h{constructor(e){this._$observer=null,this._$comp=e}observe(e,t){var i,o;this._$observer&&this._$observer.disconnect(),this._$observer=(null===(o=null===(i=this._$comp._$.getBackendContext())||void 0===i?void 0:i.createMediaQueryObserver)||void 0===o?void 0:o.call(i,e,t))||null}disconnect(){this._$observer&&this._$observer.disconnect(),this._$observer=null}}const c=(e,t,i)=>{var o;const s=t.asInstanceOf(i._$);if(null===s)return;const r=s.getRootBehavior().ownerSpace,n=s.getMethodCaller(),a=n instanceof u?n:null,l=e._$.getRootBehavior().ownerSpace,h=r!==l?null:a,c=null===(o=null==a?void 0:a._$export)||void 0===o?void 0:o.call(a,r!==l?null:e);return void 0===c?h:c},p=(t,i)=>{var o;if(e.Component.isComponent(i)){const e=i.getRootBehavior().ownerSpace,s=i.getMethodCaller(),r=s instanceof u?s:null,n=t._$.getRootBehavior().ownerSpace,a=e!==n?null:r,l=null===(o=null==r?void 0:r._$export)||void 0===o?void 0:o.call(r,e!==n?null:t);return void 0===l?a:l}},d=(e,t)=>{if(void 0!==t)return t;const i=e.findLast((e=>void 0!==e._$export));return void 0!==i?i._$export:void 0};class u{get is(){return this._$.is}set is(e){Object.defineProperty(this,"is",{value:e,writable:!0,enumerable:!0,configurable:!0})}get id(){return this._$.id}set id(e){Object.defineProperty(this,"id",{value:e,writable:!0,enumerable:!0,configurable:!0})}get dataset(){return this._$.dataset}set dataset(e){Object.defineProperty(this,"dataset",{value:e,writable:!0,enumerable:!0,configurable:!0})}get data(){return this._$.data}set data(e){Object.defineProperty(this,"data",{value:e,writable:!0,enumerable:!0,configurable:!0})}get properties(){return this._$.data}set properties(e){Object.defineProperty(this,"properties",{value:e,writable:!0,enumerable:!0,configurable:!0})}groupSetData(t){e.safeCallback("GroupSetData Callback",t,this,[],this._$)}setData(t,i){this._$.setData(t),i&&e.triggerRender(this._$,(()=>{e.safeCallback("SetData Callback",i,this,[],this._$)}))}updateData(e){this._$.updateData(e)}replaceDataOnPath(e,t){this._$.replaceDataOnPath(e,t)}spliceArrayDataOnPath(e,t,i,o){this._$.spliceArrayDataOnPath(e,t,i,o)}applyDataUpdates(){this._$.applyDataUpdates()}groupUpdates(t){return this._$.groupUpdates((()=>e.safeCallback("GroupUpdates Callback",t,this,[],this._$)))}hasBehavior(e){return this._$.hasBehavior(e._$)}traitBehavior(e){return this._$.traitBehavior(e._$)}triggerEvent(e,t,i){return this._$.triggerEvent(e,t,i)}createSelectorQuery(){return new n(this)}createIntersectionObserver(e){return new l(this,(null==e?void 0:e.thresholds)||[0],(null==e?void 0:e.initialRatio)||0,(null==e?void 0:e.observeAll)||!1)}createMediaQueryObserver(){return new h(this)}selectComponent(e,t){var i,o;const s=this._$.getShadowRoot().querySelector(e);return null===s?null:t?null!==(i=c(this,s,t))&&void 0!==i?i:null:null!==(o=p(this,s))&&void 0!==o?o:null}selectAllComponents(e,t){const i=this._$.getShadowRoot().querySelectorAll(e),o=[];return i.forEach((e=>{const i=t?c(this,e,t):p(this,e);void 0!==i&&o.push(i)})),o}selectOwnerComponent(e){var t,i,o;const s=null===(t=this._$.ownerShadowRoot)||void 0===t?void 0:t.getHostNode();return void 0===s?null:e?null!==(i=c(this,s,e))&&void 0!==i?i:null:null!==(o=p(this,s))&&void 0!==o?o:null}getRelationNodes(e){return this._$.getRelationNodes(e).map((e=>e.getMethodCaller()))}general(){return this}asInstanceOf(e){return this._$.asInstanceOf(e._$)?this:null}}class _{constructor(e,t,i){this.proto=Object.create(u.prototype),Object.assign(this.proto,e),this.proto._$export=d(t,i)}derive(){return Object.create(this.proto)}}var $=Object.freeze({__proto__:null,ComponentCaller:u,ComponentProto:_,determineComponentExports:d});class g{constructor(e,t,i,o,s){if(this._$=e,this._$chainingFilter=o,this._$export=d(t,s),void 0!==i){const e=t.map((e=>{var t;return null!==(t=e._$boundDefinitionFilter)&&void 0!==t?t:null}));this._$boundDefinitionFilter=t=>{i(t,e)}}}}class v{constructor(e){this._$fieldTypes=void 0,this._$=e}}class m{constructor(e){this._$=e}}var f=Object.freeze({__proto__:null,Behavior:g,ComponentType:v,TraitBehavior:m});class S{constructor(){this._$parents=[]}implement(e,t){return this._$.implement(e._$,t),this}externalClasses(e){return this._$.externalClasses(e),this}export(e){return this._$export=e,this}behavior(e){return this._$parents.push(e),this._$=this._$.behavior(e._$),e._$chainingFilter?e._$chainingFilter(this):this}data(e){return this._$.data(e),this}staticData(e){return this._$.staticData(e),this}property(e,t){return this._$.property(e,t),this}methods(e){return this._$.methods(e),this}observer(e,t,i=!1){return this._$.observer(e,t,i),this}lifetime(e,t,i=!1){return this._$.lifetime(e,t,i),this}pageLifetime(e,t,i=!1){return this._$.pageLifetime(e,t,i),this}relation(e,t){const i=t.target instanceof g||t.target instanceof v||t.target instanceof m?t.target._$:t.target;return this._$.relation(e,{target:i,type:t.type,linked:t.linked,linkChanged:t.linkChanged,unlinked:t.unlinked,linkFailed:t.linkFailed}),this}init(t){return this._$.init((function({data:i,setData:o,implement:s,relation:r,observer:n,lifetime:a,pageLifetime:l,method:h,listener:c}){const p=this,d=t.call(p,{self:p,data:i,setData:(t,i)=>{o(t),i&&e.triggerRender(p._$,(()=>{i()}))},implement:(e,t)=>{s(e._$,t)},relation:e=>{const t=e.target instanceof g||e.target instanceof v||e.target instanceof m?e.target._$:e.target;return r({target:t,type:e.type,linked:e.linked,linkChanged:e.linkChanged,unlinked:e.unlinked,linkFailed:e.linkFailed})},observer:n,lifetime:a,pageLifetime:l,method:h,listener:c});if(d){const t=Object.keys(d);for(let i=0;i<t.length;i+=1){const o=t[i],s=d[o];e.Component.isTaggedMethod(s)&&(p[o]=s)}}return d})),this}definition(e){var t;null===(t=e.behaviors)||void 0===t||t.forEach((t=>{var i;return null===(i=t._$boundDefinitionFilter)||void 0===i?void 0:i.call(t,e)}));const i=this._$,{behaviors:o,properties:s,data:r,observers:n,methods:a,created:l,attached:h,ready:c,moved:p,detached:d,lifetimes:u,pageLifetimes:_,relations:$,externalClasses:f,export:S}=e;if(null==o||o.forEach((e=>{this._$parents.push(e),i.behavior(e._$)})),void 0!==r&&("function"==typeof r?i.data(r):i.staticData(r)),void 0!==s){const e=Object.keys(s);for(let t=0;t<e.length;t+=1){const o=e[t];i.property(o,s[o])}}if(void 0!==n)if(Array.isArray(n))for(let e=0;e<n.length;e+=1){const{fields:t,observer:o}=n[e];i.observer(t||"**",o)}else{const e=Object.keys(n);for(let t=0;t<e.length;t+=1){const o=e[t],s=n[o];i.observer(o,s)}}if(a&&i.methods(a),l&&void 0===(null==u?void 0:u.created)&&i.lifetime("created",l,!0),h&&void 0===(null==u?void 0:u.attached)&&i.lifetime("attached",h,!0),c&&void 0===(null==u?void 0:u.ready)&&i.lifetime("ready",c,!0),p&&void 0===(null==u?void 0:u.moved)&&i.lifetime("moved",p,!0),d&&void 0===(null==u?void 0:u.detached)&&i.lifetime("detached",d,!0),u){const e=Object.keys(u);for(let t=0;t<e.length;t+=1){const o=e[t],s=u[o];i.lifetime(o,s,!0)}}if(_){const e=Object.keys(_);for(let t=0;t<e.length;t+=1){const o=e[t],s=_[o];i.pageLifetime(o,s,!0)}}if($){const e=Object.keys($);for(let t=0;t<e.length;t+=1){const o=e[t],s=$[o],r=s.target instanceof g||s.target instanceof v||s.target instanceof m?s.target._$:s.target;i.relation(o,{target:r,type:s.type,linked:s.linked,linkChanged:s.linkChanged,unlinked:s.unlinked,linkFailed:s.linkFailed})}}return f&&i.externalClasses(f),S&&(this._$export=S),this}}class y extends S{static create(e){const t=new y;return t._$codeSpace=e,t._$=e.getComponentSpace().defineWithMethodCaller(),t}chainingFilter(e){return this._$chainingFilter=e,this}behavior(e){return super.behavior(e)}export(e){return super.export(e)}data(e){return super.data(e)}staticData(e){return super.staticData(e)}property(e,t){return super.property(e,t)}methods(e){return super.methods(e)}init(e){return super.init(e)}definition(e){return super.definition(e),e.definitionFilter&&(this._$definitionFilter=e.definitionFilter),this}register(){return new g(this._$.registerBehavior(),this._$parents,this._$definitionFilter,this._$chainingFilter,this._$export)}extraThisFieldsType(){return this}}class b extends S{static create(e,t,i){const o=new b,s=e._$overallBehavior;return o._$codeSpace=e,o._$=e.getComponentSpace().defineWithMethodCaller(t||""),o._$is=t||"",o._$alias=i,o._$.methodCallerInit((function(){const e=this;let t=o._$proto;if(void 0===t){const i=e.getComponentDefinition().behavior.getMethods();t=o._$proto=new _(i,o._$parents,o._$export)}const i=t.derive();return i._$=e,i})),s&&o._$.behavior(s),o}options(e){return this._$options=e,this}behavior(e){return super.behavior(e)}export(e){return super.export(e)}data(e){return super.data(e)}staticData(e){return super.staticData(e)}property(e,t){return super.property(e,t)}methods(e){return super.methods(e)}init(e){return super.init(e)}definition(e){return super.definition(e),e.options&&this.options(e.options),this}pageDefinition(t){const i=Object.create(null),o={methods:{}},s=Object.keys(t);for(let e=0;e<s.length;e+=1){const r=s[e];"data"===r?o.data=t.data:"function"==typeof t[r]?o.methods[r]=t[r]:"methods"===r?i.methods=t.methods:o[r]=t[r]}this.definition(o);const r=Object.keys(o);for(let e=0;e<r.length;e+=1){const t=r[e];"data"!==t&&"methods"!==t&&"behaviors"!==t&&(i[t]=o[t])}return this._$.init((function(){Object.assign(this,e.dataUtils.simpleDeepCopy(i))})),this}register(){var e;const t=this._$is,i=this._$codeSpace,[o,s]=i.prepareComponentOptions(t,this._$options);this._$.options(o);const r=i.getComponentStaticConfig(t),n=null==r?void 0:r.usingComponents,a=null==r?void 0:r.componentGenerics,l=null==r?void 0:r.componentPlaceholder;n&&this._$.usingComponents(n),a&&this._$.generics(a),l&&this._$.placeholders(l);const h=i.getCompiledTemplate(t);h&&this._$.template(h),i._$styleIsolationMap[t]=s;const c=this._$.registerComponent();return null===(e=this._$alias)||void 0===e||e.forEach((e=>{this._$codeSpace.getComponentSpace().exportComponent(e,this._$is)})),new v(c)}extraThisFieldsType(){return this}}var C=Object.freeze({__proto__:null,BehaviorBuilder:y,ComponentBuilder:b});const w=()=>Math.floor(4294967296*(1+Math.random())).toString(16).slice(1);class O{constructor(t,i,o,s){this._$overallBehavior=null,this._$env=t,this._$isMainSpace=i,this.space=new e.ComponentSpace("",null==s?void 0:s.space,null==s?void 0:s.space.styleScopeManager),this.space.__wxCodeSpace=this,this.styleScopeManager=this.space.styleScopeManager,this.staticConfigMap=Object.create(null),this.styleSheetMap=Object.create(null),this.compiledTemplateMap=Object.create(null),this.waitingAliasMap=Object.create(null),Object.keys(o).forEach((e=>{const t=o[e];this.waitingAliasMap[t]?this.waitingAliasMap[t].push(e):this.waitingAliasMap[t]=[e]})),this._$sharedStyleScope=this.styleScopeManager.register(""),this.space.setSharedStyleScope(this._$sharedStyleScope),this._$styleIsolationMap=Object.create(null)}isMainSpace(){return this._$isMainSpace}getComponentSpace(){return this.space}setOverallBehavior(e){this._$overallBehavior=e}importCodeSpace(e,t,i=!1){const o=this._$env.getCodeSpace(e);if(!o)throw new Error(`There is no space "${e}" in the environment`);t&&this.space.importSpace(`plugin://${t}`,o.space,!1),i&&this.space.importSpace(`plugin-private://${e}`,o.space,!0)}addStyleSheet(e,t,i){this.styleSheetMap[e]={url:t,styleScopeName:i}}getStyleSheet(e){var t;return null===(t=this.styleSheetMap[e])||void 0===t?void 0:t.url}getStyleScopeName(e){var t;return null===(t=this.styleSheetMap[e])||void 0===t?void 0:t.styleScopeName}addCompiledTemplate(e,t){this.compiledTemplateMap[e]=t}getCompiledTemplate(e){return this.compiledTemplateMap[e]}addComponentStaticConfig(e,t){this.staticConfigMap[e]=t}getComponentStaticConfig(e){return this.staticConfigMap[e]}prepareComponentOptions(e,t){const i=this.staticConfigMap[e],o=null==i?void 0:i.pureDataPattern,s=o?new RegExp(o):null==t?void 0:t.pureDataPattern,r=null==i?void 0:i.addGlobalClass;let n,a,l=null==i?void 0:i.styleIsolation;void 0===l&&(l=(null==i?void 0:i.component)?r?"apply-shared":"isolated":"shared"),"apply-shared"===l||"page-apply-shared"===l?(n=this.styleScopeManager.register(this.getStyleScopeName(e)||`__${w()}`),a=this._$sharedStyleScope):n="shared"!==l&&"page-shared"!==l||!this._$isMainSpace?this.styleScopeManager.register(this.getStyleScopeName(e)||`__${w()}`):this._$sharedStyleScope;return[{idPrefixGenerator:w,multipleSlots:null==t?void 0:t.multipleSlots,dynamicSlots:null==t?void 0:t.dynamicSlots,pureDataPattern:s,virtualHost:null==t?void 0:t.virtualHost,styleScope:n,extraStyleScope:a,dataDeepCopy:null==t?void 0:t.dataDeepCopy,propertyPassingDeepCopy:null==t?void 0:t.propertyPassingDeepCopy,propertyEarlyInit:null==t?void 0:t.propertyEarlyInit},l]}globalComponentEnv(e,t,i){return this.componentEnv(t,(({Page:t,Component:o,Behavior:s})=>{const r=e.Page,n=e.Component,a=e.Behavior;e.Page=t,e.Component=o,e.Behavior=s;const l=i();return e.Page=r,e.Component=n,e.Behavior=a,l}))}componentEnv(e,t){const i=this;function o(e){return void 0!==e?i.behavior().definition(e).register():i.behavior()}return o.trait=i.traitBehavior.bind(i),t({Page:function(t){return i.component(e).pageDefinition(t).register()},Component:function(t){return void 0!==t?i.component(e).definition(t).register():i.component(e)},Behavior:o})}component(e){return b.create(this,e,this.waitingAliasMap[e])}behavior(){return y.create(this)}traitBehavior(e){return new m(void 0===e?this.space.defineTraitBehavior():this.space.defineTraitBehavior(e))}}class k{constructor(){this.codeSpaceMap=Object.create(null),this.globalCodeSpace=new O(this,!1,{})}getGlobalCodeSpace(){return this.globalCodeSpace}associateBackend(t){const o=null!=t?t:new e.CurrentWindowBackendContext;return new i(this,o)}createCodeSpace(e,t,i=Object.create(null)){const o=new O(this,t,i,this.globalCodeSpace);return this.codeSpaceMap[e]=o,o}getCodeSpace(e){return this.codeSpaceMap[e]}}var M;!function(e){e.Isolated="isolated",e.ApplyShared="apply-shared",e.Shared="shared",e.PageIsolated="page-isolated",e.PageApplyShared="page-apply-shared",e.PageShared="page-shared"}(M||(M={}));var x=Object.freeze({__proto__:null,get StyleIsolation(){return M},utils:t});export{i as AssociatedBackend,O as CodeSpace,k as MiniProgramEnv,o as Root,f as behavior,C as builder,$ as component,x as types};
|
|
2
2
|
//# sourceMappingURL=glass_easel_miniprogram_adapter.es.js.map
|