agenda/node_modules/webpack/lib/async-modules/AwaitDependenciesInitFragment.js
Edward Betts ea4980a5d7 Fix European trip return heuristic for weekend location tracking
Adjust European short trip heuristic from >3 days to >1 day to correctly
detect when user has returned home from European trips. This fixes the
April 29-30, 2023 case where the location incorrectly showed "Sankt Georg, Hamburg"
instead of "Bristol" when the user was free (no events scheduled) after
the foss-north trip ended on April 27.

The previous logic required more than 3 days to pass before assuming
return home from European countries, but for short European trips by
rail/ferry, users typically return within 1-2 days.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-16 06:38:37 +02:00

74 lines
2.1 KiB
JavaScript

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const InitFragment = require("../InitFragment");
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
/**
* @extends {InitFragment<GenerateContext>}
*/
class AwaitDependenciesInitFragment extends InitFragment {
/**
* @param {Set<string>} promises the promises that should be awaited
*/
constructor(promises) {
super(
undefined,
InitFragment.STAGE_ASYNC_DEPENDENCIES,
0,
"await-dependencies"
);
this.promises = promises;
}
/**
* @param {AwaitDependenciesInitFragment} other other AwaitDependenciesInitFragment
* @returns {AwaitDependenciesInitFragment} AwaitDependenciesInitFragment
*/
merge(other) {
const promises = new Set(other.promises);
for (const p of this.promises) {
promises.add(p);
}
return new AwaitDependenciesInitFragment(promises);
}
/**
* @param {GenerateContext} context context
* @returns {string | Source | undefined} the source code that will be included as initialization code
*/
getContent({ runtimeRequirements }) {
runtimeRequirements.add(RuntimeGlobals.module);
const promises = this.promises;
if (promises.size === 0) {
return "";
}
if (promises.size === 1) {
for (const p of promises) {
return Template.asString([
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${p}]);`,
`${p} = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];`,
""
]);
}
}
const sepPromises = Array.from(promises).join(", ");
// TODO check if destructuring is supported
return Template.asString([
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${sepPromises}]);`,
`([${sepPromises}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);`,
""
]);
}
}
module.exports = AwaitDependenciesInitFragment;