marko 6.0.79 → 6.0.80

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.
@@ -0,0 +1,8 @@
1
+ import { type Binding } from "./references";
2
+ export type BindingPropTree = {
3
+ binding: Binding;
4
+ props: {
5
+ [prop: string]: BindingPropTree;
6
+ } | undefined;
7
+ };
8
+ export declare function getBindingPropTree(binding: Binding): BindingPropTree;
@@ -1,6 +1,7 @@
1
1
  import { types as t } from "@marko/compiler";
2
+ import type { Section } from "./sections";
2
3
  export declare function generateUid(name?: string): string;
3
4
  export declare function generateUidIdentifier(name?: string): t.Identifier;
4
- export declare function getSharedUid(name: string): string;
5
+ export declare function getSharedUid(name: string, section?: Section): string;
5
6
  export declare function usedSharedUid(name: string): boolean;
6
7
  export declare function getSharedUidIdentifier(name: string): t.Identifier;
@@ -0,0 +1,23 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import type { BindingPropTree } from "./binding-prop-tree";
3
+ import { type Binding } from "./references";
4
+ import { type Section } from "./sections";
5
+ interface KnownExprs {
6
+ known?: Record<string, KnownExprs>;
7
+ value?: t.NodeExtra;
8
+ }
9
+ declare const kChildScopeBinding: unique symbol;
10
+ declare const kChildOffsetScopeBinding: unique symbol;
11
+ declare const kKnownExprs: unique symbol;
12
+ declare module "@marko/compiler/dist/types" {
13
+ interface MarkoTagExtra {
14
+ [kChildScopeBinding]?: Binding;
15
+ [kChildOffsetScopeBinding]?: Binding;
16
+ [kKnownExprs]?: KnownExprs;
17
+ }
18
+ }
19
+ export declare function knownTagAnalyze(tag: t.NodePath<t.MarkoTag>, contentSection: Section, propTree: BindingPropTree | undefined): void;
20
+ export declare function knownTagTranslateHTML(tag: t.NodePath<t.MarkoTag>, tagIdentifier: t.Expression, contentSection: Section, propTree: BindingPropTree | undefined): void;
21
+ export declare function knownTagTranslateDOM(tag: t.NodePath<t.MarkoTag>, propTree: BindingPropTree | undefined, getBindingIdentifier: (binding: Binding, preferedName?: string) => t.Identifier, callSetup: (section: Section, childBinding: Binding) => void): void;
22
+ export declare function getTagRelativePath(tag: t.NodePath<t.MarkoTag>): string;
23
+ export {};
@@ -5,6 +5,7 @@ export type AttrTagLookup = Record<string, {
5
5
  repeated: boolean;
6
6
  group: AttrTagNames;
7
7
  }>;
8
+ export type AttrTagGroup = AttrTagLookup[string]["group"];
8
9
  type AttrTagNames = string[];
9
10
  declare module "@marko/compiler/dist/types" {
10
11
  interface MarkoTagExtra {
@@ -12,7 +12,7 @@ export declare class Sorted<T> {
12
12
  findIndex<U extends NonNullable<T>>(data: Opt<U>, item: U): number;
13
13
  isSuperset<U extends NonNullable<T>>(superset: Opt<U>, subset: Opt<U>): boolean;
14
14
  }
15
- export declare function push<T>(data: Opt<T>, item: T): Opt<T>;
15
+ export declare function push<T>(data: Opt<T>, item: T): OneMany<T>;
16
16
  export declare function concat<T>(a: Opt<T>, b: Opt<T>): Opt<T>;
17
17
  export declare function size<T>(data: Opt<T>): number;
18
18
  export declare function filter<T>(data: Opt<T>, cb: (item: T) => boolean): Opt<T>;
@@ -25,3 +25,4 @@ export declare function filterMap<T, R>(data: Opt<T>, cb: (item: T) => undefined
25
25
  export declare function findSorted<T>(compare: Compare<T>, data: T[], item: T): T | undefined;
26
26
  export declare function findIndexSorted<T>(compare: Compare<T>, data: T[], item: T): number;
27
27
  export declare function addSorted<T, U extends T[]>(compare: Compare<T>, data: U, item: T): U;
28
+ export declare function groupBy<T, U>(data: Opt<T>, cb: (item: T) => U): Map<U, OneMany<T>>;
@@ -17,7 +17,7 @@ export declare enum BindingType {
17
17
  }
18
18
  export interface Sources {
19
19
  state: Opt<Binding>;
20
- input: Opt<InputBinding>;
20
+ param: Opt<InputBinding | ParamBinding>;
21
21
  }
22
22
  export interface Binding {
23
23
  id: number;
@@ -43,6 +43,9 @@ export interface Binding {
43
43
  export interface InputBinding extends Binding {
44
44
  type: BindingType.input;
45
45
  }
46
+ export interface ParamBinding extends Binding {
47
+ type: BindingType.param;
48
+ }
46
49
  export type ReferencedBindings = Opt<Binding>;
47
50
  export type Intersection = Many<Binding>;
48
51
  type FnExtra = (t.FunctionExpressionExtra | t.ArrowFunctionExpressionExtra | t.FunctionDeclarationExtra) & {
@@ -87,7 +90,7 @@ export declare const intersectionMeta: WeakMap<Intersection, {
87
90
  scopeOffset: Binding | undefined;
88
91
  }>;
89
92
  export declare function setBindingDownstream(binding: Binding, expr: boolean | Opt<t.NodeExtra>): void;
90
- export declare function createSources(state: Sources["state"], input: Sources["input"]): Sources;
93
+ export declare function createSources(state: Sources["state"], param: Sources["param"]): Sources;
91
94
  export declare function compareSources(a: Sources, b: Sources): number;
92
95
  export declare function mergeSources(a: undefined | Sources, b: undefined | Sources): Sources | undefined;
93
96
  export declare const bindingUtil: Sorted<Binding>;
@@ -1,7 +1,8 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import type { AccessorPrefix } from "../../common/accessor.debug";
3
+ import type { ParamSerializeReasonGroups } from "../visitors/program";
3
4
  import { Sorted } from "./optional";
4
- import type { Binding, ReferencedBindings } from "./references";
5
+ import type { Binding, InputBinding, ParamBinding, ReferencedBindings } from "./references";
5
6
  import { type SerializeReason } from "./serialize-reasons";
6
7
  export declare enum ContentType {
7
8
  Comment = 0,
@@ -20,7 +21,7 @@ export interface Section {
20
21
  binding: Binding;
21
22
  prefix: AccessorPrefix;
22
23
  } | undefined;
23
- params: undefined | Binding;
24
+ params: undefined | ParamBinding | InputBinding;
24
25
  referencedLocalClosures: ReferencedBindings;
25
26
  referencedClosures: ReferencedBindings;
26
27
  referencedHoists: ReferencedBindings;
@@ -28,6 +29,8 @@ export interface Section {
28
29
  hoisted: ReferencedBindings;
29
30
  serializeReason: undefined | SerializeReason;
30
31
  serializeReasons: Map<symbol, SerializeReason>;
32
+ paramReasonGroups: ParamSerializeReasonGroups | undefined;
33
+ returnSerializeReason: SerializeReason | undefined;
31
34
  isHoistThrough: true | undefined;
32
35
  upstreamExpression: t.NodeExtra | undefined;
33
36
  downstreamBinding: Binding | undefined;
@@ -0,0 +1,5 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import type { SerializeReason, SerializeReasons } from "./serialize-reasons";
3
+ export declare function getSerializeGuard(reason: undefined | SerializeReason, optional: boolean): t.Expression | undefined;
4
+ export declare function getSerializeGuardForAny(reasons: undefined | SerializeReasons, optional: boolean): t.Expression | undefined;
5
+ export declare function getExprIfSerialized<T extends undefined | SerializeReason, U extends t.Expression>(reason: T, expr: U): T extends {} ? U : undefined;
@@ -1,7 +1,7 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import { AccessorPrefix, AccessorProp } from "../../common/types";
3
- import { type Opt } from "./optional";
4
- import { type Binding, type ReferencedBindings, type Sources } from "./references";
3
+ import { type OneMany, type Opt } from "./optional";
4
+ import { type Binding, type InputBinding, type ParamBinding, type ReferencedBindings, type Sources } from "./references";
5
5
  import type { Section } from "./sections";
6
6
  export type SerializeReasons = true | [Sources, ...Sources[]];
7
7
  export type SerializeReason = true | Sources;
@@ -14,6 +14,10 @@ export declare function forceSectionSerialize(section: Section, prop?: AccessorP
14
14
  export declare function forceBindingSerialize(section: Section, binding: Binding, prefix?: AccessorPrefix | symbol): void;
15
15
  export declare function isSectionForceSerialized(section: Section, prop?: AccessorProp | symbol): boolean;
16
16
  export declare function isBindingForceSerialized(section: Section, binding: Binding, prefix?: AccessorPrefix | symbol): boolean;
17
+ export declare function isReasonDynamic(reason: undefined | SerializeReason): reason is {
18
+ state: undefined;
19
+ param: OneMany<InputBinding | ParamBinding>;
20
+ };
17
21
  export declare function addSectionSerializeReasonExpr(section: Section, expr: undefined | boolean | Opt<t.NodeExtra>, prop?: AccessorProp | symbol): void;
18
22
  export declare function addBindingSerializeReasonExpr(section: Section, binding: Binding, expr: undefined | boolean | Opt<t.NodeExtra>, prefix?: AccessorPrefix | symbol): void;
19
23
  export declare function addSectionSerializeReasonRef(section: Section, ref: undefined | boolean | ReferencedBindings, prop?: AccessorProp | symbol): void;
@@ -8,7 +8,7 @@ export type Signal = {
8
8
  valueAccessor?: t.Expression;
9
9
  referencedBindings: ReferencedBindings;
10
10
  section: Section;
11
- build: undefined | (() => t.Expression);
11
+ build: undefined | (() => t.Expression | undefined);
12
12
  register?: boolean;
13
13
  values: Array<{
14
14
  signal: Signal;
@@ -34,6 +34,7 @@ export declare const getHTMLSectionStatements: (section: Section) => t.Statement
34
34
  export declare function getHoistFunctionIdentifier(hoistedBinding: Binding): t.Identifier;
35
35
  export declare function getSignal(section: Section, referencedBindings: ReferencedBindings, name?: string): Signal;
36
36
  export declare function initValue(binding: Binding, isLet?: boolean): Signal;
37
+ export declare function signalHasStatements(signal: Signal): boolean;
37
38
  export declare function getSignalFn(signal: Signal): t.Expression;
38
39
  export declare function subscribe(references: ReferencedBindings, subscriber: Signal): void;
39
40
  export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
@@ -9,7 +9,7 @@ type VisitCodes = WalkCode.Get | WalkCode.Inside | WalkCode.Replace | WalkCode.D
9
9
  export declare function enter(path: t.NodePath<any>): void;
10
10
  export declare function exit(path: t.NodePath<any>): void;
11
11
  export declare function enterShallow(path: t.NodePath<any>): void;
12
- export declare function injectWalks(tag: t.NodePath<t.MarkoTag>, expr: t.Expression): void;
12
+ export declare function injectWalks(tag: t.NodePath<t.MarkoTag>, expr: t.Expression | undefined): void;
13
13
  export declare function visit(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder | t.Program>, code: VisitCodes): void;
14
14
  export declare function getWalkString(section: Section): t.Expression | undefined;
15
15
  export {};
@@ -6,9 +6,13 @@ export declare function writeTo(path: t.NodePath<any>, trailer?: boolean): (strs
6
6
  export declare function consumeHTML(path: t.NodePath<any>): t.ExpressionStatement | undefined;
7
7
  export declare function flushBefore(path: t.NodePath<any>): void;
8
8
  export declare function flushInto(path: t.NodePath<t.MarkoTag> | t.NodePath<t.Program>): void;
9
- export declare function getSectionMeta(section: Section): {
10
- setup: t.Identifier | undefined;
9
+ interface SectionMeta {
10
+ setup: t.Expression | undefined;
11
11
  walks: t.Expression | undefined;
12
12
  writes: t.Expression | undefined;
13
- };
13
+ decls: t.VariableDeclarator[] | undefined;
14
+ }
15
+ export declare const getSectionMeta: (section: Section) => SectionMeta;
16
+ export declare function getSectionMetaIdentifiers(section: Section): SectionMeta;
14
17
  export declare function markNode(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder>, nodeBinding: Binding, reason: undefined | false | SerializeReason): void;
18
+ export {};
@@ -1,9 +1,5 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import type { SerializeReason, SerializeReasons } from "../../util/serialize-reasons";
3
2
  export declare function getTemplateContentName(): string;
4
- export declare function getSerializeGuard(reason: undefined | SerializeReason, optional: boolean): t.CallExpression | t.NumericLiteral | undefined;
5
- export declare function getSerializeGuardForAny(reasons: undefined | SerializeReasons, optional: boolean): t.Expression | undefined;
6
- export declare function getExprIfSerialized<T extends undefined | SerializeReason, U extends t.Expression>(reason: T, expr: U): T extends {} ? U : undefined;
7
3
  declare const _default: {
8
4
  translate: {
9
5
  exit(this: unknown, program: t.NodePath<t.Program>): void;
@@ -1,31 +1,24 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import { type Binding, type Sources } from "../../util/references";
3
- export type InputSerializeReason = NonNullable<Sources["input"]>;
4
- export type InputSerializeReasons = [
5
- InputSerializeReason,
6
- ...InputSerializeReason[]
2
+ import { type BindingPropTree } from "../../util/binding-prop-tree";
3
+ import { type Sources } from "../../util/references";
4
+ import { type Section } from "../../util/sections";
5
+ export type ParamSerializeReason = NonNullable<Sources["param"]>;
6
+ export type ParamSerializeReasonGroups = [
7
+ ParamSerializeReason,
8
+ ...ParamSerializeReason[]
7
9
  ];
8
10
  export declare let cleanIdentifier: t.Identifier;
9
11
  export declare let scopeIdentifier: t.Identifier;
10
12
  export declare function isScopeIdentifier(node: t.Node): node is t.Identifier;
11
- export type TemplateExport = {
12
- id: string;
13
- binding: Binding;
14
- props: {
15
- [prop: string]: TemplateExport;
16
- } | undefined;
17
- };
18
- export type TemplateExports = TemplateExport["props"];
13
+ export type TemplateExports = BindingPropTree["props"];
19
14
  declare module "@marko/compiler/dist/types" {
20
15
  interface ProgramExtra {
21
- inputSerializeReasons?: InputSerializeReasons;
22
- returnSerializeReason?: InputSerializeReason | true;
23
16
  returnValueExpr?: t.NodeExtra;
24
17
  domExports?: {
25
18
  template: string;
26
19
  walks: string;
27
20
  setup: string;
28
- input: TemplateExport | undefined;
21
+ params: BindingPropTree | undefined;
29
22
  };
30
23
  }
31
24
  }
@@ -44,4 +37,4 @@ declare const _default: {
44
37
  };
45
38
  };
46
39
  export default _default;
47
- export declare function resolveSerializeReasonId(inputSerializeReasons: InputSerializeReasons, reason: InputSerializeReason): number;
40
+ export declare function resolveSerializeReasonId(paramReasonGroups: NonNullable<Section["paramReasonGroups"]>, reason: ParamSerializeReason): number;
@@ -1,15 +1,4 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import { type Binding } from "../../util/references";
3
- declare const kChildScopeBinding: unique symbol;
4
- declare const kChildOffsetScopeBinding: unique symbol;
5
- declare const kChildInputSerializePropIds: unique symbol;
6
- declare module "@marko/compiler/dist/types" {
7
- interface MarkoTagExtra {
8
- [kChildScopeBinding]?: Binding;
9
- [kChildOffsetScopeBinding]?: Binding;
10
- [kChildInputSerializePropIds]?: [symbol, ...symbol[]];
11
- }
12
- }
13
2
  declare const _default: {
14
3
  analyze: {
15
4
  enter(this: unknown, tag: t.NodePath<t.MarkoTag>): void;
@@ -21,4 +10,3 @@ declare const _default: {
21
10
  };
22
11
  export default _default;
23
12
  export declare function getTagRelativePath(tag: t.NodePath<t.MarkoTag>): string;
24
- export declare function getChildScopeBinding(path: t.NodePath<t.MarkoTag>): Binding;
@@ -1,11 +1,13 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import { type Binding } from "../../util/references";
3
+ import { type Section } from "../../util/sections";
3
4
  declare const kDOMBinding: unique symbol;
4
5
  declare const kChildOffsetScopeBinding: unique symbol;
5
6
  declare module "@marko/compiler/dist/types" {
6
7
  interface MarkoTagExtra {
7
8
  [kDOMBinding]?: Binding;
8
9
  [kChildOffsetScopeBinding]?: Binding;
10
+ defineBodySection?: Section;
9
11
  }
10
12
  }
11
13
  declare const _default: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.79",
3
+ "version": "6.0.80",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",