Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
localvoid committed Dec 2, 2024
1 parent 85d50a4 commit 01d9c75
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/@ivi/ts-transformer/src/lib/chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const stringLiteralToString = (n: ts.Node): string => {
return n.text;
};

/**
* SharedData is used for deduplicating template factories and numeric arrays.
*/
class SharedData {
readonly factories: Map<string, ts.CallExpression[]>;
readonly arrays: Map<string, ts.ArrayLiteralExpression[]>;
Expand Down Expand Up @@ -80,18 +83,19 @@ export function transformChunk(options: TransformChunkOptions): ts.TranspileOutp
const args = node.arguments;
if (args.length < 5) {
throw new Error("Expected at least 5 arguments");
} const arg0 = args[0];
const arg1 = args[1];
let arg2 = args[2];
const arg3 = args[3];
const arg4 = args[4];
}
const arg0 = args[0]; // Template DOM factory
const arg1 = args[1]; // Flags
let arg2 = args[2]; // Prop OpCodes
const arg3 = args[3]; // Child OpCodes
const arg4 = args[4]; // State OpCodes
sharedData.addFactory(arg0);
sharedData.addArray(arg3);
sharedData.addArray(arg4);

// Replace strings with shared strings
if (strings !== void 0 && args.length > 5) {
const arg5 = args[5];
const arg5 = args[5]; // Strings
if (ts.isArrayLiteralExpression(arg2) && ts.isArrayLiteralExpression(arg5)) {
const tplStrings = arg5.elements.map(stringLiteralToString);

Expand Down

0 comments on commit 01d9c75

Please sign in to comment.