@ibyar/core 0.5.0 → 0.5.4
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/binding/binding.expressions.d.ts +3 -2
- package/binding/binding.expressions.js +45 -29
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.js +8 -8
- package/component/component.js.map +1 -1
- package/component/provider.d.ts +5 -10
- package/component/provider.js +6 -31
- package/component/provider.js.map +1 -1
- package/context/stack.js +1 -1
- package/context/stack.js.map +1 -1
- package/context/subscription.d.ts +2 -0
- package/context/subscription.js +14 -0
- package/context/subscription.js.map +1 -0
- package/directive/directive.d.ts +7 -1
- package/directive/directive.js +7 -1
- package/directive/directive.js.map +1 -1
- package/directive/parser.d.ts +1 -1
- package/directive/parser.js +13 -10
- package/directive/parser.js.map +1 -1
- package/directive/providers.d.ts +2 -0
- package/directive/providers.js +4 -1
- package/directive/providers.js.map +1 -1
- package/html/expression.js +5 -4
- package/html/expression.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/linker/change-detector-ref.d.ts +7 -0
- package/linker/change-detector-ref.js +32 -0
- package/linker/change-detector-ref.js.map +1 -0
- package/linker/template-ref.d.ts +5 -1
- package/linker/template-ref.js +13 -15
- package/linker/template-ref.js.map +1 -1
- package/linker/view-container-ref.d.ts +12 -10
- package/linker/view-container-ref.js +7 -7
- package/linker/view-container-ref.js.map +1 -1
- package/linker/view-ref.d.ts +4 -2
- package/linker/view-ref.js +9 -6
- package/linker/view-ref.js.map +1 -1
- package/package.json +6 -6
- package/pipe/pipe.d.ts +18 -8
- package/pipe/pipe.js +30 -15
- package/pipe/pipe.js.map +1 -1
- package/providers/provider.d.ts +1 -1
- package/providers/provider.js +2 -0
- package/providers/provider.js.map +1 -1
- package/render/host-listener.handler.d.ts +26 -0
- package/render/host-listener.handler.js +69 -0
- package/render/host-listener.handler.js.map +1 -0
- package/render/render-handler.d.ts +5 -0
- package/render/render-handler.js +2 -0
- package/render/render-handler.js.map +1 -0
- package/view/base-view.js +11 -22
- package/view/base-view.js.map +1 -1
- package/view/render.d.ts +16 -20
- package/view/render.js +84 -103
- package/view/render.js.map +1 -1
- package/view/view.js +6 -0
- package/view/view.js.map +1 -1
package/directive/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;;AACX,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrC,mBAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,oBAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC3C,sBAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAG7C,MAAM,OAAO,yBAAyB;IAiBrC,YAAsB,aAAqB,EAAY,MAAmB;QAApD,kBAAa,GAAb,aAAa,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAa;QAHhE,wBAAmB,GAAG,IAAI,KAAK,EAAqB,CAAC;QACrD,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEwB,CAAC;IAdxE,MAAM,CAAC,KAAK,CAAC,aAAqB,EAAE,UAAkB;QAC5D,MAAM,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAI,yBAAyB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACpE,IAAI;YACH,MAAM,CAAC,IAAI,EAAE,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M,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAc,CAAC,OAAO,EAAY,CAAC;QACxE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SAC9B;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET);\n\tstatic COMMA = new TokenExpression(Token.COMMA);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let' if found, or switch to expression mode.\n\t\tif (this.isLet()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isLet(): boolean {\n\t\treturn this.stream.peek().isType(Token.LET);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isLet()) {\n\t\t\tconst list: TokenExpression[] = [];\n\t\t\tthis.consumeToList(Token.LET, list);\n\t\t\tconst peek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.L_PARENTHESES)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;;AACX,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrC,mBAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,oBAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC3C,sBAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAG7C,MAAM,OAAO,yBAAyB;IAiBrC,YAAsB,aAAqB,EAAY,MAAmB;QAApD,kBAAa,GAAb,aAAa,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAa;QAHhE,wBAAmB,GAAG,IAAI,KAAK,EAAqB,CAAC;QACrD,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEwB,CAAC;IAdxE,MAAM,CAAC,KAAK,CAAC,aAAqB,EAAE,UAAkB;QAC5D,MAAM,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAI,yBAAyB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACpE,IAAI;YACH,MAAM,CAAC,IAAI,EAAE,CAAC;SACd;QAAC,OAAO,KAAK,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,UAAU,EAAE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AC,gBAAgB,EAAE,CAAC;YAIxB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,SAAS,GAAsB,EAAE,CAAC;YACxC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;YACnG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACzC;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAc,CAAC,OAAO,EAAY,CAAC;QACxE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SAC9B;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET);\n\tstatic COMMA = new TokenExpression(Token.COMMA);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tpeek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.L_PARENTHESES)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
|
package/directive/providers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactiveScope } from '@ibyar/expressions';
|
|
2
|
+
import { TypeOf } from '@ibyar/expressions/api/utils';
|
|
2
3
|
import { AttributeDirective } from './directive.js';
|
|
3
4
|
export declare type ElementContext = {
|
|
4
5
|
this: HTMLElement;
|
|
@@ -14,4 +15,5 @@ export declare class ElementReactiveScope extends ReactiveScope<ElementContext>
|
|
|
14
15
|
get(propertyKey: PropertyKey): any;
|
|
15
16
|
set(propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
|
16
17
|
has(propertyKey: string): boolean;
|
|
18
|
+
getClass(): TypeOf<ElementReactiveScope>;
|
|
17
19
|
}
|
package/directive/providers.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ClassRegistryProvider } from '../providers/provider.js';
|
|
|
4
4
|
import { AttributeDirective } from './directive.js';
|
|
5
5
|
export class ElementReactiveScope extends ReactiveScope {
|
|
6
6
|
constructor(el) {
|
|
7
|
-
super({}
|
|
7
|
+
super({});
|
|
8
8
|
this.el = el;
|
|
9
9
|
this.directiveMap = new Map();
|
|
10
10
|
this.context.this = el;
|
|
@@ -85,5 +85,8 @@ export class ElementReactiveScope extends ReactiveScope {
|
|
|
85
85
|
}
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
88
|
+
getClass() {
|
|
89
|
+
return ElementReactiveScope;
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
92
|
//# sourceMappingURL=providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,oBAAqB,SAAQ,aAA6B;IAEtE,YAAoB,EAAe;QAClC,KAAK,CAAC,EAAoB,CAAC,CAAC;QADT,OAAE,GAAF,EAAE,CAAa;QAD3B,iBAAY,GAAoC,IAAI,GAAG,EAAE,CAAC;QAGjE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;IACxB,CAAC;IACD,UAAU;QACT,OAAO,IAAI,CAAC,EAAE,CAAC;IAChB,CAAC;IACD,aAAa;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,WAAwB;QAC3B,IAAI,WAAW,KAAK,MAAM,EAAE;YAC3B,OAAO,IAAI,CAAC,EAAE,CAAC;SACf;QACD,IAAI,IAAI,CAAC,YAA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AAI,CAAC;SACZ;QACD,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { ReactiveScope, ScopeContext } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis.context.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis.context[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this.context) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (ClassRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (ClassRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
|
package/html/expression.js
CHANGED
|
@@ -10,7 +10,7 @@ function parseLiveText(text) {
|
|
|
10
10
|
text.pipelineNames = getPipelineNames(textExpression);
|
|
11
11
|
}
|
|
12
12
|
function convertToMemberAccessStyle(source) {
|
|
13
|
-
const dashSplits = source.split('-');
|
|
13
|
+
const dashSplits = Array.isArray(source) ? source : source.split('-');
|
|
14
14
|
if (dashSplits.length === 1) {
|
|
15
15
|
return source;
|
|
16
16
|
}
|
|
@@ -91,11 +91,11 @@ function parseChild(child) {
|
|
|
91
91
|
if (!ref?.inputs?.length) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
child.inputs
|
|
94
|
+
child.inputs ?? (child.inputs = []);
|
|
95
95
|
info.directiveInputs.forEach((expression, input) => {
|
|
96
96
|
const modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;
|
|
97
97
|
const attr = createLiveAttribute(modelName, expression);
|
|
98
|
-
(child.inputs
|
|
98
|
+
(child.inputs ?? (child.inputs = [])).push(attr);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -116,7 +116,8 @@ function searchForLetAttributes(child, expressions) {
|
|
|
116
116
|
const templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));
|
|
117
117
|
templateExpressionsFromInput?.forEach(attr => {
|
|
118
118
|
child.attributes.splice(child.attributes.indexOf(attr), 1);
|
|
119
|
-
const
|
|
119
|
+
const attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));
|
|
120
|
+
const expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;
|
|
120
121
|
expressions.push(JavaScriptParser.parse(expression));
|
|
121
122
|
});
|
|
122
123
|
}
|
package/html/expression.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,mBAAmB,EAC7B,0BAA0B,EAAE,cAAc,EAC1C,eAAe,EACf,iBAAiB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACU,iBAAiB,EAAE,UAAU,EAC7C,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,oBA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AAC,IAAI,CAAC,CAAC;KACjB;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport {\n\tExpressionNode, expressionVisitor, Identifier,\n\tJavaScriptParser, MemberExpression, PipelineExpression\n} from '@ibyar/expressions';\nimport {\n\tBindingAssignment,\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\n\ndeclare module '@ibyar/elements' {\n\texport interface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\texport interface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\texport interface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\texport interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {\n\t\t/**\n\t\t * create a new scope for a template and bind the new variables to the directive scope.\n\t\t * \n\t\t * execution for let-i=\"index\".\n\t\t */\n\t\ttemplateExpressions: ExpressionNode[];\n\t}\n\n\texport interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\n\nconst ThisTextContent = JavaScriptParser.parse('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parse(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction convertToMemberAccessStyle(source: string) {\n\tconst dashSplits = source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parse(elementSource);\n\tconst modelExpression = JavaScriptParser.parse(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nfunction getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parse(elementSource);\n\tconst modelExpression = JavaScriptParser.parse(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name} is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parse(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tlet expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(JavaScriptParser.parse));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = ClassRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst expression = `let ${attr.name.replace('let-', '')} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parse(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,mBAAmB,EAC7B,0BAA0B,EAAE,cAAc,EAC1C,eAAe,EACf,iBAAiB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACU,iBAAiB,EAAE,UAAU,EAC7C,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AA8BjE,MAAM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AAU,CAAC,IAAI,CAAC,CAAC;KACjB;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport {\n\tExpressionNode, expressionVisitor, Identifier,\n\tJavaScriptParser, MemberExpression, PipelineExpression\n} from '@ibyar/expressions';\nimport {\n\tBindingAssignment,\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\n\ndeclare module '@ibyar/elements' {\n\texport interface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\texport interface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\texport interface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\texport interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {\n\t\t/**\n\t\t * create a new scope for a template and bind the new variables to the directive scope.\n\t\t * \n\t\t * execution for let-i=\"index\".\n\t\t */\n\t\ttemplateExpressions: ExpressionNode[];\n\t}\n\n\texport interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\n\nconst ThisTextContent = JavaScriptParser.parse('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parse(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction convertToMemberAccessStyle(source: string | string[]) {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parse(elementSource);\n\tconst modelExpression = JavaScriptParser.parse(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nfunction getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parse(elementSource);\n\tconst modelExpression = JavaScriptParser.parse(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name} is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parse(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tlet expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(JavaScriptParser.parse));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = ClassRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parse(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n"]}
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './providers/injector.js';
|
|
|
14
14
|
export * from './providers/provider.js';
|
|
15
15
|
export * from './utils/elements-util.js';
|
|
16
16
|
export * from './utils/path.js';
|
|
17
|
+
export * from './utils/typeof.js';
|
|
17
18
|
export * from './utils/utils.js';
|
|
18
19
|
export * from './view/mutation.js';
|
|
19
20
|
export * from './view/render.js';
|
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './providers/injector.js';
|
|
|
14
14
|
export * from './providers/provider.js';
|
|
15
15
|
export * from './utils/elements-util.js';
|
|
16
16
|
export * from './utils/path.js';
|
|
17
|
+
export * from './utils/typeof.js';
|
|
17
18
|
export * from './utils/utils.js';
|
|
18
19
|
export * from './view/mutation.js';
|
|
19
20
|
export * from './view/render.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\n\nexport * from './directive/directive.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/view.js';\n\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\n\nexport * from './directive/directive.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/view.js';\n\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactiveScopeControl, ScopeContext } from '@ibyar/expressions';
|
|
2
|
+
export declare abstract class ChangeDetectorRef {
|
|
3
|
+
abstract detach(): void;
|
|
4
|
+
abstract reattach(): void;
|
|
5
|
+
abstract markForCheck(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey: keyof ScopeContext): ChangeDetectorRef;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class ChangeDetectorRef {
|
|
2
|
+
}
|
|
3
|
+
class ChangeDetectorRefImpl extends ChangeDetectorRef {
|
|
4
|
+
constructor(changeDetectorRef) {
|
|
5
|
+
super();
|
|
6
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
7
|
+
}
|
|
8
|
+
detach() {
|
|
9
|
+
this.changeDetectorRef.detach();
|
|
10
|
+
}
|
|
11
|
+
reattach() {
|
|
12
|
+
this.changeDetectorRef.reattach();
|
|
13
|
+
}
|
|
14
|
+
markForCheck() {
|
|
15
|
+
this.changeDetectorRef.markForCheck();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function createChangeDetectorRef(scope, propertyKey) {
|
|
19
|
+
const changeDetectorRef = {
|
|
20
|
+
detach() {
|
|
21
|
+
scope.detach();
|
|
22
|
+
},
|
|
23
|
+
reattach() {
|
|
24
|
+
scope.reattach();
|
|
25
|
+
},
|
|
26
|
+
markForCheck() {
|
|
27
|
+
scope.emitChanges(propertyKey, scope.get(propertyKey));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return new ChangeDetectorRefImpl(changeDetectorRef);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=change-detector-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-detector-ref.js","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,iBAAiB;CAkBtC;AAED,MAAM,qBAAsB,SAAQ,iBAAiB;IACpD,YAAoB,iBAAoC;QAAI,KAAK,EAAE,CAAC;QAAhD,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAa,CAAC;IACtE,MAAM;QACL,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IACD,QAAQ;QACP,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IACD,YAAY;QACX,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;CACD;AAKD,MAAM,UAAU,uBAAuB,CAAC,KAAyC,EAAE,WAA+B;IACjH,MAAM,iBAAiB,GAAsB;QAC5C,MAAM;YACL,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;QACD,QAAQ;YACP,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;QACD,YAAY;YACX,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,CAAC;KACD,CAAC;IACF,OAAO,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { ReactiveScopeControl, ScopeContext } from '@ibyar/expressions';\n\nexport abstract class ChangeDetectorRef {\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\tabstract detach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\tabstract reattach(): 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\tabstract markForCheck(): void;\n}\n\nclass ChangeDetectorRefImpl extends ChangeDetectorRef {\n\tconstructor(private changeDetectorRef: ChangeDetectorRef) { super(); }\n\tdetach(): void {\n\t\tthis.changeDetectorRef.detach();\n\t}\n\treattach(): void {\n\t\tthis.changeDetectorRef.reattach();\n\t}\n\tmarkForCheck(): void {\n\t\tthis.changeDetectorRef.markForCheck();\n\t}\n}\n\n/**\n * create a change Detector Reference by property key.\n */\nexport function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey: keyof ScopeContext): ChangeDetectorRef {\n\tconst changeDetectorRef: ChangeDetectorRef = {\n\t\tdetach() {\n\t\t\tscope.detach();\n\t\t},\n\t\treattach() {\n\t\t\tscope.reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tscope.emitChanges(propertyKey, scope.get(propertyKey));\n\t\t}\n\t};\n\treturn new ChangeDetectorRefImpl(changeDetectorRef);\n}\n"]}
|
package/linker/template-ref.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DomNode } from '@ibyar/elements';
|
|
2
2
|
import { ExpressionNode, Stack } from '@ibyar/expressions';
|
|
3
|
+
import { HTMLComponent } from '../component/custom-element.js';
|
|
4
|
+
import { StructuralDirective } from '../directive/directive.js';
|
|
3
5
|
import { ComponentRender } from '../view/render.js';
|
|
4
6
|
import { EmbeddedViewRef } from './view-ref.js';
|
|
5
7
|
export declare abstract class TemplateRef {
|
|
@@ -11,8 +13,10 @@ export declare class TemplateRefImpl extends TemplateRef {
|
|
|
11
13
|
private node;
|
|
12
14
|
private stack;
|
|
13
15
|
private templateExpressions;
|
|
16
|
+
private _host;
|
|
14
17
|
constructor(render: ComponentRender<any>, node: DomNode, stack: Stack, templateExpressions: ExpressionNode[]);
|
|
15
18
|
get astNode(): DomNode;
|
|
19
|
+
set host(host: HTMLComponent<any> | StructuralDirective);
|
|
16
20
|
createEmbeddedView<C extends object>(context: C, parentNode: Node): EmbeddedViewRef<C>;
|
|
17
21
|
private executeTemplateExpressions;
|
|
18
22
|
}
|
package/linker/template-ref.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createProxyForContext, Stack } from '@ibyar/expressions';
|
|
2
|
-
import { findReactiveScopeByEventMap } from '@ibyar/expressions';
|
|
1
|
+
import { createProxyForContext, findReactiveScopeByEventMap, Stack } from '@ibyar/expressions';
|
|
3
2
|
import { EmbeddedViewRefImpl } from './view-ref.js';
|
|
4
3
|
export class TemplateRef {
|
|
5
4
|
}
|
|
@@ -14,24 +13,23 @@ export class TemplateRefImpl extends TemplateRef {
|
|
|
14
13
|
get astNode() {
|
|
15
14
|
return this.node;
|
|
16
15
|
}
|
|
16
|
+
set host(host) {
|
|
17
|
+
this._host = host;
|
|
18
|
+
}
|
|
17
19
|
createEmbeddedView(context, parentNode) {
|
|
18
20
|
const directiveStack = this.stack.copyStack();
|
|
19
|
-
const templateScope = directiveStack.
|
|
21
|
+
const templateScope = directiveStack.pushReactiveScope();
|
|
20
22
|
const sandBox = new Stack();
|
|
21
|
-
const contextScope = sandBox.
|
|
23
|
+
const contextScope = sandBox.pushReactiveScopeFor(context ?? {});
|
|
22
24
|
sandBox.pushScope(templateScope);
|
|
23
25
|
const elements = [];
|
|
24
26
|
const contextProxy = createProxyForContext(contextScope);
|
|
25
|
-
const
|
|
27
|
+
const subscriptions = [];
|
|
28
|
+
const embeddedViewRef = new EmbeddedViewRefImpl(contextProxy, elements, subscriptions);
|
|
26
29
|
const scopeSubscriptions = this.executeTemplateExpressions(sandBox);
|
|
27
|
-
|
|
28
|
-
const subscription = embeddedViewRef.onDestroy(() => {
|
|
29
|
-
subscription.unsubscribe();
|
|
30
|
-
scopeSubscriptions.forEach(sub => sub.unsubscribe());
|
|
31
|
-
});
|
|
32
|
-
}
|
|
30
|
+
scopeSubscriptions && subscriptions.push(...scopeSubscriptions);
|
|
33
31
|
const fragment = document.createDocumentFragment();
|
|
34
|
-
this.render.appendChildToParent(fragment, this.node, directiveStack, parentNode);
|
|
32
|
+
this.render.appendChildToParent(fragment, this.node, directiveStack, parentNode, subscriptions, this._host);
|
|
35
33
|
fragment.childNodes.forEach(item => elements.push(item));
|
|
36
34
|
return embeddedViewRef;
|
|
37
35
|
}
|
|
@@ -45,9 +43,9 @@ export class TemplateRefImpl extends TemplateRef {
|
|
|
45
43
|
const scopeSubscriptions = [];
|
|
46
44
|
this.templateExpressions.forEach(expression => {
|
|
47
45
|
const events = expression.events();
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const subscription =
|
|
46
|
+
const scopeTuples = findReactiveScopeByEventMap(events, sandBox);
|
|
47
|
+
scopeTuples.forEach(tuple => {
|
|
48
|
+
const subscription = tuple[1].subscribe(tuple[0], () => {
|
|
51
49
|
expression.get(sandBox);
|
|
52
50
|
});
|
|
53
51
|
scopeSubscriptions.push(subscription);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EACR,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAgB,WAAW;CAiBhC;AAGD,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAG/C,YACS,MAA4B,EAC5B,IAAa,EACb,KAAY,EACZ,mBAAqC;QAE7C,KAAK,EAAE,CAAC;QALA,WAAM,GAAN,MAAM,CAAsB;QAC5B,SAAI,GAAJ,IAAI,CAAS;QACb,UAAK,GAAL,KAAK,CAAO;QACZ,wBAAmB,GAAnB,mBAAmB,CAAkB;IAG9C,CAAC;IACD,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,IAAI,IAAI,CAAC,IAA8C;QACtD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,kBAAkB,CAAmB,OAAU,EAAE,UAAgB;QAChE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,MAAM,aAAa,GAAG,cAAc,CAAC,iBAAiB,EAAE,CAAC;QAEzD,MAAM,OAAO,GAAG,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACjE,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAEjC,MAAM,QAAQ,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AY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;oBACtD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC,CAAC,CAAC;gBACH,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,kBAAkB,CAAC;IAC3B,CAAC;CACD","sourcesContent":["import { DomNode, htmlParser } from '@ibyar/elements';\nimport {\n\tcreateProxyForContext, ExpressionNode,\n\tfindReactiveScopeByEventMap, ScopeContext,\n\tScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { StructuralDirective } from '../directive/directive.js';\nimport { ComponentRender } from '../view/render.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl } from './view-ref.js';\n\nexport abstract class TemplateRef {\n\n\t/**\n\t * get the current ref of this template\n\t */\n\tabstract get astNode(): DomNode;\n\n\t/**\n\t * Instantiates an embedded view based on this template,\n\t * `Not attached to the view`.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<template>` usage.\n\t * \n\t * To insert it to a view need to use a `ViewContainerRef.createEmbeddedView()`\n\t * @returns The new embedded view object.\n\t */\n\tabstract createEmbeddedView<C extends object>(context: C, parentNode: Node): EmbeddedViewRef<C>;\n}\n\n\nexport class TemplateRefImpl extends TemplateRef {\n\tprivate _host: HTMLComponent<any> | StructuralDirective;\n\n\tconstructor(\n\t\tprivate render: ComponentRender<any>,\n\t\tprivate node: DomNode,\n\t\tprivate stack: Stack,\n\t\tprivate templateExpressions: ExpressionNode[],\n\t) {\n\t\tsuper();\n\t}\n\tget astNode(): DomNode {\n\t\treturn this.node;\n\t}\n\tset host(host: HTMLComponent<any> | StructuralDirective) {\n\t\tthis._host = host;\n\t}\n\tcreateEmbeddedView<C extends object>(context: C, parentNode: Node): EmbeddedViewRef<C> {\n\t\tconst directiveStack = this.stack.copyStack();\n\n\t\tconst templateScope = directiveStack.pushReactiveScope();\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = sandBox.pushReactiveScopeFor(context ?? {});\n\t\tsandBox.pushScope(templateScope);\n\n\t\tconst elements: Node[] = [];\n\t\tconst contextProxy = createProxyForContext(contextScope);\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tconst embeddedViewRef = new EmbeddedViewRefImpl(contextProxy, elements, subscriptions);\n\t\tconst scopeSubscriptions = this.executeTemplateExpressions(sandBox);\n\t\tscopeSubscriptions && subscriptions.push(...scopeSubscriptions);\n\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis.render.appendChildToParent(fragment, this.node, directiveStack, parentNode, subscriptions, this._host);\n\n\t\tfragment.childNodes.forEach(item => elements.push(item));\n\t\treturn embeddedViewRef;\n\t}\n\tprivate executeTemplateExpressions(sandBox: Stack): ScopeSubscription<ScopeContext>[] | undefined {\n\t\tif (!this.templateExpressions?.length) {\n\t\t\treturn;\n\t\t}\n\t\t// init value\n\t\tthis.templateExpressions.forEach(expression => {\n\t\t\texpression.get(sandBox);\n\t\t});\n\n\t\t// subscribe to changes\n\t\tconst scopeSubscriptions: ScopeSubscription<object>[] = [];\n\t\tthis.templateExpressions.forEach(expression => {\n\t\t\tconst events = expression.events();\n\t\t\tconst scopeTuples = findReactiveScopeByEventMap(events, sandBox);\n\t\t\tscopeTuples.forEach(tuple => {\n\t\t\t\tconst subscription = tuple[1].subscribe(tuple[0], () => {\n\t\t\t\t\texpression.get(sandBox);\n\t\t\t\t});\n\t\t\t\tscopeSubscriptions.push(subscription);\n\t\t\t});\n\t\t});\n\t\treturn scopeSubscriptions;\n\t}\n}\n"]}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type { TypeOf } from '../utils/typeof.js';
|
|
2
2
|
import { TemplateRef } from './template-ref.js';
|
|
3
3
|
import { EmbeddedViewRef, ViewRef } from './view-ref.js';
|
|
4
|
+
export declare type ViewContainerOptions<C> = {
|
|
5
|
+
index?: number;
|
|
6
|
+
context?: C;
|
|
7
|
+
};
|
|
8
|
+
export declare type ViewContainerComponentOptions = {
|
|
9
|
+
index?: number | undefined;
|
|
10
|
+
selector?: string;
|
|
11
|
+
};
|
|
4
12
|
export declare abstract class ViewContainerRef {
|
|
5
13
|
abstract get anchorElement(): Element;
|
|
6
14
|
abstract clear(): void;
|
|
7
15
|
abstract get(index: number): ViewRef | undefined;
|
|
8
16
|
abstract get length(): number;
|
|
9
|
-
abstract createEmbeddedView<C extends
|
|
10
|
-
abstract createComponent<C extends
|
|
11
|
-
index?: number;
|
|
12
|
-
selector?: string;
|
|
13
|
-
}): C;
|
|
17
|
+
abstract createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
|
|
18
|
+
abstract createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
|
|
14
19
|
abstract insert(viewRef: ViewRef, index?: number): ViewRef;
|
|
15
20
|
abstract move(viewRef: ViewRef, newIndex: number): ViewRef;
|
|
16
21
|
abstract indexOf(viewRef: ViewRef): number;
|
|
@@ -31,9 +36,6 @@ export declare class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
31
36
|
remove(index?: number): void;
|
|
32
37
|
insert(viewRef: EmbeddedViewRef<any>, index?: number): ViewRef;
|
|
33
38
|
move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef;
|
|
34
|
-
createEmbeddedView<C extends
|
|
35
|
-
createComponent<C extends
|
|
36
|
-
index?: number | undefined;
|
|
37
|
-
selector?: string;
|
|
38
|
-
}): C;
|
|
39
|
+
createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
|
|
40
|
+
createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
|
|
39
41
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Components } from '../component/component.js';
|
|
2
2
|
import { EmbeddedViewRefImpl } from './view-ref.js';
|
|
3
|
-
import { getComponentView } from '../
|
|
3
|
+
import { getComponentView } from '../view/view.js';
|
|
4
4
|
export class ViewContainerRef {
|
|
5
5
|
}
|
|
6
6
|
export class ViewContainerRefImpl extends ViewContainerRef {
|
|
@@ -31,7 +31,7 @@ export class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
31
31
|
return this.views[index];
|
|
32
32
|
}
|
|
33
33
|
detach(index) {
|
|
34
|
-
index
|
|
34
|
+
index ?? (index = this.views.length - 1);
|
|
35
35
|
const viewRef = this.views[index];
|
|
36
36
|
viewRef.detach();
|
|
37
37
|
this.views.splice(index, 1);
|
|
@@ -41,12 +41,12 @@ export class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
41
41
|
return this.views.indexOf(viewRef);
|
|
42
42
|
}
|
|
43
43
|
remove(index) {
|
|
44
|
-
index
|
|
44
|
+
index ?? (index = this.views.length - 1);
|
|
45
45
|
this.views[index].destroy();
|
|
46
46
|
this.views.splice(index, 1);
|
|
47
47
|
}
|
|
48
48
|
insert(viewRef, index) {
|
|
49
|
-
index = ((index
|
|
49
|
+
index = ((index ?? (index = this.views.length)) > this.views.length) ? this.views.length : index;
|
|
50
50
|
const lastNode = index == 0 ? this.firstComment : this.views[index - 1].last;
|
|
51
51
|
this.views.splice(index, 0, viewRef);
|
|
52
52
|
viewRef.after(lastNode);
|
|
@@ -62,9 +62,9 @@ export class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
62
62
|
}
|
|
63
63
|
return this.insert(viewRef, newIndex);
|
|
64
64
|
}
|
|
65
|
-
createEmbeddedView(templateRef,
|
|
66
|
-
const viewRef = templateRef.createEmbeddedView(context || {}, this.parent);
|
|
67
|
-
this.insert(viewRef, index);
|
|
65
|
+
createEmbeddedView(templateRef, options) {
|
|
66
|
+
const viewRef = templateRef.createEmbeddedView(options?.context || {}, this.parent);
|
|
67
|
+
this.insert(viewRef, options?.index);
|
|
68
68
|
return viewRef;
|
|
69
69
|
}
|
|
70
70
|
createComponent(componentType, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-container-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAmB,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAgB,gBAAgB;CAwGrC;AAGD,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAIzD,YACS,MAAe,EACf,YAAqB;QAE7B,KAAK,EAAE,CAAC;QAHA,WAAM,GAAN,MAAM,CAAS;QACf,iBAAY,GAAZ,YAAY,CAAS;QAJtB,UAAK,GAA2B,EAAE,CAAC;IAO3C,CAAC;IACD,IAAa,aAAa;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,IAAa,MAAM;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IACQ,KAAK;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;aACd;YACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACrB;IACF,CAAC;IACQ,GAAG,CAAC,KAAa;QACzB,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC/B,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACQ,MAAM,CAAC,KAAc;QAC7B,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG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C,OAAO,CAAC,CAAC;QACvC,IAAI,QAAQ,GAAG,CAAC,CAAC,EAAE;YAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACtB;aAAM;YAEN,OAAO,CAAC,MAAM,EAAE,CAAC;SACjB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACQ,kBAAkB,CAAmB,WAAwB,EAAE,OAAW,EAAE,KAAc;QAClG,MAAM,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAI,OAAO,IAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACjF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,OAAO,CAAC;IAChB,CAAC;IACQ,eAAe,CAAmB,aAAwB,EAAE,OAA4D;QAChI,MAAM,cAAc,GAAG,UAAU,CAAC,eAAe,CAAI,aAAa,CAAC,CAAC,QAAQ,CAAC;QAC7E,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,IAAI,cAAc,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;SAC7E;QACD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAI,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC,WAAW,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { Components } from '../component/component.js';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../index.js';\n\nexport abstract class ViewContainerRef {\n\n\t/**\n\t * Anchor element that specifies the location of this container in the containing view.\n\t * Each view container can have only one anchor element, and each anchor element\n\t * can have only a single view container.\n\t * \n\t * Root elements of views attached to this container become siblings of the anchor element in\n\t * the rendered view.\n\t *\n\t * Access the `ViewContainerRef` of an element by placing a `Directive` injected\n\t * with `ViewContainerRef` on the element, or use a `ViewChild` query.\n\t *\n\t */\n\tabstract get anchorElement(): Element;\n\n\t/**\n\t * Destroys all views in this container.\n\t */\n\tabstract clear(): void;\n\n\t/**\n\t * Retrieves a view from this container.\n\t * @param index The 0-based index of the view to retrieve.\n\t * @returns The `ViewRef` instance, or null if the index is out of range.\n\t */\n\tabstract get(index: number): ViewRef | undefined;\n\n\t/**\n\t * Reports how many views are currently attached to this container.\n\t * @returns The number of views.\n\t */\n\tabstract get length(): number;\n\n\t/**\n\t * Instantiates an embedded view and inserts it\n\t * into this container.\n\t * @param templateRef The HTML template that defines the view.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<ng-template>` usage.\n\t * @param index The 0-based index at which to insert the new view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t *\n\t * @returns The `ViewRef` instance for the newly created view.\n\t */\n\tabstract createEmbeddedView<C extends object>(templateRef: TemplateRef, context?: C, index?: number): EmbeddedViewRef<C>;\n\n\t/**\n * Instantiates a single component and inserts its host view into this container.\n *\n * @param componentType Component Type to use.\n * @param options An object that contains extra parameters:\n * * index: the index at which to insert the new component's host view into this container.\n * If not specified, appends the new view as the last entry.\n * * selector: the tag name of the new create component that attached with this model class.\n * \t\t\tAny Model class can have many views with different selectors. \n *\n * @returns The new `HTMLComponent` which contains the component instance and the host view.\n */\n\tabstract createComponent<C extends object>(componentType: TypeOf<C>, options?: {\n\t\tindex?: number,\n\t\tselector?: string\n\t}): C;\n\n\t/**\n\t * Inserts a view into this container.\n\t * @param viewRef The view to insert.\n\t * @param index The 0-based index at which to insert the view.\n\t * If not specified, appends the new view as the last entry.\n\t * @returns The inserted `ViewRef` instance.\n\t *\n\t */\n\tabstract insert(viewRef: ViewRef, index?: number): ViewRef;\n\n\t/**\n\t * Moves a view to a new location in this container.\n\t * @param viewRef The view to move.\n\t * @param newIndex The 0-based index of the new location.\n\t * @returns The moved `ViewRef` instance.\n\t */\n\tabstract move(viewRef: ViewRef, newIndex: number): ViewRef;\n\n\t/**\n\t * Returns the index of a view within the current container.\n\t * @param viewRef The view to query.\n\t * @returns The 0-based index of the view's position in this container,\n\t * or `-1` if this container doesn't contain the view.\n\t */\n\tabstract indexOf(viewRef: ViewRef): number;\n\n\t/**\n\t * Destroys a view attached to this container\n\t * @param index The 0-based index of the view to destroy.\n\t * If not specified, the last view in the container is removed.\n\t */\n\tabstract remove(index?: number): void;\n\n\t/**\n\t * Detaches a view from this container without destroying it.\n\t * Use along with `insert()` to move a view within the current container.\n\t * @param index The 0-based index of the view to detach.\n\t * If not specified, the last view in the container is detached.\n\t */\n\tabstract detach(index?: number): ViewRef | undefined;\n}\n\n\nexport class ViewContainerRefImpl extends ViewContainerRef {\n\n\tprivate views: EmbeddedViewRef<any>[] = [];\n\n\tconstructor(\n\t\tprivate parent: Element,\n\t\tprivate firstComment: Comment\n\t) {\n\t\tsuper();\n\t}\n\toverride get anchorElement(): Element {\n\t\treturn this.parent;\n\t}\n\toverride get length(): number {\n\t\treturn this.views.length;\n\t}\n\toverride clear(): void {\n\t\tif (this.views.length > 0) {\n\t\t\tfor (const elm of this.views) {\n\t\t\t\telm.destroy();\n\t\t\t}\n\t\t\tthis.views.splice(0);\n\t\t}\n\t}\n\toverride get(index: number): ViewRef | undefined {\n\t\tif (index >= this.views.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.views[index];\n\t}\n\toverride detach(index?: number): ViewRef | undefined {\n\t\tindex ??= this.views.length - 1;\n\t\tconst viewRef = this.views[index];\n\t\tviewRef.detach();\n\t\tthis.views.splice(index, 1);\n\t\treturn viewRef;\n\t}\n\toverride indexOf(viewRef: EmbeddedViewRef<any>): number {\n\t\treturn this.views.indexOf(viewRef);\n\t}\n\toverride remove(index?: number): void {\n\t\tindex ??= this.views.length - 1;\n\t\tthis.views[index].destroy();\n\t\tthis.views.splice(index, 1);\n\t}\n\toverride insert(viewRef: EmbeddedViewRef<any>, index?: number): ViewRef {\n\t\tindex = ((index ??= this.views.length) > this.views.length) ? this.views.length : index;\n\t\tconst lastNode = index == 0 ? this.firstComment : this.views[index - 1].last;\n\t\tthis.views.splice(index, 0, viewRef);\n\t\tviewRef.after(lastNode);\n\t\treturn viewRef;\n\t}\n\toverride move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef {\n\t\tconst oldIndex = this.indexOf(viewRef);\n\t\tif (oldIndex > -1) {\n\t\t\tthis.detach(oldIndex);\n\t\t} else {\n\t\t\t// should remove it from the container first\n\t\t\tviewRef.detach();\n\t\t}\n\t\treturn this.insert(viewRef, newIndex);\n\t}\n\toverride createEmbeddedView<C extends object>(templateRef: TemplateRef, context?: C, index?: number): EmbeddedViewRef<C> {\n\t\tconst viewRef = templateRef.createEmbeddedView<C>(context || <C>{}, this.parent);\n\t\tthis.insert(viewRef, index);\n\t\treturn viewRef;\n\t}\n\toverride createComponent<C extends object>(componentType: TypeOf<C>, options?: { index?: number | undefined; selector?: string; }): C {\n\t\tconst defaultTagName = Components.getComponentRef<C>(componentType).selector;\n\t\tconst ViewClass = getComponentView(componentType, options?.selector ?? defaultTagName);\n\t\tif (!ViewClass) {\n\t\t\tthrow new Error(`Can't find View component for class ${componentType.name}`);\n\t\t}\n\t\tconst component = new ViewClass();\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(component._proxyModel, [component]);\n\t\tthis.insert(viewRef, options?.index);\n\t\treturn component._proxyModel;\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"view-container-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA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,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACQ,kBAAkB,CAAe,WAAwB,EAAE,OAAiC;QACpG,MAAM,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAI,OAAO,EAAE,OAAO,IAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1F,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC;IAChB,CAAC;IACQ,eAAe,CAAe,aAAwB,EAAE,OAAuC;QACvG,MAAM,cAAc,GAAG,UAAU,CAAC,eAAe,CAAI,aAAa,CAAC,CAAC,QAAQ,CAAC;QAC7E,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,IAAI,cAAc,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;SAC7E;QACD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAI,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC,WAAW,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { Components } from '../component/component.js';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../view/view.js';\n\nexport type ViewContainerOptions<C> = {\n\tindex?: number;\n\tcontext?: C;\n};\n\nexport type ViewContainerComponentOptions = {\n\tindex?: number | undefined;\n\tselector?: string;\n};\nexport abstract class ViewContainerRef {\n\n\t/**\n\t * Anchor element that specifies the location of this container in the containing view.\n\t * Each view container can have only one anchor element, and each anchor element\n\t * can have only a single view container.\n\t * \n\t * Root elements of views attached to this container become siblings of the anchor element in\n\t * the rendered view.\n\t *\n\t * Access the `ViewContainerRef` of an element by placing a `Directive` injected\n\t * with `ViewContainerRef` on the element, or use a `ViewChild` query.\n\t *\n\t */\n\tabstract get anchorElement(): Element;\n\n\t/**\n\t * Destroys all views in this container.\n\t */\n\tabstract clear(): void;\n\n\t/**\n\t * Retrieves a view from this container.\n\t * @param index The 0-based index of the view to retrieve.\n\t * @returns The `ViewRef` instance, or null if the index is out of range.\n\t */\n\tabstract get(index: number): ViewRef | undefined;\n\n\t/**\n\t * Reports how many views are currently attached to this container.\n\t * @returns The number of views.\n\t */\n\tabstract get length(): number;\n\n\t/**\n\t * Instantiates an embedded view and inserts it\n\t * into this container.\n\t * @param templateRef The HTML template that defines the view.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<ng-template>` usage.\n\t * @param index The 0-based index at which to insert the new view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t *\n\t * @returns The `ViewRef` instance for the newly created view.\n\t */\n\tabstract createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;\n\n\t/**\n * Instantiates a single component and inserts its host view into this container.\n *\n * @param componentType Component Type to use.\n * @param options An object that contains extra parameters:\n * * index: the index at which to insert the new component's host view into this container.\n * If not specified, appends the new view as the last entry.\n * * selector: the tag name of the new create component that attached with this model class.\n * \t\t\tAny Model class can have many views with different selectors. \n *\n * @returns The new `HTMLComponent` which contains the component instance and the host view.\n */\n\tabstract createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;\n\n\t/**\n\t * Inserts a view into this container.\n\t * @param viewRef The view to insert.\n\t * @param index The 0-based index at which to insert the view.\n\t * If not specified, appends the new view as the last entry.\n\t * @returns The inserted `ViewRef` instance.\n\t *\n\t */\n\tabstract insert(viewRef: ViewRef, index?: number): ViewRef;\n\n\t/**\n\t * Moves a view to a new location in this container.\n\t * @param viewRef The view to move.\n\t * @param newIndex The 0-based index of the new location.\n\t * @returns The moved `ViewRef` instance.\n\t */\n\tabstract move(viewRef: ViewRef, newIndex: number): ViewRef;\n\n\t/**\n\t * Returns the index of a view within the current container.\n\t * @param viewRef The view to query.\n\t * @returns The 0-based index of the view's position in this container,\n\t * or `-1` if this container doesn't contain the view.\n\t */\n\tabstract indexOf(viewRef: ViewRef): number;\n\n\t/**\n\t * Destroys a view attached to this container\n\t * @param index The 0-based index of the view to destroy.\n\t * If not specified, the last view in the container is removed.\n\t */\n\tabstract remove(index?: number): void;\n\n\t/**\n\t * Detaches a view from this container without destroying it.\n\t * Use along with `insert()` to move a view within the current container.\n\t * @param index The 0-based index of the view to detach.\n\t * If not specified, the last view in the container is detached.\n\t */\n\tabstract detach(index?: number): ViewRef | undefined;\n}\n\n\nexport class ViewContainerRefImpl extends ViewContainerRef {\n\n\tprivate views: EmbeddedViewRef<any>[] = [];\n\n\tconstructor(\n\t\tprivate parent: Element,\n\t\tprivate firstComment: Comment\n\t) {\n\t\tsuper();\n\t}\n\toverride get anchorElement(): Element {\n\t\treturn this.parent;\n\t}\n\toverride get length(): number {\n\t\treturn this.views.length;\n\t}\n\toverride clear(): void {\n\t\tif (this.views.length > 0) {\n\t\t\tfor (const elm of this.views) {\n\t\t\t\telm.destroy();\n\t\t\t}\n\t\t\tthis.views.splice(0);\n\t\t}\n\t}\n\toverride get(index: number): ViewRef | undefined {\n\t\tif (index >= this.views.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.views[index];\n\t}\n\toverride detach(index?: number): ViewRef | undefined {\n\t\tindex ??= this.views.length - 1;\n\t\tconst viewRef = this.views[index];\n\t\tviewRef.detach();\n\t\tthis.views.splice(index, 1);\n\t\treturn viewRef;\n\t}\n\toverride indexOf(viewRef: EmbeddedViewRef<any>): number {\n\t\treturn this.views.indexOf(viewRef);\n\t}\n\toverride remove(index?: number): void {\n\t\tindex ??= this.views.length - 1;\n\t\tthis.views[index].destroy();\n\t\tthis.views.splice(index, 1);\n\t}\n\toverride insert(viewRef: EmbeddedViewRef<any>, index?: number): ViewRef {\n\t\tindex = ((index ??= this.views.length) > this.views.length) ? this.views.length : index;\n\t\tconst lastNode = index == 0 ? this.firstComment : this.views[index - 1].last;\n\t\tthis.views.splice(index, 0, viewRef);\n\t\tviewRef.after(lastNode);\n\t\treturn viewRef;\n\t}\n\toverride move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef {\n\t\tconst oldIndex = this.indexOf(viewRef);\n\t\tif (oldIndex > -1) {\n\t\t\tthis.detach(oldIndex);\n\t\t} else {\n\t\t\t// should remove it from the container first\n\t\t\tviewRef.detach();\n\t\t}\n\t\treturn this.insert(viewRef, newIndex);\n\t}\n\toverride createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C> {\n\t\tconst viewRef = templateRef.createEmbeddedView<C>(options?.context || <C>{}, this.parent);\n\t\tthis.insert(viewRef, options?.index);\n\t\treturn viewRef;\n\t}\n\toverride createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C {\n\t\tconst defaultTagName = Components.getComponentRef<C>(componentType).selector;\n\t\tconst ViewClass = getComponentView(componentType, options?.selector ?? defaultTagName);\n\t\tif (!ViewClass) {\n\t\t\tthrow new Error(`Can't find View component for class ${componentType.name}`);\n\t\t}\n\t\tconst component = new ViewClass();\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(component._proxyModel, [component]);\n\t\tthis.insert(viewRef, options?.index);\n\t\treturn component._proxyModel;\n\t}\n\n}\n"]}
|
package/linker/view-ref.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScopeContext, ScopeSubscription } from '@ibyar/expressions';
|
|
1
2
|
export declare abstract class ViewRef {
|
|
2
3
|
abstract destroy(): void;
|
|
3
4
|
abstract get destroyed(): boolean;
|
|
@@ -17,9 +18,10 @@ export declare abstract class EmbeddedViewRef<C extends object> extends ViewRef
|
|
|
17
18
|
export declare class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewRef<C> {
|
|
18
19
|
private _context;
|
|
19
20
|
private _rootNodes;
|
|
21
|
+
private _subscriptions?;
|
|
20
22
|
private _destroyed;
|
|
21
|
-
private
|
|
22
|
-
constructor(_context: C, _rootNodes: Node[]);
|
|
23
|
+
private onDestroySubscribes;
|
|
24
|
+
constructor(_context: C, _rootNodes: Node[], _subscriptions?: ScopeSubscription<ScopeContext>[] | undefined);
|
|
23
25
|
get context(): C;
|
|
24
26
|
get rootNodes(): Node[];
|
|
25
27
|
get first(): Element;
|