@ibyar/expressions 0.6.1 → 0.8.3
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/README.md +7 -2
- package/api/abstract.d.ts +0 -3
- package/api/abstract.js +0 -4
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +85 -43
- package/api/class/class.js +232 -169
- package/api/class/class.js.map +1 -1
- package/api/class/decorator.d.ts +0 -2
- package/api/class/decorator.js +0 -3
- package/api/class/decorator.js.map +1 -1
- package/api/computing/call.d.ts +0 -2
- package/api/computing/call.js +0 -3
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +0 -2
- package/api/computing/debugger.js +0 -2
- package/api/computing/debugger.js.map +1 -1
- package/api/computing/new.d.ts +0 -2
- package/api/computing/new.js +0 -3
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +0 -2
- package/api/computing/rest.js +0 -3
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +0 -2
- package/api/computing/return.js +0 -3
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +0 -2
- package/api/computing/spread.js +0 -3
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +0 -4
- package/api/computing/throw.js +0 -5
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +0 -2
- package/api/computing/yield.js +0 -3
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +0 -3
- package/api/definition/array.js +0 -4
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +0 -1
- package/api/definition/bind.js +0 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/comment.d.ts +0 -2
- package/api/definition/comment.js +0 -1
- package/api/definition/comment.js.map +1 -1
- package/api/definition/function.d.ts +3 -11
- package/api/definition/function.js +33 -56
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +0 -1
- package/api/definition/member.js +1 -2
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +1 -5
- package/api/definition/object.js +2 -8
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +0 -2
- package/api/definition/statement.js +0 -3
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +6 -9
- package/api/definition/values.js +9 -20
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +0 -20
- package/api/expression.js.map +1 -1
- package/api/module/common.d.ts +1 -2
- package/api/module/common.js +3 -3
- package/api/module/common.js.map +1 -1
- package/api/module/export.d.ts +0 -5
- package/api/module/export.js +5 -9
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +2 -6
- package/api/module/import.js +4 -9
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +0 -2
- package/api/operators/await.js +0 -3
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +0 -1
- package/api/operators/chaining.js +0 -1
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +0 -2
- package/api/operators/comma.js +0 -3
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +0 -2
- package/api/operators/grouping.js +0 -3
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +1 -3
- package/api/operators/pipeline.js +0 -7
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +0 -2
- package/api/operators/ternary.js +0 -5
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +0 -2
- package/api/operators/unary.js +0 -3
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +0 -2
- package/api/operators/update.js +0 -3
- package/api/operators/update.js.map +1 -1
- package/api/program.d.ts +0 -2
- package/api/program.js +0 -1
- package/api/program.js.map +1 -1
- package/api/statement/control/block.d.ts +0 -2
- package/api/statement/control/block.js +3 -8
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +0 -2
- package/api/statement/control/empty.js +0 -1
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +0 -2
- package/api/statement/control/if.js +0 -5
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +0 -3
- package/api/statement/control/switch.js +0 -8
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +0 -3
- package/api/statement/control/terminate.js +0 -4
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +1 -4
- package/api/statement/declarations/declares.js +0 -6
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +1 -6
- package/api/statement/iterations/for.js +0 -18
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +0 -3
- package/api/statement/iterations/while.js +0 -8
- package/api/statement/iterations/while.js.map +1 -1
- package/package.json +3 -3
- package/scope/scope.d.ts +6 -22
- package/scope/scope.js +12 -59
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +15 -3
- package/scope/stack.js +26 -9
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +0 -7
- package/v8/enums.js +0 -15
- package/v8/enums.js.map +1 -1
- package/v8/index.d.ts +1 -0
- package/v8/index.js +1 -0
- package/v8/index.js.map +1 -1
- package/v8/inline.d.ts +5 -2
- package/v8/inline.js +31 -17
- package/v8/inline.js.map +1 -1
- package/v8/language.d.ts +7 -0
- package/v8/language.js +16 -0
- package/v8/language.js.map +1 -0
- package/v8/nodes.d.ts +1 -1
- package/v8/parser.d.ts +2 -1
- package/v8/parser.js +2 -1
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +1 -1
- package/v8/stream.js +1 -1
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +1 -1
- package/v8/token.js +1 -1
- package/v8/token.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for.js","sourceRoot":"","sources":["../../../../../src/expressions/api/stat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;IACD,QAAQ;QACP,OAAO,QAAQ,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC7F,CAAC;IACD,MAAM;QACL,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;SACxB,CAAC;IACH,CAAC;CACD,CAAA;AA/DY,cAAc;IAD1B,YAAY,CAAC,qBAAqB,CAAC;;GACvB,cAAc,CA+D1B;SA/DY,cAAc","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType\n} from '../../expression.js';\nimport type { Scope } from '../../../scope/scope.js';\nimport type { Stack } from '../../../scope/stack.js';\nimport { AbstractExpressionNode, ReturnValue } from '../../abstract.js';\nimport { Deserializer } from '../../deserialize/deserialize.js';\nimport { TerminateReturnType } from '../control/terminate.js';\nimport { VariableDeclarationNode } from '../declarations/declares.js';\nimport { ArrayPattern } from '../../definition/array.js';\nimport { ObjectPattern } from '../../definition/object.js';\n\n\n/**\n * The if statement executes a statement if a specified condition is truthy.\n * If the condition is falsy, another statement can be executed.\n * \n */\n@Deserializer('ForStatement')\nexport class ForNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForNode, deserializer: NodeDeserializer): ForNode {\n\t\treturn new ForNode(\n\t\t\tdeserializer(node.body),\n\t\t\tnode.init && deserializer(node.init),\n\t\t\tnode.test && deserializer(node.test),\n\t\t\tnode.update && deserializer(node.update)\n\t\t);\n\t}\n\tstatic visit(node: ForNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.body);\n\t\tnode.init && visitNode(node.init);\n\t\tnode.test && visitNode(node.test);\n\t\tnode.update && visitNode(node.update);\n\t}\n\tconstructor(\n\t\tprivate body: ExpressionNode,\n\t\tprivate init?: ExpressionNode,\n\t\tprivate test?: ExpressionNode,\n\t\tprivate update?: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tgetInit() {\n\t\treturn this.init;\n\t}\n\tgetTest() {\n\t\treturn this.test;\n\t}\n\tgetUpdate() {\n\t\treturn this.update;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.init?.shareVariables(scopeList);\n\t\tthis.test?.shareVariables(scopeList);\n\t\tthis.update?.shareVariables(scopeList);\n\t\tthis.body.shareVariables(scopeList);\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst forBlock = stack.pushBlockScope();\n\t\tfor (this.init?.get(stack); this.test?.get(stack) ?? true; this.update?.get(stack)) {\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(forBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tstack.clearTo(forBlock);\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\tlet dependency: ExpressionNode[] = this.body.dependency(computed);\n\t\tthis.init && (dependency = dependency.concat(this.init.dependency(computed)));\n\t\tthis.test && (dependency = dependency.concat(this.test.dependency(computed)));\n\t\tthis.update && (dependency = dependency.concat(this.update.dependency(computed)));\n\t\treturn dependency;\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tlet dependencyPath: ExpressionEventPath[] = this.body.dependencyPath(computed);\n\t\tthis.init && (dependencyPath = dependencyPath.concat(this.init.dependencyPath(computed)));\n\t\tthis.test && (dependencyPath = dependencyPath.concat(this.test.dependencyPath(computed)));\n\t\tthis.update && (dependencyPath = dependencyPath.concat(this.update.dependencyPath(computed)));\n\t\treturn dependencyPath;\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.init?.toString()};${this.test?.toString()};${this.init?.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tbody: this.body.toJSON(),\n\t\t\tinit: this.init?.toJSON(),\n\t\t\ttest: this.test?.toJSON(),\n\t\t\tupdate: this.update?.toJSON(),\n\t\t};\n\t}\n}\n\nexport type ForDeclaration = VariableDeclarationNode | ObjectPattern | ArrayPattern;\n\n@Deserializer('ForOfStatement')\nexport class ForOfNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForOfNode, deserializer: NodeDeserializer): ForOfNode {\n\t\treturn new ForOfNode(\n\t\t\tdeserializer(node.left) as ForDeclaration,\n\t\t\tdeserializer(node.right),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: ForOfNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tvisitNode(node.body);\n\t}\n\tconstructor(\n\t\tprivate left: ForDeclaration,\n\t\tprivate right: ExpressionNode,\n\t\tprivate body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.right.shareVariables(scopeList);\n\t\tthis.body.shareVariables(scopeList);\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForOfNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst iterable = <any[]>this.right.get(stack);\n\t\tfor (const iterator of iterable) {\n\t\t\tconst forBlock = stack.pushBlockScope();\n\t\t\tthis.left.declareVariable(stack, iterator);\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(forBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tstack.clearTo(forBlock);\n\t\t}\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed);\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.left?.toString()} of ${this.right.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\tbody: this.body.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('ForInStatement')\nexport class ForInNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForInNode, deserializer: NodeDeserializer): ForInNode {\n\t\treturn new ForInNode(\n\t\t\tdeserializer(node.left) as ForDeclaration,\n\t\t\tdeserializer(node.right),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: ForInNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tvisitNode(node.body);\n\t}\n\t// variable of iterable\n\tconstructor(\n\t\tprivate left: VariableDeclarationNode | ObjectPattern | ArrayPattern,\n\t\tprivate right: ExpressionNode,\n\t\tprivate body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.right.shareVariables(scopeList);\n\t\tthis.body.shareVariables(scopeList);\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForOfNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst iterable = <object>this.right.get(stack);\n\t\tfor (const iterator in iterable) {\n\t\t\tconst forBlock = stack.pushBlockScope();\n\t\t\tthis.left.declareVariable(stack, iterator);\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(forBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tstack.clearTo(forBlock);\n\t\t}\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed);\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.left.toString()} in ${this.right.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\tbody: this.body.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('ForAwaitOfStatement')\nexport class ForAwaitOfNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForAwaitOfNode, deserializer: NodeDeserializer): ForAwaitOfNode {\n\t\treturn new ForAwaitOfNode(\n\t\t\tdeserializer(node.left) as ForDeclaration,\n\t\t\tdeserializer(node.right),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: ForAwaitOfNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tvisitNode(node.body);\n\t}\n\t// variable of iterable\n\tconstructor(\n\t\tprivate left: ForDeclaration,\n\t\tprivate right: ExpressionNode,\n\t\tprivate body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.right.shareVariables(scopeList);\n\t\tthis.body.shareVariables(scopeList);\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForAwaitOfNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst iterable: AsyncIterable<any> = this.right.get(stack);\n\t\tconst forAwaitBody = (iterator: any): any => {\n\t\t\tconst forBlock = stack.pushBlockScope();\n\t\t\tthis.left.declareVariable(stack, iterator);\n\t\t\tconst result = this.body.get(stack);\n\t\t\tstack.clearTo(forBlock);\n\t\t\treturn result;\n\t\t};\n\t\tstack.forAwaitAsyncIterable = { iterable, forAwaitBody };\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed);\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.left?.toString()} of ${this.right.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\tbody: this.body.toJSON(),\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"for.js","sourceRoot":"","sources":["../../../../../src/expressions/api/statement/iterations/for.ts"],"names":[],"mappings":";;AAKA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAA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,CAAC,CAAC;YACxB,OAAO,MAAM,CAAC;QACf,CAAC,CAAC;QACF,KAAK,CAAC,qBAAqB,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAC1D,CAAC;IACD,UAAU,CAAC,QAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,cAAc,CAAC,QAAe;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACD,QAAQ;QACP,OAAO,QAAQ,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC7F,CAAC;IACD,MAAM;QACL,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;SACxB,CAAC;IACH,CAAC;CACD,CAAA;AA3DY,cAAc;IAD1B,YAAY,CAAC,qBAAqB,CAAC;;GACvB,cAAc,CA2D1B;SA3DY,cAAc","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType\n} from '../../expression.js';\nimport type { Stack } from '../../../scope/stack.js';\nimport { AbstractExpressionNode, ReturnValue } from '../../abstract.js';\nimport { Deserializer } from '../../deserialize/deserialize.js';\nimport { TerminateReturnType } from '../control/terminate.js';\nimport { VariableDeclarationNode } from '../declarations/declares.js';\nimport { ArrayPattern } from '../../definition/array.js';\nimport { ObjectPattern } from '../../definition/object.js';\n\n\n/**\n * The if statement executes a statement if a specified condition is truthy.\n * If the condition is falsy, another statement can be executed.\n * \n */\n@Deserializer('ForStatement')\nexport class ForNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForNode, deserializer: NodeDeserializer): ForNode {\n\t\treturn new ForNode(\n\t\t\tdeserializer(node.body),\n\t\t\tnode.init && deserializer(node.init),\n\t\t\tnode.test && deserializer(node.test),\n\t\t\tnode.update && deserializer(node.update)\n\t\t);\n\t}\n\tstatic visit(node: ForNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.body);\n\t\tnode.init && visitNode(node.init);\n\t\tnode.test && visitNode(node.test);\n\t\tnode.update && visitNode(node.update);\n\t}\n\tconstructor(\n\t\tprivate body: ExpressionNode,\n\t\tprivate init?: ExpressionNode,\n\t\tprivate test?: ExpressionNode,\n\t\tprivate update?: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tgetInit() {\n\t\treturn this.init;\n\t}\n\tgetTest() {\n\t\treturn this.test;\n\t}\n\tgetUpdate() {\n\t\treturn this.update;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst forBlock = stack.pushBlockScope();\n\t\tfor (this.init?.get(stack); this.test?.get(stack) ?? true; this.update?.get(stack)) {\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(forBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tstack.clearTo(forBlock);\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\tlet dependency: ExpressionNode[] = this.body.dependency(computed);\n\t\tthis.init && (dependency = dependency.concat(this.init.dependency(computed)));\n\t\tthis.test && (dependency = dependency.concat(this.test.dependency(computed)));\n\t\tthis.update && (dependency = dependency.concat(this.update.dependency(computed)));\n\t\treturn dependency;\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tlet dependencyPath: ExpressionEventPath[] = this.body.dependencyPath(computed);\n\t\tthis.init && (dependencyPath = dependencyPath.concat(this.init.dependencyPath(computed)));\n\t\tthis.test && (dependencyPath = dependencyPath.concat(this.test.dependencyPath(computed)));\n\t\tthis.update && (dependencyPath = dependencyPath.concat(this.update.dependencyPath(computed)));\n\t\treturn dependencyPath;\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.init?.toString()};${this.test?.toString()};${this.init?.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tbody: this.body.toJSON(),\n\t\t\tinit: this.init?.toJSON(),\n\t\t\ttest: this.test?.toJSON(),\n\t\t\tupdate: this.update?.toJSON(),\n\t\t};\n\t}\n}\n\nexport type ForDeclaration = VariableDeclarationNode | ObjectPattern | ArrayPattern;\n\n@Deserializer('ForOfStatement')\nexport class ForOfNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForOfNode, deserializer: NodeDeserializer): ForOfNode {\n\t\treturn new ForOfNode(\n\t\t\tdeserializer(node.left) as ForDeclaration,\n\t\t\tdeserializer(node.right),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: ForOfNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tvisitNode(node.body);\n\t}\n\tconstructor(\n\t\tprivate left: ForDeclaration,\n\t\tprivate right: ExpressionNode,\n\t\tprivate body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForOfNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst iterable = <any[]>this.right.get(stack);\n\t\tfor (const iterator of iterable) {\n\t\t\tconst forBlock = stack.pushBlockScope();\n\t\t\tthis.left.declareVariable(stack, iterator);\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(forBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tstack.clearTo(forBlock);\n\t\t}\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed);\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.left?.toString()} of ${this.right.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\tbody: this.body.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('ForInStatement')\nexport class ForInNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForInNode, deserializer: NodeDeserializer): ForInNode {\n\t\treturn new ForInNode(\n\t\t\tdeserializer(node.left) as ForDeclaration,\n\t\t\tdeserializer(node.right),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: ForInNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tvisitNode(node.body);\n\t}\n\t// variable of iterable\n\tconstructor(\n\t\tprivate left: VariableDeclarationNode | ObjectPattern | ArrayPattern,\n\t\tprivate right: ExpressionNode,\n\t\tprivate body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForOfNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst iterable = <object>this.right.get(stack);\n\t\tfor (const iterator in iterable) {\n\t\t\tconst forBlock = stack.pushBlockScope();\n\t\t\tthis.left.declareVariable(stack, iterator);\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(forBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tstack.clearTo(forBlock);\n\t\t}\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed);\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.left.toString()} in ${this.right.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\tbody: this.body.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('ForAwaitOfStatement')\nexport class ForAwaitOfNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ForAwaitOfNode, deserializer: NodeDeserializer): ForAwaitOfNode {\n\t\treturn new ForAwaitOfNode(\n\t\t\tdeserializer(node.left) as ForDeclaration,\n\t\t\tdeserializer(node.right),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: ForAwaitOfNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tvisitNode(node.body);\n\t}\n\t// variable of iterable\n\tconstructor(\n\t\tprivate left: ForDeclaration,\n\t\tprivate right: ExpressionNode,\n\t\tprivate body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ForAwaitOfNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst iterable: AsyncIterable<any> = this.right.get(stack);\n\t\tconst forAwaitBody = (iterator: any): any => {\n\t\t\tconst forBlock = stack.pushBlockScope();\n\t\t\tthis.left.declareVariable(stack, iterator);\n\t\t\tconst result = this.body.get(stack);\n\t\t\tstack.clearTo(forBlock);\n\t\t\treturn result;\n\t\t};\n\t\tstack.forAwaitAsyncIterable = { iterable, forAwaitBody };\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed);\n\t}\n\ttoString(): string {\n\t\treturn `for (${this.left?.toString()} of ${this.right.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\tbody: this.body.toJSON(),\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType } from '../../expression.js';
|
|
2
|
-
import type { Scope } from '../../../scope/scope.js';
|
|
3
2
|
import type { Stack } from '../../../scope/stack.js';
|
|
4
3
|
import { AbstractExpressionNode, ReturnValue } from '../../abstract.js';
|
|
5
4
|
/**
|
|
@@ -16,7 +15,6 @@ export declare class WhileNode extends AbstractExpressionNode {
|
|
|
16
15
|
constructor(test: ExpressionNode, body: ExpressionNode);
|
|
17
16
|
getTest(): ExpressionNode;
|
|
18
17
|
getBody(): ExpressionNode;
|
|
19
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
20
18
|
set(stack: Stack, value: any): void;
|
|
21
19
|
get(stack: Stack): ReturnValue | undefined;
|
|
22
20
|
dependency(computed?: true): ExpressionNode[];
|
|
@@ -32,7 +30,6 @@ export declare class DoWhileNode extends AbstractExpressionNode {
|
|
|
32
30
|
constructor(test: ExpressionNode, body: ExpressionNode);
|
|
33
31
|
getTest(): ExpressionNode;
|
|
34
32
|
getBody(): ExpressionNode;
|
|
35
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
36
33
|
set(stack: Stack, value: any): void;
|
|
37
34
|
get(stack: Stack): ReturnValue | undefined;
|
|
38
35
|
dependency(computed?: true): ExpressionNode[];
|
|
@@ -28,10 +28,6 @@ let WhileNode = WhileNode_1 = class WhileNode extends AbstractExpressionNode {
|
|
|
28
28
|
getBody() {
|
|
29
29
|
return this.body;
|
|
30
30
|
}
|
|
31
|
-
shareVariables(scopeList) {
|
|
32
|
-
this.test.shareVariables(scopeList);
|
|
33
|
-
this.body.shareVariables(scopeList);
|
|
34
|
-
}
|
|
35
31
|
set(stack, value) {
|
|
36
32
|
throw new Error(`WhileNode#set() has no implementation.`);
|
|
37
33
|
}
|
|
@@ -98,10 +94,6 @@ let DoWhileNode = DoWhileNode_1 = class DoWhileNode extends AbstractExpressionNo
|
|
|
98
94
|
getBody() {
|
|
99
95
|
return this.body;
|
|
100
96
|
}
|
|
101
|
-
shareVariables(scopeList) {
|
|
102
|
-
this.test.shareVariables(scopeList);
|
|
103
|
-
this.body.shareVariables(scopeList);
|
|
104
|
-
}
|
|
105
97
|
set(stack, value) {
|
|
106
98
|
throw new Error(`WhileNode#set() has no implementation.`);
|
|
107
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"while.js","sourceRoot":"","sources":["../../../../../src/expressions/api/statement/iterations/while.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"while.js","sourceRoot":"","sources":["../../../../../src/expressions/api/statement/iterations/while.ts"],"names":[],"mappings":";;AAKA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;;;;GAKG;AAEI,IAAM,SAAS,iBAAf,MAAM,SAAU,SAAQ,sBAAsB;IAWpD,YAAoB,IAAoB,EAAU,IAAoB;QACrE,KAAK,EAAE,CAAC;QADW,SAAI,GAAJ,IAAI,CAAgB;QAAU,SAAI,GAAJ,IAAI,CAAgB;IAEtE,CAAC;IAZD,MAAM,CAAC,QAAQ,CAAC,IAAe,EAAE,YAA8B;QAC9D,OAAO,IAAI,WAAS,CACnB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EACvB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CACvB,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,IAAe,EAAE,SAAwB;QACrD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAID,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,KAAU;QAC3B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC3D,CAAC;IACD,GAAG,CAAC,KAAY;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,SAAS,EAA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,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,CAAC;IACf,CAAC;IACD,UAAU,CAAC,QAAe;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,cAAc,CAAC,QAAe;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtF,CAAC;IACD,QAAQ;QACP,OAAO,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;IACvE,CAAC;IACD,MAAM;QACL,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;SACxB,CAAC;IACH,CAAC;CACD,CAAA;AA3DY,WAAW;IADvB,YAAY,CAAC,kBAAkB,CAAC;;GACpB,WAAW,CA2DvB;SA3DY,WAAW","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType\n} from '../../expression.js';\nimport type { Stack } from '../../../scope/stack.js';\nimport { AbstractExpressionNode, ReturnValue } from '../../abstract.js';\nimport { Deserializer } from '../../deserialize/deserialize.js';\nimport { TerminateReturnType } from '../control/terminate.js';\n\n/**\n * The while statement creates a loop that executes a specified\n * statement as long as the test condition evaluates to true.\n * The condition is evaluated before executing the statement.\n * \n */\n@Deserializer('WhileStatement')\nexport class WhileNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: WhileNode, deserializer: NodeDeserializer): WhileNode {\n\t\treturn new WhileNode(\n\t\t\tdeserializer(node.test),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: WhileNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.body);\n\t\tvisitNode(node.test);\n\t}\n\tconstructor(private test: ExpressionNode, private body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetTest() {\n\t\treturn this.test;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`WhileNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst condition = this.test.get(stack);\n\t\tconst whileBlock = stack.pushBlockScope();\n\t\twhile (condition) {\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(whileBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tstack.clearTo(whileBlock);\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.test.dependency(computed).concat(this.body.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.test.dependencyPath(computed).concat(this.body.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\treturn `while (${this.test.toString()}) ${this.body.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\ttest: this.test.toJSON(),\n\t\t\tbody: this.body.toJSON()\n\t\t};\n\t}\n}\n\n@Deserializer('DoWhileStatement')\nexport class DoWhileNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: DoWhileNode, deserializer: NodeDeserializer): DoWhileNode {\n\t\treturn new DoWhileNode(\n\t\t\tdeserializer(node.test),\n\t\t\tdeserializer(node.body)\n\t\t);\n\t}\n\tstatic visit(node: DoWhileNode, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.test);\n\t\tvisitNode(node.body);\n\t}\n\tconstructor(private test: ExpressionNode, private body: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetTest() {\n\t\treturn this.test;\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`WhileNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst whileBlock = stack.pushBlockScope();\n\t\tdo {\n\t\t\tconst result = this.body.get(stack);\n\t\t\t// useless case, as it at the end of for statement\n\t\t\t// an array/block statement, should return last signal\n\t\t\tif (result instanceof TerminateReturnType) {\n\t\t\t\tif (result.type === 'continue') {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result instanceof ReturnValue) {\n\t\t\t\tstack.clearTo(whileBlock);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t} while (this.test.get(stack));\n\t\tstack.clearTo(whileBlock);\n\t\treturn void 0;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.body.dependency(computed).concat(this.test.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.body.dependencyPath(computed).concat(this.test.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\treturn `do {${this.body.toString()}} while (${this.test.toString()})`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\ttest: this.test.toJSON(),\n\t\t\tbody: this.body.toJSON()\n\t\t};\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/expressions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Aurora expression, an template expression and evaluation, An 100% spec compliant ES2022 JavaScript toolchain,",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ibyar/aurora/tree/dev/packages/expressions",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"tslib": "^2.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"typescript": "^4.
|
|
30
|
+
"typescript": "^4.8.4"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc --build --verbose"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"backend",
|
|
52
52
|
"front-end"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9c3d7e7cf59692bd1cf6d8dfbada3f177ad53c7f"
|
|
55
55
|
}
|
package/scope/scope.d.ts
CHANGED
|
@@ -58,26 +58,6 @@ export declare class Scope<T extends Context> implements Scope<T> {
|
|
|
58
58
|
protected _inners: Map<keyof T, Scope<any>>;
|
|
59
59
|
constructor(context: T, propertyKeys?: (keyof T)[]);
|
|
60
60
|
}
|
|
61
|
-
/**
|
|
62
|
-
* a class scope used for class instance and private static properties
|
|
63
|
-
*/
|
|
64
|
-
export declare class ClassScope<T extends Context> extends Scope<T> {
|
|
65
|
-
private _pKeys?;
|
|
66
|
-
static for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]): ClassScope<T>;
|
|
67
|
-
static blockScope<T extends Context>(propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]): ClassScope<T>;
|
|
68
|
-
static readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]): ReadOnlyScope<{
|
|
69
|
-
this: T;
|
|
70
|
-
}>;
|
|
71
|
-
protected _private: Context;
|
|
72
|
-
constructor(context: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]);
|
|
73
|
-
getPrivateContext(): T;
|
|
74
|
-
get(key: keyof T): any;
|
|
75
|
-
set(key: keyof T, value: any, receiver?: any): boolean;
|
|
76
|
-
has(key: keyof T): boolean;
|
|
77
|
-
delete(key: keyof T): boolean;
|
|
78
|
-
protected isPrivateKey(key: keyof T): boolean;
|
|
79
|
-
getClass(): TypeOf<ReadOnlyScope<Context>>;
|
|
80
|
-
}
|
|
81
61
|
export declare class ReadOnlyScope<T extends Context> extends Scope<T> {
|
|
82
62
|
static for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): ReadOnlyScope<T>;
|
|
83
63
|
static blockScope<T extends Context>(propertyKeys?: (keyof T)[]): ReadOnlyScope<T>;
|
|
@@ -220,7 +200,11 @@ export declare class ModuleScope extends ReactiveScope<ModuleContext> {
|
|
|
220
200
|
importModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void;
|
|
221
201
|
}
|
|
222
202
|
export declare class WebModuleScope extends ModuleScope {
|
|
223
|
-
|
|
224
|
-
|
|
203
|
+
private source;
|
|
204
|
+
private importCallOptions?;
|
|
205
|
+
private import;
|
|
206
|
+
constructor(source: string, importCallOptions?: ImportCallOptions | undefined);
|
|
207
|
+
private updateContext;
|
|
208
|
+
resolveImport(): Promise<any>;
|
|
225
209
|
}
|
|
226
210
|
export {};
|
package/scope/scope.js
CHANGED
|
@@ -53,64 +53,6 @@ export class Scope {
|
|
|
53
53
|
return Scope;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
* a class scope used for class instance and private static properties
|
|
58
|
-
*/
|
|
59
|
-
export class ClassScope extends Scope {
|
|
60
|
-
constructor(context, propertyKeys, _pKeys) {
|
|
61
|
-
super(context, propertyKeys);
|
|
62
|
-
this._pKeys = _pKeys;
|
|
63
|
-
this._private = {};
|
|
64
|
-
}
|
|
65
|
-
static for(ctx, propertyKeys, privateKeys) {
|
|
66
|
-
return new ClassScope(ctx, propertyKeys, privateKeys);
|
|
67
|
-
}
|
|
68
|
-
static blockScope(propertyKeys, privateKeys) {
|
|
69
|
-
return new ClassScope({}, propertyKeys, privateKeys);
|
|
70
|
-
}
|
|
71
|
-
static readOnlyScopeForThis(ctx, propertyKeys, privateKeys) {
|
|
72
|
-
const thisScope = ClassScope.for(ctx, propertyKeys, privateKeys);
|
|
73
|
-
const thisCtx = {
|
|
74
|
-
'this': ctx,
|
|
75
|
-
};
|
|
76
|
-
const rootScope = ReadOnlyScope.for(thisCtx, ['this']);
|
|
77
|
-
rootScope.setInnerScope('this', thisScope);
|
|
78
|
-
return rootScope;
|
|
79
|
-
}
|
|
80
|
-
getPrivateContext() {
|
|
81
|
-
return this._private;
|
|
82
|
-
}
|
|
83
|
-
get(key) {
|
|
84
|
-
if (this.isPrivateKey(key)) {
|
|
85
|
-
return Reflect.get(this._private, key);
|
|
86
|
-
}
|
|
87
|
-
return super.get(key);
|
|
88
|
-
}
|
|
89
|
-
set(key, value, receiver) {
|
|
90
|
-
if (this.isPrivateKey(key)) {
|
|
91
|
-
return Reflect.set(this._private, key, value);
|
|
92
|
-
}
|
|
93
|
-
return super.set(key, value, receiver);
|
|
94
|
-
}
|
|
95
|
-
has(key) {
|
|
96
|
-
if (this.isPrivateKey(key)) {
|
|
97
|
-
return this._pKeys?.includes(key) ?? key in this._private;
|
|
98
|
-
}
|
|
99
|
-
return super.has(key);
|
|
100
|
-
}
|
|
101
|
-
delete(key) {
|
|
102
|
-
if (this.isPrivateKey(key)) {
|
|
103
|
-
return Reflect.deleteProperty(this._private, key);
|
|
104
|
-
}
|
|
105
|
-
return super.delete(key);
|
|
106
|
-
}
|
|
107
|
-
isPrivateKey(key) {
|
|
108
|
-
return typeof key === 'string' && key.startsWith('#');
|
|
109
|
-
}
|
|
110
|
-
getClass() {
|
|
111
|
-
return Scope;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
56
|
export class ReadOnlyScope extends Scope {
|
|
115
57
|
static for(ctx, propertyKeys) {
|
|
116
58
|
return new ReadOnlyScope(ctx, propertyKeys);
|
|
@@ -437,15 +379,26 @@ export class ModuleScope extends ReactiveScope {
|
|
|
437
379
|
super(context, propertyKeys);
|
|
438
380
|
}
|
|
439
381
|
importModule(propertyKey, scope) {
|
|
382
|
+
this._ctx[propertyKey] = scope._ctx;
|
|
440
383
|
this._inners.set(propertyKey, scope);
|
|
384
|
+
this.detectChanges();
|
|
441
385
|
}
|
|
442
386
|
}
|
|
443
387
|
export class WebModuleScope extends ModuleScope {
|
|
444
|
-
constructor() {
|
|
388
|
+
constructor(source, importCallOptions) {
|
|
445
389
|
super({});
|
|
390
|
+
this.source = source;
|
|
391
|
+
this.importCallOptions = importCallOptions;
|
|
392
|
+
this.import = import(source
|
|
393
|
+
/*, { assert: importCallOptions?.assert } */ // TODO: update in future, node16, ESNEXT,ES2022, ES2023, ES2024
|
|
394
|
+
).then(module => (this.updateContext(module))).then(() => this._ctx, () => this._ctx);
|
|
446
395
|
}
|
|
447
396
|
updateContext(context) {
|
|
448
397
|
this._ctx = context;
|
|
398
|
+
this.detectChanges();
|
|
399
|
+
}
|
|
400
|
+
resolveImport() {
|
|
401
|
+
return this.import;
|
|
449
402
|
}
|
|
450
403
|
}
|
|
451
404
|
//# sourceMappingURL=scope.js.map
|
package/scope/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/expressions/scope/scope.ts"],"names":[],"mappings":"AAgEA,MAAM,OAAO,KAAK;IAWjB,YAAsB,IAAO,EAAY,KAAmB;QAAtC,SAAI,GAAJ,IAAI,CAAG;QAAY,UAAK,GAAL,KAAK,CAAc;QAHlD,YAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAGa,CAAC;IAVjE,MAAM,CAAC,GAAG,CAAoB,GAAM,EAAE,YAA0B;QAC/D,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,CAAC,UAAU,CAAoB,YAA0B;QAC9D,OAAO,IAAI,KAAK,CAAC,EAAO,EAAE,YAAY,CAAC,CAAC;IACzC,CAAC;IAMD,GAAG,CAAC,GAAY;QACf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,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC9C;QACC,KAAK,CAAC,EAAmB,CAAC,CAAC;IAC5B,CAAC;IACD,aAAa,CAAC,OAAY;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;IACrB,CAAC;CACD","sourcesContent":["import { TypeOf } from '../api/utils.js';\n\nexport type Context = Record<PropertyKey, any>;\nexport interface Scope<T = Context> {\n\n\t/**\n\t * get value of `propertyKey` in current context\n\t * @param propertyKey \n\t */\n\tget(propertyKey: keyof T): any;\n\n\t/**\n\t * set the value of `propertyKey` in current context, could be instilled with `value`.\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: keyof T, value?: any, receiver?: any): boolean;\n\n\t/**\n\t * is current context has `propertyKey` in hash map keys\n\t * @param propertyKey \n\t */\n\thas(propertyKey: keyof T): boolean;\n\n\t/**\n\t * delete property from context\n\t * @param propertyKey \n\t */\n\tdelete(propertyKey: keyof T): boolean;\n\n\t/**\n\t * get current context object of this scope\n\t */\n\tgetContext(): T;\n\n\t/**\n\t * get a proxy of the current context object if exists. \n\t */\n\tgetContextProxy?(): T;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if the current value is not type od `object`, will return `undefined`.\n\t * @param propertyKey the name of the property\n\t */\n\tgetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S | undefined;\n\n\t/**\n\t * create a scope with the same type of this scope\n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S;\n\n\t/**\n\t * sc\n\t * @param propertyKey \n\t * @param scope \n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T, scope?: S): S;\n\n\tgetClass(): TypeOf<Scope<Context>>;\n}\n\nexport class Scope<T extends Context> implements Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope({} as T, propertyKeys);\n\t}\n\n\tprotected _inners = new Map<keyof T, Scope<any>>();\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[]);\n\tconstructor(protected _ctx: T, protected _keys?: (keyof T)[]) { }\n\tget(key: keyof T): any {\n\t\treturn Reflect.get(this._ctx, key);\n\t}\n\tset(key: keyof T, value: any, receiver?: any): boolean {\n\t\treturn Reflect.set(this._ctx, key, value);\n\t}\n\thas(key: keyof T): boolean {\n\t\treturn this._keys?.includes(key) ?? key in this._ctx;\n\t}\n\tdelete(key: keyof T): boolean {\n\t\treturn Reflect.deleteProperty(this._ctx, key);\n\t}\n\tgetContext(): T {\n\t\treturn this._ctx;\n\t}\n\tgetInnerScope<S extends Scope<Context>>(key: keyof T): S | undefined {\n\t\tconst ctx = this.get(key);\n\t\tlet scope = this._inners.get(key);\n\t\tif (scope) {\n\t\t\tscope._ctx = ctx;\n\t\t\treturn scope as S;\n\t\t}\n\t\tif (!(ctx && typeof ctx === 'object')) {\n\t\t\treturn;\n\t\t}\n\t\tscope = new (this.getClass())(ctx, undefined, key, this);\n\t\tthis._inners.set(key, scope);\n\t\treturn scope as S;\n\t}\n\tsetInnerScope<S extends Scope<Context>>(key: keyof T, scope?: S): S {\n\t\tif (scope) {\n\t\t\tthis._inners.set(key, scope);\n\t\t\treturn scope;\n\t\t}\n\t\tconst ctx = this.get(key);\n\t\tscope = new (this.getClass())(ctx, undefined, key, this) as S;\n\t\tthis._inners.set(key, scope);\n\t\treturn scope;\n\t}\n\tgetClass(): TypeOf<Scope<Context>> {\n\t\treturn Scope;\n\t}\n}\n\n/**\n * a class scope used for class instance and private static properties \n */\n\nexport class ClassScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]) {\n\t\treturn new ClassScope(ctx, propertyKeys, privateKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]) {\n\t\treturn new ClassScope({} as T, propertyKeys, privateKeys);\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]) {\n\t\tconst thisScope = ClassScope.for(ctx, propertyKeys, privateKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tprotected _private: Context = {};\n\tconstructor(context: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]);\n\tconstructor(context: T, propertyKeys?: (keyof T)[], private _pKeys?: (keyof T)[]) {\n\t\tsuper(context, propertyKeys);\n\t}\n\tgetPrivateContext(): T {\n\t\treturn this._private;\n\t}\n\tget(key: keyof T): any {\n\t\tif (this.isPrivateKey(key)) {\n\t\t\treturn Reflect.get(this._private, key);\n\t\t}\n\t\treturn super.get(key);\n\t}\n\tset(key: keyof T, value: any, receiver?: any): boolean {\n\t\tif (this.isPrivateKey(key)) {\n\t\t\treturn Reflect.set(this._private, key, value);\n\t\t}\n\t\treturn super.set(key, value, receiver);\n\t}\n\thas(key: keyof T): boolean {\n\t\tif (this.isPrivateKey(key)) {\n\t\t\treturn this._pKeys?.includes(key) ?? key in this._private;\n\t\t}\n\t\treturn super.has(key);\n\t}\n\tdelete(key: keyof T): boolean {\n\t\tif (this.isPrivateKey(key)) {\n\t\t\treturn Reflect.deleteProperty(this._private, key);\n\t\t}\n\t\treturn super.delete(key);\n\t}\n\tprotected isPrivateKey(key: keyof T) {\n\t\treturn typeof key === 'string' && key.startsWith('#');\n\t}\n\tgetClass(): TypeOf<ReadOnlyScope<Context>> {\n\t\treturn Scope;\n\t}\n}\n\nexport class ReadOnlyScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope({} as T, propertyKeys);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ReadOnlyScope<Context>> {\n\t\treturn ReadOnlyScope;\n\t}\n}\n\nexport class ScopeSubscription<T> {\n\tconstructor(private propertyKey: keyof T, private observer: ValueChangeObserver<T>) { }\n\tpause() {\n\t\tthis.observer.pause(this.propertyKey, this);\n\t}\n\tresume() {\n\t\tthis.observer.resume(this.propertyKey, this);\n\t}\n\tunsubscribe(): void {\n\t\tthis.observer.unsubscribe(this.propertyKey, this);\n\t}\n}\n\nexport type ValueChangedCallback = (newValue: any, oldValue?: any) => void;\n\ntype SubscriptionInfo = { callback: ValueChangedCallback, enable: boolean };\n\nexport class ValueChangeObserver<T> {\n\tprivate _subscribers: Map<keyof T, Map<ScopeSubscription<T>, SubscriptionInfo>> = new Map();\n\tprivate _lock: (keyof T)[] = [];\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._lock.includes(propertyKey)) {\n\t\t\treturn;\n\t\t}\n\t\tconst subscribers = this._subscribers.get(propertyKey);\n\t\tif (!subscribers || subscribers.size == 0) {\n\t\t\treturn;\n\t\t}\n\t\tthis._lock.push(propertyKey);\n\t\tsubscribers?.forEach(subscriptionInfo => {\n\t\t\tif (!subscriptionInfo.enable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsubscriptionInfo.callback(newValue, oldValue);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t}\n\t\t});\n\t\tif (this._lock.pop() !== propertyKey) {\n\t\t\tconsole.error('lock error');\n\t\t};\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst subscription: ScopeSubscription<T> = new ScopeSubscription(propertyKey, this);\n\t\tlet propertySubscribers = this._subscribers.get(propertyKey);\n\t\tif (!propertySubscribers) {\n\t\t\tpropertySubscribers = new Map();\n\t\t\tthis._subscribers.set(propertyKey, propertySubscribers);\n\t\t}\n\t\tpropertySubscribers.set(subscription, { callback, enable: true });\n\t\treturn subscription;\n\t}\n\n\tunsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (subscription) {\n\t\t\tthis._subscribers.get(propertyKey)?.delete(subscription);\n\t\t} else {\n\t\t\tthis._subscribers.delete(propertyKey);\n\t\t}\n\t}\n\n\tpause(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = false);\n\t}\n\n\tresume(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = true);\n\t}\n\n\t/**\n\t * check if this Observer has any subscribers\n\t */\n\thasSubscribers(): boolean;\n\n\t/**\n\t * check if there is any subscribers registered by the propertyKey.\n\t * \n\t * @param propertyKey\n\t */\n\thasSubscribers(propertyKey: keyof T): boolean;\n\thasSubscribers(propertyKey?: keyof T): boolean {\n\t\tif (propertyKey) {\n\t\t\treturn (this._subscribers.get(propertyKey)?.size ?? 0) > 0;\n\t\t}\n\t\treturn this._subscribers.size > 0;\n\t}\n\n\t/**\n\t * clear subscription maps\n\t */\n\tdestroy() {\n\t\tthis._subscribers.clear();\n\t}\n}\n\nexport class ReactiveScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tprotected _clone: T;\n\tdeclare protected _inners: Map<keyof T, ReactiveScope<any>>;\n\tprotected _observer: ValueChangeObserver<T> = new ValueChangeObserver<T>();\n\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[], protected _name?: keyof T, protected _parent?: ReactiveScope<any>) {\n\t\tsuper(context, propertyKeys);\n\t\tthis._clone = Object.assign({}, context);\n\t\tif (HTMLElement && context instanceof HTMLElement) {\n\t\t\tthis._keys = [];\n\t\t}\n\t}\n\n\tset(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst result = Reflect.set(this._ctx, propertyKey, newValue);\n\t\tif (result) {\n\t\t\tthis.emit(propertyKey, newValue, oldValue);\n\t\t}\n\t\treturn result;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst isDelete = Reflect.deleteProperty(this._ctx, propertyKey);\n\t\tif (isDelete && oldValue !== undefined) {\n\t\t\tthis.emit(propertyKey, undefined, oldValue);\n\t\t}\n\t\treturn isDelete;\n\t}\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tthis._observer.emit(propertyKey, newValue, oldValue);\n\t\tthis._parent?.emit(this._name!, this._ctx);\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\treturn this._observer.subscribe(propertyKey, callback);\n\t}\n\tunsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (propertyKey && subscription) {\n\t\t\tthis._observer.unsubscribe(propertyKey, subscription);\n\t\t} else if (propertyKey) {\n\t\t\tthis._observer.unsubscribe(propertyKey);\n\t\t} else {\n\t\t\tthis._observer.destroy();\n\t\t}\n\t}\n\tdetectChanges() {\n\t\tconst previous = this._clone;\n\t\tconst current = this._ctx;\n\t\tif ((!!!previous && !!current) || (!!previous && !!!current)) {\n\t\t\tthis._parent?.emit(this._name!, current);\n\t\t\treturn;\n\t\t}\n\t\tconst keys = this._keys ?? this.getPropertyKeys(previous, current);\n\t\tkeys.forEach(key => {\n\t\t\tconst pv = previous[key];\n\t\t\tconst cv = current[key];\n\t\t\tconst pt = typeof pv;\n\t\t\tconst ct = typeof cv;\n\t\t\tif (pt === 'object') {\n\t\t\t\tif (ct === 'object') {\n\t\t\t\t\tthis.getInnerScope<ReactiveScope<Context>>(key)?.detectChanges();\n\t\t\t\t} else if (cv != pv) {\n\t\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t\t}\n\t\t\t} else if (ct === 'object') {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t} else if (pv != cv) {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t}\n\t\t});\n\t\tthis._clone = Object.assign({}, this._ctx);\n\t}\n\tprotected getPropertyKeys<V extends Record<PropertyKey, any>>(...objs: V[]) {\n\t\tlet keys: (keyof V)[] = [];\n\t\tobjs.forEach(obj => {\n\t\t\tkeys.push(...Object.keys(obj));\n\t\t\tkeys.push(...Object.getOwnPropertySymbols(obj));\n\t\t});\n\t\tkeys = Array.from(new Set(keys));\n\t\tkeys = keys.filter(key => {\n\t\t\tswitch (typeof key) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn !key.startsWith('_');\n\t\t\t\tcase 'symbol':\n\t\t\t\t\treturn !key.toString().startsWith('Symbol(_');\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn keys;\n\t}\n\tgetClass(): TypeOf<ReactiveScope<Context>> {\n\t\treturn ReactiveScope;\n\t}\n}\n\n/**\n * used control/notify/pause scope about changes in current context\n */\nexport interface ScopeControl<T extends Context> {\n\n\t/**\n\t * get current stacte of applying change detection.\n\t */\n\tisAttached(): boolean;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t * \n\t * if a propertyKey is provided, will emit this property only \n\t * @param propertyKey \n\t */\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void;\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tcheckNoChanges(): void;\n}\n\nexport class ReactiveScopeControl<T extends Context> extends ReactiveScope<T> implements ScopeControl<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic reactiveScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\n\tprotected _attached: boolean = true;\n\tprotected _marked: { [key: keyof Context]: [any, any] } = {};\n\n\toverride emit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._attached) {\n\t\t\tsuper.emit(propertyKey, newValue, oldValue);\n\t\t} else if (this._marked[propertyKey as string]) {\n\t\t\tif (newValue == this._marked[propertyKey as string][1]) {\n\t\t\t\tdelete this._marked[propertyKey as string];\n\t\t\t} else {\n\t\t\t\tthis._marked[propertyKey as string][0] = newValue;\n\t\t\t}\n\t\t} else {\n\t\t\tthis._marked[propertyKey as string] = [newValue, oldValue];\n\t\t}\n\t}\n\tisAttached(): boolean {\n\t\treturn this._attached;\n\t}\n\tdetach(): void {\n\t\tthis._attached = false;\n\t}\n\treattach(): void {\n\t\tthis._attached = true;\n\t\tthis.emitChanges();\n\t}\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void {\n\t\tif (propertyKey) {\n\t\t\tsuper.emit(propertyKey, propertyValue);\n\t\t\tReflect.deleteProperty(this._marked, propertyKey);\n\t\t\treturn;\n\t\t}\n\t\tconst latestChanges = this._marked;\n\t\tthis._marked = {};\n\t\tconst keys = this._keys ?? this.getPropertyKeys(latestChanges);\n\t\tkeys.forEach(propertyKey => {\n\t\t\tthis._observer.emit(propertyKey, latestChanges[propertyKey][0], latestChanges[propertyKey][1]);\n\t\t});\n\t\tkeys.length && this._parent?.emit(this._name!, this._ctx);\n\t}\n\tdetectChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tthis.reattach();\n\t}\n\tcheckNoChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tconst keys = Object.keys(this._marked);\n\t\tif (keys.length > 0) {\n\t\t\tthrow new Error(`Some Changes had been detected`);\n\t\t}\n\t}\n\tgetClass(): TypeOf<ReactiveScopeControl<Context>> {\n\t\treturn ReactiveScopeControl;\n\t}\n}\n\n\ninterface ImportMeta {\n\turl: URL;\n\t/**\n\t *\n\t * Provides a module-relative resolution function scoped to each module, returning\n\t * the URL string.\n\t *\n\t * @param specified The module specifier to resolve relative to `parent`.\n\t * @param parent The absolute parent module URL to resolve from. If none\n\t * is specified, the value of `import.meta.url` is used as the default.\n\t */\n\tresolve?(specified: string, parent?: string | URL): Promise<string>;\n}\n\nexport interface ModuleImport {\n\tmeta: ImportMeta\n}\n\nexport interface ModuleContext extends Context {\n\timport: ModuleImport & ((path: string) => Promise<any>);\n}\n\nexport class ModuleScope extends ReactiveScope<ModuleContext> {\n\tconstructor(context: ModuleContext, propertyKeys?: (keyof ModuleContext)[]) {\n\t\tsuper(context, propertyKeys);\n\t}\n\timportModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void {\n\t\tthis._inners.set(propertyKey, scope);\n\t}\n}\nexport class WebModuleScope extends ModuleScope {\n\tconstructor() {\n\t\tsuper({} as ModuleContext);\n\t}\n\tupdateContext(context: any) {\n\t\tthis._ctx = context;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/expressions/scope/scope.ts"],"names":[],"mappings":"AAgEA,MAAM,OAAO,KAAK;IAWjB,YAAsB,IAAO,EAAY,KAAmB;QAAtC,SAAI,GAAJ,IAAI,CAAG;QAAY,UAAK,GAAL,KAAK,CAAc;QAHlD,YAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAGa,CAAC;IAVjE,MAAM,C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,EAAE,CAAC;IACtB,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { TypeOf } from '../api/utils.js';\n\nexport type Context = Record<PropertyKey, any>;\nexport interface Scope<T = Context> {\n\n\t/**\n\t * get value of `propertyKey` in current context\n\t * @param propertyKey \n\t */\n\tget(propertyKey: keyof T): any;\n\n\t/**\n\t * set the value of `propertyKey` in current context, could be instilled with `value`.\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: keyof T, value?: any, receiver?: any): boolean;\n\n\t/**\n\t * is current context has `propertyKey` in hash map keys\n\t * @param propertyKey \n\t */\n\thas(propertyKey: keyof T): boolean;\n\n\t/**\n\t * delete property from context\n\t * @param propertyKey \n\t */\n\tdelete(propertyKey: keyof T): boolean;\n\n\t/**\n\t * get current context object of this scope\n\t */\n\tgetContext(): T;\n\n\t/**\n\t * get a proxy of the current context object if exists. \n\t */\n\tgetContextProxy?(): T;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if the current value is not type od `object`, will return `undefined`.\n\t * @param propertyKey the name of the property\n\t */\n\tgetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S | undefined;\n\n\t/**\n\t * create a scope with the same type of this scope\n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S;\n\n\t/**\n\t * sc\n\t * @param propertyKey \n\t * @param scope \n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T, scope?: S): S;\n\n\tgetClass(): TypeOf<Scope<Context>>;\n}\n\nexport class Scope<T extends Context> implements Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope({} as T, propertyKeys);\n\t}\n\n\tprotected _inners = new Map<keyof T, Scope<any>>();\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[]);\n\tconstructor(protected _ctx: T, protected _keys?: (keyof T)[]) { }\n\tget(key: keyof T): any {\n\t\treturn Reflect.get(this._ctx, key);\n\t}\n\tset(key: keyof T, value: any, receiver?: any): boolean {\n\t\treturn Reflect.set(this._ctx, key, value);\n\t}\n\thas(key: keyof T): boolean {\n\t\treturn this._keys?.includes(key) ?? key in this._ctx;\n\t}\n\tdelete(key: keyof T): boolean {\n\t\treturn Reflect.deleteProperty(this._ctx, key);\n\t}\n\tgetContext(): T {\n\t\treturn this._ctx;\n\t}\n\tgetInnerScope<S extends Scope<Context>>(key: keyof T): S | undefined {\n\t\tconst ctx = this.get(key);\n\t\tlet scope = this._inners.get(key);\n\t\tif (scope) {\n\t\t\tscope._ctx = ctx;\n\t\t\treturn scope as S;\n\t\t}\n\t\tif (!(ctx && typeof ctx === 'object')) {\n\t\t\treturn;\n\t\t}\n\t\tscope = new (this.getClass())(ctx, undefined, key, this);\n\t\tthis._inners.set(key, scope);\n\t\treturn scope as S;\n\t}\n\tsetInnerScope<S extends Scope<Context>>(key: keyof T, scope?: S): S {\n\t\tif (scope) {\n\t\t\tthis._inners.set(key, scope);\n\t\t\treturn scope;\n\t\t}\n\t\tconst ctx = this.get(key);\n\t\tscope = new (this.getClass())(ctx, undefined, key, this) as S;\n\t\tthis._inners.set(key, scope);\n\t\treturn scope;\n\t}\n\tgetClass(): TypeOf<Scope<Context>> {\n\t\treturn Scope;\n\t}\n}\n\nexport class ReadOnlyScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope({} as T, propertyKeys);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ReadOnlyScope<Context>> {\n\t\treturn ReadOnlyScope;\n\t}\n}\n\nexport class ScopeSubscription<T> {\n\tconstructor(private propertyKey: keyof T, private observer: ValueChangeObserver<T>) { }\n\tpause() {\n\t\tthis.observer.pause(this.propertyKey, this);\n\t}\n\tresume() {\n\t\tthis.observer.resume(this.propertyKey, this);\n\t}\n\tunsubscribe(): void {\n\t\tthis.observer.unsubscribe(this.propertyKey, this);\n\t}\n}\n\nexport type ValueChangedCallback = (newValue: any, oldValue?: any) => void;\n\ntype SubscriptionInfo = { callback: ValueChangedCallback, enable: boolean };\n\nexport class ValueChangeObserver<T> {\n\tprivate _subscribers: Map<keyof T, Map<ScopeSubscription<T>, SubscriptionInfo>> = new Map();\n\tprivate _lock: (keyof T)[] = [];\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._lock.includes(propertyKey)) {\n\t\t\treturn;\n\t\t}\n\t\tconst subscribers = this._subscribers.get(propertyKey);\n\t\tif (!subscribers || subscribers.size == 0) {\n\t\t\treturn;\n\t\t}\n\t\tthis._lock.push(propertyKey);\n\t\tsubscribers?.forEach(subscriptionInfo => {\n\t\t\tif (!subscriptionInfo.enable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsubscriptionInfo.callback(newValue, oldValue);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t}\n\t\t});\n\t\tif (this._lock.pop() !== propertyKey) {\n\t\t\tconsole.error('lock error');\n\t\t};\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst subscription: ScopeSubscription<T> = new ScopeSubscription(propertyKey, this);\n\t\tlet propertySubscribers = this._subscribers.get(propertyKey);\n\t\tif (!propertySubscribers) {\n\t\t\tpropertySubscribers = new Map();\n\t\t\tthis._subscribers.set(propertyKey, propertySubscribers);\n\t\t}\n\t\tpropertySubscribers.set(subscription, { callback, enable: true });\n\t\treturn subscription;\n\t}\n\n\tunsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (subscription) {\n\t\t\tthis._subscribers.get(propertyKey)?.delete(subscription);\n\t\t} else {\n\t\t\tthis._subscribers.delete(propertyKey);\n\t\t}\n\t}\n\n\tpause(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = false);\n\t}\n\n\tresume(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = true);\n\t}\n\n\t/**\n\t * check if this Observer has any subscribers\n\t */\n\thasSubscribers(): boolean;\n\n\t/**\n\t * check if there is any subscribers registered by the propertyKey.\n\t * \n\t * @param propertyKey\n\t */\n\thasSubscribers(propertyKey: keyof T): boolean;\n\thasSubscribers(propertyKey?: keyof T): boolean {\n\t\tif (propertyKey) {\n\t\t\treturn (this._subscribers.get(propertyKey)?.size ?? 0) > 0;\n\t\t}\n\t\treturn this._subscribers.size > 0;\n\t}\n\n\t/**\n\t * clear subscription maps\n\t */\n\tdestroy() {\n\t\tthis._subscribers.clear();\n\t}\n}\n\nexport class ReactiveScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tprotected _clone: T;\n\tdeclare protected _inners: Map<keyof T, ReactiveScope<any>>;\n\tprotected _observer: ValueChangeObserver<T> = new ValueChangeObserver<T>();\n\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[], protected _name?: keyof T, protected _parent?: ReactiveScope<any>) {\n\t\tsuper(context, propertyKeys);\n\t\tthis._clone = Object.assign({}, context);\n\t\tif (HTMLElement && context instanceof HTMLElement) {\n\t\t\tthis._keys = [];\n\t\t}\n\t}\n\n\tset(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst result = Reflect.set(this._ctx, propertyKey, newValue);\n\t\tif (result) {\n\t\t\tthis.emit(propertyKey, newValue, oldValue);\n\t\t}\n\t\treturn result;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst isDelete = Reflect.deleteProperty(this._ctx, propertyKey);\n\t\tif (isDelete && oldValue !== undefined) {\n\t\t\tthis.emit(propertyKey, undefined, oldValue);\n\t\t}\n\t\treturn isDelete;\n\t}\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tthis._observer.emit(propertyKey, newValue, oldValue);\n\t\tthis._parent?.emit(this._name!, this._ctx);\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\treturn this._observer.subscribe(propertyKey, callback);\n\t}\n\tunsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (propertyKey && subscription) {\n\t\t\tthis._observer.unsubscribe(propertyKey, subscription);\n\t\t} else if (propertyKey) {\n\t\t\tthis._observer.unsubscribe(propertyKey);\n\t\t} else {\n\t\t\tthis._observer.destroy();\n\t\t}\n\t}\n\tdetectChanges() {\n\t\tconst previous = this._clone;\n\t\tconst current = this._ctx;\n\t\tif ((!!!previous && !!current) || (!!previous && !!!current)) {\n\t\t\tthis._parent?.emit(this._name!, current);\n\t\t\treturn;\n\t\t}\n\t\tconst keys = this._keys ?? this.getPropertyKeys(previous, current);\n\t\tkeys.forEach(key => {\n\t\t\tconst pv = previous[key];\n\t\t\tconst cv = current[key];\n\t\t\tconst pt = typeof pv;\n\t\t\tconst ct = typeof cv;\n\t\t\tif (pt === 'object') {\n\t\t\t\tif (ct === 'object') {\n\t\t\t\t\tthis.getInnerScope<ReactiveScope<Context>>(key)?.detectChanges();\n\t\t\t\t} else if (cv != pv) {\n\t\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t\t}\n\t\t\t} else if (ct === 'object') {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t} else if (pv != cv) {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t}\n\t\t});\n\t\tthis._clone = Object.assign({}, this._ctx);\n\t}\n\tprotected getPropertyKeys<V extends Record<PropertyKey, any>>(...objs: V[]) {\n\t\tlet keys: (keyof V)[] = [];\n\t\tobjs.forEach(obj => {\n\t\t\tkeys.push(...Object.keys(obj));\n\t\t\tkeys.push(...Object.getOwnPropertySymbols(obj));\n\t\t});\n\t\tkeys = Array.from(new Set(keys));\n\t\tkeys = keys.filter(key => {\n\t\t\tswitch (typeof key) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn !key.startsWith('_');\n\t\t\t\tcase 'symbol':\n\t\t\t\t\treturn !key.toString().startsWith('Symbol(_');\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn keys;\n\t}\n\tgetClass(): TypeOf<ReactiveScope<Context>> {\n\t\treturn ReactiveScope;\n\t}\n}\n\n/**\n * used control/notify/pause scope about changes in current context\n */\nexport interface ScopeControl<T extends Context> {\n\n\t/**\n\t * get current stacte of applying change detection.\n\t */\n\tisAttached(): boolean;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t * \n\t * if a propertyKey is provided, will emit this property only \n\t * @param propertyKey \n\t */\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void;\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tcheckNoChanges(): void;\n}\n\nexport class ReactiveScopeControl<T extends Context> extends ReactiveScope<T> implements ScopeControl<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic reactiveScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\n\tprotected _attached: boolean = true;\n\tprotected _marked: { [key: keyof Context]: [any, any] } = {};\n\n\toverride emit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._attached) {\n\t\t\tsuper.emit(propertyKey, newValue, oldValue);\n\t\t} else if (this._marked[propertyKey as string]) {\n\t\t\tif (newValue == this._marked[propertyKey as string][1]) {\n\t\t\t\tdelete this._marked[propertyKey as string];\n\t\t\t} else {\n\t\t\t\tthis._marked[propertyKey as string][0] = newValue;\n\t\t\t}\n\t\t} else {\n\t\t\tthis._marked[propertyKey as string] = [newValue, oldValue];\n\t\t}\n\t}\n\tisAttached(): boolean {\n\t\treturn this._attached;\n\t}\n\tdetach(): void {\n\t\tthis._attached = false;\n\t}\n\treattach(): void {\n\t\tthis._attached = true;\n\t\tthis.emitChanges();\n\t}\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void {\n\t\tif (propertyKey) {\n\t\t\tsuper.emit(propertyKey, propertyValue);\n\t\t\tReflect.deleteProperty(this._marked, propertyKey);\n\t\t\treturn;\n\t\t}\n\t\tconst latestChanges = this._marked;\n\t\tthis._marked = {};\n\t\tconst keys = this._keys ?? this.getPropertyKeys(latestChanges);\n\t\tkeys.forEach(propertyKey => {\n\t\t\tthis._observer.emit(propertyKey, latestChanges[propertyKey][0], latestChanges[propertyKey][1]);\n\t\t});\n\t\tkeys.length && this._parent?.emit(this._name!, this._ctx);\n\t}\n\tdetectChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tthis.reattach();\n\t}\n\tcheckNoChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tconst keys = Object.keys(this._marked);\n\t\tif (keys.length > 0) {\n\t\t\tthrow new Error(`Some Changes had been detected`);\n\t\t}\n\t}\n\tgetClass(): TypeOf<ReactiveScopeControl<Context>> {\n\t\treturn ReactiveScopeControl;\n\t}\n}\n\n\ninterface ImportMeta {\n\turl: URL;\n\t/**\n\t *\n\t * Provides a module-relative resolution function scoped to each module, returning\n\t * the URL string.\n\t *\n\t * @param specified The module specifier to resolve relative to `parent`.\n\t * @param parent The absolute parent module URL to resolve from. If none\n\t * is specified, the value of `import.meta.url` is used as the default.\n\t */\n\tresolve?(specified: string, parent?: string | URL): Promise<string>;\n}\n\nexport interface ModuleImport {\n\tmeta: ImportMeta\n}\n\nexport interface ModuleContext extends Context {\n\timport: ModuleImport & ((path: string) => Promise<any>);\n}\n\nexport class ModuleScope extends ReactiveScope<ModuleContext> {\n\tconstructor(context: ModuleContext, propertyKeys?: (keyof ModuleContext)[]) {\n\t\tsuper(context, propertyKeys);\n\t}\n\timportModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void {\n\t\tthis._ctx[propertyKey] = scope._ctx;\n\t\tthis._inners.set(propertyKey, scope);\n\t\tthis.detectChanges();\n\t}\n}\nexport class WebModuleScope extends ModuleScope {\n\n\t// private loaded = false;\n\tprivate import: Promise<any>;\n\tconstructor(private source: string, private importCallOptions?: ImportCallOptions) {\n\t\tsuper({} as ModuleContext);\n\t\tthis.import = import(\n\t\t\tsource\n\t\t\t/*, { assert: importCallOptions?.assert } */ // TODO: update in future, node16, ESNEXT,ES2022, ES2023, ES2024\n\t\t).then(module => (this.updateContext(module))).then(() => this._ctx, () => this._ctx);\n\t}\n\tprivate updateContext(context: any) {\n\t\tthis._ctx = context;\n\t\tthis.detectChanges();\n\t}\n\n\tresolveImport() {\n\t\treturn this.import;\n\t}\n}\n"]}
|
package/scope/stack.d.ts
CHANGED
|
@@ -122,6 +122,8 @@ export declare class Stack implements Stack {
|
|
|
122
122
|
constructor(globalScope: Scope<Context>, resolver: ModuleScopeResolver, moduleSource: string);
|
|
123
123
|
constructor(stack: Array<Scope<Context>>);
|
|
124
124
|
constructor(stack: Array<Scope<Context>>, resolver: ModuleScopeResolver, moduleSource: string);
|
|
125
|
+
constructor(stack: Stack);
|
|
126
|
+
constructor(stack: Stack, resolver: ModuleScopeResolver, moduleSource: string);
|
|
125
127
|
private initModuleContext;
|
|
126
128
|
detectChanges(): void;
|
|
127
129
|
private getReactiveScopeControls;
|
|
@@ -134,15 +136,25 @@ export interface ModuleScopeResolver {
|
|
|
134
136
|
export declare function createRootURL(source: string): URL;
|
|
135
137
|
export interface ResolverConfig {
|
|
136
138
|
/**
|
|
137
|
-
*
|
|
139
|
+
* allow import modules from external http(s) module
|
|
138
140
|
*/
|
|
139
141
|
allowImportExternal?: boolean;
|
|
140
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* file system provider
|
|
145
|
+
*/
|
|
146
|
+
export interface ModuleSourceProvider {
|
|
147
|
+
[url: string]: string;
|
|
148
|
+
}
|
|
141
149
|
export declare class ModuleScopeResolver implements ModuleScopeResolver {
|
|
150
|
+
protected globalStack: Stack;
|
|
151
|
+
protected provider: ModuleSourceProvider;
|
|
142
152
|
protected config?: ResolverConfig | undefined;
|
|
143
153
|
protected modules: [string, ModuleScope][];
|
|
144
|
-
constructor(config?: ResolverConfig | undefined);
|
|
145
|
-
register
|
|
154
|
+
constructor(globalStack: Stack, provider: ModuleSourceProvider, config?: ResolverConfig | undefined);
|
|
155
|
+
private register;
|
|
156
|
+
resolve(source: keyof ModuleSourceProvider): ModuleScope;
|
|
157
|
+
resolve(source: keyof ModuleSourceProvider, moduleScope: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope;
|
|
146
158
|
protected findScopeBySource(source: string, importCallOptions?: ImportCallOptions): ModuleScope;
|
|
147
159
|
protected findSourceByScope(moduleScope: ModuleScope): string;
|
|
148
160
|
protected resolveExternalModule(source: string, importCallOptions?: ImportCallOptions): WebModuleScope;
|
package/scope/stack.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LanguageMode } from '../v8/language.js';
|
|
2
|
+
import { JavaScriptParser } from '../v8/parser.js';
|
|
1
3
|
import { finalizerRegister } from './finalizer.js';
|
|
2
4
|
import { ModuleScope, ReactiveScope, ReactiveScopeControl, Scope, WebModuleScope } from './scope.js';
|
|
3
5
|
export class Stack {
|
|
@@ -5,7 +7,10 @@ export class Stack {
|
|
|
5
7
|
this.awaitPromise = [];
|
|
6
8
|
this.onDestroyActions = [];
|
|
7
9
|
if (Array.isArray(globals)) {
|
|
8
|
-
this.stack = globals;
|
|
10
|
+
this.stack = globals.slice();
|
|
11
|
+
}
|
|
12
|
+
else if (globals instanceof Stack) {
|
|
13
|
+
this.stack = globals.stack.slice();
|
|
9
14
|
}
|
|
10
15
|
else if (typeof globals == 'object') {
|
|
11
16
|
this.stack = [globals];
|
|
@@ -45,7 +50,11 @@ export class Stack {
|
|
|
45
50
|
}
|
|
46
51
|
initModuleContext() {
|
|
47
52
|
const importFunc = (path) => {
|
|
48
|
-
|
|
53
|
+
const module = this.importModule(path);
|
|
54
|
+
if (module instanceof WebModuleScope) {
|
|
55
|
+
return module.resolveImport();
|
|
56
|
+
}
|
|
57
|
+
return Promise.resolve(module.getContext());
|
|
49
58
|
};
|
|
50
59
|
importFunc.meta = {
|
|
51
60
|
url: createRootURL(this.moduleSource),
|
|
@@ -168,7 +177,9 @@ export function createRootURL(source) {
|
|
|
168
177
|
}
|
|
169
178
|
;
|
|
170
179
|
export class ModuleScopeResolver {
|
|
171
|
-
constructor(config) {
|
|
180
|
+
constructor(globalStack, provider, config) {
|
|
181
|
+
this.globalStack = globalStack;
|
|
182
|
+
this.provider = provider;
|
|
172
183
|
this.config = config;
|
|
173
184
|
this.modules = [];
|
|
174
185
|
this.isValidHTTPUrl = (string) => {
|
|
@@ -217,6 +228,17 @@ export class ModuleScopeResolver {
|
|
|
217
228
|
}
|
|
218
229
|
const importedScope = this.modules.find(tuple => tuple[0] == source)?.[1];
|
|
219
230
|
if (!importedScope) {
|
|
231
|
+
// search in the file system provider
|
|
232
|
+
const javascriptSource = this.provider[source];
|
|
233
|
+
if (javascriptSource || javascriptSource == '') {
|
|
234
|
+
// module exists
|
|
235
|
+
const moduleProgram = JavaScriptParser.parse(javascriptSource, { mode: LanguageMode.Strict });
|
|
236
|
+
const stack = new Stack(this.globalStack, this, source);
|
|
237
|
+
// register with absoluteUrl
|
|
238
|
+
this.register(source, stack.getModule());
|
|
239
|
+
moduleProgram.get(stack);
|
|
240
|
+
return stack.getModule();
|
|
241
|
+
}
|
|
220
242
|
throw new Error(`Can't find module scope`);
|
|
221
243
|
}
|
|
222
244
|
return importedScope;
|
|
@@ -232,13 +254,8 @@ export class ModuleScopeResolver {
|
|
|
232
254
|
if (!this.config?.allowImportExternal) {
|
|
233
255
|
throw new Error(`Error: Import External Module is not allowed.`);
|
|
234
256
|
}
|
|
235
|
-
const webScope = new WebModuleScope();
|
|
257
|
+
const webScope = new WebModuleScope(source, importCallOptions);
|
|
236
258
|
this.modules.push([source, webScope]);
|
|
237
|
-
// active later
|
|
238
|
-
// import(source, importCallOptions)
|
|
239
|
-
import(source).then(module => {
|
|
240
|
-
webScope.updateContext(module);
|
|
241
|
-
});
|
|
242
259
|
return webScope;
|
|
243
260
|
}
|
|
244
261
|
}
|