octane 0.14.2 → 0.14.3

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.
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  version: () => version
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const version = "0.14.2";
24
+ const version = "0.14.3";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  version
@@ -7672,11 +7672,19 @@ function hydrationFirstQueryRead(ctx, render) {
7672
7672
  first.declarations[0].id.type !== 'Identifier'
7673
7673
  )
7674
7674
  return null;
7675
- const read = unwrapTsExpr(first.declarations[0].init);
7675
+ let read = unwrapTsExpr(first.declarations[0].init);
7676
+ let guard = null;
7677
+ if (read?.type === 'ConditionalExpression') {
7678
+ const condition = unwrapTsExpr(read.test);
7679
+ if (condition?.type !== 'Identifier') return null;
7680
+ guard = condition;
7681
+ read = unwrapTsExpr(read.consequent);
7682
+ }
7676
7683
  // Type syntax inside the call cannot move out of this component's scope.
7677
7684
  if (read?.typeArguments || (read?.callee?.computed && read.callee.property?.type !== 'Literal'))
7678
7685
  return null;
7679
- return hydrationImportedGetReceiver(ctx, read);
7686
+ const receiver = hydrationImportedGetReceiver(ctx, read);
7687
+ return receiver === null ? null : { receiver, guard };
7680
7688
  }
7681
7689
 
7682
7690
  function confinedHydrationDerivedRead(render, name, propsName = null) {
@@ -8046,6 +8054,18 @@ function hydrationPropsPlans(ctx) {
8046
8054
  if (!safe) break;
8047
8055
  }
8048
8056
  if (!safe || (!exported && query === null) || (query !== null && derived !== null)) continue;
8057
+ if (query?.guard) {
8058
+ const initializer = setupLocals.get(query.guard.name);
8059
+ const lexical = ctx.activityLexical;
8060
+ const binding = lexical.resolveBinding(lexical.nodeScopes.get(query.guard), query.guard.name);
8061
+ // A same-named declaration inside the primary arm is not the setup binding.
8062
+ if (
8063
+ initializer === undefined ||
8064
+ binding === null ||
8065
+ binding.scope !== lexical.nodeScopes.get(initializer)
8066
+ )
8067
+ continue;
8068
+ }
8049
8069
  const bodies = hydrationLayoutBodies(
8050
8070
  ctx,
8051
8071
  tryBodies(component.body.render, ctx),
@@ -36807,6 +36827,7 @@ function hoistHydrationInputsEqual(ctx, bodies, envNames, origin, componentName)
36807
36827
  const propsIndex = envNames.indexOf(propsName);
36808
36828
  if (propsIndex < 0) return null;
36809
36829
  const plan = hydrationPropsPlan(ctx, componentName);
36830
+ if (plan?.query?.guard && !envNames.includes(plan.query.guard.name)) return null;
36810
36831
  const derivedIndex = plan?.derived ? envNames.indexOf(plan.derived.name) : -1;
36811
36832
  if (plan?.derived && derivedIndex < 0) return null;
36812
36833
  let fields = plan?.fields;
@@ -37020,11 +37041,22 @@ function makeTryCall(
37020
37041
  // waiter after this one returned through a different adoption frame.
37021
37042
  const first = tryStmts[0];
37022
37043
  const declaration = first.declarations[0];
37023
- const authoredRead = unwrapTsExpr(declaration.init);
37044
+ const initializer = unwrapTsExpr(declaration.init);
37045
+ const branch = hydrationInputsEqual.query.guard === null ? initializer : initializer.consequent;
37046
+ const authoredRead = unwrapTsExpr(branch);
37024
37047
  const read = allocCompilerName(ctx, '__queryRead');
37025
37048
  ctx.hoistedHelpers.push(
37026
37049
  inheritOriginLoc(b.const(read, b.arrow([], authoredRead)), authoredRead),
37027
37050
  );
37051
+ const observedRead = replaceTsInner(
37052
+ branch,
37053
+ authoredRead,
37054
+ b.call(
37055
+ requireRuntimeForContext(ctx, '__readHydrationQueryInput'),
37056
+ b.id('__extra'),
37057
+ b.id(read),
37058
+ ),
37059
+ );
37028
37060
  tryStmts = [
37029
37061
  {
37030
37062
  ...first,
@@ -37033,12 +37065,8 @@ function makeTryCall(
37033
37065
  ...declaration,
37034
37066
  init: replaceTsInner(
37035
37067
  declaration.init,
37036
- authoredRead,
37037
- b.call(
37038
- requireRuntimeForContext(ctx, '__readHydrationQueryInput'),
37039
- b.id('__extra'),
37040
- b.id(read),
37041
- ),
37068
+ initializer,
37069
+ branch === initializer ? observedRead : { ...initializer, consequent: observedRead },
37042
37070
  ),
37043
37071
  },
37044
37072
  ],
@@ -37103,7 +37131,7 @@ function makeTryCall(
37103
37131
  b.call(
37104
37132
  requireRuntimeForContext(ctx, '__beginHydrationQueryRead'),
37105
37133
  b.id(env),
37106
- b.arrow([], { ...hydrationInputsEqual.query }),
37134
+ b.arrow([], { ...hydrationInputsEqual.query.receiver }),
37107
37135
  ),
37108
37136
  ),
37109
37137
  ),
@@ -1,4 +1,4 @@
1
- const version = "0.14.2";
1
+ const version = "0.14.3";
2
2
  export {
3
3
  version
4
4
  };
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "0.14.2";
1
+ const version = "0.14.3";
2
2
  export {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octane",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": [