@ckeditor/ckeditor5-dev-manual-server 57.3.0 → 58.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +24 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -494,7 +494,7 @@ function refreshPlugin() {
494
494
  const bundledDev = server.environments.client.bundledDev;
495
495
  if (!bundledDev) return;
496
496
  wrapBundledDevClientSend(bundledDev.clients);
497
- wrapBundledDevFullReloads(bundledDev);
497
+ wrapBundledDevFullReloads(bundledDev, server.config.root);
498
498
  }
499
499
  };
500
500
  }
@@ -512,27 +512,42 @@ function wrapBundledDevClientSend(clients) {
512
512
  return setupIfNeeded(client, clientId);
513
513
  };
514
514
  }
515
- function wrapBundledDevFullReloads(bundledDev) {
515
+ function wrapBundledDevFullReloads(bundledDev, workspaceRoot) {
516
516
  if (typeof bundledDev.handleHmrOutput != "function") return;
517
517
  const handleHmrOutput = bundledDev.handleHmrOutput.bind(bundledDev);
518
518
  bundledDev.handleHmrOutput = (client, files, hmrOutput, invalidateInformation) => {
519
- if (hmrOutput.type == "FullReload" && shouldShowManualRefreshPromptForFiles(files)) {
520
- ensureLatestBuildOutput(bundledDev);
521
- client.send({
522
- type: "custom",
523
- event: MANUAL_REFRESH_EVENT_NAME
524
- });
519
+ if (hmrOutput.type != "FullReload") return handleHmrOutput(client, files, hmrOutput, invalidateInformation);
520
+ if (!shouldShowManualRefreshPromptForFiles(files)) {
521
+ reloadClientAfterLatestBuildOutput(bundledDev, client, files, workspaceRoot);
525
522
  return;
526
523
  }
527
- return handleHmrOutput(client, files, hmrOutput, invalidateInformation);
524
+ ensureLatestBuildOutput(bundledDev);
525
+ client.send({
526
+ type: "custom",
527
+ event: MANUAL_REFRESH_EVENT_NAME
528
+ });
528
529
  };
529
530
  }
531
+ async function reloadClientAfterLatestBuildOutput(bundledDev, client, files, workspaceRoot) {
532
+ try {
533
+ await bundledDev.devEngine?.ensureLatestBuildOutput();
534
+ } catch {}
535
+ client.send({
536
+ type: "full-reload",
537
+ path: getChangedHtmlPublicPath(files, workspaceRoot)
538
+ });
539
+ }
540
+ function getChangedHtmlPublicPath(files, workspaceRoot) {
541
+ const htmlFile = files.find((file) => file.endsWith(".html"));
542
+ return htmlFile ? toPublicFilePath(htmlFile, workspaceRoot) : void 0;
543
+ }
530
544
  function ensureLatestBuildOutput(bundledDev) {
531
545
  try {
532
546
  bundledDev.devEngine?.ensureLatestBuildOutput().catch(() => {});
533
547
  } catch {}
534
548
  }
535
549
  function sendManualRefreshPayload(payload, send) {
550
+ if (payload.type == "update" && !payload.updates.length) return;
536
551
  if (shouldShowManualRefreshPrompt(payload)) {
537
552
  send({
538
553
  type: "custom",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-manual-server",
3
- "version": "57.3.0",
3
+ "version": "58.0.0",
4
4
  "description": "Used to extend Vite to create a manual test server for CKEditor 5.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",