@ibyar/expressions 0.5.6 → 0.6.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.
Files changed (97) hide show
  1. package/api/abstract.js +5 -0
  2. package/api/abstract.js.map +1 -1
  3. package/api/class/class.d.ts +28 -13
  4. package/api/class/class.js +46 -41
  5. package/api/class/class.js.map +1 -1
  6. package/api/computing/return.d.ts +4 -0
  7. package/api/computing/return.js +5 -0
  8. package/api/computing/return.js.map +1 -1
  9. package/api/computing/throw.d.ts +4 -0
  10. package/api/computing/throw.js +4 -0
  11. package/api/computing/throw.js.map +1 -1
  12. package/api/definition/bind.d.ts +6 -0
  13. package/api/definition/bind.js +6 -0
  14. package/api/definition/bind.js.map +1 -1
  15. package/api/definition/function.js +6 -5
  16. package/api/definition/function.js.map +1 -1
  17. package/api/definition/member.js.map +1 -1
  18. package/api/definition/object.js +1 -1
  19. package/api/definition/object.js.map +1 -1
  20. package/api/definition/values.d.ts +12 -3
  21. package/api/definition/values.js +25 -4
  22. package/api/definition/values.js.map +1 -1
  23. package/api/deserialize/deserialize.d.ts +5 -0
  24. package/api/deserialize/deserialize.js +5 -0
  25. package/api/deserialize/deserialize.js.map +1 -1
  26. package/api/expression.d.ts +151 -5
  27. package/api/expression.js.map +1 -1
  28. package/api/module/export.d.ts +63 -0
  29. package/api/module/export.js +64 -1
  30. package/api/module/export.js.map +1 -1
  31. package/api/module/import.d.ts +53 -0
  32. package/api/module/import.js +53 -0
  33. package/api/module/import.js.map +1 -1
  34. package/api/operators/grouping.d.ts +7 -0
  35. package/api/operators/grouping.js +7 -0
  36. package/api/operators/grouping.js.map +1 -1
  37. package/api/operators/pipeline.d.ts +12 -0
  38. package/api/operators/pipeline.js +12 -0
  39. package/api/operators/pipeline.js.map +1 -1
  40. package/api/operators/unary.js +3 -0
  41. package/api/operators/unary.js.map +1 -1
  42. package/api/program.d.ts +2 -2
  43. package/api/program.js.map +1 -1
  44. package/api/statement/control/block.d.ts +4 -0
  45. package/api/statement/control/block.js +4 -0
  46. package/api/statement/control/block.js.map +1 -1
  47. package/api/statement/control/empty.d.ts +7 -0
  48. package/api/statement/control/empty.js +7 -0
  49. package/api/statement/control/empty.js.map +1 -1
  50. package/api/statement/control/if.d.ts +5 -0
  51. package/api/statement/control/if.js +5 -0
  52. package/api/statement/control/if.js.map +1 -1
  53. package/api/statement/control/switch.d.ts +6 -0
  54. package/api/statement/control/switch.js +9 -0
  55. package/api/statement/control/switch.js.map +1 -1
  56. package/api/statement/control/terminate.d.ts +8 -0
  57. package/api/statement/control/terminate.js +8 -0
  58. package/api/statement/control/terminate.js.map +1 -1
  59. package/api/statement/iterations/for.d.ts +5 -0
  60. package/api/statement/iterations/for.js +13 -0
  61. package/api/statement/iterations/for.js.map +1 -1
  62. package/api/statement/iterations/while.d.ts +6 -0
  63. package/api/statement/iterations/while.js +10 -0
  64. package/api/statement/iterations/while.js.map +1 -1
  65. package/package.json +5 -3
  66. package/scope/event.d.ts +3 -3
  67. package/scope/event.js +2 -2
  68. package/scope/event.js.map +1 -1
  69. package/scope/pool.d.ts +7 -0
  70. package/scope/pool.js +29 -0
  71. package/scope/pool.js.map +1 -0
  72. package/scope/proxy.d.ts +6 -9
  73. package/scope/proxy.js +22 -31
  74. package/scope/proxy.js.map +1 -1
  75. package/scope/scope.d.ts +161 -38
  76. package/scope/scope.js +260 -106
  77. package/scope/scope.js.map +1 -1
  78. package/scope/stack.d.ts +95 -19
  79. package/scope/stack.js +13 -0
  80. package/scope/stack.js.map +1 -1
  81. package/v8/enums.js +31 -0
  82. package/v8/enums.js.map +1 -1
  83. package/v8/inline.d.ts +36 -0
  84. package/v8/inline.js +407 -5
  85. package/v8/inline.js.map +1 -1
  86. package/v8/nodes.js +2 -1
  87. package/v8/nodes.js.map +1 -1
  88. package/v8/parser.d.ts +8 -0
  89. package/v8/parser.js +304 -1
  90. package/v8/parser.js.map +1 -1
  91. package/v8/stream.d.ts +4 -0
  92. package/v8/stream.js +79 -17
  93. package/v8/stream.js.map +1 -1
  94. package/v8/token.d.ts +229 -0
  95. package/v8/token.js +236 -1
  96. package/v8/token.js.map +1 -1
  97. package/visit/visitor.d.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/values.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAYxD,IAAa,UAAU,kBAAvB,MAAa,UAAW,SAAQ,sBAAsB;IAIrD,YAAsB,IAAqB;QAC1C,KAAK,EAAE,CAAC;QADa,SAAI,GAAJ,IAAI,CAAiB;IAE3C,CAAC;IALD,MAAM,CAAC,QAAQ,CAAC,IAAgB;QAC/B,OAAO,IAAI,YAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAID,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,cAAc,CAAC,SAAuB,IAAU,CAAC;IACjD,GAAG,CAAC,KAAY,EAAE,KAAU;QAC3B,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,WAAiB;QAClC,IAAI,WAAW,EAAE;YAChB,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAGD,SAAS,CAAmB,KAAY,EAAE,KAAkB;QAC3D,IAAI,KAAK,EAAE;YACV,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACjC;QACD,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI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AAU,CAAC,KAAK,CAAC,CAAe,CAAC;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,aAAa,CAAC,CAAe,CAAC;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAe,CAAC;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAe,CAAC","sourcesContent":["import type {\n\tDeclarationExpression, ExpressionNode, NodeDeserializer,\n\tCanFindScope, ExpressionEventPath, VisitNodeType\n} from '../expression.js';\nimport type { Scope } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { AbstractExpressionNode } from '../abstract.js';\n\n/**\n * An identifier is a sequence of characters in the code that identifies a variable, function, or property.\n * In JavaScript, identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9),\n * but may not start with a digit.\n * An identifier differs from a string in that a string is data,\n * while an identifier is part of the code. In JavaScript,\n * there is no way to convert identifiers to strings,\n * but sometimes it is possible to parse strings into identifiers.\n */\n@Deserializer('Identifier')\nexport class Identifier extends AbstractExpressionNode implements DeclarationExpression, CanFindScope {\n\tstatic fromJSON(node: Identifier): Identifier {\n\t\treturn new Identifier(node.name);\n\t}\n\tconstructor(protected name: string | number) {\n\t\tsuper();\n\t}\n\tgetName() {\n\t\treturn this.name;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack, value: any) {\n\t\treturn stack.set(this.name, value) ? value : void 0;\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tif (thisContext) {\n\t\t\treturn thisContext[this.name];\n\t\t}\n\t\treturn stack.get(this.name);\n\t}\n\tfindScope<T extends object>(stack: Stack): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope?: Scope<any>): Scope<T> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getScope(this.name);\n\t\t}\n\t\tscope = stack.findScope(this.name);\n\t\treturn scope.getScope(this.name);\n\t}\n\tdeclareVariable(stack: Stack, propertyValue: any): any {\n\t\treturn stack.declareVariable(this.name, propertyValue);\n\t}\n\tgetDeclarationName(): string {\n\t\treturn this.toString();\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [this];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tconst path: ExpressionEventPath[] = [{ computed: false, path: this.toString() }];\n\t\treturn computed ? [{ computed, path: this.toString(), computedPath: [path] }] : path;\n\t}\n\ttoString(): string {\n\t\treturn String(this.name);\n\t}\n\ttoJson(): object {\n\t\treturn { name: this.name };\n\t}\n}\n\n@Deserializer('ThisExpression')\nexport class ThisExpression extends Identifier {\n\tstatic fromJSON(node: ThisExpression): ThisExpression {\n\t\treturn ThisNode;\n\t}\n\tconstructor() {\n\t\tsuper('this');\n\t}\n}\n\n@Deserializer('Literal')\nexport class Literal<T> extends AbstractExpressionNode implements CanFindScope {\n\tstatic fromJSON(node: Literal<any>):\n\t\tLiteral<string>\n\t\t| Literal<number>\n\t\t| Literal<boolean>\n\t\t| Literal<RegExp>\n\t\t| Literal<bigint>\n\t\t| Literal<null>\n\t\t| Literal<undefined> {\n\t\tif (node.bigint) {\n\t\t\treturn new Literal(BigInt(node.bigint), node.raw, undefined, node.bigint);\n\t\t} else if (node.regex) {\n\t\t\treturn new Literal(RegExp(node.regex.pattern, node.regex.flags), node.raw, node.regex);\n\t\t}\n\t\treturn new Literal(node.value, node.raw);\n\t}\n\tconstructor(protected value: T, protected raw?: string, protected regex?: { pattern: string, flags: string }, protected bigint?: string) {\n\t\tsuper();\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tgetRegex() {\n\t\treturn this.regex;\n\t}\n\tgetBigint() {\n\t\treturn this.bigint;\n\t}\n\tgeRaw() {\n\t\treturn this.raw;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset() {\n\t\tthrow new Error(`${this.constructor.name}#set() has no implementation.`);\n\t}\n\tget(): T {\n\t\treturn this.value;\n\t}\n\tfindScope<V extends object>(stack: Stack): Scope<V>;\n\tfindScope<V extends object>(stack: Stack, scope: Scope<any>): Scope<V>;\n\tfindScope<V extends object>(stack: Stack, scope?: Scope<any>): Scope<V> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getScope<V>(this.value as any);\n\t\t}\n\t\tscope = stack.findScope<V>(this.value as any);\n\t\treturn scope.getScope<V>(this.value as any);\n\t}\n\tdependency(computed: true): ExpressionNode[] {\n\t\treturn computed ? [this] : [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn computed ? [{ computed: false, path: this.toString() }] : [];\n\t}\n\ttoString(): string {\n\t\treturn this.raw ?? String(this.value);\n\t}\n\ttoJson(): object {\n\t\tif (this.bigint) {\n\t\t\treturn {\n\t\t\t\tbigint: this.bigint,\n\t\t\t\traw: this.raw,\n\t\t\t};\n\t\t} else if (this.regex) {\n\t\t\treturn {\n\t\t\t\tregex: { pattern: this.regex?.pattern, flags: this.regex?.flags },\n\t\t\t\traw: this.raw,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tvalue: this.value,\n\t\t\traw: this.raw,\n\t\t};\n\t}\n}\n\nclass TemplateArray extends Array<string> implements TemplateStringsArray {\n\traw: readonly string[];\n\tconstructor(strings: string[]) {\n\t\tsuper(...strings);\n\t\tthis.raw = strings;\n\t}\n}\n\nexport class TemplateLiteralExpressionNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: TemplateLiteralExpressionNode, deserializer: NodeDeserializer): TemplateLiteralExpressionNode {\n\t\treturn new TemplateLiteralExpressionNode(\n\t\t\tnode.quasis,\n\t\t\tnode.expressions.map(deserializer),\n\t\t\tnode.tag ? deserializer(node.tag) : void 0\n\t\t);\n\t}\n\tstatic visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType): void {\n\t\tnode.tag && visitNode(node.tag);\n\t\tnode.expressions.forEach(visitNode);\n\t}\n\tconstructor(protected quasis: string[], protected expressions: ExpressionNode[], protected tag?: ExpressionNode,) {\n\t\tsuper();\n\t}\n\tgetTag() {\n\t\treturn this.tag;\n\t}\n\tgetExpressions() {\n\t\treturn this.expressions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.expressions.forEach(value => value.shareVariables(scopeList));\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`TemplateLiteralExpressionNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst tagged: Function = this.tag?.get(stack) || String.raw;\n\t\tconst templateStringsArray = new TemplateArray(this.quasis);\n\t\ttemplateStringsArray.raw = templateStringsArray;\n\t\tconst values = this.expressions.map(expr => expr.get(stack));\n\t\treturn tagged(templateStringsArray, ...values);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tlet str = this.tag?.toString() || '';\n\t\tstr += '`';\n\t\tlet i = 0;\n\t\tfor (; i < this.quasis.length - 1; i++) {\n\t\t\tstr += this.quasis[i];\n\t\t\tstr += '${';\n\t\t\tstr += this.expressions[i].toString();\n\t\t\tstr += '}';\n\t\t}\n\t\tstr += this.quasis[i];\n\t\tstr += '`';\n\t\treturn str;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tquasis: this.quasis,\n\t\t\texpressions: this.expressions.map(expr => expr.toJSON()),\n\t\t\ttag: this.tag?.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('TemplateLiteral')\nexport class TemplateLiteral extends TemplateLiteralExpressionNode {\n\tdeclare protected tag: undefined;\n\tconstructor(quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions);\n\t}\n\toverride getTag(): undefined {\n\t\treturn undefined;\n\t}\n}\n\n@Deserializer('TaggedTemplateExpression')\nexport class TaggedTemplateExpression extends TemplateLiteralExpressionNode {\n\tdeclare protected tag: ExpressionNode;\n\tconstructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions, tag);\n\t}\n\toverride getTag(): ExpressionNode {\n\t\treturn super.getTag()!;\n\t}\n}\n\n\n// @Deserializer('BigIntLiteral')\n// export class BigIntLiteral extends Literal<bigint> {\n// \tstatic fromJSON(node: BigIntLiteral): BigIntLiteral {\n// \t\treturn new BigIntLiteral(BigInt(String(node.value)));\n// \t}\n// \ttoString(): string {\n// \t\treturn `${this.value}n`;\n// \t}\n// \ttoJson(): object {\n// \t\treturn { value: this.value.toString() };\n// \t}\n// }\n\n\nexport const TRUE = String(true);\nexport const FALSE = String(false);\n\nexport const NULL = String(null);\nexport const UNDEFINED = String(undefined);\n\nexport const NullNode = Object.freeze(new Literal<null>(null)) as Literal<null>;\nexport const UndefinedNode = Object.freeze(new Literal<undefined>(undefined)) as Literal<undefined>;\nexport const TrueNode = Object.freeze(new Literal<boolean>(true)) as Literal<boolean>;\nexport const FalseNode = Object.freeze(new Literal<boolean>(false)) as Literal<boolean>;\nexport const ThisNode = Object.freeze(new ThisExpression()) as ThisExpression;\nexport const GlobalThisNode = Object.freeze(new Identifier('globalThis')) as Identifier;\nexport const SymbolNode = Object.freeze(new Identifier('Symbol')) as Identifier;\nexport const OfNode = Object.freeze(new Identifier('of')) as Identifier;\nexport const AsNode = Object.freeze(new Identifier('as')) as Identifier;\nexport const DefaultNode = Object.freeze(new Identifier('default')) as Identifier;\nexport const GetIdentifier = Object.freeze(new Identifier('get')) as Identifier;\nexport const SetIdentifier = Object.freeze(new Identifier('set')) as Identifier;\nexport const AsyncIdentifier = Object.freeze(new Identifier('async')) as Identifier;\nexport const AwaitIdentifier = Object.freeze(new Identifier('await')) as Identifier;\nexport const ConstructorIdentifier = Object.freeze(new Identifier('constructor')) as Identifier;\nexport const NameIdentifier = Object.freeze(new Identifier('name')) as Identifier;\nexport const EvalIdentifier = Object.freeze(new Identifier('eval')) as Identifier;\nexport const ArgumentsIdentifier = Object.freeze(new Identifier('arguments')) as Identifier;\nexport const YieldIdentifier = Object.freeze(new Identifier('yield')) as Identifier;\nexport const SuperIdentifier = Object.freeze(new Identifier('super')) as Identifier;\nexport const LetIdentifier = Object.freeze(new Identifier('let')) as Identifier;\n"]}
1
+ {"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/values.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;;;GAQG;AAEH,IAAa,UAAU,kBAAvB,MAAa,UAAW,SAAQ,sBAAsB;IAIrD,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CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,aAAa,CAAC,CAAe,CAAC;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAe,CAAC;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAe,CAAC","sourcesContent":["import type {\n\tDeclarationExpression, ExpressionNode, NodeDeserializer,\n\tCanFindScope, ExpressionEventPath, VisitNodeType\n} from '../expression.js';\nimport type { Context, Scope } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { AbstractExpressionNode } from '../abstract.js';\n\n/**\n * An identifier is a sequence of characters in the code that identifies a variable, function, or property.\n * In JavaScript, identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9),\n * but may not start with a digit.\n * An identifier differs from a string in that a string is data,\n * while an identifier is part of the code. In JavaScript,\n * there is no way to convert identifiers to strings,\n * but sometimes it is possible to parse strings into identifiers.\n */\n@Deserializer('Identifier')\nexport class Identifier extends AbstractExpressionNode implements DeclarationExpression, CanFindScope {\n\tstatic fromJSON(node: Identifier): Identifier {\n\t\treturn new Identifier(node.name);\n\t}\n\tconstructor(protected name: string | number) {\n\t\tsuper();\n\t}\n\tgetName() {\n\t\treturn this.name;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack, value: any) {\n\t\treturn stack.set(this.name, value) ? value : void 0;\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tif (thisContext) {\n\t\t\treturn thisContext[this.name];\n\t\t}\n\t\treturn stack.get(this.name);\n\t}\n\tfindScope<T extends object>(stack: Stack): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope?: Scope<any>): Scope<T> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getInnerScope(this.name);\n\t\t}\n\t\tscope = stack.findScope(this.name);\n\t\treturn scope.getInnerScope(this.name);\n\t}\n\tdeclareVariable(stack: Stack, propertyValue: any): any {\n\t\treturn stack.declareVariable(this.name, propertyValue);\n\t}\n\tgetDeclarationName(): string {\n\t\treturn this.toString();\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [this];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tconst path: ExpressionEventPath[] = [{ computed: false, path: this.toString() }];\n\t\treturn computed ? [{ computed, path: this.toString(), computedPath: [path] }] : path;\n\t}\n\ttoString(): string {\n\t\treturn String(this.name);\n\t}\n\ttoJson(): object {\n\t\treturn { name: this.name };\n\t}\n}\n\n@Deserializer('ThisExpression')\nexport class ThisExpression extends Identifier {\n\tstatic fromJSON(node: ThisExpression): ThisExpression {\n\t\treturn ThisNode;\n\t}\n\tconstructor() {\n\t\tsuper('this');\n\t}\n}\n\n@Deserializer('Literal')\nexport class Literal<T> extends AbstractExpressionNode implements CanFindScope {\n\tstatic fromJSON(node: Literal<any>):\n\t\tLiteral<string>\n\t\t| Literal<number>\n\t\t| Literal<boolean>\n\t\t| Literal<RegExp>\n\t\t| Literal<bigint>\n\t\t| Literal<null>\n\t\t| Literal<undefined> {\n\t\tif (node.bigint) {\n\t\t\treturn new Literal(BigInt(node.bigint), node.raw, undefined, node.bigint);\n\t\t} else if (node.regex) {\n\t\t\treturn new Literal(RegExp(node.regex.pattern, node.regex.flags), node.raw, node.regex);\n\t\t}\n\t\treturn new Literal(node.value, node.raw);\n\t}\n\tconstructor(protected value: T, protected raw?: string, protected regex?: { pattern: string, flags: string }, protected bigint?: string) {\n\t\tsuper();\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tgetRegex() {\n\t\treturn this.regex;\n\t}\n\tgetBigint() {\n\t\treturn this.bigint;\n\t}\n\tgeRaw() {\n\t\treturn this.raw;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset() {\n\t\tthrow new Error(`${this.constructor.name}#set() has no implementation.`);\n\t}\n\tget(): T {\n\t\treturn this.value;\n\t}\n\tfindScope<V extends Context>(stack: Stack): Scope<V>;\n\tfindScope<V extends Context>(stack: Stack, scope: Scope<Record<PropertyKey, V>>): Scope<V>;\n\tfindScope<V extends Context>(stack: Stack, scope?: Scope<Record<PropertyKey, V>>): Scope<V> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getInnerScope(this.value as any);\n\t\t}\n\t\tscope = stack.findScope(this.value as any);\n\t\treturn scope.getInnerScope(this.value as any);\n\t}\n\tdependency(computed: true): ExpressionNode[] {\n\t\treturn computed ? [this] : [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn computed ? [{ computed: false, path: this.toString() }] : [];\n\t}\n\ttoString(): string {\n\t\treturn this.raw ?? String(this.value);\n\t}\n\ttoJson(): object {\n\t\tif (this.bigint) {\n\t\t\treturn {\n\t\t\t\tbigint: this.bigint,\n\t\t\t\traw: this.raw,\n\t\t\t};\n\t\t} else if (this.regex) {\n\t\t\treturn {\n\t\t\t\tregex: { pattern: this.regex?.pattern, flags: this.regex?.flags },\n\t\t\t\traw: this.raw,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tvalue: this.value,\n\t\t\traw: this.raw,\n\t\t};\n\t}\n}\n\nclass TemplateArray extends Array<string> implements TemplateStringsArray {\n\traw: readonly string[];\n\tconstructor(strings: string[]) {\n\t\tsuper(...strings);\n\t\tthis.raw = strings;\n\t}\n}\n\nexport class TemplateLiteralExpressionNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: TemplateLiteralExpressionNode, deserializer: NodeDeserializer): TemplateLiteralExpressionNode {\n\t\treturn new TemplateLiteralExpressionNode(\n\t\t\tnode.quasis,\n\t\t\tnode.expressions.map(deserializer),\n\t\t\tnode.tag ? deserializer(node.tag) : void 0\n\t\t);\n\t}\n\tstatic visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType): void {\n\t\tnode.tag && visitNode(node.tag);\n\t\tnode.expressions.forEach(visitNode);\n\t}\n\tconstructor(protected quasis: string[], protected expressions: ExpressionNode[], protected tag?: ExpressionNode,) {\n\t\tsuper();\n\t}\n\tgetTag() {\n\t\treturn this.tag;\n\t}\n\tgetExpressions() {\n\t\treturn this.expressions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.expressions.forEach(value => value.shareVariables(scopeList));\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`TemplateLiteralExpressionNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst tagged: Function = this.tag?.get(stack) || String.raw;\n\t\tconst templateStringsArray = new TemplateArray(this.quasis);\n\t\ttemplateStringsArray.raw = templateStringsArray;\n\t\tconst values = this.expressions.map(expr => expr.get(stack));\n\t\treturn tagged(templateStringsArray, ...values);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tlet str = this.tag?.toString() || '';\n\t\tstr += '`';\n\t\tlet i = 0;\n\t\tfor (; i < this.quasis.length - 1; i++) {\n\t\t\tstr += this.quasis[i];\n\t\t\tstr += '${';\n\t\t\tstr += this.expressions[i].toString();\n\t\t\tstr += '}';\n\t\t}\n\t\tstr += this.quasis[i];\n\t\tstr += '`';\n\t\treturn str;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tquasis: this.quasis,\n\t\t\texpressions: this.expressions.map(expr => expr.toJSON()),\n\t\t\ttag: this.tag?.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('TemplateLiteral')\nexport class TemplateLiteral extends TemplateLiteralExpressionNode {\n\tdeclare protected tag: undefined;\n\tconstructor(quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions);\n\t}\n\toverride getTag(): undefined {\n\t\treturn undefined;\n\t}\n}\n\n@Deserializer('TaggedTemplateExpression')\nexport class TaggedTemplateExpression extends TemplateLiteralExpressionNode {\n\tdeclare protected tag: ExpressionNode;\n\tconstructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions, tag);\n\t}\n\toverride getTag(): ExpressionNode {\n\t\treturn super.getTag()!;\n\t}\n}\n\n\n// @Deserializer('BigIntLiteral')\n// export class BigIntLiteral extends Literal<bigint> {\n// \tstatic fromJSON(node: BigIntLiteral): BigIntLiteral {\n// \t\treturn new BigIntLiteral(BigInt(String(node.value)));\n// \t}\n// \ttoString(): string {\n// \t\treturn `${this.value}n`;\n// \t}\n// \ttoJson(): object {\n// \t\treturn { value: this.value.toString() };\n// \t}\n// }\n\n\nexport const TRUE = String(true);\nexport const FALSE = String(false);\n\nexport const NULL = String(null);\nexport const UNDEFINED = String(undefined);\n\nexport const NullNode = Object.freeze(new Literal<null>(null)) as Literal<null>;\nexport const UndefinedNode = Object.freeze(new Literal<undefined>(undefined)) as Literal<undefined>;\nexport const TrueNode = Object.freeze(new Literal<boolean>(true)) as Literal<boolean>;\nexport const FalseNode = Object.freeze(new Literal<boolean>(false)) as Literal<boolean>;\nexport const ThisNode = Object.freeze(new ThisExpression()) as ThisExpression;\nexport const GlobalThisNode = Object.freeze(new Identifier('globalThis')) as Identifier;\nexport const SymbolNode = Object.freeze(new Identifier('Symbol')) as Identifier;\nexport const OfNode = Object.freeze(new Identifier('of')) as Identifier;\nexport const AsNode = Object.freeze(new Identifier('as')) as Identifier;\nexport const DefaultNode = Object.freeze(new Identifier('default')) as Identifier;\nexport const GetIdentifier = Object.freeze(new Identifier('get')) as Identifier;\nexport const SetIdentifier = Object.freeze(new Identifier('set')) as Identifier;\nexport const AsyncIdentifier = Object.freeze(new Identifier('async')) as Identifier;\nexport const AwaitIdentifier = Object.freeze(new Identifier('await')) as Identifier;\nexport const ConstructorIdentifier = Object.freeze(new Identifier('constructor')) as Identifier;\nexport const NameIdentifier = Object.freeze(new Identifier('name')) as Identifier;\nexport const EvalIdentifier = Object.freeze(new Identifier('eval')) as Identifier;\nexport const ArgumentsIdentifier = Object.freeze(new Identifier('arguments')) as Identifier;\nexport const YieldIdentifier = Object.freeze(new Identifier('yield')) as Identifier;\nexport const SuperIdentifier = Object.freeze(new Identifier('super')) as Identifier;\nexport const LetIdentifier = Object.freeze(new Identifier('let')) as Identifier;\n"]}
@@ -2,5 +2,10 @@ import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js'
2
2
  export declare function Deserializer(type: string): Function;
3
3
  export declare function getDeserializerType(target: ExpressionNodConstructor<ExpressionNode>): string;
4
4
  export declare function serializeNode(node: ExpressionNode): string;
5
+ /**
6
+ * convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`
7
+ * @param node as type `NodeJsonType`
8
+ * @returns ExpressionNode
9
+ */
5
10
  export declare function deserialize(node: ExpressionNode): ExpressionNode;
6
11
  export declare function deserializeNode(node: string): ExpressionNode;
@@ -12,6 +12,11 @@ export function getDeserializerType(target) {
12
12
  export function serializeNode(node) {
13
13
  return JSON.stringify(node);
14
14
  }
15
+ /**
16
+ * convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`
17
+ * @param node as type `NodeJsonType`
18
+ * @returns ExpressionNode
19
+ */
15
20
  export function deserialize(node) {
16
21
  const fromJSON = expressionTypes.get(node.type)?.fromJSON;
17
22
  if (fromJSON) {
@@ -1 +1 @@
1
- {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/expressions/api/deserialize/deserialize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,CAAC,MAAgD,EAAE,EAAE;QAC3D,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAgD;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAoB;IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAQD,MAAM,UAAU,WAAW,CAAC,IAAoB;IAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAO,IAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACjE,IAAI,QAAQ,EAAE;QACb,OAAO,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;KACnC;SAAM;QACN,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACrF;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js';\nimport { expressionTypes } from './type-store.js';\n\n\n\nexport function Deserializer(type: string): Function {\n\treturn (target: ExpressionNodConstructor<ExpressionNode>) => {\n\t\ttarget.type = type;\n\t\texpressionTypes.set(type, target);\n\t\treturn target;\n\t};\n}\n\nexport function getDeserializerType(target: ExpressionNodConstructor<ExpressionNode>) {\n\treturn target.type;\n}\n\nexport function serializeNode(node: ExpressionNode) {\n\treturn JSON.stringify(node);\n}\n\n\n/**\n * convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`\n * @param node as type `NodeJsonType`\n * @returns ExpressionNode\n */\nexport function deserialize(node: ExpressionNode) {\n\tconst fromJSON = expressionTypes.get((<any>node).type)?.fromJSON;\n\tif (fromJSON) {\n\t\treturn fromJSON(node, deserialize);\n\t} else {\n\t\tthrow new Error(`Couldn't find Expression class for name: ${JSON.stringify(node)}.`);\n\t}\n}\n\nexport function deserializeNode(node: string) {\n\tconst exp = JSON.parse(node);\n\treturn deserialize(exp);\n}\n"]}
1
+ {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/expressions/api/deserialize/deserialize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,CAAC,MAAgD,EAAE,EAAE;QAC3D,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAgD;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAoB;IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAGD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAoB;IAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAO,IAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACjE,IAAI,QAAQ,EAAE;QACb,OAAO,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;KACnC;SAAM;QACN,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACrF;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js';\nimport { expressionTypes } from './type-store.js';\n\n\n\nexport function Deserializer(type: string): Function {\n\treturn (target: ExpressionNodConstructor<ExpressionNode>) => {\n\t\ttarget.type = type;\n\t\texpressionTypes.set(type, target);\n\t\treturn target;\n\t};\n}\n\nexport function getDeserializerType(target: ExpressionNodConstructor<ExpressionNode>) {\n\treturn target.type;\n}\n\nexport function serializeNode(node: ExpressionNode) {\n\treturn JSON.stringify(node);\n}\n\n\n/**\n * convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`\n * @param node as type `NodeJsonType`\n * @returns ExpressionNode\n */\nexport function deserialize(node: ExpressionNode) {\n\tconst fromJSON = expressionTypes.get((<any>node).type)?.fromJSON;\n\tif (fromJSON) {\n\t\treturn fromJSON(node, deserialize);\n\t} else {\n\t\tthrow new Error(`Couldn't find Expression class for name: ${JSON.stringify(node)}.`);\n\t}\n}\n\nexport function deserializeNode(node: string) {\n\tconst exp = JSON.parse(node);\n\treturn deserialize(exp);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Scope, ScopeContext } from '../scope/scope.js';
1
+ import type { Scope, Context } from '../scope/scope.js';
2
2
  import type { Stack } from '../scope/stack.js';
3
3
  import { TypeOf } from './utils.js';
4
4
  export declare type NodeType = {
@@ -21,29 +21,175 @@ export declare type ExpressionEventMap = {
21
21
  [key: string]: ExpressionEventMap;
22
22
  };
23
23
  export interface ExpressionNode {
24
- shareVariables(scopeList: Scope<ScopeContext>[]): void;
24
+ /**
25
+ * pass scope list from outer function to inner function,
26
+ *
27
+ * all other end point expression should do nothing,
28
+ * if this function executed.
29
+ *
30
+ * @param scopeList all outer function scopes given to the inner function,
31
+ * this solution ignore the fact that some inner function has no need to
32
+ * get shared variables, as its implementation never say that
33
+ * ```js
34
+ * function f(d) {
35
+ * function g() {
36
+ * const a = ({ d }) => d;
37
+ * return a;
38
+ * }
39
+ * return [d, g];
40
+ * }
41
+ * ```
42
+ */
43
+ shareVariables(scopeList: Scope<Context>[]): void;
44
+ /**
45
+ * assign the value to this expression in stack.
46
+ *
47
+ * most ExpressionNode will not implement this method, and will throw an exception.
48
+ * @param stack
49
+ * @param value
50
+ */
25
51
  set(stack: Stack, value: any): any;
52
+ /**
53
+ * execute/get the code for this expression and return the result value.
54
+ * @param stack
55
+ * @param thisContext
56
+ */
26
57
  get(stack: Stack, thisContext?: any): any;
58
+ /**
59
+ * get all dependencies form an expression node
60
+ *
61
+ * the return from this method, is represent an answer for what identifiers this expression depends-on.
62
+ *
63
+ *
64
+ * ex:
65
+ * ```js
66
+ * x + y;
67
+ * ```
68
+ *
69
+ * - for `+` operator : the answer should be `lhs` and `rhs`,
70
+ * - for `x` identifier: the answer should be node `x`,
71
+ * - for `y` identifier: the answer should be node `y`.
72
+ *
73
+ * so, the return from `+` will be `[ node 'x', node 'y']`
74
+ *
75
+ * and:
76
+ * - `x.y.z * a` ==> `[ member node `x.y.z`, identifier 'a']`
77
+ * @param computed
78
+ */
27
79
  dependency(computed?: true): ExpressionNode[];
80
+ /**
81
+ * ex:
82
+ * ```js
83
+ * x + y;
84
+ * ```
85
+ *
86
+ * - for `+` operator : the answer should be `lhs` and `rhs`,
87
+ * - for `x` identifier: the answer should be node `x`,
88
+ * - for `y` identifier: the answer should be node `y`.
89
+ *
90
+ * so, the return from `+` will be `['x', 'y']`
91
+ *
92
+ * and:
93
+ * - `x.y.z` ==> `['x', 'y', 'z']`
94
+ * - `x[y].z` ==> ['x', ]
95
+ * @param computed required for member and chaining operators
96
+ */
28
97
  dependencyPath(computed?: true): ExpressionEventPath[];
98
+ /**
99
+ * get all the events form this expression
100
+ *
101
+ * the return from this method, is represent an answer for what is this expression depends-on as identifier name
102
+ *
103
+ * ex:
104
+ * ```js
105
+ * x + y;
106
+ * ```
107
+ *
108
+ * - for `+` operator : the answer should be `lhs` and `rhs`,
109
+ * - for `x` identifier: the answer should be `x`
110
+ * - for `y` identifier: the answer should be `y`
111
+ * the final output will be
112
+ *
113
+ * so, the return from `+` will be `{ x: undefined, y: undefined }`
114
+ *
115
+ * and:
116
+ * - `x.y.z * a` ==> `{ x: { y: { z: undefined }, a: undefined } }`
117
+ * - `x.y.z > x.y.h.g` ==> `{ x: { y: { z: undefined, h: { g: undefined} } } }`
118
+ * - `x[Symbol.toStringTag] + 'Class' + classType + array[3]` ==> `{ x: { 'Symbol.toStringTag': undefined }, classType: undefined, array: { 3: undefined } }`
119
+ * - `'name'` ==> {}
120
+ * - ```js
121
+ * user[firstName + `son of ${fatherName}`]
122
+ * ``` ==> `{ user: { 'firstName:fatherName': undefined }, firstName: undefined, fatherName: undefined }`
123
+ * @param parent
124
+ */
29
125
  events(): ExpressionEventMap;
126
+ /**
127
+ * re-write this expression as a javascript source
128
+ */
30
129
  toString(): string;
130
+ /**
131
+ * used to map this object to represent an [ESTree](https://github.com/estree/estree) json object
132
+ * @param key
133
+ */
31
134
  toJSON(): NodeJsonType;
135
+ /**
136
+ * just a helper method to force class that implement this interface to
137
+ * have a static method `fromJSON` to help reconstruct this ExpressionNode
138
+ * from an [ESTree](https://github.com/estree/estree) json object,
139
+ * with all necessary implementation to execute the code
140
+ */
32
141
  getClass(): ExpressionNodConstructor<ExpressionNode>;
33
142
  }
34
143
  export declare type NodeDeserializer<N = ExpressionNode> = (node: N) => N;
35
144
  export declare type VisitNodeType = (expression: ExpressionNode) => void;
145
+ /**
146
+ * this is how to:
147
+ * describe a class with it's static functions and properties
148
+ * in the interface add getClass method
149
+ */
36
150
  export interface ExpressionNodConstructor<N extends ExpressionNode> extends TypeOf<N> {
151
+ /**
152
+ * the type of an expression
153
+ */
37
154
  type: string;
155
+ /**
156
+ * build expression node from [ESTree](https://github.com/estree/estree) json object
157
+ * @param node
158
+ * @param deserializer
159
+ */
38
160
  fromJSON(node: N, deserializer: NodeDeserializer): N;
161
+ /**
162
+ * visit nodes inside expression
163
+ * @param expression
164
+ * @param callback
165
+ */
39
166
  visit?(node: N, visitNode: Object): void;
40
167
  }
41
168
  export interface DeclarationExpression extends ExpressionNode {
169
+ /**
170
+ * declare variable in the current local scope (block),
171
+ * or closest function scope (global) scop,
172
+ * the propertyName will be calculated at runtime
173
+ * @param stack the stack which an identifier will be declared
174
+ * @param propertyValue the initial value of identifier
175
+ * @param scope which scop to declare this identifier
176
+ */
42
177
  declareVariable(stack: Stack, propertyValue?: any): any;
178
+ /**
179
+ * get the variable declaration name
180
+ */
43
181
  getDeclarationName?(): string;
44
182
  }
183
+ /**
184
+ * An interface meant to be implemented by MemberExpression,
185
+ * Identifier and ChainExpression and all Literal expressions
186
+ */
45
187
  export interface CanFindScope {
46
- findScope<T extends ScopeContext>(stack: Stack): Scope<T>;
47
- findScope<T extends ScopeContext>(stack: Stack, scope: Scope<ScopeContext>): Scope<T>;
48
- findScope<T extends ScopeContext>(stack: Stack, scope?: Scope<ScopeContext>): Scope<T> | undefined;
188
+ /**
189
+ * try to search for scope of this expression
190
+ * @param stack
191
+ */
192
+ findScope<V extends Context>(stack: Stack): Scope<V>;
193
+ findScope<V extends Context>(stack: Stack, scope: Scope<Record<PropertyKey, V>>): Scope<V>;
194
+ findScope<V extends Context>(stack: Stack, scope?: Scope<Record<PropertyKey, V>>): Scope<V> | undefined;
49
195
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/expressions/api/expression.ts"],"names":[],"mappings":"","sourcesContent":["import type { Scope, ScopeContext } from '../scope/scope.js';\nimport type { Stack } from '../scope/stack.js';\nimport { TypeOf } from './utils.js';\n\nexport type NodeType = { type: string };\nexport type NodeJsonType = { [key: string]: any } & NodeType;\n\nexport type ExpressionEventPathDotNotation = { computed: false, path: string };\nexport type ExpressionEventPathBracketNotation = { computed: true, path: string, computedPath: ExpressionEventPath[][] };\nexport type ExpressionEventPath = ExpressionEventPathDotNotation | ExpressionEventPathBracketNotation;\nexport type ExpressionEventMap = { [key: string]: ExpressionEventMap };\n\nexport interface ExpressionNode {\n\n\t/**\n\t * pass scope list from outer function to inner function,\n\t * \n\t * all other end point expression should do nothing,\n\t * if this function executed.\n\t * \n\t * @param scopeList all outer function scopes given to the inner function,\n\t * this solution ignore the fact that some inner function has no need to\n\t * get shared variables, as its implementation never say that\n\t * ```js\n\t * function f(d) {\n\t * \t\tfunction g() {\n\t * \t\t\tconst a = ({ d }) => d;\n\t * \t\t\treturn a;\n\t * \t\t}\n\t * \t\treturn [d, g];\n\t * }\n\t * ```\n\t */\n\tshareVariables(scopeList: Scope<ScopeContext>[]): void;\n\n\t/**\n\t * assign the value to this expression in stack.\n\t * \n\t * most ExpressionNode will not implement this method, and will throw an exception.\n\t * @param stack \n\t * @param value \n\t */\n\tset(stack: Stack, value: any): any;\n\n\t/**\n\t * execute/get the code for this expression and return the result value.\n\t * @param stack \n\t * @param thisContext \n\t */\n\tget(stack: Stack, thisContext?: any): any;\n\n\t/**\n\t * get all dependencies form an expression node\n\t *\n\t * tha return from this method, is represent an answer for what identifiers this expression depends-on.\n\t * \n\t *\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `[ node 'x', node 'y']`\n\t *\n\t * and:\n\t * - `x.y.z * a` ==> `[ member node `x.y.z`, identifier 'a']`\n\t * @param computed\n\t */\n\tdependency(computed?: true): ExpressionNode[];\n\n\t/**\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `['x', 'y']`\n\t *\n\t * and:\n\t * - `x.y.z` ==> `['x', 'y', 'z']`\n\t * - `x[y].z` ==> ['x', ]\n\t * @param computed required for member and chaining operators\n\t */\n\tdependencyPath(computed?: true): ExpressionEventPath[];\n\n\t/**\n\t * get all the events form this expression\n\t * \n\t * tha return from this method, is represent an answer for what is this expression depends-on as identifier name\n\t * \n\t * ex: \n\t * ```js\n\t * x + y;\n\t * ```\n\t * \n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier: the answer should be `x`\n\t * - for `y` identifier: the answer should be `y`\n\t * the final output will be \n\t * \n\t * so, the return from `+` will be `{ x: undefined, y: undefined }`\n\t * \n\t * and:\n\t * - `x.y.z * a` ==> `{ x: { y: { z: undefined }, a: undefined } }`\n\t * - `x.y.z > x.y.h.g` ==> `{ x: { y: { z: undefined, h: { g: undefined} } } }`\n\t * - `x[Symbol.toStringTag] + 'Class' + classType + array[3]` ==> `{ x: { 'Symbol.toStringTag': undefined }, classType: undefined, array: { 3: undefined } }`\n\t * - `'name'` ==> {}\n\t * - ```js\n\t * user[firstName + `son of ${fatherName}`]\n\t * ``` ==> `{ user: { 'firstName:fatherName': undefined }, firstName: undefined, fatherName: undefined }`\n\t * @param parent \n\t */\n\tevents(): ExpressionEventMap;\n\n\n\t/**\n\t * re-write this expression as a javascript source \n\t */\n\ttoString(): string;\n\n\t/**\n\t * used to map this object to represent an [ESTree](https://github.com/estree/estree) json object\n\t * @param key \n\t */\n\ttoJSON(): NodeJsonType;\n\n\t/**\n\t * just a helper method to force class that implement this interface to\n\t * have a static method `fromJSON` to help reconstruct this ExpressionNode\n\t * from an [ESTree](https://github.com/estree/estree) json object,\n\t * with all necessary implementation to execute the code\n\t */\n\tgetClass(): ExpressionNodConstructor<ExpressionNode>;\n}\n\nexport type NodeDeserializer<N = ExpressionNode> = (node: N) => N;\n\nexport type VisitNodeType = (expression: ExpressionNode) => void;\n\n/**\n * this is how to:\n * describe a class with it's static functions and properties\n * in the interface add getClass method\n */\nexport interface ExpressionNodConstructor<N extends ExpressionNode> extends TypeOf<N> {\n\n\t/**\n\t * the type of an expression\n\t */\n\ttype: string;\n\n\t/**\n\t * build expression node from [ESTree](https://github.com/estree/estree) json object\n\t * @param node \n\t * @param deserializer \n\t */\n\tfromJSON(node: N, deserializer: NodeDeserializer): N;\n\n\t/**\n\t * visit nodes inside expression\n\t * @param expression \n\t * @param callback \n\t */\n\tvisit?(node: N, visitNode: Object): void;\n}\n\nexport interface DeclarationExpression extends ExpressionNode {\n\t/**\n\t * declare variable in the current local scope (block),\n\t * or closest function scope (global) scop,\n\t * the propertyName will be calculated at runtime\n\t * @param stack the stack which an identifier will be declared\n\t * @param propertyValue the initial value of identifier\n\t * @param scope which scop to declare this identifier\n\t */\n\tdeclareVariable(stack: Stack, propertyValue?: any): any;\n\n\t/**\n\t * get the variable declaration name\n\t */\n\tgetDeclarationName?(): string;\n}\n\n\n/**\n * An interface meant to be implemented by MemberExpression,\n * Identifier and ChainExpression and all Literal expressions\n */\nexport interface CanFindScope {\n\t/**\n\t * try to search for scope of this expression\n\t * @param stack \n\t */\n\tfindScope<T extends ScopeContext>(stack: Stack): Scope<T>;\n\tfindScope<T extends ScopeContext>(stack: Stack, scope: Scope<ScopeContext>): Scope<T>;\n\tfindScope<T extends ScopeContext>(stack: Stack, scope?: Scope<ScopeContext>): Scope<T> | undefined;\n}\n"]}
1
+ {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/expressions/api/expression.ts"],"names":[],"mappings":"","sourcesContent":["import type { Scope, Context } from '../scope/scope.js';\nimport type { Stack } from '../scope/stack.js';\nimport { TypeOf } from './utils.js';\n\nexport type NodeType = { type: string };\nexport type NodeJsonType = { [key: string]: any } & NodeType;\n\nexport type ExpressionEventPathDotNotation = { computed: false, path: string };\nexport type ExpressionEventPathBracketNotation = { computed: true, path: string, computedPath: ExpressionEventPath[][] };\nexport type ExpressionEventPath = ExpressionEventPathDotNotation | ExpressionEventPathBracketNotation;\nexport type ExpressionEventMap = { [key: string]: ExpressionEventMap };\n\nexport interface ExpressionNode {\n\n\t/**\n\t * pass scope list from outer function to inner function,\n\t * \n\t * all other end point expression should do nothing,\n\t * if this function executed.\n\t * \n\t * @param scopeList all outer function scopes given to the inner function,\n\t * this solution ignore the fact that some inner function has no need to\n\t * get shared variables, as its implementation never say that\n\t * ```js\n\t * function f(d) {\n\t * \t\tfunction g() {\n\t * \t\t\tconst a = ({ d }) => d;\n\t * \t\t\treturn a;\n\t * \t\t}\n\t * \t\treturn [d, g];\n\t * }\n\t * ```\n\t */\n\tshareVariables(scopeList: Scope<Context>[]): void;\n\n\t/**\n\t * assign the value to this expression in stack.\n\t * \n\t * most ExpressionNode will not implement this method, and will throw an exception.\n\t * @param stack \n\t * @param value \n\t */\n\tset(stack: Stack, value: any): any;\n\n\t/**\n\t * execute/get the code for this expression and return the result value.\n\t * @param stack \n\t * @param thisContext \n\t */\n\tget(stack: Stack, thisContext?: any): any;\n\n\t/**\n\t * get all dependencies form an expression node\n\t *\n\t * the return from this method, is represent an answer for what identifiers this expression depends-on.\n\t * \n\t *\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `[ node 'x', node 'y']`\n\t *\n\t * and:\n\t * - `x.y.z * a` ==> `[ member node `x.y.z`, identifier 'a']`\n\t * @param computed\n\t */\n\tdependency(computed?: true): ExpressionNode[];\n\n\t/**\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `['x', 'y']`\n\t *\n\t * and:\n\t * - `x.y.z` ==> `['x', 'y', 'z']`\n\t * - `x[y].z` ==> ['x', ]\n\t * @param computed required for member and chaining operators\n\t */\n\tdependencyPath(computed?: true): ExpressionEventPath[];\n\n\t/**\n\t * get all the events form this expression\n\t * \n\t * the return from this method, is represent an answer for what is this expression depends-on as identifier name\n\t * \n\t * ex: \n\t * ```js\n\t * x + y;\n\t * ```\n\t * \n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier: the answer should be `x`\n\t * - for `y` identifier: the answer should be `y`\n\t * the final output will be \n\t * \n\t * so, the return from `+` will be `{ x: undefined, y: undefined }`\n\t * \n\t * and:\n\t * - `x.y.z * a` ==> `{ x: { y: { z: undefined }, a: undefined } }`\n\t * - `x.y.z > x.y.h.g` ==> `{ x: { y: { z: undefined, h: { g: undefined} } } }`\n\t * - `x[Symbol.toStringTag] + 'Class' + classType + array[3]` ==> `{ x: { 'Symbol.toStringTag': undefined }, classType: undefined, array: { 3: undefined } }`\n\t * - `'name'` ==> {}\n\t * - ```js\n\t * user[firstName + `son of ${fatherName}`]\n\t * ``` ==> `{ user: { 'firstName:fatherName': undefined }, firstName: undefined, fatherName: undefined }`\n\t * @param parent \n\t */\n\tevents(): ExpressionEventMap;\n\n\n\t/**\n\t * re-write this expression as a javascript source \n\t */\n\ttoString(): string;\n\n\t/**\n\t * used to map this object to represent an [ESTree](https://github.com/estree/estree) json object\n\t * @param key \n\t */\n\ttoJSON(): NodeJsonType;\n\n\t/**\n\t * just a helper method to force class that implement this interface to\n\t * have a static method `fromJSON` to help reconstruct this ExpressionNode\n\t * from an [ESTree](https://github.com/estree/estree) json object,\n\t * with all necessary implementation to execute the code\n\t */\n\tgetClass(): ExpressionNodConstructor<ExpressionNode>;\n}\n\nexport type NodeDeserializer<N = ExpressionNode> = (node: N) => N;\n\nexport type VisitNodeType = (expression: ExpressionNode) => void;\n\n/**\n * this is how to:\n * describe a class with it's static functions and properties\n * in the interface add getClass method\n */\nexport interface ExpressionNodConstructor<N extends ExpressionNode> extends TypeOf<N> {\n\n\t/**\n\t * the type of an expression\n\t */\n\ttype: string;\n\n\t/**\n\t * build expression node from [ESTree](https://github.com/estree/estree) json object\n\t * @param node \n\t * @param deserializer \n\t */\n\tfromJSON(node: N, deserializer: NodeDeserializer): N;\n\n\t/**\n\t * visit nodes inside expression\n\t * @param expression \n\t * @param callback \n\t */\n\tvisit?(node: N, visitNode: Object): void;\n}\n\nexport interface DeclarationExpression extends ExpressionNode {\n\t/**\n\t * declare variable in the current local scope (block),\n\t * or closest function scope (global) scop,\n\t * the propertyName will be calculated at runtime\n\t * @param stack the stack which an identifier will be declared\n\t * @param propertyValue the initial value of identifier\n\t * @param scope which scop to declare this identifier\n\t */\n\tdeclareVariable(stack: Stack, propertyValue?: any): any;\n\n\t/**\n\t * get the variable declaration name\n\t */\n\tgetDeclarationName?(): string;\n}\n\n\n/**\n * An interface meant to be implemented by MemberExpression,\n * Identifier and ChainExpression and all Literal expressions\n */\nexport interface CanFindScope {\n\t/**\n\t * try to search for scope of this expression\n\t * @param stack \n\t */\n\tfindScope<V extends Context>(stack: Stack): Scope<V>;\n\tfindScope<V extends Context>(stack: Stack, scope: Scope<Record<PropertyKey, V>>): Scope<V>;\n\tfindScope<V extends Context>(stack: Stack, scope?: Scope<Record<PropertyKey, V>>): Scope<V> | undefined;\n}\n"]}
@@ -1,3 +1,36 @@
1
+ /**
2
+ * There are two types of exports:
3
+ * 1- Named Exports (Zero or more exports per module)
4
+ * 2- Default Exports (One per module)
5
+ *
6
+ * // Exporting individual features
7
+ * export let name1, name2, …, nameN; // also var, const
8
+ * export let name1 = …, name2 = …, …, nameN; // also var, const
9
+ * export function functionName(){...}
10
+ * export class ClassName {...}
11
+ *
12
+ * // Export list
13
+ * export { name1, name2, …, nameN };
14
+ *
15
+ * // Renaming exports
16
+ * export { variable1 as name1, variable2 as name2, …, nameN };
17
+ *
18
+ * // Exporting destructed assignments with renaming
19
+ * export const { name1, name2: bar } = o;
20
+ *
21
+ * // Default exports
22
+ * export default expression;
23
+ * export default function (…) { … } // also class, function*
24
+ * export default function name1(…) { … } // also class, function*
25
+ * export { name1 as default, … };
26
+ *
27
+ * // Aggregating modules
28
+ * export * from …; // does not set the default export
29
+ * export * as name1 from …; // Draft ECMAScript® 2O21
30
+ * export { name1, name2, …, nameN } from …;
31
+ * export { import1 as name1, import2 as name2, …, nameN } from …;
32
+ * export { default, … } from …;
33
+ */
1
34
  import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType, DeclarationExpression } from '../expression.js';
2
35
  import { Scope } from '../../scope/scope.js';
3
36
  import { Stack } from '../../scope/stack.js';
@@ -6,6 +39,20 @@ import { Identifier, Literal } from '../definition/values.js';
6
39
  import { ImportAttribute, ModuleSpecifier } from './common.js';
7
40
  import { FunctionDeclaration } from '../definition/function.js';
8
41
  import { ClassDeclaration } from '../class/class.js';
42
+ /**
43
+ * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.
44
+ *
45
+ * The `exported` field refers to the name exported in the module.
46
+ *
47
+ * The `local` field refers to the binding into the local module scope.
48
+ *
49
+ * If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes;
50
+ * in this case an Identifier node representing `foo`.
51
+ *
52
+ * If it is an aliased export,
53
+ * such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,
54
+ * and the `local` field is an `Identifier` node representing `bar`.
55
+ */
9
56
  export declare class ExportSpecifier extends ModuleSpecifier {
10
57
  private exported;
11
58
  static fromJSON(node: ExportSpecifier, deserializer: NodeDeserializer): ExportSpecifier;
@@ -20,6 +67,14 @@ export declare class ExportSpecifier extends ModuleSpecifier {
20
67
  toString(): string;
21
68
  toJson(): object;
22
69
  }
70
+ /**
71
+ * An export named declaration, e.g.,
72
+ * `export {foo, bar};`,
73
+ * `export {foo} from "mod";`
74
+ * or `export var foo = 1;`.
75
+ *
76
+ * Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.
77
+ */
23
78
  export declare class ExportNamedDeclaration extends AbstractExpressionNode {
24
79
  private specifiers;
25
80
  private declaration?;
@@ -43,6 +98,11 @@ export declare class ExportNamedDeclaration extends AbstractExpressionNode {
43
98
  toString(): string;
44
99
  toJson(): object;
45
100
  }
101
+ /**
102
+ * An export default declaration, e.g.,
103
+ * `export default function () {};`
104
+ * or `export default 1;`.
105
+ */
46
106
  export declare class ExportDefaultDeclaration extends AbstractExpressionNode {
47
107
  private declaration;
48
108
  static fromJSON(node: ExportDefaultDeclaration, deserializer: NodeDeserializer): ExportDefaultDeclaration;
@@ -57,6 +117,9 @@ export declare class ExportDefaultDeclaration extends AbstractExpressionNode {
57
117
  toString(): string;
58
118
  toJson(): object;
59
119
  }
120
+ /**
121
+ * An export batch declaration, e.g., `export * from "mod";`.
122
+ */
60
123
  export declare class ExportAllDeclaration extends AbstractExpressionNode {
61
124
  private source;
62
125
  private exported?;
@@ -1,3 +1,36 @@
1
+ /**
2
+ * There are two types of exports:
3
+ * 1- Named Exports (Zero or more exports per module)
4
+ * 2- Default Exports (One per module)
5
+ *
6
+ * // Exporting individual features
7
+ * export let name1, name2, …, nameN; // also var, const
8
+ * export let name1 = …, name2 = …, …, nameN; // also var, const
9
+ * export function functionName(){...}
10
+ * export class ClassName {...}
11
+ *
12
+ * // Export list
13
+ * export { name1, name2, …, nameN };
14
+ *
15
+ * // Renaming exports
16
+ * export { variable1 as name1, variable2 as name2, …, nameN };
17
+ *
18
+ * // Exporting destructed assignments with renaming
19
+ * export const { name1, name2: bar } = o;
20
+ *
21
+ * // Default exports
22
+ * export default expression;
23
+ * export default function (…) { … } // also class, function*
24
+ * export default function name1(…) { … } // also class, function*
25
+ * export { name1 as default, … };
26
+ *
27
+ * // Aggregating modules
28
+ * export * from …; // does not set the default export
29
+ * export * as name1 from …; // Draft ECMAScript® 2O21
30
+ * export { name1, name2, …, nameN } from …;
31
+ * export { import1 as name1, import2 as name2, …, nameN } from …;
32
+ * export { default, … } from …;
33
+ */
1
34
  var ExportSpecifier_1, ExportNamedDeclaration_1, ExportDefaultDeclaration_1, ExportAllDeclaration_1;
2
35
  import { __decorate, __metadata } from "tslib";
3
36
  import { ReactiveScope } from '../../scope/scope.js';
@@ -5,6 +38,20 @@ import { AbstractExpressionNode } from '../abstract.js';
5
38
  import { Deserializer } from '../deserialize/deserialize.js';
6
39
  import { Identifier, Literal } from '../definition/values.js';
7
40
  import { ModuleSpecifier } from './common.js';
41
+ /**
42
+ * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.
43
+ *
44
+ * The `exported` field refers to the name exported in the module.
45
+ *
46
+ * The `local` field refers to the binding into the local module scope.
47
+ *
48
+ * If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes;
49
+ * in this case an Identifier node representing `foo`.
50
+ *
51
+ * If it is an aliased export,
52
+ * such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,
53
+ * and the `local` field is an `Identifier` node representing `bar`.
54
+ */
8
55
  let ExportSpecifier = ExportSpecifier_1 = class ExportSpecifier extends ModuleSpecifier {
9
56
  constructor(local, exported) {
10
57
  super(local);
@@ -54,6 +101,14 @@ ExportSpecifier = ExportSpecifier_1 = __decorate([
54
101
  __metadata("design:paramtypes", [Identifier, Identifier])
55
102
  ], ExportSpecifier);
56
103
  export { ExportSpecifier };
104
+ /**
105
+ * An export named declaration, e.g.,
106
+ * `export {foo, bar};`,
107
+ * `export {foo} from "mod";`
108
+ * or `export var foo = 1;`.
109
+ *
110
+ * Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.
111
+ */
57
112
  let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclaration extends AbstractExpressionNode {
58
113
  constructor(specifiers, declaration, source, assertions) {
59
114
  super();
@@ -188,6 +243,11 @@ ExportNamedDeclaration = ExportNamedDeclaration_1 = __decorate([
188
243
  __metadata("design:paramtypes", [Array, Object, Literal, Array])
189
244
  ], ExportNamedDeclaration);
190
245
  export { ExportNamedDeclaration };
246
+ /**
247
+ * An export default declaration, e.g.,
248
+ * `export default function () {};`
249
+ * or `export default 1;`.
250
+ */
191
251
  let ExportDefaultDeclaration = ExportDefaultDeclaration_1 = class ExportDefaultDeclaration extends AbstractExpressionNode {
192
252
  constructor(declaration) {
193
253
  super();
@@ -231,6 +291,9 @@ ExportDefaultDeclaration = ExportDefaultDeclaration_1 = __decorate([
231
291
  __metadata("design:paramtypes", [Object])
232
292
  ], ExportDefaultDeclaration);
233
293
  export { ExportDefaultDeclaration };
294
+ /**
295
+ * An export batch declaration, e.g., `export * from "mod";`.
296
+ */
234
297
  let ExportAllDeclaration = ExportAllDeclaration_1 = class ExportAllDeclaration extends AbstractExpressionNode {
235
298
  constructor(source, exported, assertions) {
236
299
  super();
@@ -274,7 +337,7 @@ let ExportAllDeclaration = ExportAllDeclaration_1 = class ExportAllDeclaration e
274
337
  if (this.exported) {
275
338
  const exportedName = this.exported.get(stack);
276
339
  localModule.set(exportedName, {});
277
- localModule = localModule.getScope(exportedName);
340
+ localModule = localModule.getInnerScope(exportedName);
278
341
  }
279
342
  const properties = Object.keys(sourceModule.getContext());
280
343
  properties.forEach(property => {