@lucidkiln/core 1.2.0 → 1.3.0
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/CHANGELOG.md +4 -0
- package/dist/{environment-DBvRrOn0.d.ts → environment-CgQfwDAJ.d.ts} +18 -2
- package/dist/environment-CgQfwDAJ.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/package.json +1 -1
- package/dist/environment-DBvRrOn0.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
- `analyze` now reports each function call and its arguments in `calls`, with the value of every literal argument. ([72780ec](https://github.com/buildlucid/kiln/commit/72780ec6a827a8d416141b0e8921efa22bcd5a65))
|
|
6
|
+
|
|
3
7
|
## 1.2.0
|
|
4
8
|
|
|
5
9
|
- Inserted content is no longer re-indented to line up with its tag. ([46e6cae](https://github.com/buildlucid/kiln/commit/46e6cae3afbbc88ded8a19dcd9018f8559d4e7ce))
|
|
@@ -169,6 +169,20 @@ type TemplateReference = {
|
|
|
169
169
|
start: Position;
|
|
170
170
|
end: Position;
|
|
171
171
|
};
|
|
172
|
+
/** An argument to a function call: its literal value, or `literal: false` when computed at render time. */
|
|
173
|
+
type CallArgument = {
|
|
174
|
+
/** The argument's name, or `null` when it is positional. */
|
|
175
|
+
name: string | null;
|
|
176
|
+
literal: boolean;
|
|
177
|
+
/** The literal's value, or `null` when the argument is computed. */
|
|
178
|
+
value: null | boolean | number | string;
|
|
179
|
+
};
|
|
180
|
+
type FunctionCall = {
|
|
181
|
+
name: string;
|
|
182
|
+
args: CallArgument[];
|
|
183
|
+
start: Position;
|
|
184
|
+
end: Position;
|
|
185
|
+
};
|
|
172
186
|
type AnalysedProp = {
|
|
173
187
|
name: string;
|
|
174
188
|
required: boolean;
|
|
@@ -185,6 +199,8 @@ type Analysis = {
|
|
|
185
199
|
/** Variables set at the top level. A layout sees those its child template sets. */
|
|
186
200
|
sets: string[];
|
|
187
201
|
functions: string[];
|
|
202
|
+
/** Each call to a host or built-in function, in source order. */
|
|
203
|
+
calls: FunctionCall[];
|
|
188
204
|
filters: string[];
|
|
189
205
|
tests: string[];
|
|
190
206
|
templates: TemplateReference[];
|
|
@@ -435,5 +451,5 @@ declare const memoryCache: ({ max }?: {
|
|
|
435
451
|
}) => void;
|
|
436
452
|
};
|
|
437
453
|
//#endregion
|
|
438
|
-
export {
|
|
439
|
-
//# sourceMappingURL=environment-
|
|
454
|
+
export { FunctionCall as A, StreamedIslands as B, HtmlCheck as C, AnalysedProp as D, PrecompiledTemplate as E, DeferredIslands as F, KilnRenderError as G, islandScript as H, IslandEntry as I, KilnSyntaxError as K, IslandManifest as L, AbortSignalLike as M, KilnCache as N, Analysis as O, RenderInfo as P, IslandMode as R, withRender as S, HtmlChecks as T, streamIslands as U, deferIslands as V, Diagnostic as W, TemplateName as _, KilnGlobals as a, memoryCache as b, KilnTemplates as c, Limits as d, Loader as f, TemplateContext as g, TemplateBlock as h, KilnFunctions as i, TemplateReference as j, CallArgument as k, KilnTests as l, RenderOptions as m, KilnCallable as n, KilnOptions as o, RenderAware as p, TemplateLocation as q, KilnFilters as r, KilnSchema as s, Kiln as t, KilnTypes as u, TypeChecks as v, HtmlCheckLevel as w, memoryLoader as x, createKiln as y, JsonValue as z };
|
|
455
|
+
//# sourceMappingURL=environment-CgQfwDAJ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-CgQfwDAJ.d.ts","names":[],"sources":["../src/errors.ts","../src/runtime/islands.ts","../src/runtime/types.ts","../src/analyzer.ts","../src/compiler/precompiled.ts","../src/html/options.ts","../src/environment.ts"],"mappings":";;KAEY;;EAEX;EACA;EACA;;EAEA;EACA,OAAO;EACP,KAAK;;KAGM;EACX;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O,cAAc,MAAM,yBACxB,MAAM,gBAAgB,gBAAgB,MAAM,sBAAsB,SACnE;;;;;EAKH,aAAa,aAAa,aAAa,sBACtC,MAAM,SACH,MAAM,gBAAgB,gBAAgB,MAAM,sBAAsB,SACnE,QAAQ,eAAe;;EAE1B,MAAM,cAAc,kBAAkB,QAAQ;;EAE9C,QAAQ,cAAc,kBAAkB,QAAQ;;;;;EAKhD,WAAW,cAAc,kBAAkB;;EAE3C,WAAW;;;;;;;;;cAUC,aAAc,aAAa,YAAU,IAC7C,SACF,YAAY;;;;;;;;;cA6iBF,aACZ,mBACA,eAAe,aAAa,eAAa,SAEhC,YAAY,OAAO,YAC1B,KAAK,OAAO;;;;;;;cA6GF,eAAY,WAErB,wBAAwB,uBACxB,qBAAqB,yBACtB,KAAK;EAAoB;;;;;;;;;;cAkBf,gBAAW;EAAsB;;;;;;;;;;;;EA0B1B,UAAA;IAAE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as PropType, l as ShapeKey, m as Position, p as TypeName, r as EscapeStrategy } from "./ast-DDhHuwaY.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as FunctionCall, B as StreamedIslands, C as HtmlCheck, D as AnalysedProp, E as PrecompiledTemplate, F as DeferredIslands, G as KilnRenderError, H as islandScript, I as IslandEntry, K as KilnSyntaxError, L as IslandManifest, M as AbortSignalLike, N as KilnCache, O as Analysis, P as RenderInfo, R as IslandMode, S as withRender, T as HtmlChecks, U as streamIslands, V as deferIslands, W as Diagnostic, _ as TemplateName, a as KilnGlobals, b as memoryCache, c as KilnTemplates, d as Limits, f as Loader, g as TemplateContext, h as TemplateBlock, i as KilnFunctions, j as TemplateReference, k as CallArgument, l as KilnTests, m as RenderOptions, n as KilnCallable, o as KilnOptions, p as RenderAware, q as TemplateLocation, r as KilnFilters, s as KilnSchema, t as Kiln, u as KilnTypes, v as TypeChecks, w as HtmlCheckLevel, x as memoryLoader, y as createKiln, z as JsonValue } from "./environment-CgQfwDAJ.js";
|
|
3
3
|
//#region src/runtime/markup.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* A string that is already safe to output with one escaping strategy.
|
|
@@ -87,5 +87,5 @@ export declare const generateManifest: <State, Schema extends KilnSchema>(kiln:
|
|
|
87
87
|
*/
|
|
88
88
|
export declare const generateTypes: (kiln: Pick<Kiln, "analyze">, names: Iterable<string>) => Promise<string>;
|
|
89
89
|
//#endregion
|
|
90
|
-
export { type AbortSignalLike, type AnalysedProp, type Analysis, type DeferredIslands, type Diagnostic, type EscapeStrategy, type HtmlCheck, type HtmlCheckLevel, type HtmlChecks, type IslandEntry, type IslandManifest, type IslandMode, type JsonValue, type Kiln, type KilnCache, type KilnCallable, type KilnFilters, type KilnFunctions, type KilnGlobals, type KilnManifest, type KilnOptions, KilnRenderError, type KilnSchema, KilnSyntaxError, type KilnTemplates, type KilnTests, type KilnTypes, type Limits, type Loader, type Position, type PrecompiledTemplate, type PropType, type RenderAware, type RenderInfo, type RenderOptions, type ShapeKey, type StreamedIslands, type TemplateBlock, type TemplateContext, type TemplateLocation, type TemplateName, type TemplateReference, type TypeChecks, type TypeName, createKiln, deferIslands, islandScript, memoryCache, memoryLoader, streamIslands, withRender };
|
|
90
|
+
export { type AbortSignalLike, type AnalysedProp, type Analysis, type CallArgument, type DeferredIslands, type Diagnostic, type EscapeStrategy, type FunctionCall, type HtmlCheck, type HtmlCheckLevel, type HtmlChecks, type IslandEntry, type IslandManifest, type IslandMode, type JsonValue, type Kiln, type KilnCache, type KilnCallable, type KilnFilters, type KilnFunctions, type KilnGlobals, type KilnManifest, type KilnOptions, KilnRenderError, type KilnSchema, KilnSyntaxError, type KilnTemplates, type KilnTests, type KilnTypes, type Limits, type Loader, type Position, type PrecompiledTemplate, type PropType, type RenderAware, type RenderInfo, type RenderOptions, type ShapeKey, type StreamedIslands, type TemplateBlock, type TemplateContext, type TemplateLocation, type TemplateName, type TemplateReference, type TypeChecks, type TypeName, createKiln, deferIslands, islandScript, memoryCache, memoryLoader, streamIslands, withRender };
|
|
91
91
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const analyzeTemplate = (template, globals, reads) => {
|
|
|
30
30
|
const source = template.source;
|
|
31
31
|
const variables = /* @__PURE__ */ new Set();
|
|
32
32
|
const functions = /* @__PURE__ */ new Set();
|
|
33
|
+
const calls = [];
|
|
33
34
|
const filters = /* @__PURE__ */ new Set();
|
|
34
35
|
const tests = /* @__PURE__ */ new Set();
|
|
35
36
|
const templates = [];
|
|
@@ -73,6 +74,18 @@ const analyzeTemplate = (template, globals, reads) => {
|
|
|
73
74
|
scopes.pop();
|
|
74
75
|
if (isolated) scopes.pop();
|
|
75
76
|
};
|
|
77
|
+
const callArgument = (arg) => {
|
|
78
|
+
const name = arg.type === "Named" ? arg.name : null;
|
|
79
|
+
return arg.type !== "Spread" && arg.value.type === "Literal" ? {
|
|
80
|
+
name,
|
|
81
|
+
literal: true,
|
|
82
|
+
value: arg.value.value
|
|
83
|
+
} : {
|
|
84
|
+
name,
|
|
85
|
+
literal: false,
|
|
86
|
+
value: null
|
|
87
|
+
};
|
|
88
|
+
};
|
|
76
89
|
const visitArguments = (args) => {
|
|
77
90
|
for (const arg of args) expression(arg.value);
|
|
78
91
|
};
|
|
@@ -145,7 +158,15 @@ const analyzeTemplate = (template, globals, reads) => {
|
|
|
145
158
|
const callee = node.callee;
|
|
146
159
|
if (callee.type === "Name") {
|
|
147
160
|
const name = callee.name;
|
|
148
|
-
if (name !== "parent" && name !== "block" && !macroNames.has(name) && !importedNames.has(name))
|
|
161
|
+
if (name !== "parent" && name !== "block" && !macroNames.has(name) && !importedNames.has(name)) {
|
|
162
|
+
functions.add(name);
|
|
163
|
+
calls.push({
|
|
164
|
+
name,
|
|
165
|
+
args: node.args.map(callArgument),
|
|
166
|
+
start: source.position(node.span.start),
|
|
167
|
+
end: source.position(node.span.end)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
149
170
|
} else if (!(callee.type === "Member" && callee.object.type === "Name" && importAliases.has(callee.object.name))) expression(callee);
|
|
150
171
|
visitArguments(node.args);
|
|
151
172
|
return;
|
|
@@ -302,6 +323,7 @@ const analyzeTemplate = (template, globals, reads) => {
|
|
|
302
323
|
rest,
|
|
303
324
|
sets: template.ast.body.flatMap((node) => node.type === "Set" || node.type === "SetBlock" ? [node.name] : []),
|
|
304
325
|
functions: [...functions],
|
|
326
|
+
calls,
|
|
305
327
|
filters: [...filters],
|
|
306
328
|
tests: [...tests],
|
|
307
329
|
templates,
|