Files
formipay/node_modules/speedline-core/lib/index.js
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

69 lines
1.9 KiB
JavaScript

'use strict';
const frame = require('./frame');
const speedIndex = require('./speed-index');
/**
* @typedef {import('../speedline').TraceEvent} TraceEvent
* @typedef {import('../speedline').IncludeType} IncludeType
* @typedef {import('../speedline').Output['frames'][number]} Frame
*/
/**
* @param {Array<Frame>} frames
* @param {{startTs: number, endTs: number}} data
*/
function calculateValues(frames, data) {
const indexes = speedIndex.calculateSpeedIndexes(frames, data);
const duration = Math.floor(data.endTs - data.startTs);
const first = Math.floor(indexes.firstPaintTs - data.startTs);
const complete = Math.floor(indexes.visuallyCompleteTs - data.startTs);
return {
beginning: data.startTs,
end: data.endTs,
frames,
first,
complete,
duration,
speedIndex: indexes.speedIndex,
perceptualSpeedIndex: indexes.perceptualSpeedIndex
};
}
/** @type {{All: 'all', pSI: 'perceptualSpeedIndex', SI: 'speedIndex'}} */
const Include = {
All: 'all',
pSI: 'perceptualSpeedIndex',
SI: 'speedIndex'
};
/**
* Retrieve speed index informations
* @template {IncludeType} I
* @param {string|Array<TraceEvent>} timeline
* @param {import('../speedline').Options<I>} opts
* @return {Promise<import('../speedline').Output<I>>}
*/
module.exports = function (timeline, opts) {
const include = opts && opts.include || Include.All;
// Check for invalid `include` values
if (!Object.keys(Include).some(key => Include[key] === include)) {
throw new Error(`Unrecognized include option: ${include}`);
}
return frame.extractFramesFromTimeline(timeline, opts).then(function (data) {
const frames = data.frames;
if (include === Include.All || include === Include.SI) {
speedIndex.calculateVisualProgress(frames, opts);
}
if (include === Include.All || include === Include.pSI) {
speedIndex.calculatePerceptualProgress(frames, opts);
}
return calculateValues(frames, data);
});
};