glass-easel-miniprogram-adapter 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/glass_easel_miniprogram_adapter.d.ts +116 -108
- 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 +23 -13
- package/src/builder/base_behavior_builder.ts +69 -23
- package/src/builder/behavior_builder.ts +34 -21
- package/src/builder/component_builder.ts +28 -29
- package/src/builder/index.ts +2 -0
- package/src/builder/type_utils.ts +2 -2
- package/src/component.ts +74 -28
- package/src/space.ts +77 -15
- package/src/types.ts +4 -3
- package/tests/env.test.ts +8 -1
- package/tests/selector.test.ts +64 -1
- package/tests/space.test.ts +59 -7
|
@@ -120,14 +120,14 @@ declare class MediaQueryObserver {
|
|
|
120
120
|
disconnect(): void;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
type Empty$5 = typeUtils.Empty;
|
|
124
123
|
type DataList$6 = typeUtils.DataList;
|
|
125
124
|
type PropertyList$6 = typeUtils.PropertyList;
|
|
126
125
|
type MethodList$5 = typeUtils.MethodList;
|
|
127
126
|
type AllData<TData extends DataList$6, TProperty extends PropertyList$6> = typeUtils.DataWithPropertyValues<TData, TProperty>;
|
|
128
|
-
type ExportType<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport> = [UComponentExport] extends [never] ? Component<UData, UProperty, UMethod, UComponentExport> : UComponentExport;
|
|
129
|
-
|
|
130
|
-
type Component<
|
|
127
|
+
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
|
+
declare const determineComponentExports: (parent: GeneralBehavior[], selfExport: ((source: GeneralComponent | null) => any) | undefined) => ((source: GeneralComponent | null) => any) | undefined;
|
|
129
|
+
type GeneralComponent = Component<Record<string, any>, Record<string, any>, Record<string, any>, any, Record<string, any>>;
|
|
130
|
+
type Component<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport, TExtraThisFields extends DataList$6> = ComponentCaller<TData, TProperty, TMethod, TComponentExport> & {
|
|
131
131
|
[k in keyof TMethod]: TMethod[k];
|
|
132
132
|
} & TExtraThisFields;
|
|
133
133
|
declare class ComponentCaller<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport> {
|
|
@@ -249,7 +249,7 @@ declare class ComponentCaller<TData extends DataList$6, TProperty extends Proper
|
|
|
249
249
|
* If the component type does not match, `null` is returned.
|
|
250
250
|
*/
|
|
251
251
|
selectComponent(selector: string): any;
|
|
252
|
-
selectComponent<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport>(selector: string, componentType: ComponentType<UData, UProperty, UMethod, UComponentExport>): ExportType<UData, UProperty, UMethod, UComponentExport> | null;
|
|
252
|
+
selectComponent<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport, UExtraThisFields extends DataList$6>(selector: string, componentType: ComponentType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields>): ExportType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields> | null;
|
|
253
253
|
/**
|
|
254
254
|
* Query all elements inside the component
|
|
255
255
|
*
|
|
@@ -257,7 +257,7 @@ declare class ComponentCaller<TData extends DataList$6, TProperty extends Proper
|
|
|
257
257
|
* If a component type does not match, it is not returned.
|
|
258
258
|
*/
|
|
259
259
|
selectAllComponents(selector: string): GeneralComponent[];
|
|
260
|
-
selectAllComponents<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport>(selector: string, componentType: ComponentType<UData, UProperty, UMethod, UComponentExport>): ExportType<UData, UProperty, UMethod, UComponentExport>[];
|
|
260
|
+
selectAllComponents<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport, UExtraThisFields extends DataList$6>(selector: string, componentType: ComponentType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields>): ExportType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields>[];
|
|
261
261
|
/**
|
|
262
262
|
* Get the owner component
|
|
263
263
|
*
|
|
@@ -265,7 +265,7 @@ declare class ComponentCaller<TData extends DataList$6, TProperty extends Proper
|
|
|
265
265
|
* If a component type does not match, `null` is returned.
|
|
266
266
|
*/
|
|
267
267
|
selectOwnerComponent(): any;
|
|
268
|
-
selectOwnerComponent<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport>(componentType: ComponentType<UData, UProperty, UMethod, UComponentExport>): ExportType<UData, UProperty, UMethod, UComponentExport> | null;
|
|
268
|
+
selectOwnerComponent<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport, UExtraThisFields extends DataList$6>(componentType: ComponentType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields>): ExportType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields> | null;
|
|
269
269
|
getRelationNodes(relationKey: string): GeneralComponent[];
|
|
270
270
|
/** Cast the component into a general-typed one */
|
|
271
271
|
general(): GeneralComponent;
|
|
@@ -274,23 +274,80 @@ declare class ComponentCaller<TData extends DataList$6, TProperty extends Proper
|
|
|
274
274
|
*
|
|
275
275
|
* Returns `null` if the component node is not the instance of the specified component.
|
|
276
276
|
*/
|
|
277
|
-
asInstanceOf<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport>(componentType: ComponentType<UData, UProperty, UMethod, UComponentExport>): Component<UData, UProperty, UMethod, UComponentExport> | null;
|
|
277
|
+
asInstanceOf<UData extends DataList$6, UProperty extends PropertyList$6, UMethod extends MethodList$5, UComponentExport, UExtraThisFields extends DataList$6>(componentType: ComponentType<UData, UProperty, UMethod, UComponentExport, UExtraThisFields>): Component<UData, UProperty, UMethod, UComponentExport, UExtraThisFields> | null;
|
|
278
278
|
}
|
|
279
|
-
declare class ComponentProto<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport> {
|
|
279
|
+
declare class ComponentProto<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport, TExtraThisFields extends DataList$6> {
|
|
280
280
|
private proto;
|
|
281
|
-
constructor(methods: TMethod, componentExport?: (source: GeneralComponent | null) => TComponentExport);
|
|
282
|
-
derive(): Component<TData, TProperty, TMethod, TComponentExport>;
|
|
281
|
+
constructor(methods: TMethod, parents: GeneralBehavior[], componentExport?: (source: GeneralComponent | null) => TComponentExport);
|
|
282
|
+
derive(): Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
type component_AllData<TData extends DataList$6, TProperty extends PropertyList$6> = AllData<TData, TProperty>;
|
|
286
|
-
type component_Component<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport, TExtraThisFields extends DataList$6
|
|
286
|
+
type component_Component<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport, TExtraThisFields extends DataList$6> = Component<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>;
|
|
287
287
|
type component_ComponentCaller<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport> = ComponentCaller<TData, TProperty, TMethod, TComponentExport>;
|
|
288
288
|
declare const component_ComponentCaller: typeof ComponentCaller;
|
|
289
|
-
type component_ComponentProto<TData extends DataList$6, TProperty extends PropertyList$6, TMethod extends MethodList$5, TComponentExport> = ComponentProto<TData, TProperty, TMethod, TComponentExport>;
|
|
289
|
+
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
290
|
declare const component_ComponentProto: typeof ComponentProto;
|
|
291
291
|
type component_GeneralComponent = GeneralComponent;
|
|
292
|
+
declare const component_determineComponentExports: typeof determineComponentExports;
|
|
292
293
|
declare namespace component {
|
|
293
|
-
export { type component_AllData as AllData, type component_Component as Component, component_ComponentCaller as ComponentCaller, component_ComponentProto as ComponentProto, type component_GeneralComponent as GeneralComponent };
|
|
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 };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
type ResolveBehaviorBuilder<B, TChainingFilter extends ChainingFilterType$4> = typeUtils.IsNever<TChainingFilter> extends false ? TChainingFilter extends ChainingFilterType$4 ? Omit<B, TChainingFilter['remove']> & TChainingFilter['add'] : B : B;
|
|
298
|
+
type DataList$5 = typeUtils.DataList;
|
|
299
|
+
type PropertyList$5 = typeUtils.PropertyList;
|
|
300
|
+
type ChainingFilterType$4 = typeUtils.ChainingFilterType;
|
|
301
|
+
type ComponentMethod$4 = typeUtils.ComponentMethod;
|
|
302
|
+
type TaggedMethod$3<Fn extends ComponentMethod$4> = typeUtils.TaggedMethod<Fn>;
|
|
303
|
+
interface RelationHandler<TTarget, TOut> {
|
|
304
|
+
list(): TTarget[];
|
|
305
|
+
listAsTrait: TOut extends never ? undefined : () => TOut[];
|
|
306
|
+
}
|
|
307
|
+
type TraitRelationParams<TOut extends {
|
|
308
|
+
[key: string]: any;
|
|
309
|
+
}> = {
|
|
310
|
+
target: TraitBehavior<any, TOut>;
|
|
311
|
+
type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node';
|
|
312
|
+
linked?: (target: GeneralComponent) => void;
|
|
313
|
+
linkChanged?: (target: GeneralComponent) => void;
|
|
314
|
+
unlinked?: (target: GeneralComponent) => void;
|
|
315
|
+
linkFailed?: (target: GeneralComponent) => void;
|
|
316
|
+
};
|
|
317
|
+
type RelationParams = {
|
|
318
|
+
target?: string | GeneralComponentType | GeneralBehavior | TraitBehavior<any>;
|
|
319
|
+
type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node';
|
|
320
|
+
linked?: (target: GeneralComponent) => void;
|
|
321
|
+
linkChanged?: (target: GeneralComponent) => void;
|
|
322
|
+
unlinked?: (target: GeneralComponent) => void;
|
|
323
|
+
linkFailed?: (target: GeneralComponent) => void;
|
|
324
|
+
};
|
|
325
|
+
type Lifetimes = {
|
|
326
|
+
created: () => void;
|
|
327
|
+
attached: () => void;
|
|
328
|
+
moved: () => void;
|
|
329
|
+
detached: () => void;
|
|
330
|
+
ready: () => void;
|
|
331
|
+
};
|
|
332
|
+
interface BuilderContext<TPrevData extends DataList$5, TProperty extends PropertyList$5, TMethodCaller> extends ThisType<TMethodCaller> {
|
|
333
|
+
self: TMethodCaller;
|
|
334
|
+
data: typeUtils.Merge<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>;
|
|
335
|
+
setData: (this: void, newData: Partial<typeUtils.SetDataSetter<TPrevData>>, callback?: () => void) => void;
|
|
336
|
+
implement: <TIn extends {
|
|
337
|
+
[x: string]: any;
|
|
338
|
+
}>(this: void, traitBehavior: TraitBehavior<TIn, any>, impl: TIn) => void;
|
|
339
|
+
relation<TOut extends {
|
|
340
|
+
[key: string]: any;
|
|
341
|
+
}>(this: void, def: TraitRelationParams<TOut> & ThisType<TMethodCaller>): RelationHandler<any, TOut>;
|
|
342
|
+
relation(this: void, def: RelationParams & ThisType<TMethodCaller>): RelationHandler<any, never>;
|
|
343
|
+
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;
|
|
344
|
+
observer<P extends typeUtils.ObserverDataPathStrings<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>[], V = {
|
|
345
|
+
[K in keyof P]: typeUtils.GetFromObserverPathString<typeUtils.DataWithPropertyValues<TPrevData, TProperty>, P[K]>;
|
|
346
|
+
}>(this: void, paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void;
|
|
347
|
+
lifetime: <L extends keyof Lifetimes>(this: void, name: L, func: Lifetimes[L]) => void;
|
|
348
|
+
pageLifetime: (this: void, name: string, func: (...args: any[]) => void) => void;
|
|
349
|
+
method: <Fn extends ComponentMethod$4>(this: void, func: Fn) => TaggedMethod$3<Fn>;
|
|
350
|
+
listener: <T>(this: void, func: glassEasel.EventListener<T>) => TaggedMethod$3<glassEasel.EventListener<T>>;
|
|
294
351
|
}
|
|
295
352
|
|
|
296
353
|
declare const enum StyleIsolation {
|
|
@@ -328,30 +385,30 @@ type ComponentDefinitionOptions = {
|
|
|
328
385
|
propertyPassingDeepCopy?: DeepCopyKind;
|
|
329
386
|
propertyEarlyInit?: boolean;
|
|
330
387
|
};
|
|
331
|
-
type ComponentMethod$
|
|
388
|
+
type ComponentMethod$3 = typeUtils.ComponentMethod;
|
|
332
389
|
type BehaviorDefinition<TData extends typeUtils.DataList, TProperty extends typeUtils.PropertyList, TMethod extends typeUtils.MethodList, TComponentExport> = {
|
|
333
|
-
behaviors?:
|
|
390
|
+
behaviors?: GeneralBehavior[];
|
|
334
391
|
properties?: TProperty;
|
|
335
392
|
data?: TData | (() => TData);
|
|
336
393
|
observers?: {
|
|
337
394
|
fields?: string;
|
|
338
|
-
observer: ComponentMethod$
|
|
395
|
+
observer: ComponentMethod$3;
|
|
339
396
|
}[] | {
|
|
340
|
-
[fields: string]: ComponentMethod$
|
|
397
|
+
[fields: string]: ComponentMethod$3;
|
|
341
398
|
};
|
|
342
399
|
methods?: TMethod;
|
|
343
|
-
created?: ComponentMethod$
|
|
344
|
-
attached?: ComponentMethod$
|
|
345
|
-
ready?: ComponentMethod$
|
|
346
|
-
moved?: ComponentMethod$
|
|
347
|
-
detached?: ComponentMethod$
|
|
400
|
+
created?: ComponentMethod$3;
|
|
401
|
+
attached?: ComponentMethod$3;
|
|
402
|
+
ready?: ComponentMethod$3;
|
|
403
|
+
moved?: ComponentMethod$3;
|
|
404
|
+
detached?: ComponentMethod$3;
|
|
348
405
|
lifetimes?: {
|
|
349
|
-
[name: string]: ComponentMethod$
|
|
406
|
+
[name: string]: ComponentMethod$3;
|
|
350
407
|
};
|
|
351
408
|
pageLifetimes?: {
|
|
352
|
-
[name: string]: ComponentMethod$
|
|
409
|
+
[name: string]: ComponentMethod$3;
|
|
353
410
|
};
|
|
354
|
-
relations?:
|
|
411
|
+
relations?: Record<string, RelationParams>;
|
|
355
412
|
externalClasses?: string[];
|
|
356
413
|
definitionFilter?: DefinitionFilter;
|
|
357
414
|
export?: (source: GeneralComponent | null) => TComponentExport;
|
|
@@ -382,17 +439,17 @@ declare namespace types {
|
|
|
382
439
|
export { type types_BehaviorDefinition as BehaviorDefinition, type types_ComponentDefinition as ComponentDefinition, type types_ComponentDefinitionOptions as ComponentDefinitionOptions, type types_ComponentStaticConfig as ComponentStaticConfig, type types_GeneralComponentDefinition as GeneralComponentDefinition, type types_PageDefinition as PageDefinition, types_StyleIsolation as StyleIsolation, typeUtils as utils };
|
|
383
440
|
}
|
|
384
441
|
|
|
385
|
-
type
|
|
386
|
-
type
|
|
387
|
-
type PropertyList$5 = typeUtils.PropertyList;
|
|
442
|
+
type DataList$4 = typeUtils.DataList;
|
|
443
|
+
type PropertyList$4 = typeUtils.PropertyList;
|
|
388
444
|
type MethodList$4 = typeUtils.MethodList;
|
|
389
|
-
type ChainingFilterType$
|
|
445
|
+
type ChainingFilterType$3 = typeUtils.ChainingFilterType;
|
|
390
446
|
type DefinitionFilter = (target: GeneralComponentDefinition, childFilters: (((target: GeneralComponentDefinition) => void) | null)[]) => void;
|
|
391
|
-
type GeneralBehavior = Behavior<Record<string, any>, Record<string, any>, Record<string, any>, any, any
|
|
392
|
-
declare class Behavior<TData extends DataList$
|
|
447
|
+
type GeneralBehavior = Behavior<Record<string, any>, Record<string, any>, Record<string, any>, any, any, Record<string, any>>;
|
|
448
|
+
declare class Behavior<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4, TChainingFilter extends ChainingFilterType$3, TComponentExport, TExtraThisFields extends DataList$4> {
|
|
393
449
|
}
|
|
394
|
-
declare class ComponentType<TData extends DataList$
|
|
450
|
+
declare class ComponentType<TData extends DataList$4, TProperty extends PropertyList$4, TMethod extends MethodList$4, TComponentExport, TExtraThisFields extends DataList$4> {
|
|
395
451
|
}
|
|
452
|
+
type GeneralComponentType = ComponentType<Record<string, any>, Record<string, any>, Record<string, any>, any, Record<string, any>>;
|
|
396
453
|
declare class TraitBehavior<TIn extends {
|
|
397
454
|
[key: string]: any;
|
|
398
455
|
}, TOut extends {
|
|
@@ -401,12 +458,13 @@ declare class TraitBehavior<TIn extends {
|
|
|
401
458
|
constructor(inner: glassEasel.TraitBehavior<TIn, TOut>);
|
|
402
459
|
}
|
|
403
460
|
|
|
404
|
-
type behavior_Behavior<TData extends DataList$
|
|
461
|
+
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>;
|
|
405
462
|
declare const behavior_Behavior: typeof Behavior;
|
|
406
|
-
type behavior_ComponentType<TData extends DataList$
|
|
463
|
+
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>;
|
|
407
464
|
declare const behavior_ComponentType: typeof ComponentType;
|
|
408
465
|
type behavior_DefinitionFilter = DefinitionFilter;
|
|
409
466
|
type behavior_GeneralBehavior = GeneralBehavior;
|
|
467
|
+
type behavior_GeneralComponentType = GeneralComponentType;
|
|
410
468
|
type behavior_TraitBehavior<TIn extends {
|
|
411
469
|
[key: string]: any;
|
|
412
470
|
}, TOut extends {
|
|
@@ -414,63 +472,7 @@ type behavior_TraitBehavior<TIn extends {
|
|
|
414
472
|
} = TIn> = TraitBehavior<TIn, TOut>;
|
|
415
473
|
declare const behavior_TraitBehavior: typeof TraitBehavior;
|
|
416
474
|
declare namespace behavior {
|
|
417
|
-
export { behavior_Behavior as Behavior, behavior_ComponentType as ComponentType, type behavior_DefinitionFilter as DefinitionFilter, type behavior_GeneralBehavior as GeneralBehavior, behavior_TraitBehavior as TraitBehavior };
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
type ResolveBehaviorBuilder<B, TChainingFilter extends ChainingFilterType$3> = typeUtils.IsNever<TChainingFilter> extends false ? TChainingFilter extends ChainingFilterType$3 ? Omit<B, TChainingFilter['remove']> & TChainingFilter['add'] : B : B;
|
|
421
|
-
type DataList$4 = typeUtils.DataList;
|
|
422
|
-
type PropertyList$4 = typeUtils.PropertyList;
|
|
423
|
-
type ChainingFilterType$3 = typeUtils.ChainingFilterType;
|
|
424
|
-
type ComponentMethod$3 = typeUtils.ComponentMethod;
|
|
425
|
-
type TaggedMethod$3<Fn extends ComponentMethod$3> = typeUtils.TaggedMethod<Fn>;
|
|
426
|
-
interface RelationHandler<TTarget, TOut> {
|
|
427
|
-
list(): TTarget[];
|
|
428
|
-
listAsTrait: TOut extends never ? undefined : () => TOut[];
|
|
429
|
-
}
|
|
430
|
-
type TraitRelationParams<TOut extends {
|
|
431
|
-
[key: string]: any;
|
|
432
|
-
}> = {
|
|
433
|
-
target: TraitBehavior<any, TOut>;
|
|
434
|
-
type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node';
|
|
435
|
-
linked?: (target: GeneralComponent) => void;
|
|
436
|
-
linkChanged?: (target: GeneralComponent) => void;
|
|
437
|
-
unlinked?: (target: GeneralComponent) => void;
|
|
438
|
-
linkFailed?: (target: GeneralComponent) => void;
|
|
439
|
-
};
|
|
440
|
-
type RelationParams = {
|
|
441
|
-
target?: string | ComponentType<any, any, any, any> | GeneralBehavior | TraitBehavior<any>;
|
|
442
|
-
type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node';
|
|
443
|
-
linked?: (target: GeneralComponent) => void;
|
|
444
|
-
linkChanged?: (target: GeneralComponent) => void;
|
|
445
|
-
unlinked?: (target: GeneralComponent) => void;
|
|
446
|
-
linkFailed?: (target: GeneralComponent) => void;
|
|
447
|
-
};
|
|
448
|
-
type Lifetimes = {
|
|
449
|
-
created: () => void;
|
|
450
|
-
attached: () => void;
|
|
451
|
-
moved: () => void;
|
|
452
|
-
detached: () => void;
|
|
453
|
-
ready: () => void;
|
|
454
|
-
};
|
|
455
|
-
interface BuilderContext<TPrevData extends DataList$4, TProperty extends PropertyList$4, TMethodCaller> extends ThisType<TMethodCaller> {
|
|
456
|
-
self: TMethodCaller;
|
|
457
|
-
data: typeUtils.Merge<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>;
|
|
458
|
-
setData: (this: void, newData: Partial<typeUtils.SetDataSetter<TPrevData>>, callback?: () => void) => void;
|
|
459
|
-
implement: <TIn extends {
|
|
460
|
-
[x: string]: any;
|
|
461
|
-
}>(this: void, traitBehavior: TraitBehavior<TIn, any>, impl: TIn) => void;
|
|
462
|
-
relation<TOut extends {
|
|
463
|
-
[key: string]: any;
|
|
464
|
-
}>(this: void, def: TraitRelationParams<TOut> & ThisType<TMethodCaller>): RelationHandler<any, TOut>;
|
|
465
|
-
relation(this: void, def: RelationParams & ThisType<TMethodCaller>): RelationHandler<any, never>;
|
|
466
|
-
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;
|
|
467
|
-
observer<P extends typeUtils.ObserverDataPathStrings<typeUtils.DataWithPropertyValues<TPrevData, TProperty>>[], V = {
|
|
468
|
-
[K in keyof P]: typeUtils.GetFromObserverPathString<typeUtils.DataWithPropertyValues<TPrevData, TProperty>, P[K]>;
|
|
469
|
-
}>(this: void, paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void;
|
|
470
|
-
lifetime: <L extends keyof Lifetimes>(this: void, name: L, func: Lifetimes[L]) => void;
|
|
471
|
-
pageLifetime: (this: void, name: string, func: (...args: any[]) => void) => void;
|
|
472
|
-
method: <Fn extends ComponentMethod$3>(this: void, func: Fn) => TaggedMethod$3<Fn>;
|
|
473
|
-
listener: <T>(this: void, func: glassEasel.EventListener<T>) => TaggedMethod$3<glassEasel.EventListener<T>>;
|
|
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 };
|
|
474
476
|
}
|
|
475
477
|
|
|
476
478
|
type Empty$3 = typeUtils.Empty;
|
|
@@ -483,7 +485,7 @@ type ChainingFilterType$2 = typeUtils.ChainingFilterType;
|
|
|
483
485
|
type ComponentMethod$2 = typeUtils.ComponentMethod;
|
|
484
486
|
type TaggedMethod$2<Fn extends ComponentMethod$2> = typeUtils.TaggedMethod<Fn>;
|
|
485
487
|
type UnTaggedMethod$2<M extends TaggedMethod$2<any>> = typeUtils.UnTaggedMethod<M>;
|
|
486
|
-
declare class BaseBehaviorBuilder<TPrevData extends DataList$3
|
|
488
|
+
declare class BaseBehaviorBuilder<TPrevData extends DataList$3, TData extends DataList$3, TProperty extends PropertyList$3, TMethod extends MethodList$3, TChainingFilter extends ChainingFilterType$2, TPendingChainingFilter extends ChainingFilterType$2, TComponentExport, TExtraThisFields extends DataList$3> {
|
|
487
489
|
protected _$codeSpace: CodeSpace;
|
|
488
490
|
protected _$: glassEasel.BehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TExtraThisFields>;
|
|
489
491
|
protected _$parents: GeneralBehavior[];
|
|
@@ -495,6 +497,8 @@ declare class BaseBehaviorBuilder<TPrevData extends DataList$3 = Empty$3, TData
|
|
|
495
497
|
/** Add external classes */
|
|
496
498
|
externalClasses(list: string[]): this;
|
|
497
499
|
export<TNewComponentExport>(f: (this: GeneralComponent, source: GeneralComponent | null) => TNewComponentExport): ResolveBehaviorBuilder<BaseBehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TNewComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
500
|
+
/** Use another behavior */
|
|
501
|
+
behavior<UData extends DataList$3, UProperty extends PropertyList$3, UMethod extends MethodList$3, UChainingFilter extends ChainingFilterType$2, UComponentExport, UExtraThisFields extends DataList$3>(behavior: Behavior<UData, UProperty, UMethod, UChainingFilter, UComponentExport, UExtraThisFields>): ResolveBehaviorBuilder<BaseBehaviorBuilder<TPrevData, TData & UData, TProperty & UProperty, TMethod & UMethod, UChainingFilter, TPendingChainingFilter, UComponentExport, TExtraThisFields & UExtraThisFields>, UChainingFilter>;
|
|
498
502
|
data<T extends DataList$3>(gen: () => typeUtils.NewFieldList<AllData<TData, TProperty>, T>): ResolveBehaviorBuilder<BaseBehaviorBuilder<T, TData & T, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
499
503
|
staticData<T extends DataList$3>(data: typeUtils.NewFieldList<AllData<TData, TProperty>, T>): ResolveBehaviorBuilder<BaseBehaviorBuilder<T, TData & T, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
500
504
|
property<N extends string, T extends PropertyType$2, V extends PropertyTypeToValueType$2<T>>(name: N, def: N extends keyof (TData & TProperty) ? never : typeUtils.PropertyListItem<T, V>): ResolveBehaviorBuilder<BaseBehaviorBuilder<TPrevData, TData, TProperty & Record<N, unknown extends V ? T : typeUtils.PropertyOption<T, V>>, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
@@ -542,7 +546,8 @@ type UnTaggedMethod$1<M extends TaggedMethod$1<any>> = typeUtils.UnTaggedMethod<
|
|
|
542
546
|
type ChainingFilterFunc<TAddedFields extends {
|
|
543
547
|
[key: string]: any;
|
|
544
548
|
}, TRemovedFields extends string = never> = typeUtils.ChainingFilterFunc<TAddedFields, TRemovedFields>;
|
|
545
|
-
|
|
549
|
+
type DefaultBehaviorBuilder = BehaviorBuilder<Empty$2, Empty$2, Empty$2, Empty$2, never, never, never, Empty$2>;
|
|
550
|
+
declare class BehaviorBuilder<TPrevData extends DataList$2, TData extends DataList$2, TProperty extends PropertyList$2, TMethod extends MethodList$2, TChainingFilter extends ChainingFilterType$1, TPendingChainingFilter extends ChainingFilterType$1, TComponentExport, TExtraThisFields extends DataList$2> extends BaseBehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields> {
|
|
546
551
|
private _$definitionFilter;
|
|
547
552
|
private _$chainingFilter?;
|
|
548
553
|
/** Define a chaining filter */
|
|
@@ -553,7 +558,7 @@ declare class BehaviorBuilder<TPrevData extends DataList$2 = Empty$2, TData exte
|
|
|
553
558
|
remove: TRemovedFields;
|
|
554
559
|
}, TComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
555
560
|
/** Use another behavior */
|
|
556
|
-
behavior<UData extends DataList$2, UProperty extends PropertyList$2, UMethod extends MethodList$2, UChainingFilter extends ChainingFilterType$1, UExtraThisFields extends DataList$2>(behavior: Behavior<UData, UProperty, UMethod, UChainingFilter, UExtraThisFields>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData & UData, TProperty & UProperty, TMethod & UMethod, UChainingFilter, TPendingChainingFilter,
|
|
561
|
+
behavior<UData extends DataList$2, UProperty extends PropertyList$2, UMethod extends MethodList$2, UChainingFilter extends ChainingFilterType$1, UComponentExport, UExtraThisFields extends DataList$2>(behavior: Behavior<UData, UProperty, UMethod, UChainingFilter, UComponentExport, UExtraThisFields>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData & UData, TProperty & UProperty, TMethod & UMethod, UChainingFilter, TPendingChainingFilter, UComponentExport, TExtraThisFields & UExtraThisFields>, UChainingFilter>;
|
|
557
562
|
/** Set the export value when the component is being selected */
|
|
558
563
|
export<TNewComponentExport>(f: (this: GeneralComponent, source: GeneralComponent | null) => TNewComponentExport): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TNewComponentExport, TExtraThisFields>, TChainingFilter>;
|
|
559
564
|
/**
|
|
@@ -612,10 +617,11 @@ type ChainingFilterType = typeUtils.ChainingFilterType;
|
|
|
612
617
|
type ComponentMethod = typeUtils.ComponentMethod;
|
|
613
618
|
type TaggedMethod<Fn extends ComponentMethod> = typeUtils.TaggedMethod<Fn>;
|
|
614
619
|
type UnTaggedMethod<M extends TaggedMethod<any>> = typeUtils.UnTaggedMethod<M>;
|
|
620
|
+
type DefaultComponentBuilder = ComponentBuilder<Empty$1, Empty$1, Empty$1, Empty$1, never, never, never, Empty$1>;
|
|
615
621
|
/**
|
|
616
622
|
* A direct way to create a component
|
|
617
623
|
*/
|
|
618
|
-
declare class ComponentBuilder<TPrevData extends DataList$1
|
|
624
|
+
declare class ComponentBuilder<TPrevData extends DataList$1, TData extends DataList$1, TProperty extends PropertyList$1, TMethod extends MethodList$1, TChainingFilter extends ChainingFilterType, TPendingChainingFilter extends ChainingFilterType, TComponentExport, TExtraThisFields extends DataList$1> extends BaseBehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields> {
|
|
619
625
|
private _$is;
|
|
620
626
|
private _$alias?;
|
|
621
627
|
private _$options?;
|
|
@@ -672,34 +678,36 @@ declare class ComponentBuilder<TPrevData extends DataList$1 = Empty$1, TData ext
|
|
|
672
678
|
/**
|
|
673
679
|
* Finish the component definition process
|
|
674
680
|
*/
|
|
675
|
-
register(): ComponentType<TData, TProperty, TMethod, TComponentExport>;
|
|
681
|
+
register(): ComponentType<TData, TProperty, TMethod, TComponentExport, TExtraThisFields>;
|
|
676
682
|
/**
|
|
677
683
|
* Add extra this fields type
|
|
678
684
|
*/
|
|
679
685
|
extraThisFieldsType<T extends DataList$1>(): ResolveBehaviorBuilder<ComponentBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields & T>, TChainingFilter>;
|
|
680
686
|
}
|
|
681
687
|
|
|
682
|
-
type index_BehaviorBuilder<TPrevData extends DataList$2
|
|
688
|
+
type index_BehaviorBuilder<TPrevData extends DataList$2, TData extends DataList$2, TProperty extends PropertyList$2, TMethod extends MethodList$2, TChainingFilter extends ChainingFilterType$1, TPendingChainingFilter extends ChainingFilterType$1, TComponentExport, TExtraThisFields extends DataList$2> = BehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>;
|
|
683
689
|
declare const index_BehaviorBuilder: typeof BehaviorBuilder;
|
|
684
|
-
type index_BuilderContext<TPrevData extends DataList$
|
|
685
|
-
type index_ComponentBuilder<TPrevData extends DataList$1
|
|
690
|
+
type index_BuilderContext<TPrevData extends DataList$5, TProperty extends PropertyList$5, TMethodCaller> = BuilderContext<TPrevData, TProperty, TMethodCaller>;
|
|
691
|
+
type index_ComponentBuilder<TPrevData extends DataList$1, TData extends DataList$1, TProperty extends PropertyList$1, TMethod extends MethodList$1, TChainingFilter extends ChainingFilterType, TPendingChainingFilter extends ChainingFilterType, TComponentExport, TExtraThisFields extends DataList$1> = ComponentBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>;
|
|
686
692
|
declare const index_ComponentBuilder: typeof ComponentBuilder;
|
|
693
|
+
type index_DefaultBehaviorBuilder = DefaultBehaviorBuilder;
|
|
694
|
+
type index_DefaultComponentBuilder = DefaultComponentBuilder;
|
|
687
695
|
declare namespace index {
|
|
688
|
-
export { index_BehaviorBuilder as BehaviorBuilder, type index_BuilderContext as BuilderContext, index_ComponentBuilder as ComponentBuilder };
|
|
696
|
+
export { index_BehaviorBuilder as BehaviorBuilder, type index_BuilderContext as BuilderContext, index_ComponentBuilder as ComponentBuilder, type index_DefaultBehaviorBuilder as DefaultBehaviorBuilder, type index_DefaultComponentBuilder as DefaultComponentBuilder };
|
|
689
697
|
}
|
|
690
698
|
|
|
691
699
|
interface PageConstructor {
|
|
692
700
|
<TData extends DataList, TNewExtraFields extends {
|
|
693
701
|
[k: PropertyKey]: any;
|
|
694
|
-
}>(definition: PageDefinition<TData, TNewExtraFields> & ThisType<Component<TData, Empty, TNewExtraFields,
|
|
702
|
+
}>(definition: PageDefinition<TData, TNewExtraFields> & ThisType<Component<TData, Empty, TNewExtraFields, never, Empty>>): void;
|
|
695
703
|
}
|
|
696
704
|
interface ComponentConstructor {
|
|
697
|
-
():
|
|
698
|
-
<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList, TComponentExport>(definition: ComponentDefinition<TData, TProperty, TMethod, TComponentExport> & ThisType<Component<TData, TProperty, TMethod, TComponentExport>>):
|
|
705
|
+
(): DefaultComponentBuilder;
|
|
706
|
+
<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList, TComponentExport>(definition: ComponentDefinition<TData, TProperty, TMethod, TComponentExport> & ThisType<Component<TData, TProperty, TMethod, TComponentExport, Empty>>): ComponentType<TData, TProperty, TMethod, TComponentExport, Empty>;
|
|
699
707
|
}
|
|
700
708
|
interface BehaviorConstructor {
|
|
701
|
-
():
|
|
702
|
-
<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList, TComponentExport>(definition: BehaviorDefinition<TData, TProperty, TMethod, TComponentExport>): Behavior<TData, TProperty, TMethod, never>;
|
|
709
|
+
(): DefaultBehaviorBuilder;
|
|
710
|
+
<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList, TComponentExport>(definition: BehaviorDefinition<TData, TProperty, TMethod, TComponentExport> & ThisType<Component<TData, TProperty, TMethod, TComponentExport, Empty>>): Behavior<TData, TProperty, TMethod, never, TComponentExport, Empty>;
|
|
703
711
|
trait<TIn extends {
|
|
704
712
|
[key: string]: any;
|
|
705
713
|
}>(): TraitBehavior<TIn, TIn>;
|
|
@@ -812,13 +820,13 @@ declare class CodeSpace {
|
|
|
812
820
|
* The method do not need a definition environment, so the global object pollution is avoided.
|
|
813
821
|
* `path` should be the component path (without ".js" extension).
|
|
814
822
|
*/
|
|
815
|
-
component(path: string):
|
|
823
|
+
component(path: string): DefaultComponentBuilder;
|
|
816
824
|
/**
|
|
817
825
|
* Build a behavior outside of a definition environment
|
|
818
826
|
*
|
|
819
827
|
* The method do not need a definition environment, so the global object pollution is avoided.
|
|
820
828
|
*/
|
|
821
|
-
behavior():
|
|
829
|
+
behavior(): DefaultBehaviorBuilder;
|
|
822
830
|
/**
|
|
823
831
|
* Define a trait behavior
|
|
824
832
|
*/
|
|
@@ -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,o){if(this._$env!==t._$env)throw new Error("The code space is not in the same environment as the backend");return new s(this._$,e,t,i,o)}}class s{constructor(t,i,s,o,r){if(this._$comp=s.getComponentSpace().createComponentByUrl(i,o,r||null,t),s.isMainSpace()){const e=s.getStyleSheet("app");if(void 0!==e){const i=s._$styleIsolationMap[this._$comp.is];"isolated"!==i&&"apply-shared"!==i&&"shared"!==i||t.appendStyleSheetPath(e,s._$sharedStyleScope)}}const n=i=>{const{styleScope:s}=i.getComponentOptions(),o=i.behavior.ownerSpace.__wxCodeSpace,r=null==o?void 0: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 o=(e,t)=>{let i=!1,s=e.length;const o=new Array(s);e.forEach(((e,r)=>{e((e=>{o[r]=e,s-=1,0===s&&i&&t(o)}))})),i=!0,0===s&&setTimeout((()=>{t(o)}),0)};class r{constructor(e,t,i,s){this._$sq=e,this._$comp=t,this._$sel=i,this._$single=s}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,s,o){this._$queue.push({component:t,selector:e,single:i,fields:s,cb:o})}exec(t=(()=>{})){const i=this._$queue;o(i.map((t=>i=>{const{component:s,selector:r,single:n,fields:a,cb:l}=t;if(null===r){const e={};o([t=>{const i=s._$.getBackendContext(),o=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=o,e.bottom=r),a.size&&(e.width=o,e.height=r),a.scrollOffset){let i=s._$.general();for(;i.ownerShadowRoot;)i=i.ownerShadowRoot.getHostNode();i.getBoundingClientRect((({left:i,top:s,width:o,height:r})=>{e.scrollLeft=i,e.scrollTop=s,e.scrollWidth=o,e.scrollHeight=r,t(void 0)}))}else t(void 0)}],(()=>{l(e),i(e)}))}else{const t=(t,i)=>{const s={};a.id&&(s.id=t.id),a.dataset&&(s.dataset=t.dataset),a.mark&&(s.mark=t.collectMarks()),o([e=>{a.rect||a.size?t.getBoundingClientRect((t=>{a.rect&&(s.left=t.left,s.top=t.top,s.right=t.left+t.width,s.bottom=t.top+t.height),a.size&&(s.width=t.width,s.height=t.height),e(void 0)})):e(void 0)},e=>{a.scrollOffset?t.getScrollOffset((t=>{s.scrollLeft=t.scrollLeft,s.scrollTop=t.scrollTop,s.scrollWidth=t.scrollWidth,s.scrollHeight=t.scrollHeight,e(void 0)})):e(void 0)},e=>{a.context?t.getContext((t=>{s.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 o=t.getComponentOptions().propertyPassingDeepCopy,r=t.data[i];o===e.DeepCopyKind.None?s[i]=r:o===e.DeepCopyKind.Simple?s[i]=e.dataUtils.simpleDeepCopy(r):o===e.DeepCopyKind.SimpleWithRecursion&&(s[i]=e.dataUtils.deepCopy(r,!0))}})),i(s)}))};if(n){const e=s._$.getShadowRoot().querySelector(r);e?t(e,(e=>{l(e),i(e)})):setTimeout((()=>{l(null),i(null)}),0)}else{const e=s._$.getShadowRoot().querySelectorAll(r);o(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,s){this._$selector=null,this._$margins=null,this._$observers=[],this._$comp=e,this._$thresholds=t,this._$initialRatio=i,this._$observeAll=s}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 s,o;if(i)if(this._$observeAll)s=i.querySelectorAll(e);else{const t=i.querySelector(e);s=null===t?[]:[t]}else s=[];if(null!==this._$selector&&i){const e=i.querySelector(this._$selector);null===e||(o=e)}else o=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`;s.forEach((e=>{let i=this._$initialRatio;const s=e.createIntersectionObserver(o,h,this._$thresholds,(e=>{if(null!==i){let t=0;for(;t<this._$thresholds.length;t+=1){const s=this._$thresholds[t];if(i!==e.intersectionRatio&&(i-s)*(e.intersectionRatio-s)<=0)break}if(i=null,t<this._$thresholds.length)return}t(e)}));null===s||this._$observers.push(s)}))}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,s;this._$observer&&this._$observer.disconnect(),this._$observer=(null===(s=null===(i=this._$comp._$.getBackendContext())||void 0===i?void 0:i.createMediaQueryObserver)||void 0===s?void 0:s.call(i,e,t))||null}disconnect(){this._$observer&&this._$observer.disconnect(),this._$observer=null}}const c=(e,t,i)=>{var s;const o=t.asInstanceOf(i._$);if(null===o)return;const r=o.getRootBehavior().ownerSpace,n=o.getMethodCaller(),a=n instanceof d?n:null,l=e._$.getRootBehavior().ownerSpace,h=r!==l?null:a,c=null===(s=null==a?void 0:a._$export)||void 0===s?void 0:s.call(a,r!==l?null:e);return void 0===c?h:c},p=(t,i)=>{var s;if(e.Component.isComponent(i)){const e=i.getRootBehavior().ownerSpace,o=i.getMethodCaller(),r=o instanceof d?o:null,n=t._$.getRootBehavior().ownerSpace,a=e!==n?null:r,l=null===(s=null==r?void 0:r._$export)||void 0===s?void 0:s.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,s){this._$.spliceArrayDataOnPath(e,t,i,s)}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,s;const o=this._$.getShadowRoot().querySelector(e);return null===o?null:t?null!==(i=c(this,o,t))&&void 0!==i?i:null:null!==(s=p(this,o))&&void 0!==s?s:null}selectAllComponents(e,t){const i=this._$.getShadowRoot().querySelectorAll(e),s=[];return i.forEach((e=>{const i=t?c(this,e,t):p(this,e);void 0!==i&&s.push(i)})),s}selectOwnerComponent(e){var t,i,s;const o=null===(t=this._$.ownerShadowRoot)||void 0===t?void 0:t.getHostNode();return void 0===o?null:e?null!==(i=c(this,o,e))&&void 0!==i?i:null:null!==(s=p(this,o))&&void 0!==s?s: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,s,o){if(this._$=e,this._$chainingFilter=s,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}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 $||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:s,implement:o,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)=>{s(t),i&&e.triggerRender(p._$,(()=>{i()}))},implement:(e,t)=>{o(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 s=t[i],o=d[s];e.Component.isTaggedMethod(o)&&(p[s]=o)}}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:s,properties:o,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==s||s.forEach((e=>{this._$parents.push(e),i.behavior(e._$)})),void 0!==r&&("function"==typeof r?i.data(r):i.staticData(r)),void 0!==o){const e=Object.keys(o);for(let t=0;t<e.length;t+=1){const s=e[t];i.property(s,o[s])}}if(void 0!==n)if(Array.isArray(n))for(let e=0;e<n.length;e+=1){const{fields:t,observer:s}=n[e];i.observer(t||"**",s)}else{const e=Object.keys(n);for(let t=0;t<e.length;t+=1){const s=e[t],o=n[s];i.observer(s,o)}}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 s=e[t],o=u[s];i.lifetime(s,o,!0)}}if(_){const e=Object.keys(_);for(let t=0;t<e.length;t+=1){const s=e[t],o=_[s];i.pageLifetime(s,o,!0)}}if($){const e=Object.keys($);for(let t=0;t<e.length;t+=1){const s=e[t],o=$[s];i.relation(s,o)}}return g&&i.externalClasses(g),v&&(this._$export=v),this}}class S extends f{static create(e){const t=new S;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._$),e._$chainingFilter?e._$chainingFilter(this):this}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 $(this._$.registerBehavior(),this._$parents,this._$definitionFilter,this._$chainingFilter,this._$export)}extraThisFieldsType(){return this}}class y extends f{static create(e,t,i){const s=new y,o=e._$overallBehavior;return s._$codeSpace=e,s._$=e.getComponentSpace().defineWithMethodCaller(t||""),s._$is=t||"",s._$alias=i,s._$.methodCallerInit((function(){const e=this;let t=s._$proto;if(void 0===t){const i=e.getComponentDefinition().behavior.getMethods();t=s._$proto=new u(i,s._$export)}const i=t.derive();return i._$=e,i})),o&&s._$.behavior(o),s}options(e){return this._$options=e,this}behavior(e){return this._$parents.push(e),this._$=this._$.behavior(e._$),e._$export&&(this._$export=e._$export),e._$chainingFilter?e._$chainingFilter(this):this}export(e){return this._$export=e,this}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),s={methods:{}},o=Object.keys(t);for(let e=0;e<o.length;e+=1){const r=o[e];"data"===r?s.data=t.data:"function"==typeof t[r]?s.methods[r]=t[r]:"methods"===r?i.methods=t.methods:s[r]=t[r]}this.definition(s);const r=Object.keys(s);for(let e=0;e<r.length;e+=1){const t=r[e];"data"!==t&&"methods"!==t&&"behaviors"!==t&&(i[t]=s[t])}return this._$.init((function(){Object.assign(this,e.dataUtils.simpleDeepCopy(i))})),this}register(){var e;const t=this._$is,i=this._$codeSpace,[s,o]=i.prepareComponentOptions(t,this._$options);this._$.options(s);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]=o;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 b=Object.freeze({__proto__:null,BehaviorBuilder:S,ComponentBuilder:y});const C=()=>Math.floor(4294967296*(1+Math.random())).toString(16).slice(1);class w{constructor(t,i,s,o){this._$overallBehavior=null,this._$env=t,this._$isMainSpace=i,this.space=new e.ComponentSpace("",null==o?void 0:o.space,null==o?void 0:o.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(s).forEach((e=>{const t=s[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 s=this._$env.getCodeSpace(e);if(!s)throw new Error(`There is no space "${e}" in the environment`);t&&this.space.importSpace(`plugin://${t}`,s.space,!1),i&&this.space.importSpace(`plugin-private://${e}`,s.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],s=null==i?void 0:i.pureDataPattern,o=s?new RegExp(s):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,dynamicSlots:null==t?void 0:t.dynamicSlots,pureDataPattern:o,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:s,Behavior:o})=>{const r=e.Page,n=e.Component,a=e.Behavior;e.Page=t,e.Component=s,e.Behavior=o;const l=i();return e.Page=r,e.Component=n,e.Behavior=a,l}))}componentEnv(e,t){const i=this;function s(e){return void 0!==e?i.behavior().definition(e).register():i.behavior()}return s.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:s})}component(e){return y.create(this,e,this.waitingAliasMap[e])}behavior(){return S.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 s=null!=t?t:new e.CurrentWindowBackendContext;return new i(this,s)}createCodeSpace(e,t,i=Object.create(null)){const s=new w(this,t,i,this.globalCodeSpace);return this.codeSpaceMap[e]=s,s}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,s as Root,m as behavior,b 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: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}=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 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};
|
|
2
2
|
//# sourceMappingURL=glass_easel_miniprogram_adapter.es.js.map
|