marko 6.4.0 → 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 (123) hide show
  1. package/cheatsheet.md +1 -1
  2. package/dist/common/constants/accessor-prefix.d.ts +1 -0
  3. package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
  4. package/dist/common/constants/reserved-id.d.ts +5 -0
  5. package/dist/common/errors.d.ts +1 -1
  6. package/dist/common/types.d.ts +3 -0
  7. package/dist/debug/dom/catch.feat.js +1 -1
  8. package/dist/debug/dom/catch.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-input.feat.js +1 -1
  10. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-open.feat.js +1 -1
  12. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable-select.feat.js +1 -1
  14. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  15. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  16. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  17. package/dist/debug/dom/controllable.feat.js +1 -1
  18. package/dist/debug/dom/controllable.feat.mjs +1 -1
  19. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  20. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  21. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  22. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  23. package/dist/debug/dom/lazy.feat.js +1 -1
  24. package/dist/debug/dom/lazy.feat.mjs +1 -1
  25. package/dist/debug/dom/placeholder.feat.js +1 -1
  26. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  27. package/dist/debug/{dom-BRO5aArp.js → dom-ClV4kVOO.js} +32 -16
  28. package/dist/debug/{dom-Btj2QJhk.mjs → dom-LFrKxOk5.mjs} +32 -16
  29. package/dist/debug/dom.js +1 -1
  30. package/dist/debug/dom.mjs +1 -1
  31. package/dist/debug/html.js +277 -222
  32. package/dist/debug/html.mjs +275 -220
  33. package/dist/dom/catch.feat.js +1 -1
  34. package/dist/dom/catch.feat.mjs +1 -1
  35. package/dist/dom/controllable-input.feat.js +1 -1
  36. package/dist/dom/controllable-input.feat.mjs +1 -1
  37. package/dist/dom/controllable-open.feat.js +1 -1
  38. package/dist/dom/controllable-open.feat.mjs +1 -1
  39. package/dist/dom/controllable-select.feat.js +1 -1
  40. package/dist/dom/controllable-select.feat.mjs +1 -1
  41. package/dist/dom/controllable-textarea.feat.js +1 -1
  42. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  43. package/dist/dom/controllable.feat.js +1 -1
  44. package/dist/dom/controllable.feat.mjs +1 -1
  45. package/dist/dom/dynamic-tag-script.feat.js +1 -1
  46. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  47. package/dist/dom/dynamic-tag-var.feat.js +1 -1
  48. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  49. package/dist/dom/lazy.feat.js +1 -1
  50. package/dist/dom/lazy.feat.mjs +1 -1
  51. package/dist/dom/placeholder.feat.js +1 -1
  52. package/dist/dom/placeholder.feat.mjs +1 -1
  53. package/dist/dom/signals.d.ts +3 -2
  54. package/dist/{dom-BSsI9OPC.js → dom-CNglVi8P.js} +13 -4
  55. package/dist/{dom-B-v8Gw6T.mjs → dom-DfP3MCo0.mjs} +13 -4
  56. package/dist/dom.js +1 -1
  57. package/dist/dom.mjs +1 -1
  58. package/dist/html/attrs.d.ts +2 -2
  59. package/dist/html/dynamic-tag.d.ts +1 -1
  60. package/dist/html/inlined-runtimes.d.ts +1 -1
  61. package/dist/html/inlined-runtimes.debug.d.ts +1 -1
  62. package/dist/html/serializer.d.ts +1 -1
  63. package/dist/html/writer.d.ts +34 -22
  64. package/dist/html.d.ts +1 -1
  65. package/dist/html.js +224 -167
  66. package/dist/html.mjs +224 -167
  67. package/dist/translator/core/html-comment.d.ts +0 -7
  68. package/dist/translator/core/let.d.ts +0 -5
  69. package/dist/translator/core/show.d.ts +2 -5
  70. package/dist/translator/core/style.d.ts +6 -8
  71. package/dist/translator/index.d.ts +9 -0
  72. package/dist/translator/index.js +8573 -8458
  73. package/dist/translator/util/binding-has-prop.d.ts +1 -1
  74. package/dist/translator/util/binding-prop-tree.d.ts +4 -4
  75. package/dist/translator/util/bindings.d.ts +127 -0
  76. package/dist/translator/util/body-to-text-literal.d.ts +1 -2
  77. package/dist/translator/util/branch-tag.d.ts +7 -7
  78. package/dist/translator/util/constants/binding-type.d.ts +5 -6
  79. package/dist/translator/util/constants/slot-kind.d.ts +14 -0
  80. package/dist/translator/util/constants/structure-kind.d.ts +1 -1
  81. package/dist/translator/util/evaluate.d.ts +11 -10
  82. package/dist/translator/util/finalize-references.d.ts +4 -0
  83. package/dist/translator/util/for-selector.d.ts +1 -1
  84. package/dist/translator/util/generate-uid.d.ts +3 -1
  85. package/dist/translator/util/get-declared-binding-expression.d.ts +2 -2
  86. package/dist/translator/util/is-core-tag.d.ts +0 -3
  87. package/dist/translator/util/is-only-child-in-parent.d.ts +2 -7
  88. package/dist/translator/util/known-tag.d.ts +8 -7
  89. package/dist/translator/util/read-replacement.d.ts +3 -0
  90. package/dist/translator/util/reasons.d.ts +32 -0
  91. package/dist/translator/util/references.d.ts +67 -166
  92. package/dist/translator/util/scope-accessor.d.ts +14 -0
  93. package/dist/translator/util/scope-read.d.ts +1 -1
  94. package/dist/translator/util/sections.d.ts +48 -48
  95. package/dist/translator/util/set-tag-derived-from.d.ts +7 -0
  96. package/dist/translator/util/setup-work.d.ts +1 -2
  97. package/dist/translator/util/signals.d.ts +3 -5
  98. package/dist/translator/util/slots.d.ts +50 -0
  99. package/dist/translator/util/solve-reasons.d.ts +10 -0
  100. package/dist/translator/util/sources.d.ts +21 -0
  101. package/dist/translator/util/structure.d.ts +5 -2
  102. package/dist/translator/util/tag-facts.d.ts +21 -0
  103. package/dist/translator/util/tag-name-type.d.ts +4 -1
  104. package/dist/translator/util/translate-attrs.d.ts +2 -0
  105. package/dist/translator/util/translate-var.d.ts +3 -0
  106. package/dist/translator/util/write-guard.d.ts +12 -0
  107. package/dist/translator/util/writer.d.ts +3 -3
  108. package/dist/translator/visitors/export-declaration.d.ts +9 -0
  109. package/dist/translator/visitors/function.d.ts +5 -4
  110. package/dist/translator/visitors/import-declaration.d.ts +2 -2
  111. package/dist/translator/visitors/placeholder.d.ts +0 -3
  112. package/dist/translator/visitors/program/index.d.ts +13 -3
  113. package/dist/translator/visitors/referenced-identifier.d.ts +2 -1
  114. package/dist/translator/visitors/tag/custom-tag.d.ts +1 -1
  115. package/dist/translator/visitors/tag/dynamic-tag.d.ts +0 -3
  116. package/dist/translator/visitors/tag/index.d.ts +2 -1
  117. package/dist/translator/visitors/tag/native-tag.d.ts +26 -12
  118. package/package.json +2 -2
  119. package/dist/translator/util/insertion-context.d.ts +0 -1
  120. package/dist/translator/util/is-non-html-text.d.ts +0 -3
  121. package/dist/translator/util/serialize-guard.d.ts +0 -11
  122. package/dist/translator/util/serialize-reasons.d.ts +0 -37
  123. package/dist/translator/util/set-tag-sections-downstream.d.ts +0 -6
@@ -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,69 +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;
121
+ export declare function dropExtra(exprExtra: ReferencedExtra): void;
204
122
  export declare function dropContent(body: t.MarkoTagBody): void;
205
- export declare function getCanonicalBinding(binding: Binding): Binding;
206
- export declare function someAlias<A>(binding: Binding, test: (binding: Binding, arg: A) => boolean, arg: A, directOnly?: boolean): boolean;
207
- export declare function someUpstream<A>(binding: Binding | undefined, test: (binding: Binding, arg: A) => boolean, arg: A): boolean;
208
- export declare function isDirectAlias(binding: Binding): boolean;
209
123
  export declare function getAllTagReferenceNodes(tag: t.MarkoTag, referenceNodes?: t.Node[], collectAttrTag?: (attrTag: t.MarkoTag) => void): t.Node[];
210
- export declare function getScopeAccessorLiteral(binding: Binding, encoded?: boolean, includeId?: boolean): t.NumericLiteral | t.StringLiteral;
211
- export declare function getScopeAccessor(binding: Binding, encoded?: boolean, includeId?: boolean): string;
212
- export declare function getLocalsScopeAccessor(binding: Binding): string;
213
- export declare function getPrefixedScopeAccessor(binding: Binding, prefix: AccessorPrefix): string;
214
- export declare function getClosureAccessorLiteral(binding: Binding): t.NumericLiteral | t.StringLiteral;
215
- export declare function getDebugScopeAccess(binding: Binding): {
216
- root: Binding;
217
- access: string;
218
- };
219
- export declare function getDebugName(binding: Binding): string;
220
- export declare function getDebugNames(refs: ReferencedBindings): string;
221
- export declare function getDebugNamesAsIdentifier(refs: ReferencedBindings): string;
222
- export declare function getSectionInstancesAccessor(section: Section): string;
223
- export declare function getSectionInstancesAccessorLiteral(section: Section): t.StringLiteral;
224
- export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression, signal?: Signal): t.Expression | undefined;
225
- export declare function isInvokeOnlyBinding(binding: Binding): boolean;
226
- export declare function hasNonConstantPropertyAlias(ref: Binding): boolean;
227
- export declare function pruneBinding(binding: Binding, settled?: true): boolean;
228
124
  export declare function createRead(binding: Binding, props: Opt<string>, ownVar?: boolean): ExtraRead;
229
125
  export declare function createGetterRead(binding: Binding, props: Opt<string>, getter: Getter): ExtraRead;
230
126
  export interface ReferencedExtra extends t.NodeExtra {
@@ -242,16 +138,21 @@ export declare function isAssignedBindingExtra(extra: t.NodeExtra | undefined):
242
138
  export interface RegisteredFnExtra extends ReferencedExtra, t.FunctionExtra {
243
139
  name: string;
244
140
  registerId: string;
245
- registerReason: SerializeReason;
141
+ reason: Reason;
246
142
  }
247
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;
248
151
  export declare function getCanonicalExtra<T extends t.NodeExtra>(extra: T): T;
249
- export declare function getAllSerializeReasonsForExtra(extra: t.NodeExtra): undefined | SerializeReason;
250
- export declare function getAllSerializeReasonsForBinding(binding: Binding, properties?: Opt<string> | true): undefined | SerializeReason;
251
- export declare function getRegisterReasonForExtra(extra: t.NodeExtra): undefined | SerializeReason;
252
152
  export interface KnownExprs {
253
153
  known?: Record<string, KnownExprs>;
254
154
  value?: t.NodeExtra;
255
155
  }
256
- export declare function mapParamReasonToExpr(exprs: KnownExprs, reason: boolean | Opt<InputBinding | ParamBinding>): true | Many<t.NodeExtra> | t.NodeExtra | undefined;
257
- 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 {};
@@ -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,41 +45,37 @@ 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
- serializeReason: undefined | SerializeReason;
67
- serializeReasons: Map<symbol, SerializeReason>;
68
- /** Reasons any of the section's dom nodes resumes, as the analyzed reasons
69
- * (not merged) so each one's guard stays buildable. */
70
- domSerializeReasons: undefined | SerializeReasons;
71
- /** Pending serialize exprs, resolved into the reasons once references
72
- * finalize. */
73
- serializeExprs: Opt<t.NodeExtra>;
74
- propSerializeExprs: Map<SerializeKey, OneMany<t.NodeExtra>> | undefined;
75
- /** Interned per-prop reason keys for string/symbol props. */
76
- serializePropKeys: Map<string | symbol, SerializeKey> | undefined;
77
- 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;
78
70
  returnValueExpr: t.NodeExtra | undefined;
79
- returnSerializeReason: SerializeReason | undefined;
80
71
  isHoistThrough: true | undefined;
81
- upstreamExpression: t.NodeExtra | undefined;
72
+ branchExpr: t.NodeExtra | undefined;
82
73
  /** For a `<define>` body or a template rendering itself, the sections whose
83
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>;
@@ -94,13 +85,20 @@ export interface Section {
94
85
  pruned: boolean;
95
86
  hasAbortSignal: boolean;
96
87
  /** Count of distinct `$signal` expression roots; analyze allocates each
97
- * root's `abortId` from this so translates read, never re-derive. */
88
+ * root's abort id from this so translates read, never re-derive. */
98
89
  abortSignalExprs: number;
99
90
  readsOwner: boolean;
100
91
  /** Whether analysis found work keyed by setup in the section, or in a
101
92
  * `<define>` body or template it calls in place. */
102
93
  hasSetupWork: boolean;
103
- isBranch: 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;
104
102
  content: null | {
105
103
  startType: ContentType;
106
104
  endType: ContentType;
@@ -124,15 +122,16 @@ export declare function getSectionForBody(body: t.NodePath<t.MarkoTagBody | t.Pr
124
122
  export declare function removePrunedContent(tag: t.NodePath<t.MarkoTag>): void;
125
123
  export declare function getSection(path: t.NodePath): Section;
126
124
  export declare const getScopeIdIdentifier: (section: Section) => t.Identifier;
127
- export declare const getSectionParentIsOwner: (section: Section) => boolean, setSectionParentIsOwner: (section: Section, value: boolean) => void;
128
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;
129
126
  export declare function forEachSection(fn: (section: Section) => void): void;
130
- export declare function getChildSections(section: Section): Section[];
131
127
  export declare function getContentClosures(section: Section): ReferencedBindings;
132
128
  export declare function forEachAncestorSection<A>(from: Section, to: Section, fn: (section: Section, arg: A) => void, arg: A): void;
133
129
  export declare function forEachSectionReverse(fn: (section: Section) => void): void;
134
130
  export declare function getNodeContentType(path: t.NodePath<t.Statement>, extraMember: "startType" | "endType", contentInfo?: Section["content"]): ContentType.Value | null;
135
- 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
+ };
136
135
  export declare function isImmediateOwner(section: Section, binding: Binding): boolean;
137
136
  export declare function isDirectClosure(section: Section, closure: Binding): boolean;
138
137
  export declare function isDynamicClosure(section: Section, closure: Binding): boolean;
@@ -140,7 +139,8 @@ export declare function getDynamicClosureIndex(closure: Binding, closureSection:
140
139
  export declare function getDirectClosures(section: Section): SortedOpt<Binding>;
141
140
  export declare function isSameOrChildSection(section: Section, other: Section): boolean;
142
141
  export declare function getCommonSection(section: Section, other: Section): Section;
143
- export declare function finalizeParamSerializeReasonGroups(section: Section): void;
144
- export declare function ensureReasonGroups(reason: Section["serializeReason"]): void;
145
- export declare function getParamReasonGroupIndex(section: Section, reason: ParamSerializeReasonGroup["reason"]): number;
146
- 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;
@@ -1,5 +1,4 @@
1
1
  import type { types as t } from "@marko/compiler";
2
2
  import { type Section } from "./sections";
3
- export declare function addSetupWork(section: Section): void;
4
- export declare function addSetupExpr(section: Section, node: t.Node | undefined): void;
3
+ export declare function addSetupExpr(section: Section, node?: t.Node): void;
5
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;
@@ -40,10 +40,8 @@ export declare function getContentClosureValues(bodySection: Section): {
40
40
  scope: t.Identifier;
41
41
  levels: t.Expression[];
42
42
  } | undefined;
43
- export declare function setSectionSerializedValue(section: Section, prop: AccessorProp, expression: t.Expression): void;
44
- 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;
45
44
  export declare function setSectionDebugVar(section: Section, accessor: string, name: string, loc: t.SourceLocation | null | undefined): void;
46
- export declare function setSerializedValue(section: Section, key: string, expression: t.Expression): void;
47
45
  export declare function addWriteScopeBuilder(section: Section, builder: (writeCall: t.Expression) => t.Expression): void;
48
46
  export declare const getHTMLSectionStatements: (section: Section) => t.Statement[];
49
47
  export declare function getBindingGetterIdentifier(binding: Binding, getterSection: Getter["hoisted"]): t.Identifier;
@@ -0,0 +1,50 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { type Binding } from "./bindings";
3
+ import * as SlotKind from "./constants/slot-kind";
4
+ import { type Opt } from "./optional";
5
+ import { type Reason } from "./reasons";
6
+ import { type ParamReasonGroup, type Section } from "./sections";
7
+ type SlotKind = SlotKind.Value;
8
+ export { SlotKind };
9
+ export type BindingSlotKind = typeof SlotKind.Value | typeof SlotKind.ChangeHandler | typeof SlotKind.ClosureScopes | typeof SlotKind.ClosureSignalIndex | typeof SlotKind.BranchExpr | typeof SlotKind.ParamGroup;
10
+ export type SectionSlotKind = Exclude<SlotKind, BindingSlotKind>;
11
+ export type PlaceSlotKind = typeof SlotKind.Value | typeof SlotKind.ChangeHandler | typeof SlotKind.ClosureScopes | typeof SlotKind.ClosureSignalIndex | typeof SlotKind.Owner | typeof SlotKind.ReturnChangeHandler | typeof SlotKind.Instances;
12
+ /** A place in a scope that client code may read after resume, or a fact about
13
+ * one a guard decides on (a condition changing, a branch or group resuming). */
14
+ export type Slot = BindingSlot | SectionSlot;
15
+ export type PlaceSlot = Slot & {
16
+ kind: PlaceSlotKind;
17
+ };
18
+ interface BaseSlot {
19
+ /** The scope it is in. */
20
+ section: Section;
21
+ /** The sources whose changes lead client code to read it after resume,
22
+ * unset while nothing does. */
23
+ reason: Reason | undefined;
24
+ /** The expressions it holds or renders, whose sources its reason takes once
25
+ * references finalize. */
26
+ reasonExprs: Opt<t.NodeExtra>;
27
+ }
28
+ export interface BindingSlot extends BaseSlot {
29
+ kind: BindingSlotKind;
30
+ /** A canonical binding. */
31
+ owner: Binding;
32
+ /** The group it guards, for a param group. */
33
+ group: ParamReasonGroup | undefined;
34
+ }
35
+ export interface SectionSlot extends BaseSlot {
36
+ kind: SectionSlotKind;
37
+ owner: Section;
38
+ group: undefined;
39
+ }
40
+ export declare function getSlot(binding: Binding, kind?: BindingSlotKind, section?: Section, group?: ParamReasonGroup): Slot;
41
+ export declare function findSlot(binding: Binding): (BindingSlot & {
42
+ kind: typeof SlotKind.Value;
43
+ }) | undefined;
44
+ export declare function findSlot<K extends BindingSlotKind>(binding: Binding, kind: K, section?: Section, group?: ParamReasonGroup): (BindingSlot & {
45
+ kind: K;
46
+ }) | undefined;
47
+ export declare function getSectionSlot(owner: Section, kind: SectionSlotKind, section?: Section): Slot;
48
+ export declare function findSectionSlot<K extends SectionSlotKind>(owner: Section, kind: K, section?: Section): (SectionSlot & {
49
+ kind: K;
50
+ }) | undefined;
@@ -0,0 +1,10 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { type Binding, type Intersection } from "./bindings";
3
+ import { type Opt } from "./optional";
4
+ import { type Reason } from "./reasons";
5
+ import { type Section } from "./sections";
6
+ export declare function solveReasons(intersectionsBySection: Map<Section, Intersection[]>): void;
7
+ export declare function getReasonForBinding(binding: Binding, properties?: Opt<string> | true): undefined | Reason;
8
+ export declare function getValueReason(extra: t.NodeExtra): undefined | Reason;
9
+ export declare function readsValuesOnResume(expr: t.NodeExtra): boolean;
10
+ export declare function addAlwaysRead(binding: Binding): void;
@@ -0,0 +1,21 @@
1
+ import { type Binding, type ParamBinding } from "./bindings";
2
+ import { type SortedOpt } from "./optional";
3
+ export interface Sources {
4
+ state: SortedOpt<Binding>;
5
+ param: SortedOpt<ParamBinding>;
6
+ global: true | undefined;
7
+ /** Read whatever changes, as an effect or handler reads on resume; the
8
+ * other fields still say what it reads. */
9
+ always: true | undefined;
10
+ }
11
+ export declare const ALWAYS: Sources;
12
+ export declare const globalSources: Sources;
13
+ export declare function sharesSources(a: Binding, b: Binding): boolean;
14
+ export declare function createSources(state: Sources["state"], param: Sources["param"], global?: Sources["global"], always?: Sources["always"]): Sources;
15
+ export declare function withSources(sources: Sources, state: Sources["state"], param: Sources["param"]): Sources | undefined;
16
+ export declare function compareSources(a: Sources, b: Sources): number;
17
+ export declare function mergeSources(a: Sources, b: undefined | Sources): Sources;
18
+ export declare function mergeSources(a: undefined | Sources, b: Sources): Sources;
19
+ export declare function mergeSources(a: undefined | Sources, b: undefined | Sources): Sources | undefined;
20
+ export declare function isInParams(binding: Binding, params: Sources["param"]): boolean;
21
+ export declare function isSupersetSources(a: Binding, b: Binding): boolean;