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>
161 lines
4.5 KiB
JavaScript
Executable File
161 lines
4.5 KiB
JavaScript
Executable File
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Tobias Koppers @sokra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
const {
|
|
compareModulesByPreOrderIndexOrIdentifier
|
|
} = require("../util/comparators");
|
|
const createSchemaValidation = require("../util/create-schema-validation");
|
|
const {
|
|
assignAscendingModuleIds,
|
|
getUsedModuleIdsAndModules
|
|
} = require("./IdHelpers");
|
|
|
|
/** @typedef {import("../../declarations/plugins/ids/OccurrenceModuleIdsPlugin").OccurrenceModuleIdsPluginOptions} OccurrenceModuleIdsPluginOptions */
|
|
/** @typedef {import("../Compiler")} Compiler */
|
|
/** @typedef {import("../Module")} Module */
|
|
|
|
const validate = createSchemaValidation(
|
|
require("../../schemas/plugins/ids/OccurrenceModuleIdsPlugin.check"),
|
|
() => require("../../schemas/plugins/ids/OccurrenceModuleIdsPlugin.json"),
|
|
{
|
|
name: "Occurrence Order Module Ids Plugin",
|
|
baseDataPath: "options"
|
|
}
|
|
);
|
|
|
|
const PLUGIN_NAME = "OccurrenceModuleIdsPlugin";
|
|
|
|
class OccurrenceModuleIdsPlugin {
|
|
/**
|
|
* @param {OccurrenceModuleIdsPluginOptions=} options options object
|
|
*/
|
|
constructor(options = {}) {
|
|
validate(options);
|
|
this.options = options;
|
|
}
|
|
|
|
/**
|
|
* Apply the plugin
|
|
* @param {Compiler} compiler the compiler instance
|
|
* @returns {void}
|
|
*/
|
|
apply(compiler) {
|
|
const prioritiseInitial = this.options.prioritiseInitial;
|
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
const moduleGraph = compilation.moduleGraph;
|
|
|
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
const chunkGraph = compilation.chunkGraph;
|
|
|
|
const [usedIds, modulesInOccurrenceOrder] =
|
|
getUsedModuleIdsAndModules(compilation);
|
|
|
|
const occursInInitialChunksMap = new Map();
|
|
const occursInAllChunksMap = new Map();
|
|
|
|
const initialChunkChunkMap = new Map();
|
|
const entryCountMap = new Map();
|
|
for (const m of modulesInOccurrenceOrder) {
|
|
let initial = 0;
|
|
let entry = 0;
|
|
for (const c of chunkGraph.getModuleChunksIterable(m)) {
|
|
if (c.canBeInitial()) initial++;
|
|
if (chunkGraph.isEntryModuleInChunk(m, c)) entry++;
|
|
}
|
|
initialChunkChunkMap.set(m, initial);
|
|
entryCountMap.set(m, entry);
|
|
}
|
|
|
|
/**
|
|
* @param {Module} module module
|
|
* @returns {number} count of occurs
|
|
*/
|
|
const countOccursInEntry = (module) => {
|
|
let sum = 0;
|
|
for (const [
|
|
originModule,
|
|
connections
|
|
] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
|
|
if (!originModule) continue;
|
|
if (!connections.some((c) => c.isTargetActive(undefined))) continue;
|
|
sum += initialChunkChunkMap.get(originModule) || 0;
|
|
}
|
|
return sum;
|
|
};
|
|
|
|
/**
|
|
* @param {Module} module module
|
|
* @returns {number} count of occurs
|
|
*/
|
|
const countOccurs = (module) => {
|
|
let sum = 0;
|
|
for (const [
|
|
originModule,
|
|
connections
|
|
] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
|
|
if (!originModule) continue;
|
|
const chunkModules =
|
|
chunkGraph.getNumberOfModuleChunks(originModule);
|
|
for (const c of connections) {
|
|
if (!c.isTargetActive(undefined)) continue;
|
|
if (!c.dependency) continue;
|
|
const factor = c.dependency.getNumberOfIdOccurrences();
|
|
if (factor === 0) continue;
|
|
sum += factor * chunkModules;
|
|
}
|
|
}
|
|
return sum;
|
|
};
|
|
|
|
if (prioritiseInitial) {
|
|
for (const m of modulesInOccurrenceOrder) {
|
|
const result =
|
|
countOccursInEntry(m) +
|
|
initialChunkChunkMap.get(m) +
|
|
entryCountMap.get(m);
|
|
occursInInitialChunksMap.set(m, result);
|
|
}
|
|
}
|
|
|
|
for (const m of modulesInOccurrenceOrder) {
|
|
const result =
|
|
countOccurs(m) +
|
|
chunkGraph.getNumberOfModuleChunks(m) +
|
|
entryCountMap.get(m);
|
|
occursInAllChunksMap.set(m, result);
|
|
}
|
|
|
|
const naturalCompare = compareModulesByPreOrderIndexOrIdentifier(
|
|
compilation.moduleGraph
|
|
);
|
|
|
|
modulesInOccurrenceOrder.sort((a, b) => {
|
|
if (prioritiseInitial) {
|
|
const aEntryOccurs = occursInInitialChunksMap.get(a);
|
|
const bEntryOccurs = occursInInitialChunksMap.get(b);
|
|
if (aEntryOccurs > bEntryOccurs) return -1;
|
|
if (aEntryOccurs < bEntryOccurs) return 1;
|
|
}
|
|
const aOccurs = occursInAllChunksMap.get(a);
|
|
const bOccurs = occursInAllChunksMap.get(b);
|
|
if (aOccurs > bOccurs) return -1;
|
|
if (aOccurs < bOccurs) return 1;
|
|
return naturalCompare(a, b);
|
|
});
|
|
|
|
assignAscendingModuleIds(
|
|
usedIds,
|
|
modulesInOccurrenceOrder,
|
|
compilation
|
|
);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = OccurrenceModuleIdsPlugin;
|