marko 6.0.0-next.3.38 → 6.0.0-next.3.40

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.
@@ -996,8 +996,15 @@ function analyzeTagNameType(tag) {
996
996
  if (name2.isStringLiteral()) {
997
997
  extra.tagNameType = name2.node.value[0] === "@" ? 3 /* AttributeTag */ : (0, import_babel_utils6.isNativeTag)(tag) ? 0 /* NativeTag */ : 1 /* CustomTag */;
998
998
  extra.tagNameNullable = extra.tagNameNullable = false;
999
- } else {
999
+ } else if (name2.isIdentifier()) {
1000
1000
  analyzeExpressionTagName(name2, extra);
1001
+ if (extra.tagNameType === 0 /* NativeTag */) {
1002
+ extra.tagNameType = 2 /* DynamicTag */;
1003
+ }
1004
+ } else if (name2.isTemplateLiteral() && !name2.node.expressions.length) {
1005
+ extra.tagNameType = 0 /* NativeTag */;
1006
+ } else {
1007
+ extra.tagNameType = 2 /* DynamicTag */;
1001
1008
  }
1002
1009
  if (extra.tagNameType === void 0) {
1003
1010
  extra.tagNameType = 2 /* DynamicTag */;
@@ -2084,13 +2091,26 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2084
2091
  scopeIdentifier,
2085
2092
  import_compiler17.types.identifier(referencedBindings.name)
2086
2093
  ]);
2087
- signal.isDynamicClosure = isDynamicClosure;
2088
2094
  const intersection = buildSignalIntersections(signal);
2089
- return isDynamicClosure ? callRuntime(
2095
+ return isDynamicClosure ? isStatefulReferences(referencedBindings) ? callRuntime(
2096
+ "registerDynamicClosure",
2097
+ import_compiler17.types.stringLiteral(
2098
+ getResumeRegisterId(
2099
+ section,
2100
+ signal.referencedBindings,
2101
+ "subscriber"
2102
+ )
2103
+ ),
2104
+ getScopeAccessorLiteral(referencedBindings),
2105
+ render,
2106
+ intersection,
2107
+ isImmediateOwner ? void 0 : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope)
2108
+ ) : callRuntime(
2090
2109
  "dynamicClosure",
2110
+ getScopeAccessorLiteral(referencedBindings),
2091
2111
  render,
2092
- isImmediateOwner ? null : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope),
2093
- intersection
2112
+ intersection,
2113
+ isImmediateOwner ? void 0 : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope)
2094
2114
  ) : builder(signal, render, intersection);
2095
2115
  };
2096
2116
  addStatement(
@@ -2100,10 +2120,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2100
2120
  import_compiler17.types.expressionStatement(
2101
2121
  import_compiler17.types.callExpression(
2102
2122
  import_compiler17.types.memberExpression(signal.identifier, import_compiler17.types.identifier("_")),
2103
- [
2104
- scopeIdentifier,
2105
- createScopeReadExpression(section, referencedBindings)
2106
- ]
2123
+ [scopeIdentifier]
2107
2124
  )
2108
2125
  )
2109
2126
  );
@@ -2191,10 +2208,7 @@ function getSignalFn(signal, params, referencedBindings) {
2191
2208
  if (isStatefulReferences(closureSignal.referencedBindings)) {
2192
2209
  signal.render.push(
2193
2210
  import_compiler17.types.expressionStatement(
2194
- import_compiler17.types.callExpression(closureSignal.identifier, [
2195
- scopeIdentifier2,
2196
- valueIdentifier
2197
- ])
2211
+ import_compiler17.types.callExpression(closureSignal.identifier, [scopeIdentifier2])
2198
2212
  )
2199
2213
  );
2200
2214
  }
@@ -2288,7 +2302,7 @@ function generateSignalName(referencedBindings) {
2288
2302
  return name2;
2289
2303
  }
2290
2304
  function finalizeSignalArgs(args) {
2291
- for (let i = args.length - 1; i >= 0; i--) {
2305
+ for (let i = args.length; i--; ) {
2292
2306
  const arg = args[i];
2293
2307
  if (import_compiler17.types.isArrowFunctionExpression(arg) && import_compiler17.types.isBlockStatement(arg.body)) {
2294
2308
  const body = arg.body.body;
@@ -2297,9 +2311,11 @@ function finalizeSignalArgs(args) {
2297
2311
  } else if (body.length === 1 && import_compiler17.types.isExpressionStatement(body[0])) {
2298
2312
  arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
2299
2313
  }
2314
+ } else if (import_compiler17.types.isNullLiteral(arg) || import_compiler17.types.isUnaryExpression(arg) && arg.operator === "void") {
2315
+ args[i] = import_compiler17.types.numericLiteral(0);
2300
2316
  }
2301
2317
  }
2302
- for (let i = args.length - 1; import_compiler17.types.isNullLiteral(args[i]); ) {
2318
+ for (let i = args.length - 1; import_compiler17.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
2303
2319
  args.length = i--;
2304
2320
  }
2305
2321
  }
@@ -2437,15 +2453,6 @@ function writeSignals(section) {
2437
2453
  value
2438
2454
  );
2439
2455
  }
2440
- if (signal.isDynamicClosure && isStatefulReferences(signal.referencedBindings)) {
2441
- value = callRuntime(
2442
- "registerSubscriber",
2443
- import_compiler17.types.stringLiteral(
2444
- getResumeRegisterId(section, signal.referencedBindings, "subscriber")
2445
- ),
2446
- value
2447
- );
2448
- }
2449
2456
  const signalDeclarator = import_compiler17.types.variableDeclarator(signal.identifier, value);
2450
2457
  let signalDeclaration = !section.parent && !signal.referencedBindings && (import_compiler17.types.isFunctionExpression(value) || import_compiler17.types.isArrowFunctionExpression(value)) ? import_compiler17.types.functionDeclaration(
2451
2458
  signal.identifier,
@@ -3973,7 +3980,7 @@ function isStatefulBinding(binding) {
3973
3980
  case 2 /* input */:
3974
3981
  return true;
3975
3982
  default:
3976
- return !binding.upstreamExpression || isStatefulReferences(binding.upstreamExpression.referencedBindings);
3983
+ return binding.upstreamAlias ? isStatefulBinding(binding.upstreamAlias) : !binding.upstreamExpression || isStatefulReferences(binding.upstreamExpression.referencedBindings);
3977
3984
  }
3978
3985
  }
3979
3986
 
@@ -5265,9 +5272,12 @@ var for_default = {
5265
5272
  const tagExtra = node.extra;
5266
5273
  const { referencedBindings } = tagExtra;
5267
5274
  const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
5268
- setClosureSignalBuilder(tag, (_closureSignal, render, intersection) => {
5275
+ setClosureSignalBuilder(tag, (closureSignal, render, intersection) => {
5269
5276
  return callRuntime(
5270
5277
  "loopClosure",
5278
+ getScopeAccessorLiteral(
5279
+ closureSignal.referencedBindings
5280
+ ),
5271
5281
  getScopeAccessorLiteral(nodeRef2),
5272
5282
  render,
5273
5283
  intersection
@@ -7150,9 +7160,12 @@ var IfTag = {
7150
7160
  rendererIdentifiers.push(import_compiler39.types.identifier(branchBodySection.name));
7151
7161
  setClosureSignalBuilder(
7152
7162
  branchTag,
7153
- (_closureSignal, render, intersection) => {
7163
+ (closureSignal, render, intersection) => {
7154
7164
  return callRuntime(
7155
7165
  "conditionalClosure",
7166
+ getScopeAccessorLiteral(
7167
+ closureSignal.referencedBindings
7168
+ ),
7156
7169
  getScopeAccessorLiteral(nodeRef2),
7157
7170
  import_compiler39.types.numericLiteral(i),
7158
7171
  render,
@@ -2,8 +2,6 @@ import { types as t } from "@marko/compiler";
2
2
  import { type Opt } from "./optional";
3
3
  import { type Binding, type ReferencedBindings } from "./references";
4
4
  import { type Section } from "./sections";
5
- export type closureSignalBuilder = (signal: Signal, render: t.Expression, intersection?: t.Expression) => t.Expression;
6
- export type registerScopeBuilder = (scope: t.Expression) => t.Expression;
7
5
  export type Signal = {
8
6
  identifier: t.Identifier;
9
7
  valueAccessor?: t.Expression;
@@ -11,7 +9,6 @@ export type Signal = {
11
9
  section: Section;
12
10
  build: () => t.Expression;
13
11
  register?: boolean;
14
- isDynamicClosure?: boolean;
15
12
  values: Array<{
16
13
  signal: {
17
14
  identifier: t.Identifier | t.MemberExpression;
@@ -35,6 +32,7 @@ export type Signal = {
35
32
  extraArgs?: t.Expression[];
36
33
  buildAssignment?: (valueSection: Section, value: t.Expression) => t.Expression;
37
34
  };
35
+ type closureSignalBuilder = (signal: Signal, render: t.Expression, intersection?: t.Expression) => t.Expression;
38
36
  export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
39
37
  export declare function setForceResumeScope(section: Section): void;
40
38
  export declare const getSerializedScopeProperties: (section: Section) => Map<t.StringLiteral | t.NumericLiteral, t.Expression>;
@@ -60,3 +58,4 @@ export declare function addHTMLEffectCall(section: Section, referencedBindings?:
60
58
  export declare function writeHTMLResumeStatements(path: t.NodePath<t.MarkoTagBody | t.Program>): void;
61
59
  export declare function getSetup(section: Section): t.Identifier | undefined;
62
60
  export declare function replaceRegisteredFunctionNode(node: t.Node): t.CallExpression | t.ClassPrivateProperty | t.ClassProperty | t.VariableDeclaration | t.Identifier | t.ObjectProperty | undefined;
61
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.38",
3
+ "version": "6.0.0-next.3.40",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",