@djvlc/contracts-types 1.7.0 → 1.7.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/index.d.mts +126 -1
- package/dist/index.d.ts +126 -1
- package/dist/index.js +17 -0
- package/dist/index.mjs +16 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -790,6 +790,116 @@ interface Expression {
|
|
|
790
790
|
returnType?: string;
|
|
791
791
|
};
|
|
792
792
|
}
|
|
793
|
+
/**
|
|
794
|
+
* 表达式求值上下文
|
|
795
|
+
*
|
|
796
|
+
* @description
|
|
797
|
+
* 表达式引擎在求值时可访问的上下文对象。
|
|
798
|
+
* 所有动态表达式(state/binding/context/template/computed)都从此上下文获取数据。
|
|
799
|
+
*
|
|
800
|
+
* 使用场景:
|
|
801
|
+
* - Runtime 表达式求值
|
|
802
|
+
* - 编辑器表达式预览
|
|
803
|
+
* - 表达式校验与调试
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```typescript
|
|
807
|
+
* const ctx: ExpressionContext = {
|
|
808
|
+
* state: { count: 0, userInfo: { name: 'Alice' } },
|
|
809
|
+
* binding: { userList: [{ id: 1, name: 'Bob' }] },
|
|
810
|
+
* context: { item: { id: 1, name: 'Bob' }, index: 0 },
|
|
811
|
+
* };
|
|
812
|
+
*
|
|
813
|
+
* // 求值 { type: 'state', value: 'userInfo.name' } => 'Alice'
|
|
814
|
+
* // 求值 { type: 'context', value: 'item.name' } => 'Bob'
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
interface ExpressionContext {
|
|
818
|
+
/**
|
|
819
|
+
* 页面状态
|
|
820
|
+
*
|
|
821
|
+
* @description
|
|
822
|
+
* 对应 PageState.fields 的运行时值。
|
|
823
|
+
* 表达式通过 { type: 'state', value: 'fieldName.path' } 访问。
|
|
824
|
+
*/
|
|
825
|
+
state: Record<string, unknown>;
|
|
826
|
+
/**
|
|
827
|
+
* 数据绑定结果
|
|
828
|
+
*
|
|
829
|
+
* @description
|
|
830
|
+
* 对应 DataBinding 查询的返回数据,按 bindingId 组织。
|
|
831
|
+
* 表达式通过 { type: 'binding', value: 'bindingId.path' } 访问。
|
|
832
|
+
*/
|
|
833
|
+
binding: Record<string, unknown>;
|
|
834
|
+
/**
|
|
835
|
+
* 局部上下文
|
|
836
|
+
*
|
|
837
|
+
* @description
|
|
838
|
+
* 包含循环变量、事件参数等临时作用域数据。
|
|
839
|
+
* 表达式通过 { type: 'context', value: 'item.path' } 访问。
|
|
840
|
+
*/
|
|
841
|
+
context: ExpressionLocalContext;
|
|
842
|
+
/**
|
|
843
|
+
* 组件属性(可选)
|
|
844
|
+
*
|
|
845
|
+
* @description
|
|
846
|
+
* 当前组件的 props 值,供组件内部表达式访问。
|
|
847
|
+
* 通常在组件内部求值时提供。
|
|
848
|
+
*/
|
|
849
|
+
props?: Record<string, unknown>;
|
|
850
|
+
/**
|
|
851
|
+
* 当前事件(可选)
|
|
852
|
+
*
|
|
853
|
+
* @description
|
|
854
|
+
* 事件处理器执行时的事件对象。
|
|
855
|
+
* 仅在事件处理链中可用。
|
|
856
|
+
*/
|
|
857
|
+
event?: ExpressionEventContext;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* 局部上下文(循环变量、事件参数等)
|
|
861
|
+
*/
|
|
862
|
+
interface ExpressionLocalContext {
|
|
863
|
+
/**
|
|
864
|
+
* 循环项(loop.itemName 指定的变量名)
|
|
865
|
+
*
|
|
866
|
+
* @description
|
|
867
|
+
* 在 loop 渲染中,当前迭代的数据项。
|
|
868
|
+
*/
|
|
869
|
+
item?: unknown;
|
|
870
|
+
/**
|
|
871
|
+
* 循环索引(loop.indexName 指定的变量名)
|
|
872
|
+
*
|
|
873
|
+
* @description
|
|
874
|
+
* 在 loop 渲染中,当前迭代的索引。
|
|
875
|
+
*/
|
|
876
|
+
index?: number;
|
|
877
|
+
/**
|
|
878
|
+
* 动态扩展字段
|
|
879
|
+
*
|
|
880
|
+
* @description
|
|
881
|
+
* 支持自定义局部变量,如嵌套循环的多个 item/index。
|
|
882
|
+
*/
|
|
883
|
+
[key: string]: unknown;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* 事件上下文
|
|
887
|
+
*/
|
|
888
|
+
interface ExpressionEventContext {
|
|
889
|
+
/** 事件类型 */
|
|
890
|
+
type: string;
|
|
891
|
+
/** 事件目标(组件实例 ID) */
|
|
892
|
+
target?: string;
|
|
893
|
+
/** 事件载荷(组件抛出的数据) */
|
|
894
|
+
payload?: unknown;
|
|
895
|
+
/** 原生事件(如 MouseEvent 的部分安全属性) */
|
|
896
|
+
nativeEvent?: {
|
|
897
|
+
clientX?: number;
|
|
898
|
+
clientY?: number;
|
|
899
|
+
key?: string;
|
|
900
|
+
keyCode?: number;
|
|
901
|
+
};
|
|
902
|
+
}
|
|
793
903
|
/**
|
|
794
904
|
* 任意值或表达式
|
|
795
905
|
*
|
|
@@ -805,6 +915,21 @@ type AnyValueOrExpression = Expression | string | number | boolean | null | AnyV
|
|
|
805
915
|
* @deprecated 使用 AnyValueOrExpression 代替
|
|
806
916
|
*/
|
|
807
917
|
type PropValue = AnyValueOrExpression;
|
|
918
|
+
/**
|
|
919
|
+
* 创建空的表达式上下文
|
|
920
|
+
*
|
|
921
|
+
* @description
|
|
922
|
+
* 用于初始化表达式求值环境,所有字段都有合理的默认值。
|
|
923
|
+
*/
|
|
924
|
+
declare function createExpressionContext(partial?: Partial<ExpressionContext>): ExpressionContext;
|
|
925
|
+
/**
|
|
926
|
+
* 创建带循环变量的局部上下文
|
|
927
|
+
*
|
|
928
|
+
* @param item - 当前循环项
|
|
929
|
+
* @param index - 当前循环索引
|
|
930
|
+
* @param extras - 额外的局部变量(如嵌套循环)
|
|
931
|
+
*/
|
|
932
|
+
declare function createLoopContext(item: unknown, index: number, extras?: Record<string, unknown>): ExpressionLocalContext;
|
|
808
933
|
/**
|
|
809
934
|
* 创建字面量表达式
|
|
810
935
|
* @deprecated V2 版本移除 literal 表达式类型,静态值请直接使用原始类型
|
|
@@ -4252,4 +4377,4 @@ declare const ACTION_SPEC_VERSION = "2.0.0";
|
|
|
4252
4377
|
*/
|
|
4253
4378
|
declare const DATA_QUERY_SPEC_VERSION = "2.0.0";
|
|
4254
4379
|
|
|
4255
|
-
export { type ABTestRolloutConfig, ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type ChangeLog, type ChangeLogItem, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatus, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CumulativeReward, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type DjvlcError, type EditorComponent, type Environment, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, ErrorMessages, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OperatorInfo, type OrderByItem, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PageResolveResponse, type PageSEO, type PageSchema, type PageState, PageStatus, type PageStatusType, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishEnvironment, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, type VersionDiff, type VersionInfo, VersionStatus, type VersionStatusType, type WhitelistRolloutConfig, bindingRef, createDjvlcError, isDjvlcError, literal, queryRef, stateRef, template };
|
|
4380
|
+
export { type ABTestRolloutConfig, ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type ChangeLog, type ChangeLogItem, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatus, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CumulativeReward, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type DjvlcError, type EditorComponent, type Environment, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, ErrorMessages, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionContext, type ExpressionEventContext, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionLocalContext, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OperatorInfo, type OrderByItem, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PageResolveResponse, type PageSEO, type PageSchema, type PageState, PageStatus, type PageStatusType, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishEnvironment, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, type VersionDiff, type VersionInfo, VersionStatus, type VersionStatusType, type WhitelistRolloutConfig, bindingRef, createDjvlcError, createExpressionContext, createLoopContext, isDjvlcError, literal, queryRef, stateRef, template };
|
package/dist/index.d.ts
CHANGED
|
@@ -790,6 +790,116 @@ interface Expression {
|
|
|
790
790
|
returnType?: string;
|
|
791
791
|
};
|
|
792
792
|
}
|
|
793
|
+
/**
|
|
794
|
+
* 表达式求值上下文
|
|
795
|
+
*
|
|
796
|
+
* @description
|
|
797
|
+
* 表达式引擎在求值时可访问的上下文对象。
|
|
798
|
+
* 所有动态表达式(state/binding/context/template/computed)都从此上下文获取数据。
|
|
799
|
+
*
|
|
800
|
+
* 使用场景:
|
|
801
|
+
* - Runtime 表达式求值
|
|
802
|
+
* - 编辑器表达式预览
|
|
803
|
+
* - 表达式校验与调试
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```typescript
|
|
807
|
+
* const ctx: ExpressionContext = {
|
|
808
|
+
* state: { count: 0, userInfo: { name: 'Alice' } },
|
|
809
|
+
* binding: { userList: [{ id: 1, name: 'Bob' }] },
|
|
810
|
+
* context: { item: { id: 1, name: 'Bob' }, index: 0 },
|
|
811
|
+
* };
|
|
812
|
+
*
|
|
813
|
+
* // 求值 { type: 'state', value: 'userInfo.name' } => 'Alice'
|
|
814
|
+
* // 求值 { type: 'context', value: 'item.name' } => 'Bob'
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
interface ExpressionContext {
|
|
818
|
+
/**
|
|
819
|
+
* 页面状态
|
|
820
|
+
*
|
|
821
|
+
* @description
|
|
822
|
+
* 对应 PageState.fields 的运行时值。
|
|
823
|
+
* 表达式通过 { type: 'state', value: 'fieldName.path' } 访问。
|
|
824
|
+
*/
|
|
825
|
+
state: Record<string, unknown>;
|
|
826
|
+
/**
|
|
827
|
+
* 数据绑定结果
|
|
828
|
+
*
|
|
829
|
+
* @description
|
|
830
|
+
* 对应 DataBinding 查询的返回数据,按 bindingId 组织。
|
|
831
|
+
* 表达式通过 { type: 'binding', value: 'bindingId.path' } 访问。
|
|
832
|
+
*/
|
|
833
|
+
binding: Record<string, unknown>;
|
|
834
|
+
/**
|
|
835
|
+
* 局部上下文
|
|
836
|
+
*
|
|
837
|
+
* @description
|
|
838
|
+
* 包含循环变量、事件参数等临时作用域数据。
|
|
839
|
+
* 表达式通过 { type: 'context', value: 'item.path' } 访问。
|
|
840
|
+
*/
|
|
841
|
+
context: ExpressionLocalContext;
|
|
842
|
+
/**
|
|
843
|
+
* 组件属性(可选)
|
|
844
|
+
*
|
|
845
|
+
* @description
|
|
846
|
+
* 当前组件的 props 值,供组件内部表达式访问。
|
|
847
|
+
* 通常在组件内部求值时提供。
|
|
848
|
+
*/
|
|
849
|
+
props?: Record<string, unknown>;
|
|
850
|
+
/**
|
|
851
|
+
* 当前事件(可选)
|
|
852
|
+
*
|
|
853
|
+
* @description
|
|
854
|
+
* 事件处理器执行时的事件对象。
|
|
855
|
+
* 仅在事件处理链中可用。
|
|
856
|
+
*/
|
|
857
|
+
event?: ExpressionEventContext;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* 局部上下文(循环变量、事件参数等)
|
|
861
|
+
*/
|
|
862
|
+
interface ExpressionLocalContext {
|
|
863
|
+
/**
|
|
864
|
+
* 循环项(loop.itemName 指定的变量名)
|
|
865
|
+
*
|
|
866
|
+
* @description
|
|
867
|
+
* 在 loop 渲染中,当前迭代的数据项。
|
|
868
|
+
*/
|
|
869
|
+
item?: unknown;
|
|
870
|
+
/**
|
|
871
|
+
* 循环索引(loop.indexName 指定的变量名)
|
|
872
|
+
*
|
|
873
|
+
* @description
|
|
874
|
+
* 在 loop 渲染中,当前迭代的索引。
|
|
875
|
+
*/
|
|
876
|
+
index?: number;
|
|
877
|
+
/**
|
|
878
|
+
* 动态扩展字段
|
|
879
|
+
*
|
|
880
|
+
* @description
|
|
881
|
+
* 支持自定义局部变量,如嵌套循环的多个 item/index。
|
|
882
|
+
*/
|
|
883
|
+
[key: string]: unknown;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* 事件上下文
|
|
887
|
+
*/
|
|
888
|
+
interface ExpressionEventContext {
|
|
889
|
+
/** 事件类型 */
|
|
890
|
+
type: string;
|
|
891
|
+
/** 事件目标(组件实例 ID) */
|
|
892
|
+
target?: string;
|
|
893
|
+
/** 事件载荷(组件抛出的数据) */
|
|
894
|
+
payload?: unknown;
|
|
895
|
+
/** 原生事件(如 MouseEvent 的部分安全属性) */
|
|
896
|
+
nativeEvent?: {
|
|
897
|
+
clientX?: number;
|
|
898
|
+
clientY?: number;
|
|
899
|
+
key?: string;
|
|
900
|
+
keyCode?: number;
|
|
901
|
+
};
|
|
902
|
+
}
|
|
793
903
|
/**
|
|
794
904
|
* 任意值或表达式
|
|
795
905
|
*
|
|
@@ -805,6 +915,21 @@ type AnyValueOrExpression = Expression | string | number | boolean | null | AnyV
|
|
|
805
915
|
* @deprecated 使用 AnyValueOrExpression 代替
|
|
806
916
|
*/
|
|
807
917
|
type PropValue = AnyValueOrExpression;
|
|
918
|
+
/**
|
|
919
|
+
* 创建空的表达式上下文
|
|
920
|
+
*
|
|
921
|
+
* @description
|
|
922
|
+
* 用于初始化表达式求值环境,所有字段都有合理的默认值。
|
|
923
|
+
*/
|
|
924
|
+
declare function createExpressionContext(partial?: Partial<ExpressionContext>): ExpressionContext;
|
|
925
|
+
/**
|
|
926
|
+
* 创建带循环变量的局部上下文
|
|
927
|
+
*
|
|
928
|
+
* @param item - 当前循环项
|
|
929
|
+
* @param index - 当前循环索引
|
|
930
|
+
* @param extras - 额外的局部变量(如嵌套循环)
|
|
931
|
+
*/
|
|
932
|
+
declare function createLoopContext(item: unknown, index: number, extras?: Record<string, unknown>): ExpressionLocalContext;
|
|
808
933
|
/**
|
|
809
934
|
* 创建字面量表达式
|
|
810
935
|
* @deprecated V2 版本移除 literal 表达式类型,静态值请直接使用原始类型
|
|
@@ -4252,4 +4377,4 @@ declare const ACTION_SPEC_VERSION = "2.0.0";
|
|
|
4252
4377
|
*/
|
|
4253
4378
|
declare const DATA_QUERY_SPEC_VERSION = "2.0.0";
|
|
4254
4379
|
|
|
4255
|
-
export { type ABTestRolloutConfig, ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type ChangeLog, type ChangeLogItem, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatus, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CumulativeReward, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type DjvlcError, type EditorComponent, type Environment, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, ErrorMessages, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OperatorInfo, type OrderByItem, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PageResolveResponse, type PageSEO, type PageSchema, type PageState, PageStatus, type PageStatusType, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishEnvironment, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, type VersionDiff, type VersionInfo, VersionStatus, type VersionStatusType, type WhitelistRolloutConfig, bindingRef, createDjvlcError, isDjvlcError, literal, queryRef, stateRef, template };
|
|
4380
|
+
export { type ABTestRolloutConfig, ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, type ActionClientContext, type ActionDefinition, type ActionDefinitionVersion, type ActionExecuteRequest, type ActionExecuteResponse, type ActionExecutor, type ActionPolicy, type ActionRef, type ActionResult, type ActionSheetItem, type ActionSheetOptions, type ActionSheetResult, type ActionSpec, ActionType, type Activity, type ActivityPrecondition, type ActivityRule, type ActivityStatus, type ActivityType, type AggregationDataSourceConfig, type AggregationQueryItem, type AnyValueOrExpression, type ApiErrorDetail, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AppContext, AuditAction, type AuditConfig, type AuditLogEntry, type BackgroundConfig, type BaseActivityRule, type BlacklistRolloutConfig, type BlockedComponentInfo, type BrowserCompat, type BuiltinActionType, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, type CacheConfig, type CacheLevel, type CanaryHealthCheck, type CanaryRolloutConfig, type CanaryStage, type CanvasType, type CapabilityDeclaration, type CapabilityName, type ChangeLog, type ChangeLogItem, type ClaimActivityRule, type ClaimPrize, type ClaimRecord, type ClaimState, type ClipboardApi, type CompatInfo, type Component, type ComponentCategory, type ComponentContext, type ComponentDependency, type ComponentIntegrity, type ComponentMeta, type ComponentNode, type ComponentQueryParams, type ComponentRegisterRequest, type ComponentStatus, type ComponentStatusChangeRequest, type ComponentVersion, type ConfirmOptions, type ConsecutiveReward, type CreateManifestRequest, type CumulativeReward, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, type DataBinding, type DataBindingErrorConfig, type DataLoadStrategy, type DataQueryDefinition, type DataQueryDefinitionVersion, type DataQueryRequest, type DataQueryResponse, type DataQuerySpec, type DataSourceConfig, type DataSourceType, type DatabaseDataSourceConfig, type DialogOptions, type DialogResult, type DjvlcError, type EditorComponent, type Environment, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, type ErrorMapping, ErrorMessages, type EventDeclaration, type EventHandler, type ExecutorContext, type ExecutorResult, type Expression, type ExpressionContext, type ExpressionEventContext, type ExpressionFunctionCategory, type ExpressionFunctionDefinition, type ExpressionLocalContext, type ExpressionType, type ExpressionValidationConfig, type ExpressionValidationError, type ExpressionValidationResult, type ExpressionValidationWarning, FORMAT_FUNCTIONS, type FallbackCondition, type FallbackConfig, type FeatureCondition, type FeatureRolloutConfig, type FieldPermission, type FieldPolicy, type FieldTransform, type FileIntegrity, type FunctionParamDefinition, type GraphQLDataSourceConfig, type HostApi, type HttpDataSourceConfig, type HttpRetryConfig, type I18nDetectionStrategy, type ISODateTime, type IdempotencyKeyStrategy, type IdempotencyRule, type IntegrityHash, type InternalDataSourceConfig, type InventoryConfig, type JsonObject, type JsonValue, LOGIC_FUNCTIONS, type LayoutConfig, type LayoutValues, type LoopConfig, type LotteryActivityRule, type LotteryCost, type LotteryPrize, type LotteryState, type Manifest, type ManifestEntry, type ManifestItem, type ManifestValidationError, type ManifestValidationResult, type ManifestValidationWarning, type MaskingConfig, type MaskingRule, type MaskingType, type MethodCategory, type MethodDeclaration, type MethodParam, NUMBER_FUNCTIONS, type NavigateOptions, type NodeStyleConfig, type OperatorInfo, type OrderByItem, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, type PageConfig, type PageDraft, type PageI18nConfig, type PageLifecycle, type PageManifest, type PageMeta, type PageResolveResponse, type PageSEO, type PageSchema, type PageState, PageStatus, type PageStatusType, type PageVersion, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ParamPermission, type ParticipationLimit, type PercentageRolloutConfig, type PityConfig, type Precondition, type PreconditionType, type PreviewImageOptions, type ProbabilityConfig, type PropDefinition, type PropFormat, type PropGroup, type PropType, type PropValue, type PropsSchema, type PublishCdnConfig, PublishChannel, type PublishConfig, type PublishEnvironment, type PublishNotificationConfig, type PublishRecord, type PublishRolloutConfig, PublishStatus, type QueryPermissions, type RateLimitDimension, type RateLimitItem, type RateLimitRule, type RequestContext, type ResolvedManifest, type ResponsiveBreakpoints, type RetryPolicy, type RiskControlConfig, type RolloutConfig, type RolloutMatchRequest, type RolloutMatchResult, type RolloutStrategy, type RolloutStrategyConfig, type RolloutStrategyType, type RuntimeConfig, type RuntimeContext, type RuntimeSpec, type SHAIntegrity, STRING_FUNCTIONS, type ScanCodeResult, type SchemaVersion, type SemVer, type ShareOptions, type ShareResult, type SigninActivityRule, type SigninRecord, type SigninRewardRecord, type SigninState, type SlotCategory, type SlotDeclaration, type StateFieldDefinition, type StorageApi, type StorageOptions, type StyleConfig, type StyleIsolation, type TimeWindowRolloutConfig, type ToastOptions, type TrackEvent, type URLString, UTILITY_FUNCTIONS, type UniqueId, type UpsertRolloutRequest, type UserActivityState, type UserContext, VERSION, type ValidationRule, type VersionDiff, type VersionInfo, VersionStatus, type VersionStatusType, type WhitelistRolloutConfig, bindingRef, createDjvlcError, createExpressionContext, createLoopContext, isDjvlcError, literal, queryRef, stateRef, template };
|
package/dist/index.js
CHANGED
|
@@ -1002,6 +1002,21 @@ var DEFAULT_EXPRESSION_VALIDATION_CONFIG = {
|
|
|
1002
1002
|
};
|
|
1003
1003
|
|
|
1004
1004
|
// src/page/expression.ts
|
|
1005
|
+
function createExpressionContext(partial) {
|
|
1006
|
+
return {
|
|
1007
|
+
state: {},
|
|
1008
|
+
binding: {},
|
|
1009
|
+
context: {},
|
|
1010
|
+
...partial
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
function createLoopContext(item, index, extras) {
|
|
1014
|
+
return {
|
|
1015
|
+
item,
|
|
1016
|
+
index,
|
|
1017
|
+
...extras
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1005
1020
|
function literal(value) {
|
|
1006
1021
|
return value;
|
|
1007
1022
|
}
|
|
@@ -1105,6 +1120,8 @@ exports.VERSION = VERSION;
|
|
|
1105
1120
|
exports.VersionStatus = VersionStatus;
|
|
1106
1121
|
exports.bindingRef = bindingRef;
|
|
1107
1122
|
exports.createDjvlcError = createDjvlcError;
|
|
1123
|
+
exports.createExpressionContext = createExpressionContext;
|
|
1124
|
+
exports.createLoopContext = createLoopContext;
|
|
1108
1125
|
exports.isDjvlcError = isDjvlcError;
|
|
1109
1126
|
exports.literal = literal;
|
|
1110
1127
|
exports.queryRef = queryRef;
|
package/dist/index.mjs
CHANGED
|
@@ -1000,6 +1000,21 @@ var DEFAULT_EXPRESSION_VALIDATION_CONFIG = {
|
|
|
1000
1000
|
};
|
|
1001
1001
|
|
|
1002
1002
|
// src/page/expression.ts
|
|
1003
|
+
function createExpressionContext(partial) {
|
|
1004
|
+
return {
|
|
1005
|
+
state: {},
|
|
1006
|
+
binding: {},
|
|
1007
|
+
context: {},
|
|
1008
|
+
...partial
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
function createLoopContext(item, index, extras) {
|
|
1012
|
+
return {
|
|
1013
|
+
item,
|
|
1014
|
+
index,
|
|
1015
|
+
...extras
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1003
1018
|
function literal(value) {
|
|
1004
1019
|
return value;
|
|
1005
1020
|
}
|
|
@@ -1071,4 +1086,4 @@ var COMPONENT_META_SCHEMA_VERSION = "2.0.0";
|
|
|
1071
1086
|
var ACTION_SPEC_VERSION = "2.0.0";
|
|
1072
1087
|
var DATA_QUERY_SPEC_VERSION = "2.0.0";
|
|
1073
1088
|
|
|
1074
|
-
export { ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, ActionType, AuditAction, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, ErrorMessages, FORMAT_FUNCTIONS, LOGIC_FUNCTIONS, NUMBER_FUNCTIONS, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, PageStatus, PublishChannel, PublishStatus, STRING_FUNCTIONS, UTILITY_FUNCTIONS, VERSION, VersionStatus, bindingRef, createDjvlcError, isDjvlcError, literal, queryRef, stateRef, template };
|
|
1089
|
+
export { ACTION_SPEC_VERSION, ALLOWED_FUNCTION_NAMES, ALL_BUILTIN_FUNCTIONS, ARRAY_FUNCTIONS, ActionType, AuditAction, COMPONENT_META_SCHEMA_VERSION, CURRENT_ACTION_SPEC_VERSION, CURRENT_COMPONENT_META_VERSION, CURRENT_DATA_QUERY_SPEC_VERSION, CURRENT_SCHEMA_VERSION, DATA_QUERY_SPEC_VERSION, DATE_FUNCTIONS, DEFAULT_EXPRESSION_VALIDATION_CONFIG, ErrorCategory, ErrorCode, ErrorCodeToHttpStatus, ErrorMessages, FORMAT_FUNCTIONS, LOGIC_FUNCTIONS, NUMBER_FUNCTIONS, PAGE_SCHEMA_VERSION, PROTOCOL_VERSION, PageStatus, PublishChannel, PublishStatus, STRING_FUNCTIONS, UTILITY_FUNCTIONS, VERSION, VersionStatus, bindingRef, createDjvlcError, createExpressionContext, createLoopContext, isDjvlcError, literal, queryRef, stateRef, template };
|