glass-easel-miniprogram-adapter 0.7.0 → 0.8.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 +22 -13
- 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/builder/base_behavior_builder.ts +20 -2
- package/src/builder/behavior_builder.ts +7 -1
- package/src/builder/component_builder.ts +7 -1
- package/src/builder/type_utils.ts +17 -6
- package/tests/env.test.ts +1 -1
- package/tests/selector.test.ts +10 -4
- package/tests/space.test.ts +12 -9
- package/tests/trait_behavior.test.ts +1 -1
|
@@ -449,22 +449,22 @@ type Lifetimes = {
|
|
|
449
449
|
interface BuilderContext<TPrevData extends DataList$4, TProperty extends PropertyList$4, TMethodCaller> extends ThisType<TMethodCaller> {
|
|
450
450
|
self: TMethodCaller;
|
|
451
451
|
data: typeUtils.Merge<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>;
|
|
452
|
-
setData: (newData: Partial<typeUtils.SetDataSetter<TPrevData>>, callback?: () => void) => void;
|
|
452
|
+
setData: (this: void, newData: Partial<typeUtils.SetDataSetter<TPrevData>>, callback?: () => void) => void;
|
|
453
453
|
implement: <TIn extends {
|
|
454
454
|
[x: string]: any;
|
|
455
|
-
}>(traitBehavior: TraitBehavior<TIn, any>, impl: TIn) => void;
|
|
455
|
+
}>(this: void, traitBehavior: TraitBehavior<TIn, any>, impl: TIn) => void;
|
|
456
456
|
relation<TOut extends {
|
|
457
457
|
[key: string]: any;
|
|
458
|
-
}>(def: TraitRelationParams<TOut> & ThisType<TMethodCaller>): RelationHandler<any, TOut>;
|
|
459
|
-
relation(def: RelationParams & ThisType<TMethodCaller>): RelationHandler<any, never>;
|
|
460
|
-
observer<P extends typeUtils.ObserverDataPathStrings<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>, V = typeUtils.GetFromObserverPathString<typeUtils.DataWithPropertyValues<TPrevData, TProperty>, P>>(paths: P, func: (newValue: V) => void): void;
|
|
458
|
+
}>(this: void, def: TraitRelationParams<TOut> & ThisType<TMethodCaller>): RelationHandler<any, TOut>;
|
|
459
|
+
relation(this: void, def: RelationParams & ThisType<TMethodCaller>): RelationHandler<any, never>;
|
|
460
|
+
observer<P extends typeUtils.ObserverDataPathStrings<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>, V = typeUtils.GetFromObserverPathString<typeUtils.DataWithPropertyValues<TPrevData, TProperty>, P>>(this: void, paths: P, func: (newValue: V) => void): void;
|
|
461
461
|
observer<P extends typeUtils.ObserverDataPathStrings<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>[], V = {
|
|
462
462
|
[K in keyof P]: typeUtils.GetFromObserverPathString<typeUtils.DataWithPropertyValues<TPrevData, TProperty>, P[K]>;
|
|
463
|
-
}>(paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void;
|
|
464
|
-
lifetime: <L extends keyof Lifetimes>(name: L, func: Lifetimes[L]) => void;
|
|
465
|
-
pageLifetime: (name: string, func: (...args: any[]) => void) => void;
|
|
466
|
-
method: <Fn extends ComponentMethod$3>(func: Fn) => TaggedMethod$3<Fn>;
|
|
467
|
-
listener: <T>(func: glassEasel.EventListener<T>) => TaggedMethod$3<glassEasel.EventListener<T>>;
|
|
463
|
+
}>(this: void, paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void;
|
|
464
|
+
lifetime: <L extends keyof Lifetimes>(this: void, name: L, func: Lifetimes[L]) => void;
|
|
465
|
+
pageLifetime: (this: void, name: string, func: (...args: any[]) => void) => void;
|
|
466
|
+
method: <Fn extends ComponentMethod$3>(this: void, func: Fn) => TaggedMethod$3<Fn>;
|
|
467
|
+
listener: <T>(this: void, func: glassEasel.EventListener<T>) => TaggedMethod$3<glassEasel.EventListener<T>>;
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
type Empty$3 = typeUtils.Empty;
|
|
@@ -476,6 +476,7 @@ type MethodList$3 = typeUtils.MethodList;
|
|
|
476
476
|
type ChainingFilterType$2 = typeUtils.ChainingFilterType;
|
|
477
477
|
type ComponentMethod$2 = typeUtils.ComponentMethod;
|
|
478
478
|
type TaggedMethod$2<Fn extends ComponentMethod$2> = typeUtils.TaggedMethod<Fn>;
|
|
479
|
+
type UnTaggedMethod$2<M extends TaggedMethod$2<any>> = typeUtils.UnTaggedMethod<M>;
|
|
479
480
|
declare class BaseBehaviorBuilder<TPrevData extends DataList$3 = Empty$3, TData extends DataList$3 = Empty$3, TProperty extends PropertyList$3 = Empty$3, TMethod extends MethodList$3 = Empty$3, TChainingFilter extends ChainingFilterType$2 = never, TPendingChainingFilter extends ChainingFilterType$2 = never, TComponentExport = never, TExtraThisFields extends DataList$3 = Empty$3> {
|
|
480
481
|
protected _$codeSpace: CodeSpace;
|
|
481
482
|
protected _$: glassEasel.BehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TExtraThisFields>;
|
|
@@ -516,7 +517,9 @@ declare class BaseBehaviorBuilder<TPrevData extends DataList$3 = Empty$3, TData
|
|
|
516
517
|
* Add a relation
|
|
517
518
|
*/
|
|
518
519
|
relation(name: string, rel: RelationParams & ThisType<Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
519
|
-
init<TExport extends Record<string, TaggedMethod$2<(...args: any[]) => any>> | void>(func: (this: Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>, builderContext: BuilderContext<TPrevData, TProperty, Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>) => TExport): ResolveBehaviorBuilder<BaseBehaviorBuilder<TPrevData, TData, TProperty, TMethod
|
|
520
|
+
init<TExport extends Record<string, TaggedMethod$2<(...args: any[]) => any>> | void>(func: (this: Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>, builderContext: BuilderContext<TPrevData, TProperty, Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>) => TExport): ResolveBehaviorBuilder<BaseBehaviorBuilder<TPrevData, TData, TProperty, TMethod & (TExport extends void ? Empty$3 : {
|
|
521
|
+
[K in keyof TExport]: UnTaggedMethod$2<TExport[K]>;
|
|
522
|
+
}), TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
520
523
|
definition<TNewData extends DataList$3 = Empty$3, TNewProperty extends PropertyList$3 = Empty$3, TNewMethod extends MethodList$3 = Empty$3, TNewComponentExport = never>(def: BehaviorDefinition<TNewData, TNewProperty, TNewMethod, TNewComponentExport> & ThisType<Component<TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TNewComponentExport, TExtraThisFields>>): ResolveBehaviorBuilder<BaseBehaviorBuilder<TPrevData, TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TChainingFilter, TPendingChainingFilter, TNewComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
521
524
|
}
|
|
522
525
|
|
|
@@ -529,6 +532,7 @@ type MethodList$2 = typeUtils.MethodList;
|
|
|
529
532
|
type ChainingFilterType$1 = typeUtils.ChainingFilterType;
|
|
530
533
|
type ComponentMethod$1 = typeUtils.ComponentMethod;
|
|
531
534
|
type TaggedMethod$1<Fn extends ComponentMethod$1> = typeUtils.TaggedMethod<Fn>;
|
|
535
|
+
type UnTaggedMethod$1<M extends TaggedMethod$1<any>> = typeUtils.UnTaggedMethod<M>;
|
|
532
536
|
type ChainingFilterFunc<TAddedFields extends {
|
|
533
537
|
[key: string]: any;
|
|
534
538
|
}, TRemovedFields extends string = never> = typeUtils.ChainingFilterFunc<TAddedFields, TRemovedFields>;
|
|
@@ -571,7 +575,9 @@ declare class BehaviorBuilder<TPrevData extends DataList$2 = Empty$2, TData exte
|
|
|
571
575
|
* The return value is used as the "export" value of the behavior,
|
|
572
576
|
* which can be imported by other behaviors.
|
|
573
577
|
*/
|
|
574
|
-
init<TExport extends Record<string, TaggedMethod$1<(...args: any[]) => any>> | void>(func: (this: Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>, builderContext: BuilderContext<TPrevData, TProperty, Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>) => TExport): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty, TMethod
|
|
578
|
+
init<TExport extends Record<string, TaggedMethod$1<(...args: any[]) => any>> | void>(func: (this: Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>, builderContext: BuilderContext<TPrevData, TProperty, Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>) => TExport): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty, TMethod & (TExport extends void ? Empty$2 : {
|
|
579
|
+
[K in keyof TExport]: UnTaggedMethod$1<TExport[K]>;
|
|
580
|
+
}), TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
575
581
|
/** Apply a classic definition object */
|
|
576
582
|
definition<TNewData extends DataList$2 = Empty$2, TNewProperty extends PropertyList$2 = Empty$2, TNewMethod extends MethodList$2 = Empty$2, TNewComponentExport = never>(def: BehaviorDefinition<TNewData, TNewProperty, TNewMethod, TNewComponentExport> & ThisType<Component<TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TNewComponentExport, TExtraThisFields>>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TChainingFilter, TPendingChainingFilter, TNewComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
577
583
|
/**
|
|
@@ -593,6 +599,7 @@ type MethodList$1 = typeUtils.MethodList;
|
|
|
593
599
|
type ChainingFilterType = typeUtils.ChainingFilterType;
|
|
594
600
|
type ComponentMethod = typeUtils.ComponentMethod;
|
|
595
601
|
type TaggedMethod<Fn extends ComponentMethod> = typeUtils.TaggedMethod<Fn>;
|
|
602
|
+
type UnTaggedMethod<M extends TaggedMethod<any>> = typeUtils.UnTaggedMethod<M>;
|
|
596
603
|
/**
|
|
597
604
|
* A direct way to create a component
|
|
598
605
|
*/
|
|
@@ -637,7 +644,9 @@ declare class ComponentBuilder<TPrevData extends DataList$1 = Empty$1, TData ext
|
|
|
637
644
|
* The return value is used as the "export" value of the behavior,
|
|
638
645
|
* which can be imported by other behaviors.
|
|
639
646
|
*/
|
|
640
|
-
init<TExport extends Record<string, TaggedMethod<(...args: any[]) => any>> | void>(func: (this: Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>, builderContext: BuilderContext<TPrevData, TProperty, Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>) => TExport): ResolveBehaviorBuilder<ComponentBuilder<TPrevData, TData, TProperty, TMethod
|
|
647
|
+
init<TExport extends Record<string, TaggedMethod<(...args: any[]) => any>> | void>(func: (this: Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>, builderContext: BuilderContext<TPrevData, TProperty, Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>>) => TExport): ResolveBehaviorBuilder<ComponentBuilder<TPrevData, TData, TProperty, TMethod & (TExport extends void ? Empty$1 : {
|
|
648
|
+
[K in keyof TExport]: UnTaggedMethod<TExport[K]>;
|
|
649
|
+
}), TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
641
650
|
/** Apply a classic definition object */
|
|
642
651
|
definition<TNewData extends DataList$1 = Empty$1, TNewProperty extends PropertyList$1 = Empty$1, TNewMethod extends MethodList$1 = Empty$1, TNewComponentExport = never>(def: ComponentDefinition<TNewData, TNewProperty, TNewMethod, TNewComponentExport> & ThisType<Component<TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TNewComponentExport, TExtraThisFields>>): ResolveBehaviorBuilder<ComponentBuilder<TPrevData, TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TChainingFilter, TPendingChainingFilter, TNewComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
643
652
|
pageDefinition<TNewData extends DataList$1, TNewExtraFields extends {
|
|
@@ -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:s}=i.getComponentOptions(),r=o.getStyleSheet(i.is);void 0!==r&&t.appendStyleSheetPath(r,null!=s?s: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}}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)}],(()=>{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}=this._$margins,h=`${n}px ${a}px ${l}px ${r}px`;o.forEach((e=>{let i=this._$initialRatio;const o=e.createIntersectionObserver(s,h,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 d?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 d?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}};class d{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 u{constructor(e,t){this.proto=Object.create(d.prototype),Object.assign(this.proto,e),this.proto._$export=t}derive(){return Object.create(this.proto)}}var _=Object.freeze({__proto__:null,ComponentCaller:d,ComponentProto:u});class ${constructor(e,t,i,o){if(this._$=e,this._$export=o,void 0!==i){const e=t.map((e=>{var t;return null!==(t=e._$bindedDefinitionFilter)&&void 0!==t?t:null}));this._$bindedDefinitionFilter=t=>{i(t,e)}}}}class g{constructor(e){this._$=e}}class v{constructor(e){this._$=e}}var m=Object.freeze({__proto__:null,Behavior:$,ComponentType:g,TraitBehavior:v});class f{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}data(e){return this._$.data(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 $||t.target instanceof g?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;return 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=>{if(e.target instanceof v)return r({target:e.target._$,type:e.type,linked:e.linked,linkChanged:e.linkChanged,unlinked:e.unlinked,linkFailed:e.linkFailed});const t=e.target instanceof $||e.target instanceof g?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})})),this}definition(e){var t;null===(t=e.behaviors)||void 0===t||t.forEach((t=>{var i;return null===(i=t._$bindedDefinitionFilter)||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:g,export:v}=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];i.relation(o,s)}}return g&&i.externalClasses(g),v&&(this._$export=v),this}}class y extends f{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 this._$parents.push(e),this._$=this._$.behavior(e._$),this}export(e){return super.export(e)}data(e){return super.data(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 $(this._$.registerBehavior(),this._$parents,this._$definitionFilter,this._$export)}extraThisFieldsType(){return this}}class b extends f{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 u(i,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 this._$parents.push(e),this._$=this._$.behavior(e._$),e._$export&&(this._$export=e._$export),this}export(e){return this._$export=e,this}data(e){return super.data(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 g(c)}extraThisFieldsType(){return this}}var S=Object.freeze({__proto__:null,BehaviorBuilder:y,ComponentBuilder:b});const C=()=>Math.floor(4294967296*(1+Math.random())).toString(16).slice(1);class w{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.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._$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)||`__${C()}`),a=this._$sharedStyleScope):n="shared"!==l&&"page-shared"!==l||!this._$isMainSpace?this.styleScopeManager.register(this.getStyleScopeName(e)||`__${C()}`):this._$sharedStyleScope;return[{idPrefixGenerator:C,multipleSlots:null==t?void 0:t.multipleSlots,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 v(void 0===e?this.space.defineTraitBehavior():this.space.defineTraitBehavior(e))}}class O{constructor(){this.codeSpaceMap=Object.create(null),this.globalCodeSpace=new w(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 w(this,t,i,this.globalCodeSpace);return this.codeSpaceMap[e]=o,o}getCodeSpace(e){return this.codeSpaceMap[e]}}var k;!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"}(k||(k={}));var M=Object.freeze({__proto__:null,get StyleIsolation(){return k},utils:t});export{i as AssociatedBackend,w as CodeSpace,O as MiniProgramEnv,o as Root,m as behavior,S as builder,_ as component,M 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:s}=i.getComponentOptions(),r=o.getStyleSheet(i.is);void 0!==r&&t.appendStyleSheetPath(r,null!=s?s: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}}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)}],(()=>{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}=this._$margins,h=`${n}px ${a}px ${l}px ${r}px`;o.forEach((e=>{let i=this._$initialRatio;const o=e.createIntersectionObserver(s,h,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 d?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 d?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}};class d{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 u{constructor(e,t){this.proto=Object.create(d.prototype),Object.assign(this.proto,e),this.proto._$export=t}derive(){return Object.create(this.proto)}}var _=Object.freeze({__proto__:null,ComponentCaller:d,ComponentProto:u});class ${constructor(e,t,i,o){if(this._$=e,this._$export=o,void 0!==i){const e=t.map((e=>{var t;return null!==(t=e._$bindedDefinitionFilter)&&void 0!==t?t:null}));this._$bindedDefinitionFilter=t=>{i(t,e)}}}}class g{constructor(e){this._$=e}}class v{constructor(e){this._$=e}}var m=Object.freeze({__proto__:null,Behavior:$,ComponentType:g,TraitBehavior:v});class f{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}data(e){return this._$.data(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 $||t.target instanceof g?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=>{if(e.target instanceof v)return r({target:e.target._$,type:e.type,linked:e.linked,linkChanged:e.linkChanged,unlinked:e.unlinked,linkFailed:e.linkFailed});const t=e.target instanceof $||e.target instanceof g?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._$bindedDefinitionFilter)||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:g,export:v}=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];i.relation(o,s)}}return g&&i.externalClasses(g),v&&(this._$export=v),this}}class y extends f{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 this._$parents.push(e),this._$=this._$.behavior(e._$),this}export(e){return super.export(e)}data(e){return super.data(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 $(this._$.registerBehavior(),this._$parents,this._$definitionFilter,this._$export)}extraThisFieldsType(){return this}}class b extends f{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 u(i,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 this._$parents.push(e),this._$=this._$.behavior(e._$),e._$export&&(this._$export=e._$export),this}export(e){return this._$export=e,this}data(e){return super.data(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 g(c)}extraThisFieldsType(){return this}}var S=Object.freeze({__proto__:null,BehaviorBuilder:y,ComponentBuilder:b});const C=()=>Math.floor(4294967296*(1+Math.random())).toString(16).slice(1);class w{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.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._$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)||`__${C()}`),a=this._$sharedStyleScope):n="shared"!==l&&"page-shared"!==l||!this._$isMainSpace?this.styleScopeManager.register(this.getStyleScopeName(e)||`__${C()}`):this._$sharedStyleScope;return[{idPrefixGenerator:C,multipleSlots:null==t?void 0:t.multipleSlots,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 v(void 0===e?this.space.defineTraitBehavior():this.space.defineTraitBehavior(e))}}class O{constructor(){this.codeSpaceMap=Object.create(null),this.globalCodeSpace=new w(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 w(this,t,i,this.globalCodeSpace);return this.codeSpaceMap[e]=o,o}getCodeSpace(e){return this.codeSpaceMap[e]}}var k;!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"}(k||(k={}));var M=Object.freeze({__proto__:null,get StyleIsolation(){return k},utils:t});export{i as AssociatedBackend,w as CodeSpace,O as MiniProgramEnv,o as Root,m as behavior,S as builder,_ as component,M as types};
|
|
2
2
|
//# sourceMappingURL=glass_easel_miniprogram_adapter.es.js.map
|