@xyd-js/plugin-docs 0.1.0-xyd.44 → 0.1.0-xyd.5

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.
package/dist/index.js CHANGED
@@ -3211,7 +3211,7 @@ File must be named 'docs' with one of the following extensions: ${extensions.joi
3211
3211
  let json = JSON.parse(rawJsonSettings);
3212
3212
  return json;
3213
3213
  } catch (e) {
3214
- console.error("\u26A0\uFE0F Error parsing settings file");
3214
+ console.error(e);
3215
3215
  return null;
3216
3216
  }
3217
3217
  }
@@ -3281,42 +3281,25 @@ function preinstall() {
3281
3281
  }
3282
3282
  function vitePluginSettings() {
3283
3283
  return async function({ preinstall: preinstall3 }) {
3284
- const virtualId = "virtual:xyd-settings";
3285
- const resolvedId = virtualId + ".jsx";
3286
- let currentSettings = globalThis.__xydSettings;
3287
- if (!currentSettings && preinstall3?.settings) {
3288
- currentSettings = typeof preinstall3?.settings === "string" ? preinstall3?.settings : JSON.stringify(preinstall3?.settings || {});
3289
- }
3290
3284
  return {
3291
- name: "xyd:virtual-settings",
3285
+ name: "virtual:xyd-settings",
3292
3286
  resolveId(id) {
3293
- if (id === virtualId) {
3294
- return resolvedId;
3287
+ if (id === "virtual:xyd-settings") {
3288
+ return id + ".jsx";
3295
3289
  }
3296
3290
  return null;
3297
3291
  },
3298
3292
  async load(id) {
3299
3293
  if (id === "virtual:xyd-settings.jsx") {
3300
3294
  return `
3301
- export default {
3302
- get settings() {
3303
- return globalThis.__xydSettings || ${typeof preinstall3.settings === "string" ? preinstall3.settings : JSON.stringify(preinstall3.settings)}
3295
+ export default {
3296
+ get settings() {
3297
+ return globalThis.__xydSettings || ${typeof preinstall3.settings === "string" ? preinstall3.settings : JSON.stringify(preinstall3.settings)}
3304
3298
  }
3305
3299
  }
3306
3300
  `;
3307
3301
  }
3308
3302
  return null;
3309
- },
3310
- async hotUpdate(ctx) {
3311
- const isPageFileChanged = ctx.file.includes("xyd-plugin-docs/src/pages/layout.tsx") || ctx.file.includes("xyd-plugin-docs/src/pages/page.tsx");
3312
- if (!isPageFileChanged) {
3313
- return;
3314
- }
3315
- const newSettings = await readSettings();
3316
- if (!newSettings) {
3317
- return;
3318
- }
3319
- globalThis.__xydSettings = newSettings;
3320
3303
  }
3321
3304
  };
3322
3305
  };