From 7edeaf6c422ed1de46c8f4350b84d32c0b7bd721 Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Sat, 6 Sep 2025 20:52:15 +0900 Subject: [PATCH 1/3] feat: add template info types --- src/types/template.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/template.ts b/src/types/template.ts index 9d5065a..9513a4a 100644 --- a/src/types/template.ts +++ b/src/types/template.ts @@ -3,6 +3,13 @@ import { Range } from "./range"; export type TemplateInfo = | Range | { + type?: + | "inline" + | "blockOpen" + | "blockClose" + | "conditionalBlockOpen" + | "conditionalBlockClose" + | "alternativeBlockOpen"; open: Range; close: Range; }; From 0c3c1a5810450b146e7342a9cfa30d246ea54e54 Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Sat, 6 Sep 2025 20:57:19 +0900 Subject: [PATCH 2/3] feat: add template token types to chars --- src/tokenizer/chars.ts | 3 ++- src/tokenizer/source-code.ts | 5 +++-- src/types/template.ts | 27 ++++++++++++++------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/tokenizer/chars.ts b/src/tokenizer/chars.ts index 5f428c3..46f43a5 100644 --- a/src/tokenizer/chars.ts +++ b/src/tokenizer/chars.ts @@ -1,4 +1,4 @@ -import { Range } from "../types"; +import { Range, TemplateTokenType } from "../types"; export enum CharsType { HTML = "HTML", @@ -11,6 +11,7 @@ export class Chars { public isTemplate: boolean; constructor( public type: CharsType, + public templateTokenType: TemplateTokenType | undefined, public value: string, public range: Range, public wrapper?: { diff --git a/src/tokenizer/source-code.ts b/src/tokenizer/source-code.ts index da3c41a..e875f0a 100644 --- a/src/tokenizer/source-code.ts +++ b/src/tokenizer/source-code.ts @@ -55,9 +55,10 @@ export class SourceCode { charsList.push( new Chars( CharsType.Template, + info.type, this.source.slice(range[0], range[1]), [range[0], range[1]], - Array.isArray(info) ? undefined : info + info ) ); templateInfoIndex++; @@ -66,7 +67,7 @@ export class SourceCode { } } charsList.push( - new Chars(CharsType.HTML, this.source[sourceIndex], [ + new Chars(CharsType.HTML, undefined, this.source[sourceIndex], [ sourceIndex, sourceIndex + 1, ]) diff --git a/src/types/template.ts b/src/types/template.ts index 9513a4a..e28e53c 100644 --- a/src/types/template.ts +++ b/src/types/template.ts @@ -1,15 +1,16 @@ import { Range } from "./range"; -export type TemplateInfo = - | Range - | { - type?: - | "inline" - | "blockOpen" - | "blockClose" - | "conditionalBlockOpen" - | "conditionalBlockClose" - | "alternativeBlockOpen"; - open: Range; - close: Range; - }; +export enum TemplateTokenType { + Inline = "inline", + BlockOpen = "blockOpen", + BlockClose = "blockClose", + ConditionalBlockOpen = "conditionalBlockOpen", + ConditionalBlockClose = "conditionalBlockClose", + AlternativeBlockOpen = "alternativeBlockOpen", +} + +export type TemplateInfo = { + type?: TemplateTokenType; + open: Range; + close: Range; +}; From 206077ad52907ad051afcca6ef967d4d5a03914c Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Sun, 14 Sep 2025 21:49:43 +0900 Subject: [PATCH 3/3] feat: add default --- src/tokenizer/chars.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tokenizer/chars.ts b/src/tokenizer/chars.ts index 46f43a5..6a5d19a 100644 --- a/src/tokenizer/chars.ts +++ b/src/tokenizer/chars.ts @@ -11,7 +11,7 @@ export class Chars { public isTemplate: boolean; constructor( public type: CharsType, - public templateTokenType: TemplateTokenType | undefined, + public templateTokenType: TemplateTokenType = TemplateTokenType.Inline, public value: string, public range: Range, public wrapper?: {