summaryrefslogtreecommitdiff
path: root/node_modules/liquidjs/dist/template
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/liquidjs/dist/template')
-rw-r--r--node_modules/liquidjs/dist/template/analysis.d.ts85
-rw-r--r--node_modules/liquidjs/dist/template/analysis.spec.d.ts1
-rw-r--r--node_modules/liquidjs/dist/template/filter-impl-options.d.ts14
-rw-r--r--node_modules/liquidjs/dist/template/filter.d.ts15
-rw-r--r--node_modules/liquidjs/dist/template/filter.spec.d.ts1
-rw-r--r--node_modules/liquidjs/dist/template/hash.d.ts18
-rw-r--r--node_modules/liquidjs/dist/template/hash.spec.d.ts1
-rw-r--r--node_modules/liquidjs/dist/template/html.d.ts9
-rw-r--r--node_modules/liquidjs/dist/template/index.d.ts11
-rw-r--r--node_modules/liquidjs/dist/template/output.d.ts12
-rw-r--r--node_modules/liquidjs/dist/template/output.spec.d.ts1
-rw-r--r--node_modules/liquidjs/dist/template/tag-options-adapter.d.ts10
-rw-r--r--node_modules/liquidjs/dist/template/tag.d.ts18
-rw-r--r--node_modules/liquidjs/dist/template/template-impl.d.ts4
-rw-r--r--node_modules/liquidjs/dist/template/template.d.ts36
-rw-r--r--node_modules/liquidjs/dist/template/value.d.ts15
-rw-r--r--node_modules/liquidjs/dist/template/value.spec.d.ts1
17 files changed, 252 insertions, 0 deletions
diff --git a/node_modules/liquidjs/dist/template/analysis.d.ts b/node_modules/liquidjs/dist/template/analysis.d.ts
new file mode 100644
index 0000000..4a0d647
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/analysis.d.ts
@@ -0,0 +1,85 @@
+import { Template } from '.';
+/**
+ * Row, column and file name where a variable was found.
+ */
+export interface VariableLocation {
+ row: number;
+ col: number;
+ file?: string;
+}
+/**
+ * A variable's segments as an array, possibly with nested arrays of segments.
+ */
+export type SegmentArray = Array<string | number | SegmentArray>;
+/**
+ * A variable's segments and location, which can be coerced to a string.
+ */
+export declare class Variable {
+ readonly segments: Array<string | number | Variable>;
+ readonly location: VariableLocation;
+ constructor(segments: Array<string | number | Variable>, location: VariableLocation);
+ toString(): string;
+ /** Return this variable's segments as an array, possibly with nested arrays for nested paths. */
+ toArray(): SegmentArray;
+}
+/**
+ * Property names and array indexes that make up a path to a variable.
+ */
+export type VariableSegments = Array<string | number | Variable>;
+/**
+ * A mapping of variable names to an array of locations at which the variable was found.
+ */
+export type Variables = {
+ [key: string]: Variable[];
+};
+/**
+ * Group variables by the string representation of their root segment.
+ */
+export declare class VariableMap {
+ private map;
+ constructor();
+ get(key: Variable): Variable[];
+ has(key: Variable): boolean;
+ push(variable: Variable): void;
+ asObject(): Variables;
+}
+/**
+ * The result of calling `analyze()` or `analyzeSync()`.
+ */
+export interface StaticAnalysis {
+ /**
+ * All variables, whether they are in scope or not. Including references to names
+ * such as `forloop` from the `for` tag.
+ */
+ variables: Variables;
+ /**
+ * Variables that are not in scope. These could be a "global" variables that are
+ * expected to be provided by the application developer, or possible mistakes
+ * from the template author.
+ *
+ * If a variable is referenced before and after assignment, you should expect
+ * that variable to be included in `globals`, `variables` and `locals`, each with
+ * a different location.
+ */
+ globals: Variables;
+ /**
+ * Template variables that are added to the template local scope using tags like
+ * `assign`, `capture` or `increment`.
+ */
+ locals: Variables;
+}
+export interface StaticAnalysisOptions {
+ /**
+ * When `true` (the default), try to load partial templates and analyze them too.
+ */
+ partials?: boolean;
+}
+export declare const defaultStaticAnalysisOptions: StaticAnalysisOptions;
+/**
+ * Statically analyze a template and report variable usage.
+ */
+export declare function analyze(template: Template[], options?: StaticAnalysisOptions): Promise<StaticAnalysis>;
+/**
+ * Statically analyze a template and report variable usage.
+ */
+export declare function analyzeSync(template: Template[], options?: StaticAnalysisOptions): StaticAnalysis;
diff --git a/node_modules/liquidjs/dist/template/analysis.spec.d.ts b/node_modules/liquidjs/dist/template/analysis.spec.d.ts
new file mode 100644
index 0000000..509db18
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/analysis.spec.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/node_modules/liquidjs/dist/template/filter-impl-options.d.ts b/node_modules/liquidjs/dist/template/filter-impl-options.d.ts
new file mode 100644
index 0000000..fa303b0
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/filter-impl-options.d.ts
@@ -0,0 +1,14 @@
+import type { Context } from '../context';
+import type { Liquid } from '../liquid';
+import type { FilterToken } from '../tokens';
+export interface FilterImpl {
+ context: Context;
+ token: FilterToken;
+ liquid: Liquid;
+}
+export type FilterHandler = (this: FilterImpl, value: any, ...args: any[]) => any;
+export interface FilterOptions {
+ handler: FilterHandler;
+ raw: boolean;
+}
+export type FilterImplOptions = FilterHandler | FilterOptions;
diff --git a/node_modules/liquidjs/dist/template/filter.d.ts b/node_modules/liquidjs/dist/template/filter.d.ts
new file mode 100644
index 0000000..987abd4
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/filter.d.ts
@@ -0,0 +1,15 @@
+import { Context } from '../context';
+import { FilterImplOptions } from './filter-impl-options';
+import { FilterArg } from '../parser/filter-arg';
+import { Liquid } from '../liquid';
+import { FilterToken } from '../tokens';
+export declare class Filter {
+ name: string;
+ args: FilterArg[];
+ readonly raw: boolean;
+ private handler;
+ private liquid;
+ private token;
+ constructor(token: FilterToken, options: FilterImplOptions | undefined, liquid: Liquid);
+ render(value: any, context: Context): IterableIterator<unknown>;
+}
diff --git a/node_modules/liquidjs/dist/template/filter.spec.d.ts b/node_modules/liquidjs/dist/template/filter.spec.d.ts
new file mode 100644
index 0000000..509db18
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/filter.spec.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/node_modules/liquidjs/dist/template/hash.d.ts b/node_modules/liquidjs/dist/template/hash.d.ts
new file mode 100644
index 0000000..b50e404
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/hash.d.ts
@@ -0,0 +1,18 @@
+import { Context } from '../context/context';
+import { Tokenizer } from '../parser/tokenizer';
+import { Token } from '../tokens/token';
+type HashValueTokens = Record<string, Token | undefined>;
+/**
+ * Key-Value Pairs Representing Tag Arguments
+ * Example:
+ * For the markup `, foo:'bar', coo:2 reversed %}`,
+ * hash['foo'] === 'bar'
+ * hash['coo'] === 2
+ * hash['reversed'] === undefined
+ */
+export declare class Hash {
+ hash: HashValueTokens;
+ constructor(input: string | Tokenizer, jekyllStyle?: boolean | string);
+ render(ctx: Context): Generator<unknown, Record<string, any>, unknown>;
+}
+export {};
diff --git a/node_modules/liquidjs/dist/template/hash.spec.d.ts b/node_modules/liquidjs/dist/template/hash.spec.d.ts
new file mode 100644
index 0000000..509db18
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/hash.spec.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/node_modules/liquidjs/dist/template/html.d.ts b/node_modules/liquidjs/dist/template/html.d.ts
new file mode 100644
index 0000000..8b8136d
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/html.d.ts
@@ -0,0 +1,9 @@
+import { TemplateImpl, Template } from '../template';
+import { HTMLToken } from '../tokens';
+import { Context } from '../context';
+import { Emitter } from '../emitters';
+export declare class HTML extends TemplateImpl<HTMLToken> implements Template {
+ private str;
+ constructor(token: HTMLToken);
+ render(ctx: Context, emitter: Emitter): IterableIterator<void>;
+}
diff --git a/node_modules/liquidjs/dist/template/index.d.ts b/node_modules/liquidjs/dist/template/index.d.ts
new file mode 100644
index 0000000..0c45314
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/index.d.ts
@@ -0,0 +1,11 @@
+export * from './template';
+export * from './template-impl';
+export * from './tag';
+export * from './tag-options-adapter';
+export * from './filter';
+export * from './filter-impl-options';
+export * from './hash';
+export * from './value';
+export * from './output';
+export * from './html';
+export * from './analysis';
diff --git a/node_modules/liquidjs/dist/template/output.d.ts b/node_modules/liquidjs/dist/template/output.d.ts
new file mode 100644
index 0000000..9191ad5
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/output.d.ts
@@ -0,0 +1,12 @@
+import { Value } from './value';
+import { Arguments, Template, TemplateImpl } from '../template';
+import { Context } from '../context/context';
+import { Emitter } from '../emitters/emitter';
+import { OutputToken } from '../tokens/output-token';
+import { Liquid } from '../liquid';
+export declare class Output extends TemplateImpl<OutputToken> implements Template {
+ value: Value;
+ constructor(token: OutputToken, liquid: Liquid);
+ render(ctx: Context, emitter: Emitter): IterableIterator<unknown>;
+ arguments(): Arguments;
+}
diff --git a/node_modules/liquidjs/dist/template/output.spec.d.ts b/node_modules/liquidjs/dist/template/output.spec.d.ts
new file mode 100644
index 0000000..509db18
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/output.spec.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/node_modules/liquidjs/dist/template/tag-options-adapter.d.ts b/node_modules/liquidjs/dist/template/tag-options-adapter.d.ts
new file mode 100644
index 0000000..e4f85e4
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/tag-options-adapter.d.ts
@@ -0,0 +1,10 @@
+import { Tag, TagClass, TagRenderReturn } from './tag';
+import { TagToken, TopLevelToken } from '../tokens';
+import { Emitter } from '../emitters';
+import { Context } from '../context';
+export interface TagImplOptions {
+ [key: string]: any;
+ parse?: (this: Tag & TagImplOptions, token: TagToken, remainingTokens: TopLevelToken[]) => void;
+ render: (this: Tag & TagImplOptions, ctx: Context, emitter: Emitter, hash: Record<string, any>) => TagRenderReturn;
+}
+export declare function createTagClass(options: TagImplOptions): TagClass;
diff --git a/node_modules/liquidjs/dist/template/tag.d.ts b/node_modules/liquidjs/dist/template/tag.d.ts
new file mode 100644
index 0000000..b33245f
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/tag.d.ts
@@ -0,0 +1,18 @@
+import { TemplateImpl } from './template-impl';
+import type { Emitter } from '../emitters/emitter';
+import type { Parser, Tokenizer } from '../parser';
+import type { Context } from '../context/context';
+import type { TopLevelToken, TagToken } from '../tokens';
+import type { Template } from './template';
+import type { Liquid } from '../liquid';
+export type TagRenderReturn = Generator<unknown, unknown, unknown> | Promise<unknown> | unknown;
+export declare abstract class Tag extends TemplateImpl<TagToken> implements Template {
+ name: string;
+ liquid: Liquid;
+ protected tokenizer: Tokenizer;
+ constructor(token: TagToken, remainTokens: TopLevelToken[], liquid: Liquid);
+ abstract render(ctx: Context, emitter: Emitter): TagRenderReturn;
+}
+export interface TagClass {
+ new (token: TagToken, tokens: TopLevelToken[], liquid: Liquid, parser: Parser): Tag;
+}
diff --git a/node_modules/liquidjs/dist/template/template-impl.d.ts b/node_modules/liquidjs/dist/template/template-impl.d.ts
new file mode 100644
index 0000000..99edd24
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/template-impl.d.ts
@@ -0,0 +1,4 @@
+export declare abstract class TemplateImpl<T> {
+ token: T;
+ constructor(token: T);
+}
diff --git a/node_modules/liquidjs/dist/template/template.d.ts b/node_modules/liquidjs/dist/template/template.d.ts
new file mode 100644
index 0000000..a1fba7d
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/template.d.ts
@@ -0,0 +1,36 @@
+import { Context } from '../context/context';
+import { Token } from '../tokens/token';
+import { Emitter } from '../emitters/emitter';
+import { IdentifierToken, QuotedToken, ValueToken } from '../tokens';
+import { Value } from './value';
+export type Argument = Value | ValueToken;
+export type Arguments = Iterable<Argument>;
+/** Scope information used when analyzing partial templates. */
+export interface PartialScope {
+ /**
+ * The name of the partial template. We need this to make sure we only analyze
+ * each template once.
+ * */
+ name: string;
+ /**
+ * If `true`, names in `scope` will be added to a new, isolated scope before
+ * analyzing any child templates, without access to the parent template's scope.
+ */
+ isolated: boolean;
+ /**
+ * A list of names that will be in scope for the child template.
+ *
+ * If an item is a [string, Argument] tuple, the string is considered an alias
+ * for the argument.
+ */
+ scope: Iterable<string | [string, Argument]>;
+}
+export interface Template {
+ token: Token;
+ render(ctx: Context, emitter: Emitter): any;
+ children?(partials: boolean, sync: boolean): Generator<unknown, Template[]>;
+ arguments?(): Arguments;
+ blockScope?(): Iterable<string>;
+ localScope?(): Iterable<IdentifierToken | QuotedToken>;
+ partialScope?(): PartialScope | undefined;
+}
diff --git a/node_modules/liquidjs/dist/template/value.d.ts b/node_modules/liquidjs/dist/template/value.d.ts
new file mode 100644
index 0000000..05e2ff9
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/value.d.ts
@@ -0,0 +1,15 @@
+import { Filter } from './filter';
+import { Expression } from '../render';
+import type { FilteredValueToken } from '../tokens';
+import type { Liquid } from '../liquid';
+import type { Context } from '../context';
+export declare class Value {
+ readonly filters: Filter[];
+ readonly initial: Expression;
+ /**
+ * @param str the value to be valuated, eg.: "foobar" | truncate: 3
+ */
+ constructor(input: string | FilteredValueToken, liquid: Liquid);
+ value(ctx: Context, lenient?: boolean): Generator<unknown, unknown, unknown>;
+ private getFilter;
+}
diff --git a/node_modules/liquidjs/dist/template/value.spec.d.ts b/node_modules/liquidjs/dist/template/value.spec.d.ts
new file mode 100644
index 0000000..509db18
--- /dev/null
+++ b/node_modules/liquidjs/dist/template/value.spec.d.ts
@@ -0,0 +1 @@
+export {};