Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
88 lines
2.5 KiB
JavaScript
88 lines
2.5 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 {Map<string, string>} dependencies maps an import var to an async module that needs to be awaited
|
|
*/
|
|
constructor(dependencies) {
|
|
super(
|
|
undefined,
|
|
InitFragment.STAGE_ASYNC_DEPENDENCIES,
|
|
0,
|
|
"await-dependencies"
|
|
);
|
|
this.dependencies = dependencies;
|
|
}
|
|
|
|
/**
|
|
* @param {AwaitDependenciesInitFragment} other other AwaitDependenciesInitFragment
|
|
* @returns {AwaitDependenciesInitFragment} AwaitDependenciesInitFragment
|
|
*/
|
|
merge(other) {
|
|
const dependencies = new Map(other.dependencies);
|
|
for (const [key, value] of this.dependencies) {
|
|
dependencies.set(key, value);
|
|
}
|
|
return new AwaitDependenciesInitFragment(dependencies);
|
|
}
|
|
|
|
/**
|
|
* @param {GenerateContext} context context
|
|
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
|
*/
|
|
getContent({ runtimeRequirements, runtimeTemplate }) {
|
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
if (this.dependencies.size === 0) {
|
|
return "";
|
|
}
|
|
|
|
const importVars = [...this.dependencies.keys()];
|
|
const asyncModuleValues = [...this.dependencies.values()].join(", ");
|
|
|
|
const templateInput = [
|
|
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${asyncModuleValues}]);`
|
|
];
|
|
|
|
if (
|
|
this.dependencies.size === 1 ||
|
|
!runtimeTemplate.supportsDestructuring()
|
|
) {
|
|
templateInput.push(
|
|
"var __webpack_async_dependencies_result__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);"
|
|
);
|
|
for (const [index, importVar] of importVars.entries()) {
|
|
templateInput.push(
|
|
`${importVar} = __webpack_async_dependencies_result__[${index}];`
|
|
);
|
|
}
|
|
} else {
|
|
const importVarsStr = importVars.join(", ");
|
|
|
|
templateInput.push(
|
|
`([${importVarsStr}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);`
|
|
);
|
|
}
|
|
|
|
templateInput.push("");
|
|
|
|
return Template.asString(templateInput);
|
|
}
|
|
}
|
|
|
|
module.exports = AwaitDependenciesInitFragment;
|