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>
122 lines
3.7 KiB
JavaScript
Executable File
122 lines
3.7 KiB
JavaScript
Executable File
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Tobias Koppers @sokra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
const {
|
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
JAVASCRIPT_MODULE_TYPE_ESM
|
|
} = require("./ModuleTypeConstants");
|
|
const ConstDependency = require("./dependencies/ConstDependency");
|
|
const ProvidedDependency = require("./dependencies/ProvidedDependency");
|
|
const { approve } = require("./javascript/JavascriptParserHelpers");
|
|
|
|
/** @typedef {import("../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
/** @typedef {import("./Compiler")} Compiler */
|
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
|
|
const PLUGIN_NAME = "ProvidePlugin";
|
|
|
|
class ProvidePlugin {
|
|
/**
|
|
* @param {Record<string, string | string[]>} definitions the provided identifiers
|
|
*/
|
|
constructor(definitions) {
|
|
this.definitions = definitions;
|
|
}
|
|
|
|
/**
|
|
* Apply the plugin
|
|
* @param {Compiler} compiler the compiler instance
|
|
* @returns {void}
|
|
*/
|
|
apply(compiler) {
|
|
const definitions = this.definitions;
|
|
compiler.hooks.compilation.tap(
|
|
PLUGIN_NAME,
|
|
(compilation, { normalModuleFactory }) => {
|
|
compilation.dependencyTemplates.set(
|
|
ConstDependency,
|
|
new ConstDependency.Template()
|
|
);
|
|
compilation.dependencyFactories.set(
|
|
ProvidedDependency,
|
|
normalModuleFactory
|
|
);
|
|
compilation.dependencyTemplates.set(
|
|
ProvidedDependency,
|
|
new ProvidedDependency.Template()
|
|
);
|
|
/**
|
|
* @param {JavascriptParser} parser the parser
|
|
* @param {JavascriptParserOptions} parserOptions options
|
|
* @returns {void}
|
|
*/
|
|
const handler = (parser, parserOptions) => {
|
|
for (const name of Object.keys(definitions)) {
|
|
const request = [
|
|
...(Array.isArray(definitions[name])
|
|
? definitions[name]
|
|
: [definitions[name]])
|
|
];
|
|
const splittedName = name.split(".");
|
|
if (splittedName.length > 0) {
|
|
for (const [i, _] of splittedName.slice(1).entries()) {
|
|
const name = splittedName.slice(0, i + 1).join(".");
|
|
parser.hooks.canRename.for(name).tap(PLUGIN_NAME, approve);
|
|
}
|
|
}
|
|
|
|
parser.hooks.expression.for(name).tap(PLUGIN_NAME, (expr) => {
|
|
const nameIdentifier = name.includes(".")
|
|
? `__webpack_provided_${name.replace(/\./g, "_dot_")}`
|
|
: name;
|
|
const dep = new ProvidedDependency(
|
|
request[0],
|
|
nameIdentifier,
|
|
request.slice(1),
|
|
/** @type {Range} */ (expr.range)
|
|
);
|
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
parser.state.module.addDependency(dep);
|
|
return true;
|
|
});
|
|
|
|
parser.hooks.call.for(name).tap(PLUGIN_NAME, (expr) => {
|
|
const nameIdentifier = name.includes(".")
|
|
? `__webpack_provided_${name.replace(/\./g, "_dot_")}`
|
|
: name;
|
|
const dep = new ProvidedDependency(
|
|
request[0],
|
|
nameIdentifier,
|
|
request.slice(1),
|
|
/** @type {Range} */ (expr.callee.range)
|
|
);
|
|
dep.loc = /** @type {DependencyLocation} */ (expr.callee.loc);
|
|
parser.state.module.addDependency(dep);
|
|
parser.walkExpressions(expr.arguments);
|
|
return true;
|
|
});
|
|
}
|
|
};
|
|
normalModuleFactory.hooks.parser
|
|
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
|
.tap(PLUGIN_NAME, handler);
|
|
normalModuleFactory.hooks.parser
|
|
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
|
.tap(PLUGIN_NAME, handler);
|
|
normalModuleFactory.hooks.parser
|
|
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
|
.tap(PLUGIN_NAME, handler);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = ProvidePlugin;
|