marko 6.3.56 → 6.4.1

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.
Files changed (135) hide show
  1. package/cheatsheet.md +3 -3
  2. package/dist/common/constants/accessor-prefix.d.ts +2 -0
  3. package/dist/common/constants/accessor-prefix.debug.d.ts +2 -0
  4. package/dist/common/constants/accessor-prop.d.ts +3 -0
  5. package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
  6. package/dist/common/constants/reserved-id.d.ts +5 -0
  7. package/dist/common/errors.d.ts +1 -1
  8. package/dist/common/types.d.ts +11 -2
  9. package/dist/debug/dom/catch.feat.js +12 -14
  10. package/dist/debug/dom/catch.feat.mjs +12 -14
  11. package/dist/debug/dom/controllable-input.feat.js +1 -1
  12. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable-open.feat.js +1 -1
  14. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable-select.feat.js +1 -1
  16. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  17. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  18. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  19. package/dist/debug/dom/controllable.feat.js +1 -1
  20. package/dist/debug/dom/controllable.feat.mjs +1 -1
  21. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  22. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  23. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  24. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  25. package/dist/debug/dom/lazy.feat.js +4 -0
  26. package/dist/debug/dom/lazy.feat.mjs +4 -0
  27. package/dist/debug/dom/placeholder.feat.js +1 -1
  28. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  29. package/dist/debug/{dom-DcwejnYg.js → dom-ClV4kVOO.js} +263 -193
  30. package/dist/debug/{dom-BeCNT5R5.mjs → dom-LFrKxOk5.mjs} +246 -182
  31. package/dist/debug/dom.js +14 -12
  32. package/dist/debug/dom.mjs +14 -12
  33. package/dist/debug/html.js +826 -685
  34. package/dist/debug/html.mjs +822 -683
  35. package/dist/dom/abort-signal.d.ts +2 -0
  36. package/dist/dom/catch.feat.js +6 -7
  37. package/dist/dom/catch.feat.mjs +5 -7
  38. package/dist/dom/control-flow.d.ts +3 -5
  39. package/dist/dom/controllable-input.feat.js +3 -2
  40. package/dist/dom/controllable-input.feat.mjs +1 -1
  41. package/dist/dom/controllable-open.feat.js +3 -2
  42. package/dist/dom/controllable-open.feat.mjs +1 -1
  43. package/dist/dom/controllable-select.feat.js +3 -2
  44. package/dist/dom/controllable-select.feat.mjs +1 -1
  45. package/dist/dom/controllable-textarea.feat.js +3 -2
  46. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  47. package/dist/dom/controllable.feat.js +3 -2
  48. package/dist/dom/controllable.feat.mjs +1 -1
  49. package/dist/dom/dynamic-tag-script.feat.js +3 -2
  50. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  51. package/dist/dom/dynamic-tag-var.feat.js +2 -1
  52. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  53. package/dist/dom/lazy.feat.d.ts +1 -0
  54. package/dist/dom/lazy.feat.js +4 -0
  55. package/dist/dom/lazy.feat.mjs +4 -0
  56. package/dist/dom/load.d.ts +3 -3
  57. package/dist/dom/placeholder.feat.js +4 -3
  58. package/dist/dom/placeholder.feat.mjs +1 -1
  59. package/dist/dom/queue.d.ts +2 -4
  60. package/dist/dom/resume.d.ts +1 -1
  61. package/dist/dom/scope.d.ts +0 -1
  62. package/dist/dom/signals.d.ts +3 -2
  63. package/dist/{dom-QEF0csuC.js → dom-CNglVi8P.js} +222 -185
  64. package/dist/{dom-BwNsIevR.mjs → dom-DfP3MCo0.mjs} +126 -90
  65. package/dist/dom.js +59 -56
  66. package/dist/dom.mjs +34 -32
  67. package/dist/html/attrs.d.ts +4 -2
  68. package/dist/html/dynamic-tag.d.ts +1 -1
  69. package/dist/html/inlined-runtimes.d.ts +1 -1
  70. package/dist/html/inlined-runtimes.debug.d.ts +1 -1
  71. package/dist/html/serializer.d.ts +1 -1
  72. package/dist/html/writer.d.ts +39 -33
  73. package/dist/html.d.ts +2 -2
  74. package/dist/html.js +526 -424
  75. package/dist/html.mjs +524 -423
  76. package/dist/translator/core/html-comment.d.ts +0 -7
  77. package/dist/translator/core/let.d.ts +0 -5
  78. package/dist/translator/core/show.d.ts +2 -5
  79. package/dist/translator/core/style.d.ts +6 -8
  80. package/dist/translator/index.d.ts +9 -0
  81. package/dist/translator/index.js +8195 -7939
  82. package/dist/translator/util/binding-has-prop.d.ts +3 -1
  83. package/dist/translator/util/binding-prop-tree.d.ts +4 -4
  84. package/dist/translator/util/bindings.d.ts +127 -0
  85. package/dist/translator/util/body-to-text-literal.d.ts +1 -2
  86. package/dist/translator/util/branch-tag.d.ts +7 -7
  87. package/dist/translator/util/constants/binding-type.d.ts +5 -6
  88. package/dist/translator/util/constants/slot-kind.d.ts +14 -0
  89. package/dist/translator/util/constants/structure-kind.d.ts +1 -1
  90. package/dist/translator/util/entry-builder.d.ts +2 -0
  91. package/dist/translator/util/evaluate.d.ts +11 -10
  92. package/dist/translator/util/finalize-references.d.ts +4 -0
  93. package/dist/translator/util/for-selector.d.ts +1 -1
  94. package/dist/translator/util/generate-uid.d.ts +7 -0
  95. package/dist/translator/util/get-declared-binding-expression.d.ts +2 -2
  96. package/dist/translator/util/is-core-tag.d.ts +0 -3
  97. package/dist/translator/util/is-only-child-in-parent.d.ts +2 -7
  98. package/dist/translator/util/known-tag.d.ts +8 -7
  99. package/dist/translator/util/read-replacement.d.ts +3 -0
  100. package/dist/translator/util/reasons.d.ts +32 -0
  101. package/dist/translator/util/references.d.ts +69 -167
  102. package/dist/translator/util/runtime.d.ts +3 -3
  103. package/dist/translator/util/scope-accessor.d.ts +14 -0
  104. package/dist/translator/util/scope-read.d.ts +1 -1
  105. package/dist/translator/util/sections.d.ts +56 -50
  106. package/dist/translator/util/set-tag-derived-from.d.ts +7 -0
  107. package/dist/translator/util/setup-work.d.ts +4 -0
  108. package/dist/translator/util/signals.d.ts +8 -12
  109. package/dist/translator/util/slots.d.ts +50 -0
  110. package/dist/translator/util/solve-reasons.d.ts +10 -0
  111. package/dist/translator/util/sources.d.ts +21 -0
  112. package/dist/translator/util/structure.d.ts +5 -2
  113. package/dist/translator/util/tag-facts.d.ts +21 -0
  114. package/dist/translator/util/tag-name-type.d.ts +4 -1
  115. package/dist/translator/util/translate-attrs.d.ts +2 -0
  116. package/dist/translator/util/translate-var.d.ts +3 -0
  117. package/dist/translator/util/write-guard.d.ts +12 -0
  118. package/dist/translator/util/writer.d.ts +3 -3
  119. package/dist/translator/visitors/export-declaration.d.ts +9 -0
  120. package/dist/translator/visitors/function.d.ts +5 -4
  121. package/dist/translator/visitors/import-declaration.d.ts +2 -2
  122. package/dist/translator/visitors/placeholder.d.ts +0 -3
  123. package/dist/translator/visitors/program/index.d.ts +13 -3
  124. package/dist/translator/visitors/referenced-identifier.d.ts +2 -1
  125. package/dist/translator/visitors/tag/custom-tag.d.ts +1 -1
  126. package/dist/translator/visitors/tag/dynamic-tag.d.ts +0 -3
  127. package/dist/translator/visitors/tag/index.d.ts +2 -1
  128. package/dist/translator/visitors/tag/native-tag.d.ts +26 -11
  129. package/package.json +3 -3
  130. package/dist/translator/util/insertion-context.d.ts +0 -1
  131. package/dist/translator/util/is-non-html-text.d.ts +0 -3
  132. package/dist/translator/util/serialize-guard.d.ts +0 -11
  133. package/dist/translator/util/serialize-reasons.d.ts +0 -37
  134. package/dist/translator/util/set-tag-sections-downstream.d.ts +0 -6
  135. package/dist/translator/util/setup-statements.d.ts +0 -5
@@ -1,103 +1,20 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import { type AccessorPrefix } from "../../common/accessor.debug";
3
- import * as BindingType from "./constants/binding-type";
4
- import { type Many, type Opt, type SortedMany, type SortedOpt, Sorted } from "./optional";
2
+ import { type Binding, BindingType, type Getter, type ParamBinding, type ReferencedBindings } from "./bindings";
3
+ import { type OneMany, type Opt, type SortedOpt } from "./optional";
4
+ import { type Reason } from "./reasons";
5
5
  import { type Section } from "./sections";
6
- import { type SerializeKey, type SerializeReason } from "./serialize-reasons";
7
- import { type Signal } from "./signals";
8
- export declare const kBranchSerializeReason: unique symbol;
9
- export type Aliases = undefined | Binding | {
10
- [property: string]: Aliases;
11
- };
12
- type BindingType = BindingType.Value;
13
- export { BindingType };
14
- export interface Sources {
15
- state: SortedOpt<Binding>;
16
- param: SortedOpt<InputBinding | ParamBinding>;
17
- global: true | undefined;
18
- /** Serialized unconditionally; the sources still say what it reads. */
19
- forced: true | undefined;
20
- }
21
- export declare const FORCED: Sources;
22
- export declare const globalSources: Sources;
23
- export interface Binding {
24
- id: number;
25
- uid: number;
26
- name: string;
27
- originalName: string | undefined;
28
- type: BindingType;
29
- loc: t.SourceLocation | null;
30
- section: Section;
31
- closureSections: SortedOpt<Section>;
32
- /** The identifier of each emitted assignment to it (set in finalize). */
33
- assignments: Opt<AssignedBindingExtra>;
34
- /** Emitted code the graph stopped tracking still names it. */
35
- untracked?: true;
36
- sources: undefined | Sources;
37
- /** The intersection whose work computes it, or the nearest one upstream. Set on alias roots only. */
38
- upstreamIntersection: Intersection | undefined;
39
- /** Complete only once `finalizeReferences` runs at program analyze exit. */
40
- reads: Set<ReferencedExtra>;
41
- aliases: Set<Binding>;
42
- hoists: SortedOpt<Section>;
43
- getters: Map<Getter["hoisted"], boolean>;
44
- property: string | undefined;
45
- propertyAliases: Map<string, Binding>;
46
- excludeProperties: SortedOpt<string>;
47
- upstreamAlias: Binding | undefined;
48
- /** The value these `<for>` params iterate, by `of` or `in`. */
49
- iterates: {
50
- expr: t.NodeExtra;
51
- type: "of" | "in";
52
- } | undefined;
53
- restOffset: number | undefined;
54
- scopeOffset: Binding | undefined;
55
- scopeAccessor: string | undefined;
56
- export: string | undefined;
57
- directContentExport: string | undefined;
58
- /** A name declared for this value, or all of it but its `excludeProperties`
59
- * (a rest element), even once pruned. */
60
- declaredAlias: Binding | undefined;
61
- /** The attribute tag `<for>` param a local closure holds in its section. */
62
- upstreamLocal: Binding | undefined;
63
- /** An attribute tag `<for>` param's local closure in each content the loop
64
- * creates that reads it. */
65
- localClosures: Map<Section, Binding> | undefined;
66
- declared: boolean;
67
- nullable: boolean;
68
- /** Settled only once `finalizeReferences` runs at program analyze exit. */
69
- pruned: boolean | undefined;
70
- exposed: boolean;
71
- forcePersist: boolean;
72
- /** Binding-side counterpart of `Section.serializePropKeys`, keyed by
73
- * accessor prefix (`undefined` is the plain binding key). */
74
- serializePropKeys: Map<AccessorPrefix | symbol | undefined, SerializeKey> | undefined;
75
- reserveSize: number;
76
- }
77
- export interface InputBinding extends Binding {
78
- type: typeof BindingType.input;
79
- }
80
- export interface ParamBinding extends Binding {
81
- type: typeof BindingType.param;
82
- }
83
- export type ReferencedBindings = SortedOpt<Binding>;
84
- export type Intersection = SortedMany<Binding>;
85
6
  interface ReferencedFunctionExtra extends t.FunctionExtra, ReferencedExtra {
86
7
  }
87
- export interface Getter {
88
- hoisted: Section | false;
89
- invoked: boolean;
90
- }
91
- interface Read {
8
+ export interface Read {
92
9
  binding: Binding;
93
10
  extra: t.NodeExtra;
94
11
  ownVar: boolean;
95
12
  getter: Getter | undefined;
96
13
  comparedTo: t.Node | undefined;
97
14
  deferred: boolean;
98
- serializedValue?: true;
15
+ inFunction: boolean;
99
16
  }
100
- interface ExtraRead {
17
+ export interface ExtraRead {
101
18
  binding: Binding;
102
19
  props: Opt<string>;
103
20
  ownVar: boolean;
@@ -105,25 +22,42 @@ interface ExtraRead {
105
22
  /** Set for same-section local reads: the function root that owns the read. */
106
23
  localFn?: ReferencedFunctionExtra;
107
24
  }
25
+ declare const kReferencedBindings: unique symbol;
26
+ declare const kLazyBindings: unique symbol;
27
+ declare const kGlobalBindings: unique symbol;
28
+ declare const kReferencedBindingsInFunction: unique symbol;
29
+ declare const kConstantBindingsInFunction: unique symbol;
108
30
  declare module "@marko/compiler/dist/types" {
109
31
  interface ProgramExtra {
110
- /** The template emits a `$global` read, so HTML output declares a const
111
- * for it. */
32
+ /** An expression reads `$global`, so HTML output declares a const for it. */
112
33
  hasGlobalRead?: true;
113
34
  }
35
+ interface MarkoTagExtra {
36
+ /** The dom binding the tag is addressed by: its node, marker or child
37
+ * scope; an only child control flow tag shares its parent's. */
38
+ nodeBinding?: Binding;
39
+ }
40
+ interface MarkoPlaceholderExtra {
41
+ /** The dom binding the placeholder's text node is held in. */
42
+ nodeBinding?: Binding;
43
+ }
114
44
  interface NodeExtra {
115
45
  section?: Section;
116
- /** The dom node binding of a tag rendering a branch or body (a dynamic
117
- * tag, `<try>`, `<await>`). */
118
- nodeBinding?: Binding;
119
- referencedBindings?: ReferencedBindings;
120
- downstream?: SortedOpt<Binding>;
46
+ [kReferencedBindings]?: ReferencedBindings;
47
+ [kLazyBindings]?: ReferencedBindings;
48
+ [kGlobalBindings]?: ReferencedBindings;
49
+ /** The bindings it feeds, in the order it feeds them: a call site's
50
+ * values feed the child template's, so no one template's order sorts them. */
51
+ derives?: Opt<Binding>;
121
52
  /** The initial value of the binding it feeds, which keeps it rather than
122
53
  * following it, so the binding derives no sources from it. */
123
54
  initialValue?: true;
55
+ /** Its value has no side effect to evaluate, so an unread one can go: an
56
+ * expression's from `evaluate`, a tag's from its value attributes. */
57
+ pure?: boolean;
124
58
  /** The tag-root `KnownExprs` of the call site that linked this expression
125
- * to a downstream template's binding, for dereferencing its reasons. */
126
- downstreamExprs?: KnownExprs;
59
+ * to a derives template's binding, for dereferencing its reasons. */
60
+ callSiteExprs?: KnownExprs;
127
61
  binding?: Binding;
128
62
  assignment?: Binding;
129
63
  assignmentTo?: Binding;
@@ -132,27 +66,31 @@ declare module "@marko/compiler/dist/types" {
132
66
  /** The expression this node sits in: dropped or merged as one. */
133
67
  exprRoot?: NodeExtra;
134
68
  isEffect?: true;
135
- /** A value here may reach the client as written (a change handler, a
136
- * native spread, a dynamic tag's input), so a function in it registers. */
137
- forceRegister?: true;
69
+ /** Retained past render (a change handler, a native spread, a dynamic tag's
70
+ * input), so client code may read a value here as it is, a function too. */
71
+ retained?: true;
72
+ /** Consumed where it is written (a handler its tag attaches, an
73
+ * effect's callback, a key function), so it reaches no client as is. */
74
+ consumed?: true;
75
+ /** Any function it holds is only ever invoked, never read as a value, so
76
+ * the reads inside resolve when it runs. */
138
77
  invokeOnly?: true;
139
- lazyBindings?: ReferencedBindings;
140
- /** `$global` bindings this expression reads: the root means an opaque
141
- * (dynamic/aliased) read, a property alias names the key. */
142
- globalBindings?: ReferencedBindings;
143
78
  /** The bindings this expression reads only by spreading them as is. */
144
79
  spreadFrom?: SortedOpt<Binding>;
145
- nativeTagSpread?: true;
80
+ /** A `content` it spreads is rendered (as the element's body, or as a
81
+ * `<meta>`'s attribute), so its effect never reads it. */
82
+ rendersContent?: true;
146
83
  merged?: NodeExtra;
147
84
  }
148
85
  interface FunctionExtra {
149
86
  referencesScope?: boolean;
150
- referencedBindingsInFunction?: ReferencedBindings;
87
+ [kReferencedBindingsInFunction]?: ReferencedBindings;
151
88
  referencedLocalBindingsInFunction?: SortedOpt<Binding>;
152
- constantBindingsInFunction?: ReferencedBindings;
89
+ [kConstantBindingsInFunction]?: ReferencedBindings;
153
90
  name?: string;
154
91
  registerId?: string;
155
- registerReason?: SerializeReason;
92
+ /** When client code reads the function itself, which registers it. */
93
+ reason?: Reason;
156
94
  exportRegisterId?: string;
157
95
  }
158
96
  interface ArrowFunctionExpressionExtra extends FunctionExtra {
@@ -162,68 +100,27 @@ declare module "@marko/compiler/dist/types" {
162
100
  interface FunctionExpressionExtra extends FunctionExtra {
163
101
  }
164
102
  }
165
- export declare function createBinding(name: string, type: Binding["type"], refSection: Section, upstreamAlias?: Binding["upstreamAlias"], property?: string, excludeProperties?: SortedOpt<string>, loc?: t.SourceLocation | null, refDeclared?: boolean): Binding;
166
- export declare function getOrCreatePropertyAlias(binding: Binding, property: string): Binding;
167
- export declare function getPropertyAlias(binding: Binding | undefined, properties: Opt<string>): Binding | undefined;
168
- export declare function isTagVarRead(tag: t.NodePath<t.MarkoTag>): boolean;
103
+ export declare function isTagVarUsed(tag: t.NodePath<t.MarkoTag>): boolean;
169
104
  export declare function trackDomVarReferences(tag: t.NodePath<t.MarkoTag>, binding: Binding): Binding | undefined;
170
- export declare function trackVarReferences(tag: t.NodePath<t.MarkoTag>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
105
+ export declare function trackVarReferences(tag: t.NodePath<t.MarkoTag>, type: BindingType, aliased?: Binding["aliasOf"]): Binding | undefined;
171
106
  export declare function trackParamsReferences(body: t.NodePath<t.MarkoTagBody | t.Program>, type: BindingType): Binding | undefined;
172
107
  export declare function isReferenceInOwnBody(bindingPath: t.NodePath, reference: t.NodePath): boolean;
173
108
  export declare function isReferenceHoisted(bindingPath: t.NodePath, reference: t.NodePath): boolean;
174
109
  export declare function setReferencesScope(path: t.NodePath<any>): void;
175
110
  export declare function trackGlobalReference(path: t.NodePath<t.Identifier>): void;
176
111
  export declare function mergeReferences<T extends t.Node>(section: Section, target: T, nodes: (t.Node | undefined)[]): NonNullable<T["extra"]> & ReferencedExtra;
177
- export declare function compareReferences(a: ReferencedBindings, b: ReferencedBindings): number;
178
- export declare function finalizeReferences(): void;
179
- /**
180
- * Every member computed from one local source in the same pass, or the
181
- * intersection's own render id and scope offset.
182
- */
183
- type IntersectionMeta = {
184
- source: Binding;
185
- id?: undefined;
186
- scopeOffset?: undefined;
187
- } | {
188
- source: undefined;
189
- id: number;
190
- scopeOffset: Binding | undefined;
191
- };
192
- export declare const intersectionMeta: WeakMap<Intersection, IntersectionMeta>;
193
- export declare function setBindingDownstream(binding: Binding, expr: boolean | Opt<t.NodeExtra>, exprs?: KnownExprs): void;
194
- export declare function createSources(state: Sources["state"], param: Sources["param"], global?: Sources["global"], forced?: Sources["forced"]): Sources;
195
- export declare function compareSources(a: Sources, b: Sources): number;
196
- export declare function mergeSources(a: undefined | Sources, b: undefined | Sources): Sources | undefined;
197
- export declare const bindingUtil: Sorted<Binding>;
198
- export declare const propsUtil: Sorted<string>;
112
+ export declare function mergeReferenceGroup(section: Section, nodes: (t.Node | undefined)[]): ReferencedExtra;
113
+ export declare function setDerivedFrom(binding: Binding, expr: boolean | Opt<t.NodeExtra>, exprs?: KnownExprs): void;
114
+ export declare const getAssignments: () => AssignedBindingExtra[];
115
+ export declare const getReadsByExpression: () => Map<ReferencedExtra, Opt<Read>>;
116
+ export declare const getFunctionReadsByExpression: () => Map<ReferencedExtra, Map<ReferencedFunctionExtra, OneMany<Read>>>;
117
+ export declare const getReferenceFinalizers: () => (() => void)[];
199
118
  export declare function onFinalizeReferences(finalize: () => void): void;
200
- export declare function getExpressionReads(exprExtra: ReferencedExtra): Opt<Read>;
201
119
  export declare function addRead(exprExtra: ReferencedExtra, extra: t.NodeExtra, binding: Binding, section: Section, getter: Getter | undefined): Read;
202
120
  export declare function dropNodes(node: t.Node | t.Node[]): void;
203
- export declare function untrackNode(node: t.Node): void;
204
- export declare function getCanonicalBinding(binding: Binding): Binding;
205
- export declare function someAlias<A>(binding: Binding, test: (binding: Binding, arg: A) => boolean, arg: A, directOnly?: boolean): boolean;
206
- export declare function someUpstream<A>(binding: Binding | undefined, test: (binding: Binding, arg: A) => boolean, arg: A): boolean;
207
- export declare function isDirectAlias(binding: Binding): boolean;
208
- export declare function getAllTagReferenceNodes(tag: t.MarkoTag, referenceNodes?: t.Node[], getAttrTagNodes?: (attrTag: t.MarkoTag) => t.Node[]): t.Node[];
209
- export declare function getScopeAccessorLiteral(binding: Binding, encoded?: boolean, includeId?: boolean): t.NumericLiteral | t.StringLiteral;
210
- export declare function getScopeAccessor(binding: Binding, encoded?: boolean, includeId?: boolean): string;
211
- export declare function getLocalsScopeAccessor(binding: Binding): string;
212
- export declare function getPrefixedScopeAccessor(binding: Binding, prefix: AccessorPrefix): string;
213
- export declare function getClosureAccessorId(binding: Binding): number;
214
- export declare function getDebugScopeAccess(binding: Binding): {
215
- root: Binding;
216
- access: string;
217
- };
218
- export declare function getDebugName(binding: Binding): string;
219
- export declare function getDebugNames(refs: ReferencedBindings): string;
220
- export declare function getDebugNamesAsIdentifier(refs: ReferencedBindings): string;
221
- export declare function getSectionInstancesAccessor(section: Section): string;
222
- export declare function getSectionInstancesAccessorLiteral(section: Section): t.StringLiteral;
223
- export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression, signal?: Signal): t.Expression | undefined;
224
- export declare function isInvokeOnlyBinding(binding: Binding): boolean;
225
- export declare function hasNonConstantPropertyAlias(ref: Binding): boolean;
226
- export declare function pruneBinding(binding: Binding, settled?: true): boolean;
121
+ export declare function dropExtra(exprExtra: ReferencedExtra): void;
122
+ export declare function dropContent(body: t.MarkoTagBody): void;
123
+ export declare function getAllTagReferenceNodes(tag: t.MarkoTag, referenceNodes?: t.Node[], collectAttrTag?: (attrTag: t.MarkoTag) => void): t.Node[];
227
124
  export declare function createRead(binding: Binding, props: Opt<string>, ownVar?: boolean): ExtraRead;
228
125
  export declare function createGetterRead(binding: Binding, props: Opt<string>, getter: Getter): ExtraRead;
229
126
  export interface ReferencedExtra extends t.NodeExtra {
@@ -241,16 +138,21 @@ export declare function isAssignedBindingExtra(extra: t.NodeExtra | undefined):
241
138
  export interface RegisteredFnExtra extends ReferencedExtra, t.FunctionExtra {
242
139
  name: string;
243
140
  registerId: string;
244
- registerReason: SerializeReason;
141
+ reason: Reason;
245
142
  }
246
143
  export declare function isRegisteredFnExtra(extra: t.NodeExtra | undefined): extra is RegisteredFnExtra;
144
+ export declare function getReferencedBindings(extra: t.NodeExtra | undefined): ReferencedBindings;
145
+ export declare function getLazyBindings(extra: t.NodeExtra | undefined): ReferencedBindings;
146
+ export declare function getGlobalBindings(extra: t.NodeExtra | undefined): ReferencedBindings;
147
+ export declare function getReferencedBindingsInFunction(extra: t.FunctionExtra): ReferencedBindings;
148
+ export declare function getConstantBindingsInFunction(extra: t.FunctionExtra): ReferencedBindings;
149
+ export declare function setResolvedFunctionReads(extra: t.FunctionExtra, referencedBindings: ReferencedBindings, constantBindings: ReferencedBindings): void;
150
+ export declare function setResolvedReads(extra: ReferencedExtra, referencedBindings: ReferencedBindings, lazyBindings: ReferencedBindings, globalBindings: ReferencedBindings): void;
247
151
  export declare function getCanonicalExtra<T extends t.NodeExtra>(extra: T): T;
248
- export declare function getAllSerializeReasonsForExtra(extra: t.NodeExtra): undefined | SerializeReason;
249
- export declare function getAllSerializeReasonsForBinding(binding: Binding, properties?: Opt<string> | true): undefined | SerializeReason;
250
- export declare function getRegisterReasonForExtra(extra: t.NodeExtra): undefined | SerializeReason;
251
152
  export interface KnownExprs {
252
153
  known?: Record<string, KnownExprs>;
253
154
  value?: t.NodeExtra;
254
155
  }
255
- export declare function mapParamReasonToExpr(exprs: KnownExprs, reason: boolean | Opt<InputBinding | ParamBinding>): true | Many<t.NodeExtra> | t.NodeExtra | undefined;
256
- export declare function mapParamBindingToExpr(exprs: KnownExprs, binding: InputBinding | ParamBinding): Opt<t.NodeExtra>;
156
+ export declare function mapParamReasonToExpr(exprs: KnownExprs, reason: boolean | Opt<ParamBinding>): true | import("./optional").Many<t.NodeExtra> | t.NodeExtra | undefined;
157
+ export declare function mapParamBindingToExpr(exprs: KnownExprs, binding: ParamBinding): Opt<t.NodeExtra>;
158
+ export {};
@@ -1,18 +1,18 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import type { Falsy } from "../../common/types";
3
- import { _attr, _attr_class, _attr_style, _escape, _escape_comment, _escape_script, _escape_style, _unescaped } from "../../html";
3
+ import { _attr, _attr_class, _attr_style, _escape, _escape_script, _escape_style, _unescaped } from "../../html";
4
4
  export type DOMRuntimeHelpers = keyof typeof import("../../dom");
5
5
  export type HTMLRuntimeHelpers = keyof typeof import("../../html");
6
6
  export declare function importRuntime(name: DOMRuntimeHelpers | HTMLRuntimeHelpers): t.Identifier;
7
7
  export declare function registerRuntimeValue(id: string, value: t.Expression): t.AssignmentExpression;
8
8
  export declare function callRuntime(name: DOMRuntimeHelpers | HTMLRuntimeHelpers, ...args: Array<Parameters<typeof t.callExpression>[1][number] | Falsy>): t.CallExpression;
9
9
  export declare function dynamicImport(request: string, ...handlers: Array<t.Expression | Falsy>): t.CallExpression;
10
- export declare const domRuntimeFeatures: readonly ["catch", "controllable", "controllable-input", "controllable-open", "controllable-select", "controllable-textarea", "dynamic-tag-script", "dynamic-tag-var", "placeholder"];
10
+ export declare const domRuntimeFeatures: readonly ["catch", "controllable", "controllable-input", "controllable-open", "controllable-select", "controllable-textarea", "dynamic-tag-script", "dynamic-tag-var", "lazy", "placeholder"];
11
11
  export type DOMRuntimeFeature = (typeof domRuntimeFeatures)[number];
12
12
  export declare function importRuntimeFeature(feature: DOMRuntimeFeature): void;
13
+ export declare function getRuntimeFeatureImport(feature: DOMRuntimeFeature): t.ImportDeclaration;
13
14
  export declare function getHTMLRuntime(): {
14
15
  _escape: typeof _escape;
15
- _escape_comment: typeof _escape_comment;
16
16
  _unescaped: typeof _unescaped;
17
17
  _attr: typeof _attr;
18
18
  _attr_class: typeof _attr_class;
@@ -0,0 +1,14 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { type AccessorPrefix } from "../../common/accessor.debug";
3
+ import { type Binding } from "./bindings";
4
+ import { type Section } from "./sections";
5
+ import { type PlaceSlot } from "./slots";
6
+ export declare function getSlotAccessor(slot: PlaceSlot): string;
7
+ export declare function getScopeOffsetAccessorLiteral(nodeBinding: Binding, encoded?: boolean): t.NumericLiteral | t.StringLiteral;
8
+ export declare function getScopeAccessorLiteral(binding: Binding, encoded?: boolean, includeId?: boolean): t.NumericLiteral | t.StringLiteral;
9
+ export declare function getScopeAccessor(binding: Binding, encoded?: boolean, includeId?: boolean): string;
10
+ export declare function getLocalsScopeAccessor(binding: Binding): string;
11
+ export declare function getPrefixedScopeAccessor(binding: Binding, prefix: AccessorPrefix): string;
12
+ export declare function getClosureAccessorLiteral(binding: Binding): t.NumericLiteral | t.StringLiteral;
13
+ export declare function getSectionInstancesAccessor(section: Section): string;
14
+ export declare function getSectionInstancesAccessorLiteral(section: Section): t.StringLiteral;
@@ -1,5 +1,5 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import { type Binding } from "./references";
2
+ import { type Binding } from "./bindings";
3
3
  import type { Section } from "./sections";
4
4
  export declare function getScopeExpression(section: Section, targetSection: Section): t.Identifier | t.MemberExpression;
5
5
  export declare function createScopeReadExpression(reference: Binding, section?: Section): t.MemberExpression;
@@ -1,20 +1,15 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import type { AccessorPrefix } from "../../common/accessor.debug";
3
- import type { WalkCode } from "../../common/types";
2
+ import { type Binding, type Intersection, type IntersectionMeta, type ParamBinding, type ReferencedBindings } from "./bindings";
4
3
  import * as ContentType from "./constants/content-type";
5
4
  import type * as Step from "./constants/step";
6
5
  import * as StructureKind from "./constants/structure-kind";
7
6
  import { type OneMany, type Opt, Sorted, type SortedOpt } from "./optional";
8
- import { type Binding, type InputBinding, type KnownExprs, type ParamBinding, type ReferencedBindings, type Sources } from "./references";
9
- import { type SerializeKey, type SerializeReason, type SerializeReasons } from "./serialize-reasons";
10
- export interface ParamSerializeReasonGroup {
11
- id: symbol;
12
- reason: NonNullable<Sources["param"]>;
13
- }
14
- export type ParamSerializeReasonGroups = [
15
- ParamSerializeReasonGroup,
16
- ...ParamSerializeReasonGroup[]
17
- ];
7
+ import { type Reason } from "./reasons";
8
+ import { type KnownExprs } from "./references";
9
+ import { type Slot } from "./slots";
10
+ import { type Sources } from "./sources";
11
+ export type ParamReasonGroup = NonNullable<Sources["param"]>;
12
+ export type ParamReasonGroups = [ParamReasonGroup, ...ParamReasonGroup[]];
18
13
  type ContentType = ContentType.Value;
19
14
  export { ContentType, StructureKind };
20
15
  export type StructureRef = StructureSectionRef | StructureExportRef;
@@ -28,20 +23,20 @@ export interface StructureExportRef {
28
23
  path: string;
29
24
  hint: string;
30
25
  }
31
- export type StructureOp = string | Step.Value | StructureText | StructureVisit | StructureChild;
26
+ export type StructureOp = string | Step.Value | StructureText | StructureNode | StructureChild;
32
27
  export interface StructureText {
33
28
  kind: typeof StructureKind.Text;
34
29
  value: string;
35
30
  }
36
- export interface StructureVisit {
37
- kind: typeof StructureKind.Visit;
38
- code: typeof WalkCode.Get | typeof WalkCode.Replace | typeof WalkCode.DynamicTagWithVar;
39
- claimed: boolean;
31
+ export interface StructureNode {
32
+ kind: typeof StructureKind.Node;
33
+ binding: Binding | undefined;
34
+ marker: boolean;
40
35
  }
41
36
  export interface StructureChild {
42
37
  kind: typeof StructureKind.Child;
43
38
  name: string;
44
- hasVar: boolean;
39
+ binding: Binding;
45
40
  renderer?: StructureRef;
46
41
  }
47
42
  export interface Section {
@@ -50,52 +45,60 @@ export interface Section {
50
45
  loc: t.SourceLocation | undefined;
51
46
  depth: number;
52
47
  parent: Section | undefined;
48
+ children: Section[];
53
49
  program: Section;
54
- sectionAccessor: {
55
- binding: Binding;
56
- prefix: AccessorPrefix;
57
- } | undefined;
58
- params: undefined | ParamBinding | InputBinding;
50
+ params: undefined | ParamBinding;
59
51
  /** The attribute tag `<for>` params this content reads, held as its own
60
52
  * bindings that the loop binds as it creates it. */
61
53
  localClosures: ReferencedBindings;
62
54
  referencedClosures: ReferencedBindings;
63
- referencedHoists: ReferencedBindings;
64
55
  bindings: ReferencedBindings;
65
56
  hoisted: ReferencedBindings;
66
- hoistedTo: ReferencedBindings;
67
- serializeReason: undefined | SerializeReason;
68
- serializeReasons: Map<symbol, SerializeReason>;
69
- /** Reasons any of the section's dom nodes resumes, as the analyzed reasons
70
- * (not merged) so each one's guard stays buildable. */
71
- domSerializeReasons: undefined | SerializeReasons;
72
- /** Pending serialize exprs, resolved into the reasons once references
73
- * finalize. */
74
- serializeExprs: Opt<t.NodeExtra>;
75
- propSerializeExprs: Map<SerializeKey, OneMany<t.NodeExtra>> | undefined;
76
- /** Interned per-prop reason keys for string/symbol props. */
77
- serializePropKeys: Map<string | symbol, SerializeKey> | undefined;
78
- paramReasonGroups: ParamSerializeReasonGroups | undefined;
57
+ /** The closures its `<for>` rows read only by comparing them to the row's
58
+ * key, which a row selector updates. */
59
+ selector: {
60
+ key: Binding;
61
+ closures: Set<Binding>;
62
+ } | undefined;
63
+ /** The canonical intersections its work waits on, once ids allocate. */
64
+ intersections: Map<Intersection, IntersectionMeta> | undefined;
65
+ /** The slots of its scope, its own and its bindings'. */
66
+ slots: SortedOpt<Slot>;
67
+ /** When client code reads anything in its scope: its slots' reasons merged. */
68
+ reason: undefined | Reason;
69
+ paramReasonGroups: ParamReasonGroups | undefined;
79
70
  returnValueExpr: t.NodeExtra | undefined;
80
- returnSerializeReason: SerializeReason | undefined;
81
71
  isHoistThrough: true | undefined;
82
- upstreamExpression: t.NodeExtra | undefined;
83
- /** For a `<define>` body, the sections whose direct calls render it. */
72
+ branchExpr: t.NodeExtra | undefined;
73
+ /** For a `<define>` body or a template rendering itself, the sections whose
74
+ * direct calls render it. */
84
75
  callSections: SortedOpt<Section>;
85
76
  /** The content's rendering tag (its extra), and each child binding the
86
77
  * content feeds, at `properties`. */
87
- downstream: {
78
+ derives: {
88
79
  tag: t.MarkoTagExtra;
89
80
  binding: OneMany<Binding>;
90
81
  properties: Opt<string>;
91
82
  exprs: KnownExprs | undefined;
92
83
  } | undefined;
84
+ /** Content a known child never reads, which no output renders. */
85
+ pruned: boolean;
93
86
  hasAbortSignal: boolean;
94
87
  /** Count of distinct `$signal` expression roots; analyze allocates each
95
- * root's `abortId` from this so translates read, never re-derive. */
88
+ * root's abort id from this so translates read, never re-derive. */
96
89
  abortSignalExprs: number;
97
90
  readsOwner: boolean;
98
- isBranch: boolean;
91
+ /** Whether analysis found work keyed by setup in the section, or in a
92
+ * `<define>` body or template it calls in place. */
93
+ hasSetupWork: boolean;
94
+ /** Its tag, which renders it in place into branch scopes at the tag's node
95
+ * binding, and whether its branch expression's value can leave it unrendered. */
96
+ branch: {
97
+ nodeBinding: Binding;
98
+ optional: boolean;
99
+ /** An `<if>` branch's place in its chain, the renderer index it renders as. */
100
+ index?: number;
101
+ } | undefined;
99
102
  content: null | {
100
103
  startType: ContentType;
101
104
  endType: ContentType;
@@ -116,17 +119,19 @@ export declare const sectionUtil: Sorted<Section>;
116
119
  export declare function startSection(path: t.NodePath<t.MarkoTagBody | t.Program>): Section | undefined;
117
120
  export declare function getOrCreateSection(path: t.NodePath<any>): Section;
118
121
  export declare function getSectionForBody(body: t.NodePath<t.MarkoTagBody | t.Program>): Section | undefined;
122
+ export declare function removePrunedContent(tag: t.NodePath<t.MarkoTag>): void;
119
123
  export declare function getSection(path: t.NodePath): Section;
120
124
  export declare const getScopeIdIdentifier: (section: Section) => t.Identifier;
121
- export declare const getSectionParentIsOwner: (section: Section) => boolean, setSectionParentIsOwner: (section: Section, value: boolean) => void;
122
125
  export declare const getBranchRendererArgs: (section: Section) => [template?: t.Expression | undefined, walks?: t.Expression | undefined, setup?: t.Expression | undefined, params?: t.Expression | undefined], setBranchRendererArgs: (section: Section, value: [template?: t.Expression | undefined, walks?: t.Expression | undefined, setup?: t.Expression | undefined, params?: t.Expression | undefined]) => void;
123
126
  export declare function forEachSection(fn: (section: Section) => void): void;
124
- export declare function getChildSections(section: Section): Section[];
125
127
  export declare function getContentClosures(section: Section): ReferencedBindings;
126
128
  export declare function forEachAncestorSection<A>(from: Section, to: Section, fn: (section: Section, arg: A) => void, arg: A): void;
127
129
  export declare function forEachSectionReverse(fn: (section: Section) => void): void;
128
130
  export declare function getNodeContentType(path: t.NodePath<t.Statement>, extraMember: "startType" | "endType", contentInfo?: Section["content"]): ContentType.Value | null;
129
- export declare function getSectionRegisterReasons(section: Section): boolean | Sources;
131
+ export declare function getRendererReason(section: Section): boolean | Sources;
132
+ export declare function isResumedBranch(section: Section): section is Section & {
133
+ branch: NonNullable<Section["branch"]>;
134
+ };
130
135
  export declare function isImmediateOwner(section: Section, binding: Binding): boolean;
131
136
  export declare function isDirectClosure(section: Section, closure: Binding): boolean;
132
137
  export declare function isDynamicClosure(section: Section, closure: Binding): boolean;
@@ -134,7 +139,8 @@ export declare function getDynamicClosureIndex(closure: Binding, closureSection:
134
139
  export declare function getDirectClosures(section: Section): SortedOpt<Binding>;
135
140
  export declare function isSameOrChildSection(section: Section, other: Section): boolean;
136
141
  export declare function getCommonSection(section: Section, other: Section): Section;
137
- export declare function finalizeParamSerializeReasonGroups(section: Section): void;
138
- export declare function ensureReasonGroups(reason: Section["serializeReason"]): void;
139
- export declare function getParamReasonGroupIndex(section: Section, reason: ParamSerializeReasonGroup["reason"]): number;
140
- export declare function groupParamsBySection(params: Sources["param"]): Map<Section, import("./optional").SortedOneMany<InputBinding | ParamBinding>>;
142
+ export declare function finalizeParamReasonGroups(section: Section): void;
143
+ export declare function ensureReasonGroups(reason: Section["reason"]): void;
144
+ export declare function getParamReasonGroupIndex(section: Section, group: ParamReasonGroup): number;
145
+ export declare function groupParamsBySection(params: Sources["param"]): Map<Section, import("./optional").SortedOneMany<ParamBinding>>;
146
+ export declare function setReadsOwner(from: Section, to: Section): void;
@@ -0,0 +1,7 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { type Binding } from "./bindings";
3
+ import { type Opt } from "./optional";
4
+ import { type KnownExprs } from "./references";
5
+ import { type Section } from "./sections";
6
+ export declare function setTagDerivedFrom(tag: t.NodePath<t.MarkoTag>, binding: Opt<Binding>, exprs?: KnownExprs): void;
7
+ export declare function finalizeTagDerivations(section: Section): void;
@@ -0,0 +1,4 @@
1
+ import type { types as t } from "@marko/compiler";
2
+ import { type Section } from "./sections";
3
+ export declare function addSetupExpr(section: Section, node?: t.Node): void;
4
+ export declare function finalizeSetupWork(): void;
@@ -1,8 +1,8 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import { type AccessorPrefix, AccessorProp } from "../../common/types";
2
+ import { type Binding, type Getter, type ReferencedBindings } from "./bindings";
3
3
  import { type Opt } from "./optional";
4
- import { type Binding, type Getter, type ReferencedBindings } from "./references";
5
4
  import { type Section } from "./sections";
5
+ import { type PlaceSlot } from "./slots";
6
6
  export interface Signal {
7
7
  identifier: t.Identifier;
8
8
  referencedBindings: ReferencedBindings;
@@ -12,22 +12,20 @@ export interface Signal {
12
12
  referenced?: boolean;
13
13
  values: Array<{
14
14
  signal: Signal;
15
- value: t.Expression;
15
+ /** None for a signal that runs on the scope alone. */
16
+ value: t.Expression | undefined;
16
17
  }>;
17
18
  intersection: Opt<Signal>;
18
19
  /** Signals this one forwards into: they must declare first when the
19
20
  * forward simplifies to a bare, eagerly evaluated reference. */
20
21
  forwards: Opt<Signal>;
21
- /** Runs before `render`: registrations (eg `_var`) that an earlier tag's
22
- * synchronous `_return` may reach before the registering tag's own setup. */
23
- prepare: t.Statement[];
24
22
  render: t.Statement[];
25
23
  effect: t.Statement[];
26
24
  hasHTMLEffect: boolean;
27
25
  hasSideEffect: boolean;
28
26
  forcePersist: boolean;
29
27
  inline: {
30
- value: t.Expression;
28
+ value: t.Expression | undefined;
31
29
  } | undefined;
32
30
  export: boolean;
33
31
  extraArgs: t.Expression[] | undefined;
@@ -42,10 +40,8 @@ export declare function getContentClosureValues(bodySection: Section): {
42
40
  scope: t.Identifier;
43
41
  levels: t.Expression[];
44
42
  } | undefined;
45
- export declare function setSectionSerializedValue(section: Section, prop: AccessorProp, expression: t.Expression): void;
46
- export declare function setBindingSerializedValue(section: Section, binding: Binding, expression: t.Expression, prefix?: AccessorPrefix): void;
43
+ export declare function setScopeProperty(found: PlaceSlot | undefined, expression: t.Expression): string | undefined;
47
44
  export declare function setSectionDebugVar(section: Section, accessor: string, name: string, loc: t.SourceLocation | null | undefined): void;
48
- export declare function setSerializedValue(section: Section, key: string, expression: t.Expression): void;
49
45
  export declare function addWriteScopeBuilder(section: Section, builder: (writeCall: t.Expression) => t.Expression): void;
50
46
  export declare const getHTMLSectionStatements: (section: Section) => t.Statement[];
51
47
  export declare function getBindingGetterIdentifier(binding: Binding, getterSection: Getter["hoisted"]): t.Identifier;
@@ -55,8 +51,8 @@ export declare function signalHasStatements(signal: Signal): boolean;
55
51
  export declare function getSignalFn(signal: Signal): t.Expression;
56
52
  export declare function getSignalValueIdentifier(signal: Signal): t.Identifier;
57
53
  export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
58
- export declare function addStatement(type: "prepare" | "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
59
- export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value: t.Expression): void;
54
+ export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
55
+ export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value?: t.Expression): void;
60
56
  export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
61
57
  export declare function writeSignals(section: Section): Set<Signal>;
62
58
  export declare function writeRegisteredFns(): void;