@next-core/cook 2.3.0 → 2.4.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.
@@ -1,14 +1,35 @@
1
1
  import type { ArrowFunctionExpression, Expression, FunctionDeclaration, FunctionExpression, Statement } from "@babel/types";
2
2
  import type { EstreeNode } from "./interfaces.js";
3
+ export declare enum Mode {
4
+ LEXICAL = 0,
5
+ STRICT = 1
6
+ }
7
+ export declare const SourceNode: unique symbol;
8
+ export declare const FormalParameters: unique symbol;
9
+ export declare const ECMAScriptCode: unique symbol;
10
+ export declare const Environment: unique symbol;
11
+ export declare const IsConstructor: unique symbol;
12
+ export declare const ThisMode: unique symbol;
13
+ export declare const DebuggerCall: unique symbol;
14
+ export declare const DebuggerScope: unique symbol;
15
+ export declare const DebuggerNode: unique symbol;
16
+ export declare const DebuggerReturn: unique symbol;
3
17
  export declare class ExecutionContext {
4
18
  VariableEnvironment?: EnvironmentRecord;
5
19
  LexicalEnvironment?: EnvironmentRecord;
6
20
  Function?: FunctionObject;
7
21
  }
8
22
  export type EnvironmentRecordType = "function" | "declarative";
23
+ export declare enum BindingStatus {
24
+ UNINITIALIZED = 0,
25
+ LEXICAL = 1,
26
+ INITIALIZED = 2
27
+ }
9
28
  export declare class EnvironmentRecord {
10
29
  readonly OuterEnv: EnvironmentRecord | null | undefined;
11
30
  private readonly bindingMap;
31
+ protected ThisValue: unknown;
32
+ protected ThisBindingStatus: BindingStatus | undefined;
12
33
  constructor(outer: EnvironmentRecord | null | undefined);
13
34
  HasBinding(name: string): boolean;
14
35
  CreateMutableBinding(name: string, deletable: boolean): CompletionRecord;
@@ -31,10 +52,15 @@ export declare class EnvironmentRecord {
31
52
  */
32
53
  SetMutableBinding(name: string, value: unknown, _strict?: boolean): CompletionRecord;
33
54
  GetBindingValue(name: string, _strict?: boolean): unknown;
55
+ HasThisBinding(): boolean;
34
56
  }
35
57
  export declare class DeclarativeEnvironment extends EnvironmentRecord {
36
58
  }
37
59
  export declare class FunctionEnvironment extends EnvironmentRecord {
60
+ constructor(F: FunctionObject);
61
+ HasThisBinding(): boolean;
62
+ BindThisValue(value: unknown): void;
63
+ GetThisBinding(): unknown;
38
64
  }
39
65
  export interface BindingState {
40
66
  initialized?: boolean;
@@ -49,14 +75,6 @@ export interface BindingState {
49
75
  */
50
76
  strict?: boolean;
51
77
  }
52
- export declare const SourceNode: unique symbol;
53
- export declare const FormalParameters: unique symbol;
54
- export declare const ECMAScriptCode: unique symbol;
55
- export declare const Environment: unique symbol;
56
- export declare const IsConstructor: unique symbol;
57
- export declare const DebuggerCall: unique symbol;
58
- export declare const DebuggerScope: unique symbol;
59
- export declare const DebuggerNode: unique symbol;
60
78
  export interface FunctionObject {
61
79
  (...args: unknown[]): unknown;
62
80
  [SourceNode]: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
@@ -64,6 +82,7 @@ export interface FunctionObject {
64
82
  [ECMAScriptCode]: Statement[] | Expression;
65
83
  [Environment]: EnvironmentRecord;
66
84
  [IsConstructor]: boolean;
85
+ [ThisMode]?: Mode;
67
86
  [DebuggerCall]?: (...args: unknown[]) => IterableIterator<unknown>;
68
87
  [DebuggerScope]?: () => EnvironmentRecord | null | undefined;
69
88
  [DebuggerNode]?: () => EstreeNode | undefined;
@@ -5,6 +5,8 @@ export interface CookOptions {
5
5
  globalVariables?: Record<string, unknown>;
6
6
  hooks?: CookHooks;
7
7
  debug?: boolean;
8
+ externalSourceForDebug?: boolean;
9
+ ArrayConstructor?: typeof Array;
8
10
  }
9
11
  export interface CookHooks {
10
12
  beforeEvaluate?(node: EstreeNode): void;
@@ -12,4 +14,4 @@ export interface CookHooks {
12
14
  beforeBranch?(node: EstreeNode, branch: "if" | "else"): void;
13
15
  }
14
16
  /** For next-core internal usage only. */
15
- export declare function cook(rootAst: FunctionDeclaration | Expression, codeSource: string, { rules, debug, globalVariables, hooks }?: CookOptions): unknown;
17
+ export declare function cook(rootAst: FunctionDeclaration | Expression, codeSource: string, { rules, debug, externalSourceForDebug, globalVariables, ArrayConstructor, hooks, }?: CookOptions): unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/cook",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "Cook expressions and storyboard functions",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/cook",
6
6
  "license": "GPL-3.0",
@@ -57,5 +57,5 @@
57
57
  "@next-core/test-next": "^1.1.3",
58
58
  "lodash": "^4.17.21"
59
59
  },
60
- "gitHead": "a143984961ebb50532250cad45a7dbdfd23d8728"
60
+ "gitHead": "aec9d60454930de541f57f1eee2382e8d20a326c"
61
61
  }