marko 6.0.126 → 6.0.128

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.
@@ -7,3 +7,5 @@ export type BindingPropTree = {
7
7
  rest: BindingPropTree | undefined;
8
8
  };
9
9
  export declare function getBindingPropTree(binding: Binding): BindingPropTree;
10
+ export declare function getBindingPropTreeProp(propTree: BindingPropTree, name: string): BindingPropTree | undefined;
11
+ export declare function getAllBindingPropTreePropKeys(propTree: BindingPropTree): string[];
@@ -1,5 +1,5 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import type { BindingPropTree } from "./binding-prop-tree";
2
+ import { type BindingPropTree } from "./binding-prop-tree";
3
3
  import { type Binding } from "./references";
4
4
  import { type Section } from "./sections";
5
5
  interface KnownExprs {
@@ -20,6 +20,7 @@ export declare function filter<T>(data: Opt<T>, cb: (item: T) => boolean): Opt<T
20
20
  export declare function forEach<T>(data: Opt<T>, cb: (item: T, index: number) => void): void;
21
21
  export declare function fromIter<T>(data: Iterable<T>): T | Many<T> | undefined;
22
22
  export declare function toIter<T>(data: Opt<T>): Iterable<T>;
23
+ export declare function includes<T>(data: Opt<T>, item: T): boolean;
23
24
  export declare function find<T>(data: Opt<T>, cb: (item: T, index: number) => boolean): Opt<T>;
24
25
  export declare function some<T>(data: Opt<T>, cb: (item: T, index: number) => boolean): boolean;
25
26
  export declare function toArray<T, R>(data: Opt<T>, cb: (item: T, index: number) => R): R[];
@@ -2,6 +2,7 @@ import { types as t } from "@marko/compiler";
2
2
  import { type Many, type Opt, Sorted } from "./optional";
3
3
  import { type Section } from "./sections";
4
4
  import { type SerializeReason } from "./serialize-reasons";
5
+ import { type Signal } from "./signals";
5
6
  declare const kIsInvoked: unique symbol;
6
7
  export declare const kBranchSerializeReason: unique symbol;
7
8
  export type Aliases = undefined | Binding | {
@@ -14,7 +15,8 @@ export declare enum BindingType {
14
15
  param = 3,
15
16
  local = 4,
16
17
  derived = 5,
17
- hoist = 6
18
+ hoist = 6,
19
+ constant = 7
18
20
  }
19
21
  export interface Sources {
20
22
  state: Opt<Binding>;
@@ -37,6 +39,7 @@ export interface Binding {
37
39
  upstreamAlias: Binding | undefined;
38
40
  downstreamExpressions: Set<ReferencedExtra>;
39
41
  scopeOffset: Binding | undefined;
42
+ scopeAccessor: string | undefined;
40
43
  export: string | undefined;
41
44
  declared: boolean;
42
45
  nullable: boolean;
@@ -51,6 +54,10 @@ export type ReferencedBindings = Opt<Binding>;
51
54
  export type Intersection = Many<Binding>;
52
55
  interface ReferencedFunctionExtra extends t.FunctionExtra, ReferencedExtra {
53
56
  }
57
+ interface Read {
58
+ binding: Binding;
59
+ extra: t.NodeExtra | undefined;
60
+ }
54
61
  declare module "@marko/compiler/dist/types" {
55
62
  interface NodeExtra {
56
63
  section?: Section;
@@ -65,6 +72,7 @@ declare module "@marko/compiler/dist/types" {
65
72
  };
66
73
  pruned?: true;
67
74
  isEffect?: true;
75
+ spreadFrom?: Binding;
68
76
  [kIsInvoked]?: true;
69
77
  }
70
78
  interface FunctionExtra {
@@ -82,6 +90,7 @@ declare module "@marko/compiler/dist/types" {
82
90
  }
83
91
  }
84
92
  export declare function createBinding(name: string, type: Binding["type"], section: Section, upstreamAlias?: Binding["upstreamAlias"], property?: string, excludeProperties?: Opt<string>, loc?: t.SourceLocation | null, declared?: boolean): Binding;
93
+ export declare function getOrCreatePropertyAlias(binding: Binding, property: string): Binding;
85
94
  export declare function trackDomVarReferences(tag: t.NodePath<t.MarkoTag>, binding: Binding): Binding | undefined;
86
95
  export declare function trackVarReferences(tag: t.NodePath<t.MarkoTag>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
87
96
  export declare function trackParamsReferences(body: t.NodePath<t.MarkoTagBody | t.Program>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
@@ -101,6 +110,8 @@ export declare function compareSources(a: Sources, b: Sources): number;
101
110
  export declare function mergeSources(a: undefined | Sources, b: undefined | Sources): Sources | undefined;
102
111
  export declare const bindingUtil: Sorted<Binding>;
103
112
  export declare const propsUtil: Sorted<string>;
113
+ export declare function addRead(exprExtra: ReferencedExtra, readExtra: t.NodeExtra | undefined, binding: Binding, section: Section): Read;
114
+ export declare function dropRead(exprExtra: ReferencedExtra): void;
104
115
  export declare function dropReferences(node: t.Node | t.Node[]): void;
105
116
  export declare function getCanonicalBinding(binding: Binding): Binding;
106
117
  export declare function getAllTagReferenceNodes(tag: t.MarkoTag, referenceNodes?: t.Node[]): t.Node[];
@@ -114,7 +125,12 @@ export declare function getDebugName(binding: Binding): string;
114
125
  export declare function getDebugNames(refs: ReferencedBindings): string;
115
126
  export declare function getSectionInstancesAccessor(section: Section): string;
116
127
  export declare function getSectionInstancesAccessorLiteral(section: Section): t.StringLiteral | t.NumericLiteral | undefined;
117
- export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression): t.Expression | undefined;
128
+ export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression, signal?: Signal): t.Expression | undefined;
129
+ export declare function hasNonConstantPropertyAlias(ref: Binding): boolean;
130
+ export declare function createRead(binding: Binding, props: Opt<string>): {
131
+ binding: Binding;
132
+ props: Opt<string>;
133
+ };
118
134
  export declare function getObjectPropertyKeyString(expr: t.ObjectProperty | t.ObjectMethod): string | undefined;
119
135
  export interface ReferencedExtra extends t.NodeExtra {
120
136
  section: Section;
@@ -1,5 +1,5 @@
1
1
  import { types as t } from "@marko/compiler";
2
- import type { AccessorPrefix, AccessorProp } from "../../common/types";
2
+ import { type AccessorPrefix, AccessorProp } from "../../common/types";
3
3
  import { type Opt } from "./optional";
4
4
  import { type Binding, type ReferencedBindings } from "./references";
5
5
  import { type Section } from "./sections";
@@ -19,6 +19,7 @@ export type Signal = {
19
19
  effect: t.Statement[];
20
20
  effectReferencedBindings: ReferencedBindings;
21
21
  hasDynamicSubscribers?: true;
22
+ hasSideEffect?: true;
22
23
  export: boolean;
23
24
  extraArgs?: t.Expression[];
24
25
  prependStatements?: t.Statement[];
@@ -37,10 +38,11 @@ export declare function getSignal(section: Section, referencedBindings: Referenc
37
38
  export declare function initValue(binding: Binding, isLet?: boolean): Signal;
38
39
  export declare function signalHasStatements(signal: Signal): boolean;
39
40
  export declare function getSignalFn(signal: Signal): t.Expression;
41
+ export declare function getSignalValueIdentifier(signal: Signal): t.Identifier;
40
42
  export declare function subscribe(references: ReferencedBindings, subscriber: Signal): void;
41
43
  export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
42
- export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], usedReferences?: ReferencedBindings[] | false): void;
43
- export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal["values"][number]["signal"], value: t.Expression): void;
44
+ export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], usedReferences?: ReferencedBindings[] | false, isPure?: boolean): void;
45
+ export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value: t.Expression): void;
44
46
  export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
45
47
  export declare function getRegisterUID(section: Section, name: string): string;
46
48
  export declare function writeSignals(section: Section): void;
@@ -4,7 +4,7 @@ type VisitValue = null | void | t.Node | t.Node[];
4
4
  type VisitKeys<T> = (string | number) & (T extends T ? {
5
5
  [K in keyof T]: T[K] extends VisitValue ? K : never;
6
6
  }[keyof T] : never);
7
- export declare function traverseReplace<T, K extends VisitKeys<T>>(container: T, key: K, enter: (node: t.Node, container: t.Node | t.Node[], key: string | number) => t.Node | void): void;
7
+ export declare function traverseReplace<T, K extends VisitKeys<T>, S>(container: T, key: K, enter: (node: t.Node, state?: S) => t.Node | void, state?: S): void;
8
8
  export declare function traverseContains(node: undefined | null | t.Node | t.Node[], check: (node: t.Node) => void | boolean | typeof skip): boolean;
9
9
  export declare function traverse(visit: (node: t.Node, parent?: t.Node, grandParent?: t.Node) => void | typeof skip, node: undefined | t.Node | t.Node[], parent?: t.Node, grandParent?: t.Node): void;
10
10
  export {};
@@ -7,4 +7,4 @@ declare const _default: {
7
7
  };
8
8
  };
9
9
  export default _default;
10
- export declare function replaceRegisteredFunctionNode(node: t.Node, container: t.Node[] | t.Node): t.CallExpression | t.ClassPrivateProperty | t.ClassProperty | t.ObjectProperty | undefined;
10
+ export declare function replaceRegisteredFunctionNode(node: t.Node): t.CallExpression | t.ClassPrivateProperty | t.ClassProperty | t.ObjectProperty | undefined;
@@ -11,7 +11,6 @@ export type ParamSerializeReasonGroups = [
11
11
  ParamSerializeReasonGroup,
12
12
  ...ParamSerializeReasonGroup[]
13
13
  ];
14
- export declare let cleanIdentifier: t.Identifier;
15
14
  export declare let scopeIdentifier: t.Identifier;
16
15
  export declare function isScopeIdentifier(node: t.Node): node is t.Identifier;
17
16
  export type TemplateExports = BindingPropTree["props"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.126",
3
+ "version": "6.0.128",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",