Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
84 lines
2.0 KiB
JavaScript
84 lines
2.0 KiB
JavaScript
/* global __resourceQuery */
|
|
|
|
"use strict";
|
|
|
|
if (typeof EventSource !== "function") {
|
|
throw new Error(
|
|
"Environment doesn't support lazy compilation (requires EventSource)"
|
|
);
|
|
}
|
|
|
|
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
|
/** @type {EventSource | undefined} */
|
|
var activeEventSource;
|
|
var activeKeys = new Map();
|
|
var errorHandlers = new Set();
|
|
|
|
var updateEventSource = function updateEventSource() {
|
|
if (activeEventSource) activeEventSource.close();
|
|
if (activeKeys.size) {
|
|
activeEventSource = new EventSource(
|
|
urlBase + Array.from(activeKeys.keys()).join("@")
|
|
);
|
|
/**
|
|
* @this {EventSource}
|
|
* @param {Event & { message?: string, filename?: string, lineno?: number, colno?: number, error?: Error }} event event
|
|
*/
|
|
activeEventSource.onerror = function (event) {
|
|
errorHandlers.forEach(function (onError) {
|
|
onError(
|
|
new Error(
|
|
"Problem communicating active modules to the server: " +
|
|
event.message +
|
|
" " +
|
|
event.filename +
|
|
":" +
|
|
event.lineno +
|
|
":" +
|
|
event.colno +
|
|
" " +
|
|
event.error
|
|
)
|
|
);
|
|
});
|
|
};
|
|
} else {
|
|
activeEventSource = undefined;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
|
|
* @returns {() => void} function to destroy response
|
|
*/
|
|
exports.keepAlive = function (options) {
|
|
var data = options.data;
|
|
var onError = options.onError;
|
|
var active = options.active;
|
|
var module = options.module;
|
|
errorHandlers.add(onError);
|
|
var value = activeKeys.get(data) || 0;
|
|
activeKeys.set(data, value + 1);
|
|
if (value === 0) {
|
|
updateEventSource();
|
|
}
|
|
if (!active && !module.hot) {
|
|
console.log(
|
|
"Hot Module Replacement is not enabled. Waiting for process restart..."
|
|
);
|
|
}
|
|
|
|
return function () {
|
|
errorHandlers.delete(onError);
|
|
setTimeout(function () {
|
|
var value = activeKeys.get(data);
|
|
if (value === 1) {
|
|
activeKeys.delete(data);
|
|
updateEventSource();
|
|
} else {
|
|
activeKeys.set(data, value - 1);
|
|
}
|
|
}, 1000);
|
|
};
|
|
};
|