private INP()

in src/performance/index.ts [202:240]


  private INP() {
    if (!isEventSupported()) {
      return;
    }
    prerenderChangeListener(() => {
      const processEntries = (entries: INPMetric['entries']) => {
        idlePeriod(() => {
          entries.forEach(handleInteractionEntry);
          const interaction = getLongestInteraction();
          const len = this.inpList.length;

          if (interaction && (!len ||  this.inpList[len - 1].inpTime !== interaction.latency)) {
            const param = {
              inpTime: interaction.latency,
              ...this.perfInfo,
            };
            this.inpList.push(param);
          }
        })
      };
      const obs = observe('event', processEntries, {
        durationThreshold: DEFAULT_DURATION_THRESHOLD,
      });
      if (!obs) {
        return;
      }
      obs.observe({type: 'first-input', buffered: true});
      onHidden(
        runOnce(() => {
          processEntries(obs.takeRecords() as INPMetric['entries']);
          obs.disconnect();
        }),
      );
      onBFCacheRestore(() => {
        clearInteractions();
        this.inpList.length = 0;
      })
    })
  }