@xyd-js/documan 0.0.0-build-ba549ac-20251203173500 → 0.0.0-build-83b15db-20251213220910

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
@@ -259,6 +259,40 @@ var package_default4 = {
259
259
  }
260
260
  };
261
261
 
262
+ // ../xyd-plugin-extra-diagram/package.json
263
+ var package_default5 = {
264
+ name: "@xyd-js/plugin-extra-diagram",
265
+ version: "0.0.0",
266
+ author: "",
267
+ description: "",
268
+ license: "MIT",
269
+ main: "./dist/index.js",
270
+ type: "module",
271
+ exports: {
272
+ "./package.json": "./package.json",
273
+ ".": {
274
+ import: "./dist/index.js"
275
+ }
276
+ },
277
+ scripts: {
278
+ clean: "rimraf build",
279
+ prebuild: "pnpm clean",
280
+ build: "tsup",
281
+ test: "vitest",
282
+ "test:coverage": "vitest run --coverage"
283
+ },
284
+ dependencies: {
285
+ "unist-util-visit": "^5.0.0"
286
+ },
287
+ devDependencies: {
288
+ "@vitest/coverage-v8": "^1.6.1",
289
+ rimraf: "^3.0.2",
290
+ tsup: "^8.4.0",
291
+ vite: "^7.0.0",
292
+ vitest: "^1.6.1"
293
+ }
294
+ };
295
+
262
296
  // src/const.ts
263
297
  var XYD_FOLDER_PATH = ".xyd";
264
298
  var HOST_FOLDER_PATH = `${XYD_FOLDER_PATH}/host`;
@@ -722,11 +756,39 @@ var ANALYTICS_INTEGRATION_DEPENDENCIES = {
722
756
  "@pluganalytics/provider-livesession": "0.0.0-pre.7"
723
757
  }
724
758
  };
759
+ var resolveComponentDist = (dist) => {
760
+ if (!dist || typeof dist !== "string") {
761
+ return { resolvedDist: dist, exists: false };
762
+ }
763
+ const looksLikePath = /^([./]|[A-Za-z]:)/.test(dist);
764
+ if (looksLikePath) {
765
+ const candidates = [
766
+ dist,
767
+ `${dist}.js`,
768
+ `${dist}.ts`,
769
+ `${dist}.tsx`,
770
+ path2.join(dist, "index.js"),
771
+ path2.join(dist, "index.ts"),
772
+ path2.join(dist, "index.tsx")
773
+ ];
774
+ for (const candidate of candidates) {
775
+ try {
776
+ if (fs.existsSync(candidate)) {
777
+ return { resolvedDist: candidate, exists: true };
778
+ }
779
+ } catch {
780
+ }
781
+ }
782
+ return { resolvedDist: dist, exists: false };
783
+ }
784
+ return { resolvedDist: dist, exists: true };
785
+ };
725
786
  var EXTERNAL_XYD_PLUGINS = {
726
787
  "@xyd-js/plugin-supademo": package_default.version,
727
788
  "@xyd-js/plugin-chatwoot": package_default2.version,
728
789
  "@xyd-js/plugin-intercom": package_default3.version,
729
- "@xyd-js/plugin-livechat": package_default4.version
790
+ "@xyd-js/plugin-livechat": package_default4.version,
791
+ "@xyd-js/plugin-extra-diagram": package_default5.version
730
792
  };
731
793
  function isLLMsTxtPath(settings) {
732
794
  const aiLlms = settings?.ai?.llmsTxt;
@@ -737,6 +799,24 @@ function isLLMsTxtPath(settings) {
737
799
  }
738
800
  return false;
739
801
  }
802
+ function cloneComponentsPreservingReferences(componentPlugins) {
803
+ return componentPlugins.map((comp) => {
804
+ const cloned = { ...comp };
805
+ for (const key in cloned) {
806
+ if (cloned.hasOwnProperty(key)) {
807
+ const value = cloned[key];
808
+ if (typeof value === "function" || key === "component") {
809
+ cloned[key] = value;
810
+ } else if (Array.isArray(value)) {
811
+ cloned[key] = [...value];
812
+ } else if (value && typeof value === "object" && value.constructor === Object) {
813
+ cloned[key] = { ...value };
814
+ }
815
+ }
816
+ }
817
+ return cloned;
818
+ });
819
+ }
740
820
  async function appInit(options) {
741
821
  const readPreloadSettings = await readSettings2();
742
822
  if (!readPreloadSettings) {
@@ -763,8 +843,26 @@ async function appInit(options) {
763
843
  {
764
844
  resolvedPlugins = await loadPlugins(preloadSettings, options) || [];
765
845
  const userUniformVitePlugins = [];
846
+ const userMarkdownPlugins = {
847
+ rehype: [],
848
+ remark: [],
849
+ remarkRehypeHandlers: {}
850
+ };
766
851
  const componentPlugins = [];
852
+ const userHooks = {};
767
853
  resolvedPlugins?.forEach((p) => {
854
+ if (p.hooks) {
855
+ Object.keys(p.hooks).map((hookKey) => {
856
+ if (!p.hooks) {
857
+ return;
858
+ }
859
+ const hook = p.hooks[hookKey];
860
+ if (!userHooks[hookKey]) {
861
+ userHooks[hookKey] = [];
862
+ }
863
+ userHooks[hookKey].push(hook);
864
+ });
865
+ }
768
866
  if (p.uniform) {
769
867
  userUniformVitePlugins.push(...p.uniform);
770
868
  }
@@ -793,14 +891,23 @@ async function appInit(options) {
793
891
  if (!component.name) {
794
892
  component.name = component.component.name;
795
893
  }
796
- if (!component.dist) {
797
- component.dist = p._pluginPkg + "/" + component.name;
798
- continue;
799
- }
800
894
  if (!component.name) {
801
895
  console.error("No component name");
802
896
  continue;
803
897
  }
898
+ if (!component.dist) {
899
+ const pluginPkg = p._pluginPkg || "";
900
+ const looksLikeFilePath = /\.[tj]sx?$/.test(path2.basename(pluginPkg));
901
+ const pluginPkgBase = looksLikeFilePath ? path2.dirname(pluginPkg) : pluginPkg.replace(/\/[^\/]+\.(ts|js|tsx|jsx|mjs|cjs)$/, "");
902
+ const componentFunctionName = component.component.name;
903
+ const distName = componentFunctionName || component.name;
904
+ component.dist = `${pluginPkgBase}/${distName}`;
905
+ }
906
+ const { resolvedDist, exists } = resolveComponentDist(component.dist);
907
+ component.dist = resolvedDist;
908
+ if (!component.isInline) {
909
+ component.isInline = !exists;
910
+ }
804
911
  }
805
912
  components.push(...p.components);
806
913
  }
@@ -810,9 +917,24 @@ async function appInit(options) {
810
917
  if (head?.length && preloadSettings?.theme?.head) {
811
918
  preloadSettings.theme.head.push(...head);
812
919
  }
920
+ if (p.markdown?.rehype) {
921
+ userMarkdownPlugins.rehype.push(...p.markdown?.rehype || []);
922
+ }
923
+ if (p.markdown?.remark) {
924
+ userMarkdownPlugins.remark.push(...p.markdown?.remark || []);
925
+ }
926
+ if (p.markdown?.remarkRehypeHandlers) {
927
+ userMarkdownPlugins.remarkRehypeHandlers = {
928
+ ...userMarkdownPlugins.remarkRehypeHandlers,
929
+ ...p.markdown?.remarkRehypeHandlers || {}
930
+ };
931
+ }
813
932
  });
814
933
  globalThis.__xydUserUniformVitePlugins = userUniformVitePlugins;
934
+ globalThis.__xydUserMarkdownPlugins = userMarkdownPlugins;
815
935
  globalThis.__xydUserComponents = componentPlugins;
936
+ globalThis.__xydUserHooks = userHooks;
937
+ globalThis.__xydUserComponentsSERVER = cloneComponentsPreservingReferences(componentPlugins);
816
938
  }
817
939
  const respPluginDocs = await pluginDocs({
818
940
  ...options,
@@ -864,19 +986,61 @@ function virtualComponentsPlugin() {
864
986
  },
865
987
  async load(id) {
866
988
  if (id === "virtual:xyd-user-components.jsx") {
867
- const userComponents = globalThis.__xydUserComponents || [];
868
- if (userComponents.length > 0 && userComponents[0]?.component) {
869
- const imports = userComponents.map(
870
- (component, index) => `import Component${index} from '${component.dist}';`
871
- ).join("\n");
872
- const componentObjects = userComponents.map(
873
- (component, index) => `{
989
+ const userComponents = globalThis.__xydUserComponentsSERVER || [];
990
+ const resolveExistingDist = (dist) => {
991
+ if (!dist || typeof dist !== "string") return null;
992
+ const looksLikePath = /^([./]|[A-Za-z]:)/.test(dist);
993
+ if (!looksLikePath) return dist;
994
+ const candidates = [dist, `${dist}.js`, `${dist}.ts`, `${dist}.tsx`];
995
+ for (const candidate of candidates) {
996
+ if (fs.existsSync(candidate)) {
997
+ const stat2 = fs.statSync(candidate);
998
+ if (stat2.isDirectory()) {
999
+ const indexCandidates = [
1000
+ path2.join(candidate, "index.js"),
1001
+ path2.join(candidate, "index.ts"),
1002
+ path2.join(candidate, "index.tsx")
1003
+ ];
1004
+ for (const idx of indexCandidates) {
1005
+ if (fs.existsSync(idx)) return idx;
1006
+ }
1007
+ } else {
1008
+ return candidate;
1009
+ }
1010
+ }
1011
+ }
1012
+ return null;
1013
+ };
1014
+ const imports = userComponents.map((component, index) => {
1015
+ const dist = component?.dist;
1016
+ const explicitInline = component?.isInline === true;
1017
+ const looksLikePath = typeof dist === "string" && /^([./]|[A-Za-z]:)/.test(dist);
1018
+ const resolvedDist = resolveExistingDist(dist);
1019
+ const missingLocalFile = looksLikePath && !resolvedDist;
1020
+ const shouldInline = explicitInline || !dist || missingLocalFile;
1021
+ const importTarget = resolvedDist || dist;
1022
+ if (!shouldInline && importTarget) {
1023
+ return `import Component${index} from '${importTarget}';`;
1024
+ }
1025
+ return `const Component${index} = ${component?.component?.toString()}`;
1026
+ }).join("\n");
1027
+ const componentObjects = userComponents.map((component, index) => {
1028
+ const dist = component?.dist;
1029
+ const explicitInline = component?.isInline === true;
1030
+ const looksLikePath = typeof dist === "string" && /^([./]|[A-Za-z]:)/.test(dist);
1031
+ const resolvedDist = resolveExistingDist(dist);
1032
+ const missingLocalFile = looksLikePath && !resolvedDist;
1033
+ const shouldInline = explicitInline || !dist || missingLocalFile;
1034
+ const finalDist = shouldInline ? "" : resolvedDist || dist || "";
1035
+ return `{
874
1036
  component: Component${index},
875
1037
  name: '${component.name}',
876
- dist: '${component.dist}'
877
- }`
878
- ).join(",\n ");
879
- return `
1038
+ dist: '${finalDist}'
1039
+ }`;
1040
+ }).join(",\n ");
1041
+ const resp = `
1042
+ import React from 'react';
1043
+
880
1044
  // Pre-bundled at build time - no async loading needed
881
1045
  ${imports}
882
1046
 
@@ -884,10 +1048,7 @@ function virtualComponentsPlugin() {
884
1048
  ${componentObjects}
885
1049
  ];
886
1050
  `;
887
- }
888
- return `
889
- export const components = globalThis.__xydUserComponents || []
890
- `;
1051
+ return resp;
891
1052
  }
892
1053
  return null;
893
1054
  }
@@ -925,6 +1086,30 @@ function virtualProvidersPlugin(settings) {
925
1086
  }
926
1087
  };
927
1088
  }
1089
+ function virtualScriptsPlugin(settings) {
1090
+ return {
1091
+ name: "xyd-plugin-virtual-scripts",
1092
+ enforce: "pre",
1093
+ resolveId(id) {
1094
+ if (id === "virtual:xyd-scripts") {
1095
+ return id;
1096
+ }
1097
+ },
1098
+ async load(id) {
1099
+ if (id === "virtual:xyd-scripts") {
1100
+ const scripts = settings?.theme?.scripts || [];
1101
+ if (scripts.length === 0) {
1102
+ return `// No scripts configured`;
1103
+ }
1104
+ const imports = scripts.map((script) => `import '${script}';`).join("\n");
1105
+ return `
1106
+ // Auto-generated imports from settings.theme.scripts
1107
+ ${imports}
1108
+ `;
1109
+ }
1110
+ }
1111
+ };
1112
+ }
928
1113
  async function commonVitePlugins(respPluginDocs, resolvedPlugins) {
929
1114
  const userVitePlugins = resolvedPlugins.map((p) => p.vite).flat() || [];
930
1115
  return [
@@ -938,6 +1123,7 @@ async function commonVitePlugins(respPluginDocs, resolvedPlugins) {
938
1123
  reactRouter(),
939
1124
  virtualComponentsPlugin(),
940
1125
  virtualProvidersPlugin(respPluginDocs.settings),
1126
+ virtualScriptsPlugin(respPluginDocs.settings),
941
1127
  pluginIconSet(respPluginDocs.settings),
942
1128
  ...userVitePlugins
943
1129
  ];
@@ -1235,20 +1421,33 @@ async function loadPlugins(settings, options) {
1235
1421
  return [];
1236
1422
  }
1237
1423
  let mod;
1238
- try {
1239
- mod = await import(pluginName);
1240
- } catch (e) {
1241
- pluginName = path2.join(
1242
- process.cwd(),
1243
- ".xyd/host/node_modules",
1244
- pluginName
1245
- );
1246
- const pluginPreview = await createServer({
1247
- optimizeDeps: {
1248
- include: []
1249
- }
1250
- });
1251
- mod = await pluginPreview.ssrLoadModule(pluginName);
1424
+ if (pluginName?.startsWith("./")) {
1425
+ try {
1426
+ pluginName = path2.join(process.cwd(), pluginName);
1427
+ const pluginPreview = await createServer({
1428
+ optimizeDeps: {
1429
+ include: []
1430
+ }
1431
+ });
1432
+ mod = await pluginPreview.ssrLoadModule(pluginName);
1433
+ } catch (e) {
1434
+ }
1435
+ } else {
1436
+ try {
1437
+ mod = await import(pluginName);
1438
+ } catch (e) {
1439
+ pluginName = path2.join(
1440
+ process.cwd(),
1441
+ ".xyd/host/node_modules",
1442
+ pluginName
1443
+ );
1444
+ const pluginPreview = await createServer({
1445
+ optimizeDeps: {
1446
+ include: []
1447
+ }
1448
+ });
1449
+ mod = await pluginPreview.ssrLoadModule(pluginName);
1450
+ }
1252
1451
  }
1253
1452
  if (!mod.default) {
1254
1453
  console.error(`Plugin ${plugin} has no default export`);
@@ -1310,6 +1509,12 @@ function integrationsToPlugins(integrations) {
1310
1509
  if (integrations?.support?.livechat) {
1311
1510
  plugins.push(["@xyd-js/plugin-livechat", integrations.support.livechat]);
1312
1511
  }
1512
+ if (integrations?.diagrams && typeof integrations?.diagrams === "object" && ".config" in integrations?.diagrams) {
1513
+ const diagramCfg = integrations?.diagrams[".config"];
1514
+ if (diagramCfg?.interactive) {
1515
+ plugins.push(["@xyd-js/plugin-extra-diagram", {}]);
1516
+ }
1517
+ }
1313
1518
  return plugins;
1314
1519
  }
1315
1520
  async function preWorkspaceSetup(options = {}) {