marko 6.4.3 → 6.4.5

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 (74) hide show
  1. package/cheatsheet.md +2 -2
  2. package/dist/common/constants/renderer-prop.d.ts +2 -0
  3. package/dist/common/constants/renderer-prop.debug.d.ts +2 -0
  4. package/dist/debug/dom/catch.feat.js +1 -1
  5. package/dist/debug/dom/catch.feat.mjs +1 -1
  6. package/dist/debug/dom/controllable-input.feat.js +1 -1
  7. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  8. package/dist/debug/dom/controllable-open.feat.js +1 -1
  9. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  10. package/dist/debug/dom/controllable-select.feat.js +1 -1
  11. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  12. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  13. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  14. package/dist/debug/dom/controllable.feat.js +1 -1
  15. package/dist/debug/dom/controllable.feat.mjs +1 -1
  16. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  17. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  18. package/dist/debug/dom/dynamic-tag-var.feat.js +5 -1
  19. package/dist/debug/dom/dynamic-tag-var.feat.mjs +5 -1
  20. package/dist/debug/dom/lazy.feat.js +1 -1
  21. package/dist/debug/dom/lazy.feat.mjs +1 -1
  22. package/dist/debug/dom/placeholder.feat.js +1 -1
  23. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  24. package/dist/debug/{dom-uEY0J_H9.mjs → dom-BeY1nGUb.mjs} +15 -12
  25. package/dist/debug/{dom-C7F3yZTh.js → dom-CUxvM4i9.js} +32 -23
  26. package/dist/debug/dom.js +3 -10
  27. package/dist/debug/dom.mjs +3 -10
  28. package/dist/debug/html.js +30 -24
  29. package/dist/debug/html.mjs +30 -24
  30. package/dist/dom/catch.feat.js +4 -4
  31. package/dist/dom/catch.feat.mjs +1 -1
  32. package/dist/dom/control-flow.d.ts +2 -2
  33. package/dist/dom/controllable-input.feat.js +2 -2
  34. package/dist/dom/controllable-input.feat.mjs +1 -1
  35. package/dist/dom/controllable-open.feat.js +2 -2
  36. package/dist/dom/controllable-open.feat.mjs +1 -1
  37. package/dist/dom/controllable-select.feat.js +2 -2
  38. package/dist/dom/controllable-select.feat.mjs +1 -1
  39. package/dist/dom/controllable-textarea.feat.js +2 -2
  40. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  41. package/dist/dom/controllable.feat.js +2 -2
  42. package/dist/dom/controllable.feat.mjs +1 -1
  43. package/dist/dom/dynamic-tag-script.feat.js +2 -2
  44. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  45. package/dist/dom/dynamic-tag-var.feat.js +3 -3
  46. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  47. package/dist/dom/lazy.feat.js +1 -1
  48. package/dist/dom/lazy.feat.mjs +1 -1
  49. package/dist/dom/load.d.ts +0 -1
  50. package/dist/dom/placeholder.feat.js +3 -3
  51. package/dist/dom/placeholder.feat.mjs +1 -1
  52. package/dist/dom/renderer.d.ts +9 -2
  53. package/dist/{dom-DHg9YChM.mjs → dom-DefWmvQB.mjs} +10 -7
  54. package/dist/{dom-CtIT8Mpr.js → dom-Diu8MpmL.js} +124 -126
  55. package/dist/dom.d.ts +2 -2
  56. package/dist/dom.js +31 -37
  57. package/dist/dom.mjs +2 -8
  58. package/dist/html/assets.d.ts +1 -1
  59. package/dist/html/content.d.ts +1 -0
  60. package/dist/html/dynamic-tag.d.ts +1 -1
  61. package/dist/html/template.d.ts +1 -0
  62. package/dist/html.js +12 -11
  63. package/dist/html.mjs +12 -11
  64. package/dist/translator/index.js +202 -109
  65. package/dist/translator/util/entry-builder.d.ts +10 -3
  66. package/dist/translator/util/module-registrations.d.ts +1 -1
  67. package/dist/translator/util/references.d.ts +2 -1
  68. package/dist/translator/util/signals.d.ts +10 -1
  69. package/dist/translator/util/solve-reasons.d.ts +1 -0
  70. package/dist/translator/util/write-guard.d.ts +4 -0
  71. package/dist/translator/visitors/function.d.ts +15 -10
  72. package/dist/translator/visitors/import-declaration.d.ts +3 -4
  73. package/package.json +4 -4
  74. package/tags-html.d.ts +3 -2
@@ -16,19 +16,26 @@ interface EntryState {
16
16
  * below a root everything arrives through its imports, and a lazy subtree
17
17
  * is loaded by its own load entry. */
18
18
  bundled: number;
19
+ /** Depth of enclosing lazy imports, whose load entries bring their assets. */
20
+ lazyDepth: number;
19
21
  roots: string[];
20
22
  /** Assets of templates the bundle never loads; the entry imports them. */
21
23
  assets: Set<string>;
22
24
  /** Assets that arrive through a bundled template's imports; the entry
23
25
  * imports them itself only when it links nothing (a server only page). */
24
26
  bundledAssets: Set<string>;
25
- /** Whether each reached file was only ever seen below a bundled template. */
26
- visited: Map<string, boolean>;
27
+ /** The most eager way each file has been reached. */
28
+ visited: Map<string, Reach>;
27
29
  }
30
+ /** How a file was reached: 0 eagerly, 1 below a bundled template, 2 only
31
+ * within a lazy subtree. Lower is more eager, so `seen <= reach` means it was
32
+ * already visited at least as eagerly and is skipped; a file reached more
33
+ * eagerly than before is re-visited, since it may then own assets or a root. */
34
+ export type Reach = 0 | 1 | 2;
28
35
  type EntryFile = t.BabelFile & {
29
36
  [kState]?: EntryState;
30
37
  };
31
- type VisitChild = (id: string, bundled?: boolean) => void;
38
+ type VisitChild = (id: string, reach?: Reach) => void;
32
39
  declare const kState: unique symbol;
33
40
  declare const builder: {
34
41
  build(entryFile: EntryFile, exportInit?: boolean): t.Statement[];
@@ -2,6 +2,6 @@ import { types as t } from "@marko/compiler";
2
2
  /**
3
3
  * Writes the registrations for module scoped functions: the ones this template
4
4
  * exports and registers itself, and the ones it imports from a template that
5
- * reserved a register id without registering it.
5
+ * reserved a register id without registering it; and for templates it imports.
6
6
  */
7
7
  export declare function writeModuleRegistrations(program: t.NodePath<t.Program>): void;
@@ -12,7 +12,8 @@ export interface Read {
12
12
  getter: Getter | undefined;
13
13
  comparedTo: t.Node | undefined;
14
14
  deferred: boolean;
15
- inFunction: boolean;
15
+ /** The outermost function holding it; none when that escapes into a call. */
16
+ fnRoot: ReferencedFunctionExtra | undefined;
16
17
  }
17
18
  export interface ExtraRead {
18
19
  binding: Binding;
@@ -33,8 +33,17 @@ export interface Signal {
33
33
  buildAssignment: ((valueSection: Section, value: t.Expression) => t.Expression | undefined) | undefined;
34
34
  }
35
35
  type closureSignalBuilder = (closure: Binding, render: t.Expression) => t.Expression;
36
+ export type ClosureHop = {
37
+ kind: "if";
38
+ ref: Binding;
39
+ index: number;
40
+ } | {
41
+ kind: "for";
42
+ ref: Binding;
43
+ };
36
44
  export declare const getSignals: (section: Section) => Map<unknown, Signal>;
37
- export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
45
+ export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, hop: ClosureHop, build?: closureSignalBuilder): void;
46
+ export declare function buildClosureHop(hop: ClosureHop, render: t.Expression): t.CallExpression;
38
47
  export declare function setSectionOwnerResumedByMarker(section: Section): void;
39
48
  export declare function getContentClosureValues(bodySection: Section): {
40
49
  scope: t.Identifier;
@@ -6,5 +6,6 @@ import { type Section } from "./sections";
6
6
  export declare function solveReasons(intersectionsBySection: Map<Section, Intersection[]>): void;
7
7
  export declare function getReasonForBinding(binding: Binding, properties?: Opt<string> | true): undefined | Reason;
8
8
  export declare function getValueReason(extra: t.NodeExtra): undefined | Reason;
9
+ export declare function getReasonForExpr(extra: t.NodeExtra): undefined | Reason;
9
10
  export declare function readsValuesOnResume(expr: t.NodeExtra): boolean;
10
11
  export declare function addAlwaysRead(binding: Binding): void;
@@ -1,12 +1,16 @@
1
1
  import { types as t } from "@marko/compiler";
2
+ import { type Binding } from "./bindings";
2
3
  import { type Reason, type Reasons } from "./reasons";
3
4
  import { type Section } from "./sections";
5
+ import { type Sources } from "./sources";
4
6
  export declare function isSameReason(a: Reason | undefined, b: Reason | undefined): boolean;
5
7
  export declare function buildGroupMask(groups: {
6
8
  value: number | t.Expression | undefined;
7
9
  names: string;
8
10
  }[]): t.Expression | undefined;
9
11
  export declare function getScopeReasonStatement(section: Section): t.Statement;
12
+ export declare function getWriteReason(binding: Binding): Sources | undefined;
13
+ export declare function getBranchWriteReason(section: Section): Sources | undefined;
10
14
  export declare function getWriteGuard(section: Section, reason: undefined | Reason, optional: boolean): t.Expression | undefined;
11
15
  export declare function getWriteGuardForAny(section: Section, reasons: undefined | Reasons, optional: boolean): t.Expression | undefined;
12
16
  export declare function getExprIfWritten<T extends undefined | Reason, R extends (T extends {} ? t.Expression : undefined)>(section: Section, reason: T, expr: t.Expression): R;
@@ -2,16 +2,16 @@ import { types as t } from "@marko/compiler";
2
2
  declare const kRegisteredExports: unique symbol;
3
3
  declare module "@marko/compiler/dist/types" {
4
4
  interface ProgramExtra {
5
- [kRegisteredExports]?: Map<string, ReservedExport>;
5
+ [kRegisteredExports]?: Map<string, RegisteredExport>;
6
6
  }
7
7
  }
8
- /** The canonical name a reserved register id is exported under, and its id. */
9
- export interface ReservedExport {
8
+ /**
9
+ * An export registered under an id: the template that declares it, and the
10
+ * canonical name it is exported under.
11
+ */
12
+ export interface RegisteredExport {
10
13
  registerId: string;
11
14
  exportName: string;
12
- }
13
- /** A reserved export, plus the template that declares it. */
14
- export interface ResolvedExport extends ReservedExport {
15
15
  filename: string;
16
16
  }
17
17
  declare const _default: {
@@ -21,15 +21,20 @@ export default _default;
21
21
  export declare function resolveFunctionReason(): void;
22
22
  export declare function finalizeFunctionRegistry(): void;
23
23
  /**
24
- * Tracks a function imported from another template that reserved a register id.
25
- * The importing template registers it (under the reserved id) when client
24
+ * Tracks a template imported as a default export. The server writes a template
25
+ * only as a binding's value, so the importing template registers it when one may.
26
+ */
27
+ export declare function trackImportedTemplate(importDecl: t.NodePath<t.ImportDeclaration>, local: string, templateFile: t.BabelFile): void;
28
+ /**
29
+ * Tracks an export imported from another template that registers under an id,
30
+ * if it does. The importing template registers it (under that id) when client
26
31
  * code reads its own references.
27
32
  */
28
- export declare function trackImportedFn(importDecl: t.NodePath<t.ImportDeclaration>, local: string, resolved: ResolvedExport): void;
33
+ export declare function trackImport(importDecl: t.NodePath<t.ImportDeclaration>, local: string, registered: RegisteredExport | undefined, fnRoots?: Set<t.NodeExtra>): void;
29
34
  /**
30
35
  * Finds the id reserved for an export, following `export ... from` hops. Each
31
36
  * template only records the exports it declares, so this resolves on demand:
32
37
  * a template in an import cycle is read while it is still analyzing, and would
33
38
  * hand out an incomplete map if the ids were pushed ahead of time.
34
39
  */
35
- export declare function resolveRegisteredExport(file: t.BabelFile, exportName: string, seen?: Set<string>): ResolvedExport | undefined;
40
+ export declare function resolveRegisteredExport(file: t.BabelFile, exportName: string, seen?: Set<string>): RegisteredExport | undefined;
@@ -1,6 +1,6 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import type { LoadTrigger } from "../../html/assets";
3
- import { type ResolvedExport } from "./function";
3
+ import { type RegisteredExport } from "./function";
4
4
  declare module "@marko/compiler/dist/types" {
5
5
  interface ProgramExtra {
6
6
  /** Absolute filenames of templates this one imports with `load`. */
@@ -9,9 +9,8 @@ declare module "@marko/compiler/dist/types" {
9
9
  interface ImportDeclarationExtra {
10
10
  tagImport?: string;
11
11
  loadImport?: LoadImportConfig;
12
- registeredImportedFns?: (ResolvedExport & {
13
- local: string;
14
- })[];
12
+ /** Each local binding the template registers -> the export it imports. */
13
+ registeredImports?: Map<string, RegisteredExport>;
15
14
  }
16
15
  }
17
16
  export type LoadImportConfig = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.4.3",
3
+ "version": "6.4.5",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -51,14 +51,14 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@marko/compiler": "^5.42.10",
54
+ "@marko/compiler": "^5.42.11",
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.4.3",
61
- "marko": "5.39.45"
60
+ "@marko/runtime-tags": "npm:marko@6.4.5",
61
+ "marko": "5.39.46"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22"
package/tags-html.d.ts CHANGED
@@ -5939,10 +5939,11 @@ interface CommonAttributes<T extends Element> {
5939
5939
  type AttrMissing = undefined | null | false;
5940
5940
  type AttrClass =
5941
5941
  | AttrMissing
5942
+ | 0
5942
5943
  | string
5943
5944
  | AttrClass[]
5944
- | Record<string, AttrMissing | boolean>;
5945
- type AttrStyle = AttrMissing | string | Marko.CSS.Properties | AttrStyle[];
5945
+ | Record<string, AttrMissing | boolean | number>;
5946
+ type AttrStyle = AttrMissing | 0 | string | Marko.CSS.Properties | AttrStyle[];
5946
5947
  type AttrCrossOrigin = AttrBoolean | "anonymous" | "use-credentials";
5947
5948
  type AttrEventHandler<Event, Target> =
5948
5949
  | AttrMissing