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>
169 lines
4.1 KiB
JavaScript
Executable File
169 lines
4.1 KiB
JavaScript
Executable File
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Tobias Koppers @sokra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("tapable");
|
|
const {
|
|
makeWebpackError,
|
|
makeWebpackErrorCallback
|
|
} = require("./HookWebpackError");
|
|
|
|
/** @typedef {import("./WebpackError")} WebpackError */
|
|
|
|
/**
|
|
* @typedef {object} Etag
|
|
* @property {() => string} toString
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @callback CallbackCache
|
|
* @param {WebpackError | null} err
|
|
* @param {T=} result
|
|
* @returns {void}
|
|
*/
|
|
|
|
/** @typedef {EXPECTED_ANY} Data */
|
|
|
|
/**
|
|
* @template T
|
|
* @callback GotHandler
|
|
* @param {T} result
|
|
* @param {() => void} callback
|
|
* @returns {void}
|
|
*/
|
|
|
|
/**
|
|
* @param {number} times times
|
|
* @param {(err?: Error | null) => void} callback callback
|
|
* @returns {(err?: Error | null) => void} callback
|
|
*/
|
|
const needCalls = (times, callback) => (err) => {
|
|
if (--times === 0) {
|
|
return callback(err);
|
|
}
|
|
if (err && times > 0) {
|
|
times = 0;
|
|
return callback(err);
|
|
}
|
|
};
|
|
|
|
class Cache {
|
|
constructor() {
|
|
this.hooks = {
|
|
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler<EXPECTED_ANY>[]], Data>} */
|
|
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
|
/** @type {AsyncParallelHook<[string, Etag | null, Data]>} */
|
|
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
|
/** @type {AsyncParallelHook<[Iterable<string>]>} */
|
|
storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
|
|
/** @type {SyncHook<[]>} */
|
|
beginIdle: new SyncHook([]),
|
|
/** @type {AsyncParallelHook<[]>} */
|
|
endIdle: new AsyncParallelHook([]),
|
|
/** @type {AsyncParallelHook<[]>} */
|
|
shutdown: new AsyncParallelHook([])
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @template T
|
|
* @param {string} identifier the cache identifier
|
|
* @param {Etag | null} etag the etag
|
|
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
* @returns {void}
|
|
*/
|
|
get(identifier, etag, callback) {
|
|
/** @type {GotHandler<T>[]} */
|
|
const gotHandlers = [];
|
|
this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
|
|
if (err) {
|
|
callback(makeWebpackError(err, "Cache.hooks.get"));
|
|
return;
|
|
}
|
|
if (result === null) {
|
|
result = undefined;
|
|
}
|
|
if (gotHandlers.length > 1) {
|
|
const innerCallback = needCalls(gotHandlers.length, () =>
|
|
callback(null, result)
|
|
);
|
|
for (const gotHandler of gotHandlers) {
|
|
gotHandler(result, innerCallback);
|
|
}
|
|
} else if (gotHandlers.length === 1) {
|
|
gotHandlers[0](result, () => callback(null, result));
|
|
} else {
|
|
callback(null, result);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @template T
|
|
* @param {string} identifier the cache identifier
|
|
* @param {Etag | null} etag the etag
|
|
* @param {T} data the value to store
|
|
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
* @returns {void}
|
|
*/
|
|
store(identifier, etag, data, callback) {
|
|
this.hooks.store.callAsync(
|
|
identifier,
|
|
etag,
|
|
data,
|
|
makeWebpackErrorCallback(callback, "Cache.hooks.store")
|
|
);
|
|
}
|
|
|
|
/**
|
|
* After this method has succeeded the cache can only be restored when build dependencies are
|
|
* @param {Iterable<string>} dependencies list of all build dependencies
|
|
* @param {CallbackCache<void>} callback signals when the dependencies are stored
|
|
* @returns {void}
|
|
*/
|
|
storeBuildDependencies(dependencies, callback) {
|
|
this.hooks.storeBuildDependencies.callAsync(
|
|
dependencies,
|
|
makeWebpackErrorCallback(callback, "Cache.hooks.storeBuildDependencies")
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @returns {void}
|
|
*/
|
|
beginIdle() {
|
|
this.hooks.beginIdle.call();
|
|
}
|
|
|
|
/**
|
|
* @param {CallbackCache<void>} callback signals when the call finishes
|
|
* @returns {void}
|
|
*/
|
|
endIdle(callback) {
|
|
this.hooks.endIdle.callAsync(
|
|
makeWebpackErrorCallback(callback, "Cache.hooks.endIdle")
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param {CallbackCache<void>} callback signals when the call finishes
|
|
* @returns {void}
|
|
*/
|
|
shutdown(callback) {
|
|
this.hooks.shutdown.callAsync(
|
|
makeWebpackErrorCallback(callback, "Cache.hooks.shutdown")
|
|
);
|
|
}
|
|
}
|
|
|
|
Cache.STAGE_MEMORY = -10;
|
|
Cache.STAGE_DEFAULT = 0;
|
|
Cache.STAGE_DISK = 10;
|
|
Cache.STAGE_NETWORK = 20;
|
|
|
|
module.exports = Cache;
|