marko 6.3.56 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/cheatsheet.md +2 -2
  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/accessor-prop.d.ts +3 -0
  5. package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
  6. package/dist/common/types.d.ts +8 -2
  7. package/dist/debug/dom/catch.feat.js +12 -14
  8. package/dist/debug/dom/catch.feat.mjs +12 -14
  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 +4 -0
  24. package/dist/debug/dom/lazy.feat.mjs +4 -0
  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-DcwejnYg.js → dom-BRO5aArp.js} +232 -178
  28. package/dist/debug/{dom-BeCNT5R5.mjs → dom-Btj2QJhk.mjs} +215 -167
  29. package/dist/debug/dom.js +14 -12
  30. package/dist/debug/dom.mjs +14 -12
  31. package/dist/debug/html.js +603 -517
  32. package/dist/debug/html.mjs +602 -518
  33. package/dist/dom/abort-signal.d.ts +2 -0
  34. package/dist/dom/catch.feat.js +6 -7
  35. package/dist/dom/catch.feat.mjs +5 -7
  36. package/dist/dom/control-flow.d.ts +3 -5
  37. package/dist/dom/controllable-input.feat.js +3 -2
  38. package/dist/dom/controllable-input.feat.mjs +1 -1
  39. package/dist/dom/controllable-open.feat.js +3 -2
  40. package/dist/dom/controllable-open.feat.mjs +1 -1
  41. package/dist/dom/controllable-select.feat.js +3 -2
  42. package/dist/dom/controllable-select.feat.mjs +1 -1
  43. package/dist/dom/controllable-textarea.feat.js +3 -2
  44. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  45. package/dist/dom/controllable.feat.js +3 -2
  46. package/dist/dom/controllable.feat.mjs +1 -1
  47. package/dist/dom/dynamic-tag-script.feat.js +3 -2
  48. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  49. package/dist/dom/dynamic-tag-var.feat.js +2 -1
  50. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  51. package/dist/dom/lazy.feat.d.ts +1 -0
  52. package/dist/dom/lazy.feat.js +4 -0
  53. package/dist/dom/lazy.feat.mjs +4 -0
  54. package/dist/dom/load.d.ts +3 -3
  55. package/dist/dom/placeholder.feat.js +4 -3
  56. package/dist/dom/placeholder.feat.mjs +1 -1
  57. package/dist/dom/queue.d.ts +2 -4
  58. package/dist/dom/resume.d.ts +1 -1
  59. package/dist/dom/scope.d.ts +0 -1
  60. package/dist/{dom-BwNsIevR.mjs → dom-B-v8Gw6T.mjs} +114 -87
  61. package/dist/{dom-QEF0csuC.js → dom-BSsI9OPC.js} +210 -182
  62. package/dist/dom.js +59 -56
  63. package/dist/dom.mjs +34 -32
  64. package/dist/html/attrs.d.ts +2 -0
  65. package/dist/html/writer.d.ts +5 -11
  66. package/dist/html.d.ts +1 -1
  67. package/dist/html.js +362 -317
  68. package/dist/html.mjs +361 -317
  69. package/dist/translator/index.js +791 -650
  70. package/dist/translator/util/binding-has-prop.d.ts +2 -0
  71. package/dist/translator/util/entry-builder.d.ts +2 -0
  72. package/dist/translator/util/generate-uid.d.ts +5 -0
  73. package/dist/translator/util/references.d.ts +3 -2
  74. package/dist/translator/util/runtime.d.ts +3 -3
  75. package/dist/translator/util/sections.d.ts +8 -2
  76. package/dist/translator/util/serialize-reasons.d.ts +2 -2
  77. package/dist/translator/util/setup-work.d.ts +5 -0
  78. package/dist/translator/util/signals.d.ts +5 -7
  79. package/dist/translator/visitors/tag/native-tag.d.ts +1 -0
  80. package/package.json +3 -3
  81. package/dist/translator/util/setup-statements.d.ts +0 -5
@@ -1,6 +1,8 @@
1
+ import { types as t } from "@marko/compiler";
1
2
  import { type Opt } from "./optional";
2
3
  import type { Binding } from "./references";
3
4
  import type { Section } from "./sections";
5
+ export declare function getSectionRendererIdentifier(section: Section): t.Identifier | undefined;
4
6
  export declare function isSectionRendererElided(section: Section): boolean;
5
7
  export declare function bindingHasProperty(binding: Binding, properties: Opt<string>): boolean;
6
8
  export declare function getPropertyPathAlias(binding: Binding, properties: Opt<string>): Binding;
@@ -10,6 +10,8 @@ declare module "@marko/compiler/dist/types" {
10
10
  interface EntryState {
11
11
  init: boolean;
12
12
  load: boolean;
13
+ /** Whether a reached template lazily imports another. */
14
+ lazy: boolean;
13
15
  /** Depth of enclosing templates whose modules the bundle already loads:
14
16
  * below a root everything arrives through its imports, and a lazy subtree
15
17
  * is loaded by its own load entry. */
@@ -1,5 +1,10 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import type { Section } from "./sections";
3
+ declare module "@marko/compiler/dist/types" {
4
+ interface ProgramExtra {
5
+ uidCounts?: Map<string, number>;
6
+ }
7
+ }
3
8
  export declare function generateUid(name?: string): string;
4
9
  export declare function generateUidIdentifier(name?: string): t.Identifier;
5
10
  export declare function getSharedUid(name: string, section?: Section): string;
@@ -201,16 +201,17 @@ export declare function getExpressionReads(exprExtra: ReferencedExtra): Opt<Read
201
201
  export declare function addRead(exprExtra: ReferencedExtra, extra: t.NodeExtra, binding: Binding, section: Section, getter: Getter | undefined): Read;
202
202
  export declare function dropNodes(node: t.Node | t.Node[]): void;
203
203
  export declare function untrackNode(node: t.Node): void;
204
+ export declare function dropContent(body: t.MarkoTagBody): void;
204
205
  export declare function getCanonicalBinding(binding: Binding): Binding;
205
206
  export declare function someAlias<A>(binding: Binding, test: (binding: Binding, arg: A) => boolean, arg: A, directOnly?: boolean): boolean;
206
207
  export declare function someUpstream<A>(binding: Binding | undefined, test: (binding: Binding, arg: A) => boolean, arg: A): boolean;
207
208
  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 getAllTagReferenceNodes(tag: t.MarkoTag, referenceNodes?: t.Node[], collectAttrTag?: (attrTag: t.MarkoTag) => void): t.Node[];
209
210
  export declare function getScopeAccessorLiteral(binding: Binding, encoded?: boolean, includeId?: boolean): t.NumericLiteral | t.StringLiteral;
210
211
  export declare function getScopeAccessor(binding: Binding, encoded?: boolean, includeId?: boolean): string;
211
212
  export declare function getLocalsScopeAccessor(binding: Binding): string;
212
213
  export declare function getPrefixedScopeAccessor(binding: Binding, prefix: AccessorPrefix): string;
213
- export declare function getClosureAccessorId(binding: Binding): number;
214
+ export declare function getClosureAccessorLiteral(binding: Binding): t.NumericLiteral | t.StringLiteral;
214
215
  export declare function getDebugScopeAccess(binding: Binding): {
215
216
  root: Binding;
216
217
  access: string;
@@ -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;
@@ -63,7 +63,6 @@ export interface Section {
63
63
  referencedHoists: ReferencedBindings;
64
64
  bindings: ReferencedBindings;
65
65
  hoisted: ReferencedBindings;
66
- hoistedTo: ReferencedBindings;
67
66
  serializeReason: undefined | SerializeReason;
68
67
  serializeReasons: Map<symbol, SerializeReason>;
69
68
  /** Reasons any of the section's dom nodes resumes, as the analyzed reasons
@@ -80,7 +79,8 @@ export interface Section {
80
79
  returnSerializeReason: SerializeReason | undefined;
81
80
  isHoistThrough: true | undefined;
82
81
  upstreamExpression: t.NodeExtra | undefined;
83
- /** For a `<define>` body, the sections whose direct calls render it. */
82
+ /** For a `<define>` body or a template rendering itself, the sections whose
83
+ * direct calls render it. */
84
84
  callSections: SortedOpt<Section>;
85
85
  /** The content's rendering tag (its extra), and each child binding the
86
86
  * content feeds, at `properties`. */
@@ -90,11 +90,16 @@ export interface Section {
90
90
  properties: Opt<string>;
91
91
  exprs: KnownExprs | undefined;
92
92
  } | undefined;
93
+ /** Content a known child never reads, which no output renders. */
94
+ pruned: boolean;
93
95
  hasAbortSignal: boolean;
94
96
  /** Count of distinct `$signal` expression roots; analyze allocates each
95
97
  * root's `abortId` from this so translates read, never re-derive. */
96
98
  abortSignalExprs: number;
97
99
  readsOwner: boolean;
100
+ /** Whether analysis found work keyed by setup in the section, or in a
101
+ * `<define>` body or template it calls in place. */
102
+ hasSetupWork: boolean;
98
103
  isBranch: boolean;
99
104
  content: null | {
100
105
  startType: ContentType;
@@ -116,6 +121,7 @@ export declare const sectionUtil: Sorted<Section>;
116
121
  export declare function startSection(path: t.NodePath<t.MarkoTagBody | t.Program>): Section | undefined;
117
122
  export declare function getOrCreateSection(path: t.NodePath<any>): Section;
118
123
  export declare function getSectionForBody(body: t.NodePath<t.MarkoTagBody | t.Program>): Section | undefined;
124
+ export declare function removePrunedContent(tag: t.NodePath<t.MarkoTag>): void;
119
125
  export declare function getSection(path: t.NodePath): Section;
120
126
  export declare const getScopeIdIdentifier: (section: Section) => t.Identifier;
121
127
  export declare const getSectionParentIsOwner: (section: Section) => boolean, setSectionParentIsOwner: (section: Section, value: boolean) => void;
@@ -2,7 +2,7 @@ import { types as t } from "@marko/compiler";
2
2
  import { AccessorPrefix, AccessorProp } from "../../common/types";
3
3
  import { type Opt, Sorted, type SortedOneMany } from "./optional";
4
4
  import { type Binding, type KnownExprs, type ReferencedBindings, type Sources } from "./references";
5
- import { type Section } from "./sections";
5
+ import { type ParamSerializeReasonGroups, type Section } from "./sections";
6
6
  export type SerializeReasons = SortedOneMany<Sources>;
7
7
  export declare const sourcesUtil: Sorted<Sources>;
8
8
  export type SerializeReason = Sources;
@@ -31,7 +31,7 @@ export declare function mergeSerializeReasons(a: SerializeReason, b: undefined |
31
31
  export declare function mergeSerializeReasons(a: undefined | SerializeReason, b: SerializeReason): SerializeReason;
32
32
  export declare function mergeSerializeReasons(a: undefined | SerializeReason, b: undefined | SerializeReason): SerializeReason | undefined;
33
33
  export declare function isOwnResumeReason(reason: SerializeReason | undefined): boolean;
34
- export declare function hasOwnResumeReason(section: Section): boolean;
35
34
  export declare function applySerializeExprs(section: Section): void;
36
35
  export declare function finalizeSerializeReason(section: Section): void;
37
36
  export declare function getSerializeReasonsVersion(): number;
37
+ export declare function setParamReasonGroups(section: Section, groups: ParamSerializeReasonGroups): void;
@@ -0,0 +1,5 @@
1
+ import type { types as t } from "@marko/compiler";
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;
5
+ export declare function finalizeSetupWork(): void;
@@ -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;
@@ -55,8 +53,8 @@ export declare function signalHasStatements(signal: Signal): boolean;
55
53
  export declare function getSignalFn(signal: Signal): t.Expression;
56
54
  export declare function getSignalValueIdentifier(signal: Signal): t.Identifier;
57
55
  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;
56
+ export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
57
+ export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value?: t.Expression): void;
60
58
  export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
61
59
  export declare function writeSignals(section: Section): Set<Signal>;
62
60
  export declare function writeRegisteredFns(): void;
@@ -33,3 +33,4 @@ export declare function controllableClaimFor(tagName: string | undefined): "_con
33
33
  * kind at run time, and a run-time tag name can be any of them. */
34
34
  export declare function controllableFeatureFor(tagName: string | undefined): "controllable" | "controllable-input" | "controllable-open" | "controllable-select" | "controllable-textarea" | undefined;
35
35
  export declare function enableControllable(feature: DOMRuntimeFeature | undefined): void;
36
+ export declare function isPageElement(tagName: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.56",
3
+ "version": "6.4.0",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -51,13 +51,13 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@marko/compiler": "^5.42.9",
54
+ "@marko/compiler": "^5.42.10",
55
55
  "csstype": "^3.2.3",
56
56
  "fastest-levenshtein": "^1.0.16",
57
57
  "magic-string": "^0.30.21"
58
58
  },
59
59
  "devDependencies": {
60
- "@marko/runtime-tags": "npm:marko@6.3.56",
60
+ "@marko/runtime-tags": "npm:marko@6.4.0",
61
61
  "marko": "5.39.44"
62
62
  },
63
63
  "engines": {
@@ -1,5 +0,0 @@
1
- import type { types as t } from "@marko/compiler";
2
- import type { Section } from "./sections";
3
- export declare function addSetupStatement(section: Section): void;
4
- export declare function addSetupExpr(section: Section, node: t.Node | undefined): void;
5
- export declare function sectionHasSetupStatements(section: Section): boolean;