marko 6.3.32 → 6.3.34

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 (63) hide show
  1. package/cheatsheet.md +38 -31
  2. package/dist/common/errors.d.ts +1 -0
  3. package/dist/debug/dom/catch.feat.js +1 -1
  4. package/dist/debug/dom/catch.feat.mjs +1 -1
  5. package/dist/debug/dom/controllable-input.feat.js +1 -1
  6. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  7. package/dist/debug/dom/controllable-open.feat.js +1 -1
  8. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-select.feat.js +1 -1
  10. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  12. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable.feat.js +1 -1
  14. package/dist/debug/dom/controllable.feat.mjs +1 -1
  15. package/dist/debug/{dom-CiFITSPN.js → dom-Bj58jt8y.js} +55 -30
  16. package/dist/debug/{dom-BJ93mcSe.mjs → dom-klf8Ec_o.mjs} +55 -30
  17. package/dist/debug/dom.js +3 -1
  18. package/dist/debug/dom.mjs +3 -1
  19. package/dist/debug/html.js +154 -86
  20. package/dist/debug/html.mjs +155 -84
  21. package/dist/dom/catch.feat.js +1 -1
  22. package/dist/dom/catch.feat.mjs +1 -1
  23. package/dist/dom/control-flow.d.ts +3 -1
  24. package/dist/dom/controllable-input.feat.js +1 -1
  25. package/dist/dom/controllable-input.feat.mjs +1 -1
  26. package/dist/dom/controllable-open.feat.js +1 -1
  27. package/dist/dom/controllable-open.feat.mjs +1 -1
  28. package/dist/dom/controllable-select.feat.js +1 -1
  29. package/dist/dom/controllable-select.feat.mjs +1 -1
  30. package/dist/dom/controllable-textarea.feat.js +1 -1
  31. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  32. package/dist/dom/controllable.feat.js +1 -1
  33. package/dist/dom/controllable.feat.mjs +1 -1
  34. package/dist/{dom-Cj4HQ7T_.mjs → dom-6hBvZW7X.mjs} +27 -21
  35. package/dist/{dom-CI-06TZb.js → dom-B-XpL2_H.js} +27 -21
  36. package/dist/dom.js +3 -1
  37. package/dist/dom.mjs +3 -1
  38. package/dist/html/compat.d.ts +6 -2
  39. package/dist/html/writer.d.ts +3 -0
  40. package/dist/html.d.ts +1 -1
  41. package/dist/html.js +104 -65
  42. package/dist/html.mjs +104 -65
  43. package/dist/translator/core/client.d.ts +1 -2
  44. package/dist/translator/core/server.d.ts +1 -2
  45. package/dist/translator/core/static.d.ts +1 -2
  46. package/dist/translator/index.js +430 -294
  47. package/dist/translator/util/branch-tag.d.ts +5 -0
  48. package/dist/translator/util/constants/binding-type.d.ts +1 -0
  49. package/dist/translator/util/references.d.ts +8 -1
  50. package/dist/translator/util/serialize-reasons.d.ts +4 -4
  51. package/dist/translator/util/signals.d.ts +4 -3
  52. package/dist/translator/util/statement-tag.d.ts +2 -0
  53. package/dist/translator/visitors/program/index.d.ts +0 -1
  54. package/index.d.ts +19 -1
  55. package/package.json +5 -4
  56. package/tags/html-comment.d.marko +2 -0
  57. package/tags/html-script.d.marko +2 -0
  58. package/tags/html-style.d.marko +2 -0
  59. package/tags/let.d.marko +2 -2
  60. package/tags/show.d.marko +6 -0
  61. package/tags/try.d.marko +1 -1
  62. package/tags-html.d.ts +6 -1
  63. /package/dist/translator/util/{get-accessor-char.d.ts → get-accessor-enums.d.ts} +0 -0
@@ -0,0 +1,5 @@
1
+ import { type Binding } from "./references";
2
+ import type { Section } from "./sections";
3
+ export declare function getBranchSectionAccessor(nodeBinding: Binding): NonNullable<Section["sectionAccessor"]>;
4
+ export declare function initBranchSection(bodySection: Section, upstreamExpression: Section["upstreamExpression"], sectionAccessor: Section["sectionAccessor"]): void;
5
+ export declare function resumeOwnerByMarkerWhenStatic(tagSection: Section, bodySection: Section, nodeBinding: Binding, statefulReasonKey: symbol): void;
@@ -6,5 +6,6 @@ export declare const param = 3;
6
6
  export declare const local = 4;
7
7
  export declare const derived = 5;
8
8
  export declare const constant = 6;
9
+ export declare const global = 7;
9
10
  type Self = typeof import("./binding-type");
10
11
  export type Value = Self[keyof Self];
@@ -14,7 +14,9 @@ export { BindingType };
14
14
  export interface Sources {
15
15
  state: Opt<Binding>;
16
16
  param: Opt<InputBinding | ParamBinding>;
17
+ global: true | undefined;
17
18
  }
19
+ export declare const globalSources: Sources;
18
20
  export interface Binding {
19
21
  id: number;
20
22
  name: string;
@@ -68,6 +70,7 @@ interface Read {
68
70
  getter: Getter | undefined;
69
71
  comparedTo: t.Node | undefined;
70
72
  deferred: boolean;
73
+ serializedValue?: true;
71
74
  }
72
75
  interface ExtraRead {
73
76
  binding: Binding;
@@ -90,6 +93,9 @@ declare module "@marko/compiler/dist/types" {
90
93
  isEffect?: true;
91
94
  invokeOnly?: true;
92
95
  lazyBindings?: ReferencedBindings;
96
+ /** `$global` bindings this expression reads: the root means an opaque
97
+ * (dynamic/aliased) read, a property alias names the key. */
98
+ globalBindings?: ReferencedBindings;
93
99
  spreadFrom?: Binding;
94
100
  nativeTagSpread?: true;
95
101
  nativeTagSpreadMerged?: true;
@@ -120,6 +126,7 @@ export declare function trackParamsReferences(body: t.NodePath<t.MarkoTagBody |
120
126
  export declare function isReferenceInOwnBody(bindingPath: t.NodePath, reference: t.NodePath): boolean;
121
127
  export declare function isReferenceHoisted(bindingPath: t.NodePath, reference: t.NodePath): boolean;
122
128
  export declare function setReferencesScope(path: t.NodePath<any>): void;
129
+ export declare function trackGlobalReference(path: t.NodePath<t.Identifier>): void;
123
130
  export declare function mergeReferences<T extends t.Node>(section: Section, target: T, nodes: (t.Node | undefined)[]): NonNullable<T["extra"]> & ReferencedExtra;
124
131
  export declare function compareReferences(a: ReferencedBindings, b: ReferencedBindings): number;
125
132
  export declare function finalizeReferences(): void;
@@ -130,7 +137,7 @@ export declare const intersectionMeta: WeakMap<Intersection, {
130
137
  }>;
131
138
  export declare const collapsedIntersectionSource: WeakMap<Intersection, Binding>;
132
139
  export declare function setBindingDownstream(binding: Binding, expr: boolean | Opt<t.NodeExtra>): void;
133
- export declare function createSources(state: Sources["state"], param: Sources["param"]): Sources;
140
+ export declare function createSources(state: Sources["state"], param: Sources["param"], global?: Sources["global"]): Sources;
134
141
  export declare function compareSources(a: Sources, b: Sources): number;
135
142
  export declare function mergeSources(a: undefined | Sources, b: undefined | Sources): Sources | undefined;
136
143
  export declare const bindingUtil: Sorted<Binding>;
@@ -1,7 +1,7 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import { AccessorPrefix, AccessorProp } from "../../common/types";
3
- import { type OneMany, type Opt } from "./optional";
4
- import { type Binding, type InputBinding, type ParamBinding, type ReferencedBindings, type Sources } from "./references";
3
+ import { type Opt } from "./optional";
4
+ import { type Binding, type ReferencedBindings, type Sources } from "./references";
5
5
  import type { Section } from "./sections";
6
6
  export type SerializeReasons = true | [Sources, ...Sources[]];
7
7
  export type SerializeReason = true | Sources;
@@ -10,9 +10,8 @@ export declare function isForceSerialized(section: Section, prop?: Binding | Acc
10
10
  export declare function addSerializeReason(section: Section, reason: undefined | false | SerializeReason, prop?: Binding | AccessorProp | symbol, prefix?: AccessorPrefix | symbol): void;
11
11
  export declare function addSerializeExpr(section: Section, expr: boolean | Opt<t.NodeExtra>, prop?: Binding | AccessorProp | symbol, prefix?: AccessorPrefix | symbol): void;
12
12
  export declare function addOwnerSerializeReason(from: Section, to: Section, reason: undefined | boolean | SerializeReason): void;
13
- export declare function isReasonDynamic(reason: undefined | SerializeReason): reason is {
13
+ export declare function isReasonDynamic(reason: undefined | SerializeReason): reason is Sources & {
14
14
  state: undefined;
15
- param: OneMany<InputBinding | ParamBinding>;
16
15
  };
17
16
  export declare function isStaticSerializeReason(reason: undefined | SerializeReason): reason is SerializeReason;
18
17
  export declare function isStateSerializeReason(reason: undefined | SerializeReason): reason is Sources;
@@ -25,3 +24,4 @@ export declare function mergeSerializeReasons(a: undefined | SerializeReason, b:
25
24
  export declare function mergeSerializeReasons(a: undefined | SerializeReason, b: undefined | SerializeReason): SerializeReason | undefined;
26
25
  export declare function applySerializeExprs(section: Section): void;
27
26
  export declare function finalizeSerializeReason(section: Section): void;
27
+ export declare function getSerializeProvenance(section: Section, prop?: Binding | AccessorProp | symbol, prefix?: AccessorPrefix | symbol): Sources | undefined;
@@ -14,10 +14,11 @@ export interface Signal {
14
14
  value: t.Expression;
15
15
  }>;
16
16
  intersection: Opt<Signal>;
17
+ /** Signals this one forwards into: they must declare first when the
18
+ * forward simplifies to a bare, eagerly evaluated reference. */
19
+ forwards: Opt<Signal>;
17
20
  render: t.Statement[];
18
- renderReferencedBindings: ReferencedBindings;
19
21
  effect: t.Statement[];
20
- effectReferencedBindings: ReferencedBindings;
21
22
  hasHTMLEffect: boolean;
22
23
  hasSideEffect: boolean;
23
24
  forcePersist: boolean;
@@ -46,7 +47,7 @@ export declare function signalHasStatements(signal: Signal): boolean;
46
47
  export declare function getSignalFn(signal: Signal): t.Expression;
47
48
  export declare function getSignalValueIdentifier(signal: Signal): t.Identifier;
48
49
  export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
49
- export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], usedReferences?: ReferencedBindings[] | false, isPure?: boolean): void;
50
+ export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
50
51
  export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value: t.Expression): void;
51
52
  export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
52
53
  export declare function writeSignals(section: Section): Set<Signal>;
@@ -0,0 +1,2 @@
1
+ import { type Tag } from "@marko/compiler/babel-utils";
2
+ export declare function createStatementTag(keyword: "client" | "server" | "static"): Tag;
@@ -3,7 +3,6 @@ import { type BindingPropTree } from "../../util/binding-prop-tree";
3
3
  import { preAnalyze } from "./pre-analyze";
4
4
  export declare let scopeIdentifier: t.Identifier;
5
5
  export declare let localsIdentifier: t.Identifier;
6
- export declare function isScopeIdentifier(node: t.Node): node is t.Identifier;
7
6
  declare module "@marko/compiler/dist/types" {
8
7
  interface ProgramExtra {
9
8
  domExports?: {
package/index.d.ts CHANGED
@@ -11,7 +11,25 @@ declare global {
11
11
  }
12
12
 
13
13
  namespace Marko {
14
- /** A mutable global object for the current render. */
14
+ /**
15
+ * A mutable global object for the current render.
16
+ *
17
+ * The open index signature means an unaugmented `$global` is unchecked. To
18
+ * type your own keys, merge into this interface:
19
+ *
20
+ * ```ts
21
+ * declare global {
22
+ * namespace Marko {
23
+ * interface Global {
24
+ * data?: MyRouteContext;
25
+ * }
26
+ * }
27
+ * }
28
+ * ```
29
+ *
30
+ * Declare merged members OPTIONAL — a required one makes every
31
+ * `render({ $global: {} })` call fail with TS2741.
32
+ */
15
33
  export interface Global {
16
34
  [x: PropertyKey]: unknown;
17
35
  /** An AbortSignal instance that, when aborted, stops further streamed content. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.32",
3
+ "version": "6.3.34",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -48,14 +48,14 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@marko/compiler": "^5.41.16",
51
+ "@marko/compiler": "^5.41.18",
52
52
  "csstype": "^3.2.3",
53
53
  "fastest-levenshtein": "^1.0.16",
54
54
  "magic-string": "^0.30.21"
55
55
  },
56
56
  "devDependencies": {
57
- "@marko/runtime-tags": "npm:marko@6.3.32",
58
- "marko": "5.39.30"
57
+ "@marko/runtime-tags": "npm:marko@6.3.34",
58
+ "marko": "5.39.32"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=22"
@@ -65,6 +65,7 @@
65
65
  "types": "./index.d.ts"
66
66
  },
67
67
  "./cheatsheet.md": "./cheatsheet.md",
68
+ "./package.json": "./package.json",
68
69
  "./translator": "./src/translator/index.ts",
69
70
  "./tags/*": "./tags/*",
70
71
  "./debug/*": "./src/*.ts",
@@ -1 +1,3 @@
1
1
  export interface Input {}
2
+
3
+ return=(null! as () => Comment)
@@ -1 +1,3 @@
1
1
  export interface Input extends Marko.HTML.Script {}
2
+
3
+ return=(null! as () => HTMLScriptElement)
@@ -1 +1,3 @@
1
1
  export interface Input extends Marko.HTML.Style {}
2
+
3
+ return=(null! as () => HTMLStyleElement)
package/tags/let.d.marko CHANGED
@@ -1,8 +1,8 @@
1
1
  /** File for types only, not actual implementation **/
2
2
 
3
3
  export interface Input<T, K = T> {
4
- value: T;
4
+ value?: T;
5
5
  valueChange?: ((newValue: K) => void) | false | null;
6
6
  }
7
7
 
8
- return=input.value valueChange=(input.valueChange as (newValue: K) => void)
8
+ return=(input.value as T) valueChange=(input.valueChange as (newValue: K) => void)
@@ -0,0 +1,6 @@
1
+ /** File for types only, not actual implementation **/
2
+
3
+ export interface Input {
4
+ value: unknown;
5
+ content: Marko.Body;
6
+ }
package/tags/try.d.marko CHANGED
@@ -3,5 +3,5 @@
3
3
  export interface Input {
4
4
  content: Marko.Body,
5
5
  placeholder?: Marko.AttrTag<{ content?: Marko.Body }>,
6
- catch?: Marko.AttrTag<{ content?: Marko.Body<[unknown]> }>,
6
+ catch?: Marko.AttrTag<{ content?: Marko.Body<[any]> }>,
7
7
  }
package/tags-html.d.ts CHANGED
@@ -5936,7 +5936,12 @@ type AttrStyle = AttrMissing | string | Marko.CSS.Properties | AttrStyle[];
5936
5936
  type AttrCrossOrigin = AttrBoolean | "anonymous" | "use-credentials";
5937
5937
  type AttrEventHandler<Event, Target> =
5938
5938
  | AttrMissing
5939
- | ((event: Event, target: Target) => unknown);
5939
+ | ((
5940
+ event: Event & {
5941
+ currentTarget: "Marko delegates events, so `event.currentTarget` is not this element — use the handler's second parameter: (event, target) => ...";
5942
+ },
5943
+ target: Target,
5944
+ ) => unknown);
5940
5945
  type AttrTarget =
5941
5946
  | AttrMissing
5942
5947
  | "_blank"