智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. declare module 'jsep' {
  2. namespace jsep {
  3. export type baseTypes = string | number | boolean | RegExp | null | undefined | object;
  4. export interface Expression {
  5. type: string;
  6. [key: string]: baseTypes | Expression | Array<baseTypes | Expression>;
  7. }
  8. export interface ArrayExpression extends Expression {
  9. type: 'ArrayExpression';
  10. /** The expression can be null in the case of array holes ([ , , ]) */
  11. elements: Array<null | Expression>;
  12. }
  13. export interface BinaryExpression extends Expression {
  14. type: 'BinaryExpression';
  15. operator: string;
  16. left: Expression;
  17. right: Expression;
  18. }
  19. export interface CallExpression extends Expression {
  20. type: 'CallExpression';
  21. arguments: Expression[];
  22. callee: Expression;
  23. }
  24. export interface Compound extends Expression {
  25. type: 'Compound';
  26. body: Expression[];
  27. }
  28. export interface SequenceExpression extends Expression {
  29. type: 'SequenceExpression';
  30. expressions: Expression[];
  31. }
  32. export interface ConditionalExpression extends Expression {
  33. type: 'ConditionalExpression';
  34. test: Expression;
  35. consequent: Expression;
  36. alternate: Expression;
  37. }
  38. export interface Identifier extends Expression {
  39. type: 'Identifier';
  40. name: string;
  41. }
  42. export interface Literal extends Expression {
  43. type: 'Literal';
  44. value: boolean | number | string | RegExp | null;
  45. raw: string;
  46. }
  47. export interface MemberExpression extends Expression {
  48. type: 'MemberExpression';
  49. computed: boolean;
  50. object: Expression;
  51. property: Expression;
  52. optional?: boolean;
  53. }
  54. export interface ThisExpression extends Expression {
  55. type: 'ThisExpression';
  56. }
  57. export interface UnaryExpression extends Expression {
  58. type: 'UnaryExpression';
  59. operator: string;
  60. argument: Expression;
  61. prefix: boolean;
  62. }
  63. export type ExpressionType =
  64. 'Compound'
  65. | 'SequenceExpression'
  66. | 'Identifier'
  67. | 'MemberExpression'
  68. | 'Literal'
  69. | 'ThisExpression'
  70. | 'CallExpression'
  71. | 'UnaryExpression'
  72. | 'BinaryExpression'
  73. | 'ConditionalExpression'
  74. | 'ArrayExpression';
  75. export type CoreExpression =
  76. ArrayExpression
  77. | BinaryExpression
  78. | CallExpression
  79. | Compound
  80. | SequenceExpression
  81. | ConditionalExpression
  82. | Identifier
  83. | Literal
  84. | MemberExpression
  85. | ThisExpression
  86. | UnaryExpression;
  87. export type PossibleExpression = Expression | undefined;
  88. export interface HookScope {
  89. index: number;
  90. readonly expr: string;
  91. readonly char: string; // current character of the expression
  92. readonly code: number; // current character code of the expression
  93. gobbleSpaces: () => void;
  94. gobbleExpressions: (untilICode?: number) => Expression[];
  95. gobbleExpression: () => Expression;
  96. gobbleBinaryOp: () => PossibleExpression;
  97. gobbleBinaryExpression: () => PossibleExpression;
  98. gobbleToken: () => PossibleExpression;
  99. gobbleTokenProperty: (node: Expression) => Expression
  100. gobbleNumericLiteral: () => PossibleExpression;
  101. gobbleStringLiteral: () => PossibleExpression;
  102. gobbleIdentifier: () => PossibleExpression;
  103. gobbleArguments: (untilICode: number) => PossibleExpression;
  104. gobbleGroup: () => Expression;
  105. gobbleArray: () => PossibleExpression;
  106. throwError: (msg: string) => never;
  107. }
  108. export type HookType = 'gobble-expression' | 'after-expression' | 'gobble-token' | 'after-token' | 'gobble-spaces';
  109. export type HookCallback = (this: HookScope, env: { node?: Expression }) => void;
  110. type HookTypeObj = Partial<{ [key in HookType]: HookCallback}>
  111. export interface IHooks extends HookTypeObj {
  112. add(name: HookType, cb: HookCallback, first?: boolean): void;
  113. add(obj: { [name in HookType]: HookCallback }, first?: boolean): void;
  114. run(name: string, env: { context?: typeof jsep, node?: Expression }): void;
  115. }
  116. let hooks: IHooks;
  117. export interface IPlugin {
  118. name: string;
  119. init: (this: typeof jsep) => void;
  120. }
  121. export interface IPlugins {
  122. registered: { [name: string]: IPlugin };
  123. register: (...plugins: IPlugin[]) => void;
  124. }
  125. let plugins: IPlugins;
  126. let unary_ops: { [op: string]: any };
  127. let binary_ops: { [op: string]: number };
  128. let right_associative: Set<string>;
  129. let additional_identifier_chars: Set<string>;
  130. let literals: { [literal: string]: any };
  131. let this_str: string;
  132. function addBinaryOp(operatorName: string, precedence: number, rightToLeft?: boolean): void;
  133. function addUnaryOp(operatorName: string): void;
  134. function addLiteral(literalName: string, literalValue: any): void;
  135. function addIdentifierChar(identifierName: string): void;
  136. function removeBinaryOp(operatorName: string): void;
  137. function removeUnaryOp(operatorName: string): void;
  138. function removeLiteral(literalName: string): void;
  139. function removeIdentifierChar(identifierName: string): void;
  140. function removeAllBinaryOps(): void;
  141. function removeAllUnaryOps(): void;
  142. function removeAllLiterals(): void;
  143. const version: string;
  144. }
  145. function jsep(val: string | jsep.Expression): jsep.Expression;
  146. export = jsep;
  147. }