Add semantic token highlighting for 'that' variable and comment file references in VS Code extension Add Phone_Text_Input and Currency_Input components with formatting utilities Implement client widgets, form standardization, and soft delete functionality Add modal scroll lock and update documentation Implement comprehensive modal system with form integration and validation Fix modal component instantiation using jQuery plugin API Implement modal system with responsive sizing, queuing, and validation support Implement form submission with validation, error handling, and loading states Implement country/state selectors with dynamic data loading and Bootstrap styling Revert Rsx::Route() highlighting in Blade/PHP files Target specific PHP scopes for Rsx::Route() highlighting in Blade Expand injection selector for Rsx::Route() highlighting Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls Update jqhtml packages to v2.2.165 Add bundle path validation for common mistakes (development mode only) Create Ajax_Select_Input widget and Rsx_Reference_Data controller Create Country_Select_Input widget with default country support Initialize Tom Select on Select_Input widgets Add Tom Select bundle for enhanced select dropdowns Implement ISO 3166 geographic data system for country/region selection Implement widget-based form system with disabled state support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
209 lines
6.1 KiB
JavaScript
Executable File
209 lines
6.1 KiB
JavaScript
Executable File
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Tobias Koppers @sokra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
const { SyncWaterfallHook } = require("tapable");
|
|
const Compilation = require("../Compilation");
|
|
const Generator = require("../Generator");
|
|
const { tryRunOrWebpackError } = require("../HookWebpackError");
|
|
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
const { compareModulesByIdOrIdentifier } = require("../util/comparators");
|
|
const memoize = require("../util/memoize");
|
|
|
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
/** @typedef {import("../Chunk")} Chunk */
|
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
/** @typedef {import("../Compiler")} Compiler */
|
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
/** @typedef {import("../Module")} Module */
|
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
|
|
const getAsyncWebAssemblyGenerator = memoize(() =>
|
|
require("./AsyncWebAssemblyGenerator")
|
|
);
|
|
const getAsyncWebAssemblyJavascriptGenerator = memoize(() =>
|
|
require("./AsyncWebAssemblyJavascriptGenerator")
|
|
);
|
|
const getAsyncWebAssemblyParser = memoize(() =>
|
|
require("./AsyncWebAssemblyParser")
|
|
);
|
|
|
|
/**
|
|
* @typedef {object} WebAssemblyRenderContext
|
|
* @property {Chunk} chunk the chunk
|
|
* @property {DependencyTemplates} dependencyTemplates the dependency templates
|
|
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
|
* @property {ModuleGraph} moduleGraph the module graph
|
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
|
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
|
*/
|
|
|
|
/**
|
|
* @typedef {object} CompilationHooks
|
|
* @property {SyncWaterfallHook<[Source, Module, WebAssemblyRenderContext]>} renderModuleContent
|
|
*/
|
|
|
|
/**
|
|
* @typedef {object} AsyncWebAssemblyModulesPluginOptions
|
|
* @property {boolean=} mangleImports mangle imports
|
|
*/
|
|
|
|
/** @type {WeakMap<Compilation, CompilationHooks>} */
|
|
const compilationHooksMap = new WeakMap();
|
|
|
|
const PLUGIN_NAME = "AsyncWebAssemblyModulesPlugin";
|
|
|
|
class AsyncWebAssemblyModulesPlugin {
|
|
/**
|
|
* @param {Compilation} compilation the compilation
|
|
* @returns {CompilationHooks} the attached hooks
|
|
*/
|
|
static getCompilationHooks(compilation) {
|
|
if (!(compilation instanceof Compilation)) {
|
|
throw new TypeError(
|
|
"The 'compilation' argument must be an instance of Compilation"
|
|
);
|
|
}
|
|
let hooks = compilationHooksMap.get(compilation);
|
|
if (hooks === undefined) {
|
|
hooks = {
|
|
renderModuleContent: new SyncWaterfallHook([
|
|
"source",
|
|
"module",
|
|
"renderContext"
|
|
])
|
|
};
|
|
compilationHooksMap.set(compilation, hooks);
|
|
}
|
|
return hooks;
|
|
}
|
|
|
|
/**
|
|
* @param {AsyncWebAssemblyModulesPluginOptions} options options
|
|
*/
|
|
constructor(options) {
|
|
this.options = options;
|
|
}
|
|
|
|
/**
|
|
* Apply the plugin
|
|
* @param {Compiler} compiler the compiler instance
|
|
* @returns {void}
|
|
*/
|
|
apply(compiler) {
|
|
compiler.hooks.compilation.tap(
|
|
PLUGIN_NAME,
|
|
(compilation, { normalModuleFactory }) => {
|
|
const hooks =
|
|
AsyncWebAssemblyModulesPlugin.getCompilationHooks(compilation);
|
|
compilation.dependencyFactories.set(
|
|
WebAssemblyImportDependency,
|
|
normalModuleFactory
|
|
);
|
|
|
|
normalModuleFactory.hooks.createParser
|
|
.for(WEBASSEMBLY_MODULE_TYPE_ASYNC)
|
|
.tap(PLUGIN_NAME, () => {
|
|
const AsyncWebAssemblyParser = getAsyncWebAssemblyParser();
|
|
|
|
return new AsyncWebAssemblyParser();
|
|
});
|
|
normalModuleFactory.hooks.createGenerator
|
|
.for(WEBASSEMBLY_MODULE_TYPE_ASYNC)
|
|
.tap(PLUGIN_NAME, () => {
|
|
const AsyncWebAssemblyJavascriptGenerator =
|
|
getAsyncWebAssemblyJavascriptGenerator();
|
|
const AsyncWebAssemblyGenerator = getAsyncWebAssemblyGenerator();
|
|
|
|
return Generator.byType({
|
|
javascript: new AsyncWebAssemblyJavascriptGenerator(),
|
|
webassembly: new AsyncWebAssemblyGenerator(this.options)
|
|
});
|
|
});
|
|
|
|
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
|
|
const { moduleGraph, chunkGraph, runtimeTemplate } = compilation;
|
|
const {
|
|
chunk,
|
|
outputOptions,
|
|
dependencyTemplates,
|
|
codeGenerationResults
|
|
} = options;
|
|
|
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
|
chunk,
|
|
compareModulesByIdOrIdentifier(chunkGraph)
|
|
)) {
|
|
if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
|
|
const filenameTemplate = outputOptions.webassemblyModuleFilename;
|
|
|
|
result.push({
|
|
render: () =>
|
|
this.renderModule(
|
|
module,
|
|
{
|
|
chunk,
|
|
dependencyTemplates,
|
|
runtimeTemplate,
|
|
moduleGraph,
|
|
chunkGraph,
|
|
codeGenerationResults
|
|
},
|
|
hooks
|
|
),
|
|
filenameTemplate,
|
|
pathOptions: {
|
|
module,
|
|
runtime: chunk.runtime,
|
|
chunkGraph
|
|
},
|
|
auxiliary: true,
|
|
identifier: `webassemblyAsyncModule${chunkGraph.getModuleId(
|
|
module
|
|
)}`,
|
|
hash: chunkGraph.getModuleHash(module, chunk.runtime)
|
|
});
|
|
}
|
|
}
|
|
|
|
return result;
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param {Module} module the rendered module
|
|
* @param {WebAssemblyRenderContext} renderContext options object
|
|
* @param {CompilationHooks} hooks hooks
|
|
* @returns {Source} the newly generated source from rendering
|
|
*/
|
|
renderModule(module, renderContext, hooks) {
|
|
const { codeGenerationResults, chunk } = renderContext;
|
|
try {
|
|
const moduleSource = codeGenerationResults.getSource(
|
|
module,
|
|
chunk.runtime,
|
|
"webassembly"
|
|
);
|
|
return tryRunOrWebpackError(
|
|
() =>
|
|
hooks.renderModuleContent.call(moduleSource, module, renderContext),
|
|
"AsyncWebAssemblyModulesPlugin.getCompilationHooks().renderModuleContent"
|
|
);
|
|
} catch (err) {
|
|
/** @type {WebpackError} */ (err).module = module;
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = AsyncWebAssemblyModulesPlugin;
|