@angular/core 19.0.0-next.4 → 19.0.0-next.6

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-next.4
3
+ * @license Angular v19.0.0-next.6
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -8,9 +8,9 @@
8
8
 
9
9
  var ts = require('typescript');
10
10
  require('os');
11
+ var p = require('path');
11
12
  var fs$1 = require('fs');
12
13
  var module$1 = require('module');
13
- var p = require('path');
14
14
  var url = require('url');
15
15
 
16
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -34,8 +34,8 @@ function _interopNamespace(e) {
34
34
  }
35
35
 
36
36
  var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
37
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
38
37
  var p__namespace = /*#__PURE__*/_interopNamespace(p);
38
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
39
39
 
40
40
  const _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + // 1: ":not("
41
41
  '(([\\.\\#]?)[-\\w]+)|' + // 2: "tag"; 3: "."/"#";
@@ -2403,6 +2403,32 @@ class Identifiers {
2403
2403
  name: 'ɵɵdeferPrefetchOnViewport',
2404
2404
  moduleName: CORE,
2405
2405
  }; }
2406
+ static { this.deferHydrateWhen = { name: 'ɵɵdeferHydrateWhen', moduleName: CORE }; }
2407
+ static { this.deferHydrateNever = { name: 'ɵɵdeferHydrateNever', moduleName: CORE }; }
2408
+ static { this.deferHydrateOnIdle = {
2409
+ name: 'ɵɵdeferHydrateOnIdle',
2410
+ moduleName: CORE,
2411
+ }; }
2412
+ static { this.deferHydrateOnImmediate = {
2413
+ name: 'ɵɵdeferHydrateOnImmediate',
2414
+ moduleName: CORE,
2415
+ }; }
2416
+ static { this.deferHydrateOnTimer = {
2417
+ name: 'ɵɵdeferHydrateOnTimer',
2418
+ moduleName: CORE,
2419
+ }; }
2420
+ static { this.deferHydrateOnHover = {
2421
+ name: 'ɵɵdeferHydrateOnHover',
2422
+ moduleName: CORE,
2423
+ }; }
2424
+ static { this.deferHydrateOnInteraction = {
2425
+ name: 'ɵɵdeferHydrateOnInteraction',
2426
+ moduleName: CORE,
2427
+ }; }
2428
+ static { this.deferHydrateOnViewport = {
2429
+ name: 'ɵɵdeferHydrateOnViewport',
2430
+ moduleName: CORE,
2431
+ }; }
2406
2432
  static { this.deferEnableTimerScheduling = {
2407
2433
  name: 'ɵɵdeferEnableTimerScheduling',
2408
2434
  moduleName: CORE,
@@ -4323,49 +4349,52 @@ class Element$1 {
4323
4349
  }
4324
4350
  }
4325
4351
  class DeferredTrigger {
4326
- constructor(nameSpan, sourceSpan, prefetchSpan, whenOrOnSourceSpan) {
4352
+ constructor(nameSpan, sourceSpan, prefetchSpan, whenOrOnSourceSpan, hydrateSpan) {
4327
4353
  this.nameSpan = nameSpan;
4328
4354
  this.sourceSpan = sourceSpan;
4329
4355
  this.prefetchSpan = prefetchSpan;
4330
4356
  this.whenOrOnSourceSpan = whenOrOnSourceSpan;
4357
+ this.hydrateSpan = hydrateSpan;
4331
4358
  }
4332
4359
  visit(visitor) {
4333
4360
  return visitor.visitDeferredTrigger(this);
4334
4361
  }
4335
4362
  }
4336
4363
  class BoundDeferredTrigger extends DeferredTrigger {
4337
- constructor(value, sourceSpan, prefetchSpan, whenSourceSpan) {
4364
+ constructor(value, sourceSpan, prefetchSpan, whenSourceSpan, hydrateSpan) {
4338
4365
  // BoundDeferredTrigger is for 'when' triggers. These aren't really "triggers" and don't have a
4339
4366
  // nameSpan. Trigger names are the built in event triggers like hover, interaction, etc.
4340
- super(/** nameSpan */ null, sourceSpan, prefetchSpan, whenSourceSpan);
4367
+ super(/** nameSpan */ null, sourceSpan, prefetchSpan, whenSourceSpan, hydrateSpan);
4341
4368
  this.value = value;
4342
4369
  }
4343
4370
  }
4371
+ class NeverDeferredTrigger extends DeferredTrigger {
4372
+ }
4344
4373
  class IdleDeferredTrigger extends DeferredTrigger {
4345
4374
  }
4346
4375
  class ImmediateDeferredTrigger extends DeferredTrigger {
4347
4376
  }
4348
4377
  class HoverDeferredTrigger extends DeferredTrigger {
4349
- constructor(reference, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
4350
- super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
4378
+ constructor(reference, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
4379
+ super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
4351
4380
  this.reference = reference;
4352
4381
  }
4353
4382
  }
4354
4383
  class TimerDeferredTrigger extends DeferredTrigger {
4355
- constructor(delay, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
4356
- super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
4384
+ constructor(delay, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
4385
+ super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
4357
4386
  this.delay = delay;
4358
4387
  }
4359
4388
  }
4360
4389
  class InteractionDeferredTrigger extends DeferredTrigger {
4361
- constructor(reference, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
4362
- super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
4390
+ constructor(reference, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
4391
+ super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
4363
4392
  this.reference = reference;
4364
4393
  }
4365
4394
  }
4366
4395
  class ViewportDeferredTrigger extends DeferredTrigger {
4367
- constructor(reference, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
4368
- super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
4396
+ constructor(reference, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
4397
+ super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
4369
4398
  this.reference = reference;
4370
4399
  }
4371
4400
  }
@@ -4411,7 +4440,7 @@ class DeferredBlockError extends BlockNode {
4411
4440
  }
4412
4441
  }
4413
4442
  class DeferredBlock extends BlockNode {
4414
- constructor(children, triggers, prefetchTriggers, placeholder, loading, error, nameSpan, sourceSpan, mainBlockSpan, startSourceSpan, endSourceSpan, i18n) {
4443
+ constructor(children, triggers, prefetchTriggers, hydrateTriggers, placeholder, loading, error, nameSpan, sourceSpan, mainBlockSpan, startSourceSpan, endSourceSpan, i18n) {
4415
4444
  super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
4416
4445
  this.children = children;
4417
4446
  this.placeholder = placeholder;
@@ -4421,15 +4450,19 @@ class DeferredBlock extends BlockNode {
4421
4450
  this.i18n = i18n;
4422
4451
  this.triggers = triggers;
4423
4452
  this.prefetchTriggers = prefetchTriggers;
4453
+ this.hydrateTriggers = hydrateTriggers;
4424
4454
  // We cache the keys since we know that they won't change and we
4425
4455
  // don't want to enumarate them every time we're traversing the AST.
4426
4456
  this.definedTriggers = Object.keys(triggers);
4427
4457
  this.definedPrefetchTriggers = Object.keys(prefetchTriggers);
4458
+ this.definedHydrateTriggers = Object.keys(hydrateTriggers);
4428
4459
  }
4429
4460
  visit(visitor) {
4430
4461
  return visitor.visitDeferredBlock(this);
4431
4462
  }
4432
4463
  visitAll(visitor) {
4464
+ // Visit the hydrate triggers first to match their insertion order.
4465
+ this.visitTriggers(this.definedHydrateTriggers, this.hydrateTriggers, visitor);
4433
4466
  this.visitTriggers(this.definedTriggers, this.triggers, visitor);
4434
4467
  this.visitTriggers(this.definedPrefetchTriggers, this.prefetchTriggers, visitor);
4435
4468
  visitAll$1(visitor, this.children);
@@ -8037,6 +8070,7 @@ var DeferTriggerKind;
8037
8070
  DeferTriggerKind[DeferTriggerKind["Hover"] = 3] = "Hover";
8038
8071
  DeferTriggerKind[DeferTriggerKind["Interaction"] = 4] = "Interaction";
8039
8072
  DeferTriggerKind[DeferTriggerKind["Viewport"] = 5] = "Viewport";
8073
+ DeferTriggerKind[DeferTriggerKind["Never"] = 6] = "Never";
8040
8074
  })(DeferTriggerKind || (DeferTriggerKind = {}));
8041
8075
  /**
8042
8076
  * Kinds of i18n contexts. They can be created because of root i18n blocks, or ICUs.
@@ -8351,12 +8385,12 @@ function createRepeaterOp(repeaterCreate, targetSlot, collection, sourceSpan) {
8351
8385
  ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,
8352
8386
  };
8353
8387
  }
8354
- function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
8388
+ function createDeferWhenOp(target, expr, modifier, sourceSpan) {
8355
8389
  return {
8356
8390
  kind: OpKind.DeferWhen,
8357
8391
  target,
8358
8392
  expr,
8359
- prefetch,
8393
+ modifier,
8360
8394
  sourceSpan,
8361
8395
  ...NEW_OP,
8362
8396
  ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,
@@ -9911,12 +9945,12 @@ function createDeferOp(xref, main, mainSlot, ownResolverFn, resolverFn, sourceSp
9911
9945
  numSlotsUsed: 2,
9912
9946
  };
9913
9947
  }
9914
- function createDeferOnOp(defer, trigger, prefetch, sourceSpan) {
9948
+ function createDeferOnOp(defer, trigger, modifier, sourceSpan) {
9915
9949
  return {
9916
9950
  kind: OpKind.DeferOn,
9917
9951
  defer,
9918
9952
  trigger,
9919
- prefetch,
9953
+ modifier,
9920
9954
  sourceSpan,
9921
9955
  ...NEW_OP,
9922
9956
  };
@@ -11276,6 +11310,7 @@ function resolveDeferTargetNames(job) {
11276
11310
  function resolveTrigger(deferOwnerView, op, placeholderView) {
11277
11311
  switch (op.trigger.kind) {
11278
11312
  case DeferTriggerKind.Idle:
11313
+ case DeferTriggerKind.Never:
11279
11314
  case DeferTriggerKind.Immediate:
11280
11315
  case DeferTriggerKind.Timer:
11281
11316
  return;
@@ -11335,7 +11370,9 @@ function resolveDeferTargetNames(job) {
11335
11370
  break;
11336
11371
  case OpKind.DeferOn:
11337
11372
  const deferOp = defers.get(op.defer);
11338
- resolveTrigger(unit, op, deferOp.placeholderView);
11373
+ resolveTrigger(unit, op, op.modifier === "hydrate" /* ir.DeferOpModifierKind.HYDRATE */
11374
+ ? deferOp.mainView
11375
+ : deferOp.placeholderView);
11339
11376
  break;
11340
11377
  }
11341
11378
  }
@@ -21047,28 +21084,68 @@ function defer(selfSlot, primarySlot, dependencyResolverFn, loadingSlot, placeho
21047
21084
  return call(Identifiers.defer, args, sourceSpan);
21048
21085
  }
21049
21086
  const deferTriggerToR3TriggerInstructionsMap = new Map([
21050
- [DeferTriggerKind.Idle, [Identifiers.deferOnIdle, Identifiers.deferPrefetchOnIdle]],
21087
+ [
21088
+ DeferTriggerKind.Idle,
21089
+ {
21090
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferOnIdle,
21091
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferPrefetchOnIdle,
21092
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateOnIdle,
21093
+ },
21094
+ ],
21051
21095
  [
21052
21096
  DeferTriggerKind.Immediate,
21053
- [Identifiers.deferOnImmediate, Identifiers.deferPrefetchOnImmediate],
21097
+ {
21098
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferOnImmediate,
21099
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferPrefetchOnImmediate,
21100
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateOnImmediate,
21101
+ },
21102
+ ],
21103
+ [
21104
+ DeferTriggerKind.Timer,
21105
+ {
21106
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferOnTimer,
21107
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferPrefetchOnTimer,
21108
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateOnTimer,
21109
+ },
21110
+ ],
21111
+ [
21112
+ DeferTriggerKind.Hover,
21113
+ {
21114
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferOnHover,
21115
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferPrefetchOnHover,
21116
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateOnHover,
21117
+ },
21054
21118
  ],
21055
- [DeferTriggerKind.Timer, [Identifiers.deferOnTimer, Identifiers.deferPrefetchOnTimer]],
21056
- [DeferTriggerKind.Hover, [Identifiers.deferOnHover, Identifiers.deferPrefetchOnHover]],
21057
21119
  [
21058
21120
  DeferTriggerKind.Interaction,
21059
- [Identifiers.deferOnInteraction, Identifiers.deferPrefetchOnInteraction],
21121
+ {
21122
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferOnInteraction,
21123
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferPrefetchOnInteraction,
21124
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateOnInteraction,
21125
+ },
21060
21126
  ],
21061
21127
  [
21062
21128
  DeferTriggerKind.Viewport,
21063
- [Identifiers.deferOnViewport, Identifiers.deferPrefetchOnViewport],
21129
+ {
21130
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferOnViewport,
21131
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferPrefetchOnViewport,
21132
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateOnViewport,
21133
+ },
21134
+ ],
21135
+ [
21136
+ DeferTriggerKind.Never,
21137
+ {
21138
+ ["none" /* ir.DeferOpModifierKind.NONE */]: Identifiers.deferHydrateNever,
21139
+ ["prefetch" /* ir.DeferOpModifierKind.PREFETCH */]: Identifiers.deferHydrateNever,
21140
+ ["hydrate" /* ir.DeferOpModifierKind.HYDRATE */]: Identifiers.deferHydrateNever,
21141
+ },
21064
21142
  ],
21065
21143
  ]);
21066
- function deferOn(trigger, args, prefetch, sourceSpan) {
21067
- const instructions = deferTriggerToR3TriggerInstructionsMap.get(trigger);
21068
- if (instructions === undefined) {
21144
+ function deferOn(trigger, args, modifier, sourceSpan) {
21145
+ const instructionToCall = deferTriggerToR3TriggerInstructionsMap.get(trigger)?.[modifier];
21146
+ if (instructionToCall === undefined) {
21069
21147
  throw new Error(`Unable to determine instruction for trigger ${trigger}`);
21070
21148
  }
21071
- const instructionToCall = prefetch ? instructions[1] : instructions[0];
21072
21149
  return call(instructionToCall, args.map((a) => literal$1(a)), sourceSpan);
21073
21150
  }
21074
21151
  function projectionDef(def) {
@@ -21124,8 +21201,14 @@ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByF
21124
21201
  function repeater(collection, sourceSpan) {
21125
21202
  return call(Identifiers.repeater, [collection], sourceSpan);
21126
21203
  }
21127
- function deferWhen(prefetch, expr, sourceSpan) {
21128
- return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
21204
+ function deferWhen(modifier, expr, sourceSpan) {
21205
+ if (modifier === "prefetch" /* ir.DeferOpModifierKind.PREFETCH */) {
21206
+ return call(Identifiers.deferPrefetchWhen, [expr], sourceSpan);
21207
+ }
21208
+ else if (modifier === "hydrate" /* ir.DeferOpModifierKind.HYDRATE */) {
21209
+ return call(Identifiers.deferHydrateWhen, [expr], sourceSpan);
21210
+ }
21211
+ return call(Identifiers.deferWhen, [expr], sourceSpan);
21129
21212
  }
21130
21213
  function declareLet(slot, sourceSpan) {
21131
21214
  return call(Identifiers.declareLet, [literal$1(slot)], sourceSpan);
@@ -21589,6 +21672,7 @@ function reifyCreateOperations(unit, ops) {
21589
21672
  case OpKind.DeferOn:
21590
21673
  let args = [];
21591
21674
  switch (op.trigger.kind) {
21675
+ case DeferTriggerKind.Never:
21592
21676
  case DeferTriggerKind.Idle:
21593
21677
  case DeferTriggerKind.Immediate:
21594
21678
  break;
@@ -21598,18 +21682,24 @@ function reifyCreateOperations(unit, ops) {
21598
21682
  case DeferTriggerKind.Interaction:
21599
21683
  case DeferTriggerKind.Hover:
21600
21684
  case DeferTriggerKind.Viewport:
21601
- if (op.trigger.targetSlot?.slot == null || op.trigger.targetSlotViewSteps === null) {
21602
- throw new Error(`Slot or view steps not set in trigger reification for trigger kind ${op.trigger.kind}`);
21685
+ // `hydrate` triggers don't support targets.
21686
+ if (op.modifier === "hydrate" /* ir.DeferOpModifierKind.HYDRATE */) {
21687
+ args = [];
21603
21688
  }
21604
- args = [op.trigger.targetSlot.slot];
21605
- if (op.trigger.targetSlotViewSteps !== 0) {
21606
- args.push(op.trigger.targetSlotViewSteps);
21689
+ else {
21690
+ if (op.trigger.targetSlot?.slot == null || op.trigger.targetSlotViewSteps === null) {
21691
+ throw new Error(`Slot or view steps not set in trigger reification for trigger kind ${op.trigger.kind}`);
21692
+ }
21693
+ args = [op.trigger.targetSlot.slot];
21694
+ if (op.trigger.targetSlotViewSteps !== 0) {
21695
+ args.push(op.trigger.targetSlotViewSteps);
21696
+ }
21607
21697
  }
21608
21698
  break;
21609
21699
  default:
21610
21700
  throw new Error(`AssertionError: Unsupported reification of defer trigger kind ${op.trigger.kind}`);
21611
21701
  }
21612
- OpList.replace(op, deferOn(op.trigger.kind, args, op.prefetch, op.sourceSpan));
21702
+ OpList.replace(op, deferOn(op.trigger.kind, args, op.modifier, op.sourceSpan));
21613
21703
  break;
21614
21704
  case OpKind.ProjectionDef:
21615
21705
  OpList.replace(op, projectionDef(op.def));
@@ -21767,7 +21857,7 @@ function reifyUpdateOperations(_unit, ops) {
21767
21857
  OpList.replace(op, repeater(op.collection, op.sourceSpan));
21768
21858
  break;
21769
21859
  case OpKind.DeferWhen:
21770
- OpList.replace(op, deferWhen(op.prefetch, op.expr, op.sourceSpan));
21860
+ OpList.replace(op, deferWhen(op.modifier, op.expr, op.sourceSpan));
21771
21861
  break;
21772
21862
  case OpKind.StoreLet:
21773
21863
  throw new Error(`AssertionError: unexpected storeLet ${op.declaredName}`);
@@ -24160,73 +24250,81 @@ function ingestDeferBlock(unit, deferBlock) {
24160
24250
  // Configure all defer `on` conditions.
24161
24251
  // TODO: refactor prefetch triggers to use a separate op type, with a shared superclass. This will
24162
24252
  // make it easier to refactor prefetch behavior in the future.
24163
- let prefetch = false;
24164
- let deferOnOps = [];
24165
- let deferWhenOps = [];
24166
- for (const triggers of [deferBlock.triggers, deferBlock.prefetchTriggers]) {
24167
- if (triggers.idle !== undefined) {
24168
- const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Idle }, prefetch, triggers.idle.sourceSpan);
24169
- deferOnOps.push(deferOnOp);
24170
- }
24171
- if (triggers.immediate !== undefined) {
24172
- const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Immediate }, prefetch, triggers.immediate.sourceSpan);
24173
- deferOnOps.push(deferOnOp);
24174
- }
24175
- if (triggers.timer !== undefined) {
24176
- const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Timer, delay: triggers.timer.delay }, prefetch, triggers.timer.sourceSpan);
24177
- deferOnOps.push(deferOnOp);
24178
- }
24179
- if (triggers.hover !== undefined) {
24180
- const deferOnOp = createDeferOnOp(deferXref, {
24181
- kind: DeferTriggerKind.Hover,
24182
- targetName: triggers.hover.reference,
24183
- targetXref: null,
24184
- targetSlot: null,
24185
- targetView: null,
24186
- targetSlotViewSteps: null,
24187
- }, prefetch, triggers.hover.sourceSpan);
24188
- deferOnOps.push(deferOnOp);
24189
- }
24190
- if (triggers.interaction !== undefined) {
24191
- const deferOnOp = createDeferOnOp(deferXref, {
24192
- kind: DeferTriggerKind.Interaction,
24193
- targetName: triggers.interaction.reference,
24194
- targetXref: null,
24195
- targetSlot: null,
24196
- targetView: null,
24197
- targetSlotViewSteps: null,
24198
- }, prefetch, triggers.interaction.sourceSpan);
24199
- deferOnOps.push(deferOnOp);
24200
- }
24201
- if (triggers.viewport !== undefined) {
24202
- const deferOnOp = createDeferOnOp(deferXref, {
24203
- kind: DeferTriggerKind.Viewport,
24204
- targetName: triggers.viewport.reference,
24205
- targetXref: null,
24206
- targetSlot: null,
24207
- targetView: null,
24208
- targetSlotViewSteps: null,
24209
- }, prefetch, triggers.viewport.sourceSpan);
24210
- deferOnOps.push(deferOnOp);
24211
- }
24212
- if (triggers.when !== undefined) {
24213
- if (triggers.when.value instanceof Interpolation$1) {
24214
- // TemplateDefinitionBuilder supports this case, but it's very strange to me. What would it
24215
- // even mean?
24216
- throw new Error(`Unexpected interpolation in defer block when trigger`);
24217
- }
24218
- const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), prefetch, triggers.when.sourceSpan);
24219
- deferWhenOps.push(deferOnOp);
24220
- }
24221
- // If no (non-prefetching) defer triggers were provided, default to `idle`.
24222
- if (deferOnOps.length === 0 && deferWhenOps.length === 0) {
24223
- deferOnOps.push(createDeferOnOp(deferXref, { kind: DeferTriggerKind.Idle }, false, null));
24224
- }
24225
- prefetch = true;
24253
+ const deferOnOps = [];
24254
+ const deferWhenOps = [];
24255
+ // Ingest the hydrate triggers first since they set up all the other triggers during SSR.
24256
+ ingestDeferTriggers("hydrate" /* ir.DeferOpModifierKind.HYDRATE */, deferBlock.hydrateTriggers, deferOnOps, deferWhenOps, unit, deferXref);
24257
+ ingestDeferTriggers("none" /* ir.DeferOpModifierKind.NONE */, deferBlock.triggers, deferOnOps, deferWhenOps, unit, deferXref);
24258
+ ingestDeferTriggers("prefetch" /* ir.DeferOpModifierKind.PREFETCH */, deferBlock.prefetchTriggers, deferOnOps, deferWhenOps, unit, deferXref);
24259
+ // If no (non-prefetching or hydrating) defer triggers were provided, default to `idle`.
24260
+ const hasConcreteTrigger = deferOnOps.some((op) => op.modifier === "none" /* ir.DeferOpModifierKind.NONE */) ||
24261
+ deferWhenOps.some((op) => op.modifier === "none" /* ir.DeferOpModifierKind.NONE */);
24262
+ if (!hasConcreteTrigger) {
24263
+ deferOnOps.push(createDeferOnOp(deferXref, { kind: DeferTriggerKind.Idle }, "none" /* ir.DeferOpModifierKind.NONE */, null));
24226
24264
  }
24227
24265
  unit.create.push(deferOnOps);
24228
24266
  unit.update.push(deferWhenOps);
24229
24267
  }
24268
+ function ingestDeferTriggers(modifier, triggers, onOps, whenOps, unit, deferXref) {
24269
+ if (triggers.idle !== undefined) {
24270
+ const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Idle }, modifier, triggers.idle.sourceSpan);
24271
+ onOps.push(deferOnOp);
24272
+ }
24273
+ if (triggers.immediate !== undefined) {
24274
+ const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Immediate }, modifier, triggers.immediate.sourceSpan);
24275
+ onOps.push(deferOnOp);
24276
+ }
24277
+ if (triggers.timer !== undefined) {
24278
+ const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Timer, delay: triggers.timer.delay }, modifier, triggers.timer.sourceSpan);
24279
+ onOps.push(deferOnOp);
24280
+ }
24281
+ if (triggers.hover !== undefined) {
24282
+ const deferOnOp = createDeferOnOp(deferXref, {
24283
+ kind: DeferTriggerKind.Hover,
24284
+ targetName: triggers.hover.reference,
24285
+ targetXref: null,
24286
+ targetSlot: null,
24287
+ targetView: null,
24288
+ targetSlotViewSteps: null,
24289
+ }, modifier, triggers.hover.sourceSpan);
24290
+ onOps.push(deferOnOp);
24291
+ }
24292
+ if (triggers.interaction !== undefined) {
24293
+ const deferOnOp = createDeferOnOp(deferXref, {
24294
+ kind: DeferTriggerKind.Interaction,
24295
+ targetName: triggers.interaction.reference,
24296
+ targetXref: null,
24297
+ targetSlot: null,
24298
+ targetView: null,
24299
+ targetSlotViewSteps: null,
24300
+ }, modifier, triggers.interaction.sourceSpan);
24301
+ onOps.push(deferOnOp);
24302
+ }
24303
+ if (triggers.viewport !== undefined) {
24304
+ const deferOnOp = createDeferOnOp(deferXref, {
24305
+ kind: DeferTriggerKind.Viewport,
24306
+ targetName: triggers.viewport.reference,
24307
+ targetXref: null,
24308
+ targetSlot: null,
24309
+ targetView: null,
24310
+ targetSlotViewSteps: null,
24311
+ }, modifier, triggers.viewport.sourceSpan);
24312
+ onOps.push(deferOnOp);
24313
+ }
24314
+ if (triggers.never !== undefined) {
24315
+ const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Never }, modifier, triggers.never.sourceSpan);
24316
+ onOps.push(deferOnOp);
24317
+ }
24318
+ if (triggers.when !== undefined) {
24319
+ if (triggers.when.value instanceof Interpolation$1) {
24320
+ // TemplateDefinitionBuilder supports this case, but it's very strange to me. What would it
24321
+ // even mean?
24322
+ throw new Error(`Unexpected interpolation in defer block when trigger`);
24323
+ }
24324
+ const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), modifier, triggers.when.sourceSpan);
24325
+ whenOps.push(deferOnOp);
24326
+ }
24327
+ }
24230
24328
  function ingestIcu(unit, icu) {
24231
24329
  if (icu.i18n instanceof Message && isSingleI18nIcu(icu.i18n)) {
24232
24330
  const xref = unit.job.allocateXrefId();
@@ -25970,12 +26068,29 @@ var OnTriggerType;
25970
26068
  OnTriggerType["IMMEDIATE"] = "immediate";
25971
26069
  OnTriggerType["HOVER"] = "hover";
25972
26070
  OnTriggerType["VIEWPORT"] = "viewport";
26071
+ OnTriggerType["NEVER"] = "never";
25973
26072
  })(OnTriggerType || (OnTriggerType = {}));
25974
26073
  /** Parses a `when` deferred trigger. */
26074
+ function parseNeverTrigger({ expression, sourceSpan }, triggers, errors) {
26075
+ const neverIndex = expression.indexOf('never');
26076
+ const neverSourceSpan = new ParseSourceSpan(sourceSpan.start.moveBy(neverIndex), sourceSpan.start.moveBy(neverIndex + 'never'.length));
26077
+ const prefetchSpan = getPrefetchSpan(expression, sourceSpan);
26078
+ const hydrateSpan = getHydrateSpan(expression, sourceSpan);
26079
+ // This is here just to be safe, we shouldn't enter this function
26080
+ // in the first place if a block doesn't have the "on" keyword.
26081
+ if (neverIndex === -1) {
26082
+ errors.push(new ParseError(sourceSpan, `Could not find "never" keyword in expression`));
26083
+ }
26084
+ else {
26085
+ trackTrigger('never', triggers, errors, new NeverDeferredTrigger(neverSourceSpan, sourceSpan, prefetchSpan, null, hydrateSpan));
26086
+ }
26087
+ }
26088
+ /** Parses a `when` deferred trigger. */
25975
26089
  function parseWhenTrigger({ expression, sourceSpan }, bindingParser, triggers, errors) {
25976
26090
  const whenIndex = expression.indexOf('when');
25977
26091
  const whenSourceSpan = new ParseSourceSpan(sourceSpan.start.moveBy(whenIndex), sourceSpan.start.moveBy(whenIndex + 'when'.length));
25978
26092
  const prefetchSpan = getPrefetchSpan(expression, sourceSpan);
26093
+ const hydrateSpan = getHydrateSpan(expression, sourceSpan);
25979
26094
  // This is here just to be safe, we shouldn't enter this function
25980
26095
  // in the first place if a block doesn't have the "when" keyword.
25981
26096
  if (whenIndex === -1) {
@@ -25984,7 +26099,7 @@ function parseWhenTrigger({ expression, sourceSpan }, bindingParser, triggers, e
25984
26099
  else {
25985
26100
  const start = getTriggerParametersStart(expression, whenIndex + 1);
25986
26101
  const parsed = bindingParser.parseBinding(expression.slice(start), false, sourceSpan, sourceSpan.start.offset + start);
25987
- trackTrigger('when', triggers, errors, new BoundDeferredTrigger(parsed, sourceSpan, prefetchSpan, whenSourceSpan));
26102
+ trackTrigger('when', triggers, errors, new BoundDeferredTrigger(parsed, sourceSpan, prefetchSpan, whenSourceSpan, hydrateSpan));
25988
26103
  }
25989
26104
  }
25990
26105
  /** Parses an `on` trigger */
@@ -25992,6 +26107,7 @@ function parseOnTrigger({ expression, sourceSpan }, triggers, errors, placeholde
25992
26107
  const onIndex = expression.indexOf('on');
25993
26108
  const onSourceSpan = new ParseSourceSpan(sourceSpan.start.moveBy(onIndex), sourceSpan.start.moveBy(onIndex + 'on'.length));
25994
26109
  const prefetchSpan = getPrefetchSpan(expression, sourceSpan);
26110
+ const hydrateSpan = getHydrateSpan(expression, sourceSpan);
25995
26111
  // This is here just to be safe, we shouldn't enter this function
25996
26112
  // in the first place if a block doesn't have the "on" keyword.
25997
26113
  if (onIndex === -1) {
@@ -25999,7 +26115,9 @@ function parseOnTrigger({ expression, sourceSpan }, triggers, errors, placeholde
25999
26115
  }
26000
26116
  else {
26001
26117
  const start = getTriggerParametersStart(expression, onIndex + 1);
26002
- const parser = new OnTriggerParser(expression, start, sourceSpan, triggers, errors, placeholder, prefetchSpan, onSourceSpan);
26118
+ const parser = new OnTriggerParser(expression, start, sourceSpan, triggers, errors, expression.startsWith('hydrate')
26119
+ ? validateHydrateReferenceBasedTrigger
26120
+ : validatePlainReferenceBasedTrigger, placeholder, prefetchSpan, onSourceSpan, hydrateSpan);
26003
26121
  parser.parse();
26004
26122
  }
26005
26123
  }
@@ -26009,16 +26127,24 @@ function getPrefetchSpan(expression, sourceSpan) {
26009
26127
  }
26010
26128
  return new ParseSourceSpan(sourceSpan.start, sourceSpan.start.moveBy('prefetch'.length));
26011
26129
  }
26130
+ function getHydrateSpan(expression, sourceSpan) {
26131
+ if (!expression.startsWith('hydrate')) {
26132
+ return null;
26133
+ }
26134
+ return new ParseSourceSpan(sourceSpan.start, sourceSpan.start.moveBy('hydrate'.length));
26135
+ }
26012
26136
  class OnTriggerParser {
26013
- constructor(expression, start, span, triggers, errors, placeholder, prefetchSpan, onSourceSpan) {
26137
+ constructor(expression, start, span, triggers, errors, validator, placeholder, prefetchSpan, onSourceSpan, hydrateSpan) {
26014
26138
  this.expression = expression;
26015
26139
  this.start = start;
26016
26140
  this.span = span;
26017
26141
  this.triggers = triggers;
26018
26142
  this.errors = errors;
26143
+ this.validator = validator;
26019
26144
  this.placeholder = placeholder;
26020
26145
  this.prefetchSpan = prefetchSpan;
26021
26146
  this.onSourceSpan = onSourceSpan;
26147
+ this.hydrateSpan = hydrateSpan;
26022
26148
  this.index = 0;
26023
26149
  this.tokens = new Lexer().tokenize(expression.slice(start));
26024
26150
  }
@@ -26073,26 +26199,27 @@ class OnTriggerParser {
26073
26199
  const isFirstTrigger = identifier.index === 0;
26074
26200
  const onSourceSpan = isFirstTrigger ? this.onSourceSpan : null;
26075
26201
  const prefetchSourceSpan = isFirstTrigger ? this.prefetchSpan : null;
26202
+ const hydrateSourceSpan = isFirstTrigger ? this.hydrateSpan : null;
26076
26203
  const sourceSpan = new ParseSourceSpan(isFirstTrigger ? this.span.start : triggerNameStartSpan, endSpan);
26077
26204
  try {
26078
26205
  switch (identifier.toString()) {
26079
26206
  case OnTriggerType.IDLE:
26080
- this.trackTrigger('idle', createIdleTrigger(parameters, nameSpan, sourceSpan, prefetchSourceSpan, onSourceSpan));
26207
+ this.trackTrigger('idle', createIdleTrigger(parameters, nameSpan, sourceSpan, prefetchSourceSpan, onSourceSpan, hydrateSourceSpan));
26081
26208
  break;
26082
26209
  case OnTriggerType.TIMER:
26083
- this.trackTrigger('timer', createTimerTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan));
26210
+ this.trackTrigger('timer', createTimerTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan));
26084
26211
  break;
26085
26212
  case OnTriggerType.INTERACTION:
26086
- this.trackTrigger('interaction', createInteractionTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.placeholder));
26213
+ this.trackTrigger('interaction', createInteractionTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.placeholder, this.validator));
26087
26214
  break;
26088
26215
  case OnTriggerType.IMMEDIATE:
26089
- this.trackTrigger('immediate', createImmediateTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan));
26216
+ this.trackTrigger('immediate', createImmediateTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan));
26090
26217
  break;
26091
26218
  case OnTriggerType.HOVER:
26092
- this.trackTrigger('hover', createHoverTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.placeholder));
26219
+ this.trackTrigger('hover', createHoverTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.placeholder, this.validator));
26093
26220
  break;
26094
26221
  case OnTriggerType.VIEWPORT:
26095
- this.trackTrigger('viewport', createViewportTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.placeholder));
26222
+ this.trackTrigger('viewport', createViewportTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.placeholder, this.validator));
26096
26223
  break;
26097
26224
  default:
26098
26225
  throw new Error(`Unrecognized trigger type "${identifier}"`);
@@ -26182,13 +26309,13 @@ function trackTrigger(name, allTriggers, errors, trigger) {
26182
26309
  allTriggers[name] = trigger;
26183
26310
  }
26184
26311
  }
26185
- function createIdleTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
26312
+ function createIdleTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
26186
26313
  if (parameters.length > 0) {
26187
26314
  throw new Error(`"${OnTriggerType.IDLE}" trigger cannot have parameters`);
26188
26315
  }
26189
- return new IdleDeferredTrigger(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
26316
+ return new IdleDeferredTrigger(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
26190
26317
  }
26191
- function createTimerTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
26318
+ function createTimerTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
26192
26319
  if (parameters.length !== 1) {
26193
26320
  throw new Error(`"${OnTriggerType.TIMER}" trigger must have exactly one parameter`);
26194
26321
  }
@@ -26196,27 +26323,33 @@ function createTimerTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSo
26196
26323
  if (delay === null) {
26197
26324
  throw new Error(`Could not parse time value of trigger "${OnTriggerType.TIMER}"`);
26198
26325
  }
26199
- return new TimerDeferredTrigger(delay, nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
26326
+ return new TimerDeferredTrigger(delay, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
26200
26327
  }
26201
- function createImmediateTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan) {
26328
+ function createImmediateTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan) {
26202
26329
  if (parameters.length > 0) {
26203
26330
  throw new Error(`"${OnTriggerType.IMMEDIATE}" trigger cannot have parameters`);
26204
26331
  }
26205
- return new ImmediateDeferredTrigger(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
26332
+ return new ImmediateDeferredTrigger(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
26206
26333
  }
26207
- function createHoverTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, placeholder) {
26208
- validateReferenceBasedTrigger(OnTriggerType.HOVER, parameters, placeholder);
26209
- return new HoverDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
26334
+ function createHoverTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan, placeholder, validator) {
26335
+ validator(OnTriggerType.HOVER, parameters, placeholder);
26336
+ return new HoverDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
26210
26337
  }
26211
- function createInteractionTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, placeholder) {
26212
- validateReferenceBasedTrigger(OnTriggerType.INTERACTION, parameters, placeholder);
26213
- return new InteractionDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
26338
+ function createInteractionTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan, placeholder, validator) {
26339
+ validator(OnTriggerType.INTERACTION, parameters, placeholder);
26340
+ return new InteractionDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
26214
26341
  }
26215
- function createViewportTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, placeholder) {
26216
- validateReferenceBasedTrigger(OnTriggerType.VIEWPORT, parameters, placeholder);
26217
- return new ViewportDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan);
26342
+ function createViewportTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan, placeholder, validator) {
26343
+ validator(OnTriggerType.VIEWPORT, parameters, placeholder);
26344
+ return new ViewportDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
26218
26345
  }
26219
- function validateReferenceBasedTrigger(type, parameters, placeholder) {
26346
+ /**
26347
+ * Checks whether the structure of a non-hydrate reference-based trigger is valid.
26348
+ * @param type Type of the trigger being validated.
26349
+ * @param parameters Parameters of the trigger.
26350
+ * @param placeholder Placeholder of the defer block.
26351
+ */
26352
+ function validatePlainReferenceBasedTrigger(type, parameters, placeholder) {
26220
26353
  if (parameters.length > 1) {
26221
26354
  throw new Error(`"${type}" trigger can only have zero or one parameters`);
26222
26355
  }
@@ -26230,6 +26363,16 @@ function validateReferenceBasedTrigger(type, parameters, placeholder) {
26230
26363
  }
26231
26364
  }
26232
26365
  }
26366
+ /**
26367
+ * Checks whether the structure of a hydrate trigger is valid.
26368
+ * @param type Type of the trigger being validated.
26369
+ * @param parameters Parameters of the trigger.
26370
+ */
26371
+ function validateHydrateReferenceBasedTrigger(type, parameters) {
26372
+ if (parameters.length > 0) {
26373
+ throw new Error(`Hydration trigger "${type}" cannot have parameters`);
26374
+ }
26375
+ }
26233
26376
  /** Gets the index within an expression at which the trigger parameters start. */
26234
26377
  function getTriggerParametersStart(value, startPosition = 0) {
26235
26378
  let hasFoundSeparator = false;
@@ -26260,6 +26403,12 @@ function parseDeferredTime(value) {
26260
26403
  const PREFETCH_WHEN_PATTERN = /^prefetch\s+when\s/;
26261
26404
  /** Pattern to identify a `prefetch on` trigger. */
26262
26405
  const PREFETCH_ON_PATTERN = /^prefetch\s+on\s/;
26406
+ /** Pattern to identify a `hydrate when` trigger. */
26407
+ const HYDRATE_WHEN_PATTERN = /^hydrate\s+when\s/;
26408
+ /** Pattern to identify a `hydrate on` trigger. */
26409
+ const HYDRATE_ON_PATTERN = /^hydrate\s+on\s/;
26410
+ /** Pattern to identify a `hydrate never` trigger. */
26411
+ const HYDRATE_NEVER_PATTERN = /^hydrate\s+never\s*/;
26263
26412
  /** Pattern to identify a `minimum` parameter in a block. */
26264
26413
  const MINIMUM_PARAMETER_PATTERN = /^minimum\s/;
26265
26414
  /** Pattern to identify a `after` parameter in a block. */
@@ -26279,7 +26428,7 @@ function isConnectedDeferLoopBlock(name) {
26279
26428
  function createDeferredBlock(ast, connectedBlocks, visitor, bindingParser) {
26280
26429
  const errors = [];
26281
26430
  const { placeholder, loading, error } = parseConnectedBlocks(connectedBlocks, errors, visitor);
26282
- const { triggers, prefetchTriggers } = parsePrimaryTriggers(ast.parameters, bindingParser, errors, placeholder);
26431
+ const { triggers, prefetchTriggers, hydrateTriggers } = parsePrimaryTriggers(ast, bindingParser, errors, placeholder);
26283
26432
  // The `defer` block has a main span encompassing all of the connected branches as well.
26284
26433
  let lastEndSourceSpan = ast.endSourceSpan;
26285
26434
  let endOfLastSourceSpan = ast.sourceSpan.end;
@@ -26289,7 +26438,7 @@ function createDeferredBlock(ast, connectedBlocks, visitor, bindingParser) {
26289
26438
  endOfLastSourceSpan = lastConnectedBlock.sourceSpan.end;
26290
26439
  }
26291
26440
  const sourceSpanWithConnectedBlocks = new ParseSourceSpan(ast.sourceSpan.start, endOfLastSourceSpan);
26292
- const node = new DeferredBlock(visitAll(visitor, ast.children, ast.children), triggers, prefetchTriggers, placeholder, loading, error, ast.nameSpan, sourceSpanWithConnectedBlocks, ast.sourceSpan, ast.startSourceSpan, lastEndSourceSpan, ast.i18n);
26441
+ const node = new DeferredBlock(visitAll(visitor, ast.children, ast.children), triggers, prefetchTriggers, hydrateTriggers, placeholder, loading, error, ast.nameSpan, sourceSpanWithConnectedBlocks, ast.sourceSpan, ast.startSourceSpan, lastEndSourceSpan, ast.i18n);
26293
26442
  return { node, errors };
26294
26443
  }
26295
26444
  function parseConnectedBlocks(connectedBlocks, errors, visitor) {
@@ -26390,10 +26539,11 @@ function parseErrorBlock(ast, visitor) {
26390
26539
  }
26391
26540
  return new DeferredBlockError(visitAll(visitor, ast.children, ast.children), ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.i18n);
26392
26541
  }
26393
- function parsePrimaryTriggers(params, bindingParser, errors, placeholder) {
26542
+ function parsePrimaryTriggers(ast, bindingParser, errors, placeholder) {
26394
26543
  const triggers = {};
26395
26544
  const prefetchTriggers = {};
26396
- for (const param of params) {
26545
+ const hydrateTriggers = {};
26546
+ for (const param of ast.parameters) {
26397
26547
  // The lexer ignores the leading spaces so we can assume
26398
26548
  // that the expression starts with a keyword.
26399
26549
  if (WHEN_PARAMETER_PATTERN.test(param.expression)) {
@@ -26408,11 +26558,23 @@ function parsePrimaryTriggers(params, bindingParser, errors, placeholder) {
26408
26558
  else if (PREFETCH_ON_PATTERN.test(param.expression)) {
26409
26559
  parseOnTrigger(param, prefetchTriggers, errors, placeholder);
26410
26560
  }
26561
+ else if (HYDRATE_WHEN_PATTERN.test(param.expression)) {
26562
+ parseWhenTrigger(param, bindingParser, hydrateTriggers, errors);
26563
+ }
26564
+ else if (HYDRATE_ON_PATTERN.test(param.expression)) {
26565
+ parseOnTrigger(param, hydrateTriggers, errors, placeholder);
26566
+ }
26567
+ else if (HYDRATE_NEVER_PATTERN.test(param.expression)) {
26568
+ parseNeverTrigger(param, hydrateTriggers, errors);
26569
+ }
26411
26570
  else {
26412
26571
  errors.push(new ParseError(param.sourceSpan, 'Unrecognized trigger'));
26413
26572
  }
26414
26573
  }
26415
- return { triggers, prefetchTriggers };
26574
+ if (hydrateTriggers.never && Object.keys(hydrateTriggers).length > 1) {
26575
+ errors.push(new ParseError(ast.startSourceSpan, 'Cannot specify additional `hydrate` triggers if `hydrate never` is present'));
26576
+ }
26577
+ return { triggers, prefetchTriggers, hydrateTriggers };
26416
26578
  }
26417
26579
 
26418
26580
  const BIND_NAME_REGEXP = /^(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.*)$/;
@@ -28125,6 +28287,8 @@ class TemplateBinder extends RecursiveAstVisitor {
28125
28287
  this.ingestScopedNode(deferred);
28126
28288
  deferred.triggers.when?.value.visit(this);
28127
28289
  deferred.prefetchTriggers.when?.value.visit(this);
28290
+ deferred.hydrateTriggers.when?.value.visit(this);
28291
+ deferred.hydrateTriggers.never?.visit(this);
28128
28292
  deferred.placeholder && this.visitNode(deferred.placeholder);
28129
28293
  deferred.loading && this.visitNode(deferred.loading);
28130
28294
  deferred.error && this.visitNode(deferred.error);
@@ -29070,7 +29234,7 @@ function publishFacade(global) {
29070
29234
  * @description
29071
29235
  * Entry point for all public APIs of the compiler package.
29072
29236
  */
29073
- new Version('19.0.0-next.4');
29237
+ new Version('19.0.0-next.6');
29074
29238
 
29075
29239
  const _I18N_ATTR = 'i18n';
29076
29240
  const _I18N_ATTR_PREFIX = 'i18n-';
@@ -30414,7 +30578,7 @@ class NodeJSPathManipulation {
30414
30578
  // G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
30415
30579
  // CommonJS/ESM interop for determining the current file name and containing dir.
30416
30580
  const isCommonJS = typeof __filename !== 'undefined';
30417
- const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('compiler_host-ca7ba733.js', document.baseURI).href));
30581
+ const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('checker-dcf9a14e.js', document.baseURI).href));
30418
30582
  const currentFileName = isCommonJS ? __filename : url.fileURLToPath(currentFileUrl);
30419
30583
  /**
30420
30584
  * A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
@@ -41727,6 +41891,10 @@ class Scope {
41727
41891
  appendDeferredBlock(block) {
41728
41892
  this.appendDeferredTriggers(block, block.triggers);
41729
41893
  this.appendDeferredTriggers(block, block.prefetchTriggers);
41894
+ // Only the `when` hydration trigger needs to be checked.
41895
+ if (block.hydrateTriggers.when) {
41896
+ this.opQueue.push(new TcbExpressionOp(this.tcb, this, block.hydrateTriggers.when.value));
41897
+ }
41730
41898
  this.appendChildren(block);
41731
41899
  if (block.placeholder !== null) {
41732
41900
  this.appendChildren(block.placeholder);
@@ -44201,285 +44369,6 @@ class SingleShimTypeCheckingHost extends SingleFileTypeCheckingHost {
44201
44369
  }
44202
44370
  }
44203
44371
 
44204
- /** Tracks changes that have to be made for specific files. */
44205
- class ChangeTracker {
44206
- _printer;
44207
- _importRemapper;
44208
- _changes = new Map();
44209
- _importManager;
44210
- _quotesCache = new WeakMap();
44211
- constructor(_printer, _importRemapper) {
44212
- this._printer = _printer;
44213
- this._importRemapper = _importRemapper;
44214
- this._importManager = new ImportManager({
44215
- shouldUseSingleQuotes: (file) => this._getQuoteKind(file) === 0 /* QuoteKind.SINGLE */,
44216
- });
44217
- }
44218
- /**
44219
- * Tracks the insertion of some text.
44220
- * @param sourceFile File in which the text is being inserted.
44221
- * @param start Index at which the text is insert.
44222
- * @param text Text to be inserted.
44223
- */
44224
- insertText(sourceFile, index, text) {
44225
- this._trackChange(sourceFile, { start: index, text });
44226
- }
44227
- /**
44228
- * Replaces text within a file.
44229
- * @param sourceFile File in which to replace the text.
44230
- * @param start Index from which to replace the text.
44231
- * @param removeLength Length of the text being replaced.
44232
- * @param text Text to be inserted instead of the old one.
44233
- */
44234
- replaceText(sourceFile, start, removeLength, text) {
44235
- this._trackChange(sourceFile, { start, removeLength, text });
44236
- }
44237
- /**
44238
- * Replaces the text of an AST node with a new one.
44239
- * @param oldNode Node to be replaced.
44240
- * @param newNode New node to be inserted.
44241
- * @param emitHint Hint when formatting the text of the new node.
44242
- * @param sourceFileWhenPrinting File to use when printing out the new node. This is important
44243
- * when copying nodes from one file to another, because TypeScript might not output literal nodes
44244
- * without it.
44245
- */
44246
- replaceNode(oldNode, newNode, emitHint = ts__default["default"].EmitHint.Unspecified, sourceFileWhenPrinting) {
44247
- const sourceFile = oldNode.getSourceFile();
44248
- this.replaceText(sourceFile, oldNode.getStart(), oldNode.getWidth(), this._printer.printNode(emitHint, newNode, sourceFileWhenPrinting || sourceFile));
44249
- }
44250
- /**
44251
- * Removes the text of an AST node from a file.
44252
- * @param node Node whose text should be removed.
44253
- */
44254
- removeNode(node) {
44255
- this._trackChange(node.getSourceFile(), {
44256
- start: node.getStart(),
44257
- removeLength: node.getWidth(),
44258
- text: '',
44259
- });
44260
- }
44261
- /**
44262
- * Adds an import to a file.
44263
- * @param sourceFile File to which to add the import.
44264
- * @param symbolName Symbol being imported.
44265
- * @param moduleName Module from which the symbol is imported.
44266
- * @param alias Alias to use for the import.
44267
- */
44268
- addImport(sourceFile, symbolName, moduleName, alias) {
44269
- if (this._importRemapper) {
44270
- moduleName = this._importRemapper(moduleName, sourceFile.fileName);
44271
- }
44272
- // It's common for paths to be manipulated with Node's `path` utilties which
44273
- // can yield a path with back slashes. Normalize them since outputting such
44274
- // paths will also cause TS to escape the forward slashes.
44275
- moduleName = normalizePath(moduleName);
44276
- if (!this._changes.has(sourceFile)) {
44277
- this._changes.set(sourceFile, []);
44278
- }
44279
- return this._importManager.addImport({
44280
- requestedFile: sourceFile,
44281
- exportSymbolName: symbolName,
44282
- exportModuleSpecifier: moduleName,
44283
- unsafeAliasOverride: alias,
44284
- });
44285
- }
44286
- /**
44287
- * Removes an import from a file.
44288
- * @param sourceFile File from which to remove the import.
44289
- * @param symbolName Original name of the symbol to be removed. Used even if the import is aliased.
44290
- * @param moduleName Module from which the symbol is imported.
44291
- */
44292
- removeImport(sourceFile, symbolName, moduleName) {
44293
- // It's common for paths to be manipulated with Node's `path` utilties which
44294
- // can yield a path with back slashes. Normalize them since outputting such
44295
- // paths will also cause TS to escape the forward slashes.
44296
- moduleName = normalizePath(moduleName);
44297
- if (!this._changes.has(sourceFile)) {
44298
- this._changes.set(sourceFile, []);
44299
- }
44300
- this._importManager.removeImport(sourceFile, symbolName, moduleName);
44301
- }
44302
- /**
44303
- * Gets the changes that should be applied to all the files in the migration.
44304
- * The changes are sorted in the order in which they should be applied.
44305
- */
44306
- recordChanges() {
44307
- this._recordImports();
44308
- return this._changes;
44309
- }
44310
- /**
44311
- * Clear the tracked changes
44312
- */
44313
- clearChanges() {
44314
- this._changes.clear();
44315
- }
44316
- /**
44317
- * Adds a change to a `ChangesByFile` map.
44318
- * @param file File that the change is associated with.
44319
- * @param change Change to be added.
44320
- */
44321
- _trackChange(file, change) {
44322
- const changes = this._changes.get(file);
44323
- if (changes) {
44324
- // Insert the changes in reverse so that they're applied in reverse order.
44325
- // This ensures that the offsets of subsequent changes aren't affected by
44326
- // previous changes changing the file's text.
44327
- const insertIndex = changes.findIndex((current) => current.start <= change.start);
44328
- if (insertIndex === -1) {
44329
- changes.push(change);
44330
- }
44331
- else {
44332
- changes.splice(insertIndex, 0, change);
44333
- }
44334
- }
44335
- else {
44336
- this._changes.set(file, [change]);
44337
- }
44338
- }
44339
- /** Determines what kind of quotes to use for a specific file. */
44340
- _getQuoteKind(sourceFile) {
44341
- if (this._quotesCache.has(sourceFile)) {
44342
- return this._quotesCache.get(sourceFile);
44343
- }
44344
- let kind = 0 /* QuoteKind.SINGLE */;
44345
- for (const statement of sourceFile.statements) {
44346
- if (ts__default["default"].isImportDeclaration(statement) && ts__default["default"].isStringLiteral(statement.moduleSpecifier)) {
44347
- kind = statement.moduleSpecifier.getText()[0] === '"' ? 1 /* QuoteKind.DOUBLE */ : 0 /* QuoteKind.SINGLE */;
44348
- this._quotesCache.set(sourceFile, kind);
44349
- break;
44350
- }
44351
- }
44352
- return kind;
44353
- }
44354
- /** Records the pending import changes from the import manager. */
44355
- _recordImports() {
44356
- const { newImports, updatedImports, deletedImports } = this._importManager.finalize();
44357
- for (const [original, replacement] of updatedImports) {
44358
- this.replaceNode(original, replacement);
44359
- }
44360
- for (const node of deletedImports) {
44361
- this.removeNode(node);
44362
- }
44363
- for (const [sourceFile] of this._changes) {
44364
- const importsToAdd = newImports.get(sourceFile.fileName);
44365
- if (!importsToAdd) {
44366
- continue;
44367
- }
44368
- const importLines = [];
44369
- let lastImport = null;
44370
- for (const statement of sourceFile.statements) {
44371
- if (ts__default["default"].isImportDeclaration(statement)) {
44372
- lastImport = statement;
44373
- }
44374
- }
44375
- for (const decl of importsToAdd) {
44376
- importLines.push(this._printer.printNode(ts__default["default"].EmitHint.Unspecified, decl, sourceFile));
44377
- }
44378
- this.insertText(sourceFile, lastImport ? lastImport.getEnd() : 0, (lastImport ? '\n' : '') + importLines.join('\n'));
44379
- }
44380
- }
44381
- }
44382
- /** Normalizes a path to use posix separators. */
44383
- function normalizePath(path) {
44384
- return path.replace(/\\/g, '/');
44385
- }
44386
-
44387
- function parseTsconfigFile(tsconfigPath, basePath) {
44388
- const { config } = ts__default["default"].readConfigFile(tsconfigPath, ts__default["default"].sys.readFile);
44389
- const parseConfigHost = {
44390
- useCaseSensitiveFileNames: ts__default["default"].sys.useCaseSensitiveFileNames,
44391
- fileExists: ts__default["default"].sys.fileExists,
44392
- readDirectory: ts__default["default"].sys.readDirectory,
44393
- readFile: ts__default["default"].sys.readFile,
44394
- };
44395
- // Throw if incorrect arguments are passed to this function. Passing relative base paths
44396
- // results in root directories not being resolved and in later type checking runtime errors.
44397
- // More details can be found here: https://github.com/microsoft/TypeScript/issues/37731.
44398
- if (!p__namespace.isAbsolute(basePath)) {
44399
- throw Error('Unexpected relative base path has been specified.');
44400
- }
44401
- return ts__default["default"].parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
44402
- }
44403
-
44404
- /**
44405
- * Creates a TypeScript program instance for a TypeScript project within
44406
- * the virtual file system tree.
44407
- * @param tree Virtual file system tree that contains the source files.
44408
- * @param tsconfigPath Virtual file system path that resolves to the TypeScript project.
44409
- * @param basePath Base path for the virtual file system tree.
44410
- * @param fakeFileRead Optional file reader function. Can be used to overwrite files in
44411
- * the TypeScript program, or to add in-memory files (e.g. to add global types).
44412
- * @param additionalFiles Additional file paths that should be added to the program.
44413
- */
44414
- function createMigrationProgram(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles) {
44415
- const { rootNames, options, host } = createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles);
44416
- return ts__default["default"].createProgram(rootNames, options, host);
44417
- }
44418
- /**
44419
- * Creates the options necessary to instantiate a TypeScript program.
44420
- * @param tree Virtual file system tree that contains the source files.
44421
- * @param tsconfigPath Virtual file system path that resolves to the TypeScript project.
44422
- * @param basePath Base path for the virtual file system tree.
44423
- * @param fakeFileRead Optional file reader function. Can be used to overwrite files in
44424
- * the TypeScript program, or to add in-memory files (e.g. to add global types).
44425
- * @param additionalFiles Additional file paths that should be added to the program.
44426
- * @param optionOverrides Overrides of the parsed compiler options.
44427
- */
44428
- function createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles, optionOverrides) {
44429
- // Resolve the tsconfig path to an absolute path. This is needed as TypeScript otherwise
44430
- // is not able to resolve root directories in the given tsconfig. More details can be found
44431
- // in the following issue: https://github.com/microsoft/TypeScript/issues/37731.
44432
- tsconfigPath = p.resolve(basePath, tsconfigPath);
44433
- const parsed = parseTsconfigFile(tsconfigPath, p.dirname(tsconfigPath));
44434
- const options = optionOverrides ? { ...parsed.options, ...optionOverrides } : parsed.options;
44435
- const host = createMigrationCompilerHost(tree, options, basePath, fakeFileRead);
44436
- return { rootNames: parsed.fileNames.concat(additionalFiles || []), options, host };
44437
- }
44438
- function createMigrationCompilerHost(tree, options, basePath, fakeRead) {
44439
- const host = ts__default["default"].createCompilerHost(options, true);
44440
- const defaultReadFile = host.readFile;
44441
- // We need to overwrite the host "readFile" method, as we want the TypeScript
44442
- // program to be based on the file contents in the virtual file tree. Otherwise
44443
- // if we run multiple migrations we might have intersecting changes and
44444
- // source files.
44445
- host.readFile = (fileName) => {
44446
- const treeRelativePath = p.relative(basePath, fileName);
44447
- let result = fakeRead?.(treeRelativePath);
44448
- if (typeof result !== 'string') {
44449
- // If the relative path resolved to somewhere outside of the tree, fall back to
44450
- // TypeScript's default file reading function since the `tree` will throw an error.
44451
- result = treeRelativePath.startsWith('..')
44452
- ? defaultReadFile.call(host, fileName)
44453
- : tree.read(treeRelativePath)?.toString();
44454
- }
44455
- // Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
44456
- // which breaks the CLI UpdateRecorder.
44457
- // See: https://github.com/angular/angular/pull/30719
44458
- return typeof result === 'string' ? result.replace(/^\uFEFF/, '') : undefined;
44459
- };
44460
- return host;
44461
- }
44462
- /**
44463
- * Checks whether a file can be migrate by our automated migrations.
44464
- * @param basePath Absolute path to the project.
44465
- * @param sourceFile File being checked.
44466
- * @param program Program that includes the source file.
44467
- */
44468
- function canMigrateFile(basePath, sourceFile, program) {
44469
- // We shouldn't migrate .d.ts files, files from an external library or type checking files.
44470
- if (sourceFile.fileName.endsWith('.ngtypecheck.ts') ||
44471
- sourceFile.isDeclarationFile ||
44472
- program.isSourceFileFromExternalLibrary(sourceFile)) {
44473
- return false;
44474
- }
44475
- // Our migrations are set up to create a `Program` from the project's tsconfig and to migrate all
44476
- // the files within the program. This can include files that are outside of the Angular CLI
44477
- // project. We can't migrate files outside of the project, because our file system interactions
44478
- // go through the CLI's `Tree` which assumes that all files are within the project. See:
44479
- // https://github.com/angular/angular-cli/blob/0b0961c9c233a825b6e4bb59ab7f0790f9b14676/packages/angular_devkit/schematics/src/tree/host-tree.ts#L131
44480
- return !p.relative(basePath, sourceFile.fileName).startsWith('..');
44481
- }
44482
-
44483
44372
  exports.AST = AST;
44484
44373
  exports.ASTWithSource = ASTWithSource;
44485
44374
  exports.AbsoluteModuleStrategy = AbsoluteModuleStrategy;
@@ -44495,7 +44384,6 @@ exports.CR = CR;
44495
44384
  exports.CUSTOM_ELEMENTS_SCHEMA = CUSTOM_ELEMENTS_SCHEMA;
44496
44385
  exports.Call = Call;
44497
44386
  exports.Chain = Chain;
44498
- exports.ChangeTracker = ChangeTracker;
44499
44387
  exports.CloneVisitor = CloneVisitor;
44500
44388
  exports.CompoundMetadataReader = CompoundMetadataReader;
44501
44389
  exports.Conditional = Conditional;
@@ -44590,7 +44478,6 @@ exports.absoluteFromSourceFile = absoluteFromSourceFile;
44590
44478
  exports.arrowFn = arrowFn;
44591
44479
  exports.asLiteral = asLiteral;
44592
44480
  exports.assertSuccessfulReferenceEmit = assertSuccessfulReferenceEmit;
44593
- exports.canMigrateFile = canMigrateFile;
44594
44481
  exports.combineResolvers = combineResolvers;
44595
44482
  exports.compileComponentFromMetadata = compileComponentFromMetadata;
44596
44483
  exports.compileDeferResolverFunction = compileDeferResolverFunction;
@@ -44611,10 +44498,8 @@ exports.createHostDirectivesMappingArray = createHostDirectivesMappingArray;
44611
44498
  exports.createInjectableType = createInjectableType;
44612
44499
  exports.createInjectorType = createInjectorType;
44613
44500
  exports.createMayBeForwardRefExpression = createMayBeForwardRefExpression;
44614
- exports.createMigrationProgram = createMigrationProgram;
44615
44501
  exports.createNgModuleType = createNgModuleType;
44616
44502
  exports.createPipeType = createPipeType;
44617
- exports.createProgramOptions = createProgramOptions;
44618
44503
  exports.createSourceSpan = createSourceSpan;
44619
44504
  exports.decimalDigest = decimalDigest;
44620
44505
  exports.devOnlyGuardedExpression = devOnlyGuardedExpression;
@@ -44655,6 +44540,7 @@ exports.isFatalDiagnosticError = isFatalDiagnosticError;
44655
44540
  exports.isFileShimSourceFile = isFileShimSourceFile;
44656
44541
  exports.isFromDtsFile = isFromDtsFile;
44657
44542
  exports.isHostDirectiveMetaForGlobalMode = isHostDirectiveMetaForGlobalMode;
44543
+ exports.isLocalRelativePath = isLocalRelativePath;
44658
44544
  exports.isNamedClassDeclaration = isNamedClassDeclaration;
44659
44545
  exports.isNonDeclarationTsPath = isNonDeclarationTsPath;
44660
44546
  exports.isShim = isShim;
@@ -44670,7 +44556,6 @@ exports.mapLiteral = mapLiteral;
44670
44556
  exports.ngErrorCode = ngErrorCode;
44671
44557
  exports.nodeDebugInfo = nodeDebugInfo;
44672
44558
  exports.nodeNameForError = nodeNameForError;
44673
- exports.normalizePath = normalizePath;
44674
44559
  exports.parseHostBindings = parseHostBindings;
44675
44560
  exports.parseTemplate = parseTemplate;
44676
44561
  exports.presetImportManagerForceNamespaceImports = presetImportManagerForceNamespaceImports;