@xyd-js/documan 0.1.0-xyd.31 → 0.1.0-xyd.32
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/package.json +4 -4
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -981
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/documan",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"vfile": "^6.0.3",
|
|
40
40
|
"yaml": "^2.6.0",
|
|
41
41
|
"@xyd-js/content": "0.1.0-xyd.16",
|
|
42
|
-
"@xyd-js/
|
|
43
|
-
"@xyd-js/
|
|
42
|
+
"@xyd-js/core": "0.1.0-xyd.15",
|
|
43
|
+
"@xyd-js/plugin-docs": "0.1.0-xyd.3",
|
|
44
44
|
"@xyd-js/uniform": "0.1.0-xyd.17",
|
|
45
|
-
"@xyd-js/
|
|
45
|
+
"@xyd-js/plugins": "0.1.0-xyd.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@mdx-js/rollup": "^3.1.0",
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,981 +0,0 @@
|
|
|
1
|
-
// src/build.ts
|
|
2
|
-
import path2 from "path";
|
|
3
|
-
import fs2 from "fs";
|
|
4
|
-
import { build as viteBuild } from "vite";
|
|
5
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
6
|
-
|
|
7
|
-
// src/utils.ts
|
|
8
|
-
import path from "path";
|
|
9
|
-
import fs from "fs";
|
|
10
|
-
import { fileURLToPath } from "url";
|
|
11
|
-
import { execSync } from "child_process";
|
|
12
|
-
import crypto from "crypto";
|
|
13
|
-
import { createServer } from "vite";
|
|
14
|
-
import { reactRouter } from "@react-router/dev/vite";
|
|
15
|
-
import { IconSet } from "@iconify/tools";
|
|
16
|
-
import { readSettings, pluginDocs } from "@xyd-js/plugin-docs";
|
|
17
|
-
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content/vite";
|
|
18
|
-
|
|
19
|
-
// ../xyd-host/package.json
|
|
20
|
-
var package_default = {
|
|
21
|
-
name: "@xyd-js/host",
|
|
22
|
-
version: "0.1.0-xyd.0",
|
|
23
|
-
type: "module",
|
|
24
|
-
scripts: {},
|
|
25
|
-
dependencies: {
|
|
26
|
-
"@xyd-js/core": "workspace:*",
|
|
27
|
-
"@xyd-js/components": "workspace:*",
|
|
28
|
-
"@xyd-js/framework": "workspace:*",
|
|
29
|
-
"@xyd-js/composer": "workspace:*",
|
|
30
|
-
"@xyd-js/themes": "workspace:*",
|
|
31
|
-
"@xyd-js/atlas": "workspace:*",
|
|
32
|
-
"@xyd-js/theme-poetry": "workspace:*",
|
|
33
|
-
"@xyd-js/theme-cosmo": "workspace:*",
|
|
34
|
-
"@xyd-js/theme-opener": "workspace:*",
|
|
35
|
-
"@xyd-js/theme-picasso": "workspace:*",
|
|
36
|
-
"@xyd-js/plugin-orama": "workspace:*",
|
|
37
|
-
"@xyd-js/plugin-algolia": "workspace:*",
|
|
38
|
-
"@react-router/dev": "^7.5.0",
|
|
39
|
-
"@react-router/node": "^7.5.0",
|
|
40
|
-
"@react-router/serve": "^7.5.0",
|
|
41
|
-
isbot: "^5",
|
|
42
|
-
"react-router": "^7.5.0"
|
|
43
|
-
},
|
|
44
|
-
devDependencies: {
|
|
45
|
-
autoprefixer: "^10.4.20",
|
|
46
|
-
postcss: "^8.4.47",
|
|
47
|
-
semver: "^7.6.3",
|
|
48
|
-
vite: "^6.1.0",
|
|
49
|
-
"vite-tsconfig-paths": "^5.1.4"
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/const.ts
|
|
54
|
-
var HOST_FOLDER_PATH = ".xyd/host";
|
|
55
|
-
var CACHE_FOLDER_PATH = ".xyd/.cache";
|
|
56
|
-
var BUILD_FOLDER_PATH = ".xyd/build";
|
|
57
|
-
var SUPPORTED_SETTINGS_FILES = [
|
|
58
|
-
"docs.json",
|
|
59
|
-
"docs.ts",
|
|
60
|
-
"docs.tsx"
|
|
61
|
-
];
|
|
62
|
-
var SUPPORTED_WATCH_FILES = [
|
|
63
|
-
".md",
|
|
64
|
-
".mdx",
|
|
65
|
-
...SUPPORTED_SETTINGS_FILES
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
// src/cli.ts
|
|
69
|
-
import readline from "readline";
|
|
70
|
-
import cliSpinners from "cli-spinners";
|
|
71
|
-
var CLI = class {
|
|
72
|
-
spinner;
|
|
73
|
-
spinnerInterval = null;
|
|
74
|
-
currentFrame = 0;
|
|
75
|
-
currentMessage = "";
|
|
76
|
-
isSpinning = false;
|
|
77
|
-
constructor(spinnerType = "dots") {
|
|
78
|
-
this.spinner = cliSpinners[spinnerType];
|
|
79
|
-
}
|
|
80
|
-
startSpinner(message) {
|
|
81
|
-
if (this.isSpinning) {
|
|
82
|
-
this.stopSpinner();
|
|
83
|
-
}
|
|
84
|
-
this.currentMessage = message;
|
|
85
|
-
this.isSpinning = true;
|
|
86
|
-
this.currentFrame = 0;
|
|
87
|
-
this.write(`${this.spinner.frames[0]} ${this.currentMessage}`);
|
|
88
|
-
this.spinnerInterval = setInterval(() => {
|
|
89
|
-
const frame = this.spinner.frames[this.currentFrame];
|
|
90
|
-
this.write(`${frame} ${this.currentMessage}`);
|
|
91
|
-
this.currentFrame = (this.currentFrame + 1) % this.spinner.frames.length;
|
|
92
|
-
}, this.spinner.interval);
|
|
93
|
-
}
|
|
94
|
-
stopSpinner() {
|
|
95
|
-
if (this.spinnerInterval) {
|
|
96
|
-
clearInterval(this.spinnerInterval);
|
|
97
|
-
this.spinnerInterval = null;
|
|
98
|
-
}
|
|
99
|
-
this.isSpinning = false;
|
|
100
|
-
this.clearLine();
|
|
101
|
-
}
|
|
102
|
-
clearLine() {
|
|
103
|
-
readline.clearLine(process.stdout, 0);
|
|
104
|
-
readline.cursorTo(process.stdout, 0);
|
|
105
|
-
}
|
|
106
|
-
write(message) {
|
|
107
|
-
this.clearLine();
|
|
108
|
-
process.stdout.write(message);
|
|
109
|
-
}
|
|
110
|
-
log(message) {
|
|
111
|
-
if (this.isSpinning) {
|
|
112
|
-
this.stopSpinner();
|
|
113
|
-
}
|
|
114
|
-
console.log(message);
|
|
115
|
-
}
|
|
116
|
-
error(message) {
|
|
117
|
-
if (this.isSpinning) {
|
|
118
|
-
this.stopSpinner();
|
|
119
|
-
}
|
|
120
|
-
console.error(message);
|
|
121
|
-
}
|
|
122
|
-
updateMessage(message) {
|
|
123
|
-
this.currentMessage = message;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var cli = new CLI();
|
|
127
|
-
|
|
128
|
-
// src/utils.ts
|
|
129
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
130
|
-
var __dirname = path.dirname(__filename);
|
|
131
|
-
var HOST_VERSION = package_default?.version;
|
|
132
|
-
async function appInit(options) {
|
|
133
|
-
const readPreloadSettings = await readSettings();
|
|
134
|
-
if (!readPreloadSettings) {
|
|
135
|
-
throw new Error("cannot preload settings");
|
|
136
|
-
}
|
|
137
|
-
const preloadSettings = typeof readPreloadSettings === "string" ? JSON.parse(readPreloadSettings) : readPreloadSettings;
|
|
138
|
-
{
|
|
139
|
-
if (!preloadSettings.integrations?.search) {
|
|
140
|
-
preloadSettings.integrations = {
|
|
141
|
-
...preloadSettings.integrations || {},
|
|
142
|
-
search: {
|
|
143
|
-
orama: true
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
const plugins = integrationsToPlugins(preloadSettings.integrations);
|
|
148
|
-
if (preloadSettings.plugins) {
|
|
149
|
-
preloadSettings.plugins = [...plugins, ...preloadSettings.plugins];
|
|
150
|
-
} else {
|
|
151
|
-
preloadSettings.plugins = plugins;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
let resolvedPlugins = [];
|
|
155
|
-
{
|
|
156
|
-
resolvedPlugins = await loadPlugins(preloadSettings) || [];
|
|
157
|
-
const userUniformVitePlugins = [];
|
|
158
|
-
resolvedPlugins?.forEach((p) => {
|
|
159
|
-
if (p.uniform) {
|
|
160
|
-
userUniformVitePlugins.push(...p.uniform);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
globalThis.__xydUserUniformVitePlugins = userUniformVitePlugins;
|
|
164
|
-
}
|
|
165
|
-
const respPluginDocs = await pluginDocs(options);
|
|
166
|
-
if (!respPluginDocs) {
|
|
167
|
-
throw new Error("PluginDocs not found");
|
|
168
|
-
}
|
|
169
|
-
if (!respPluginDocs.settings) {
|
|
170
|
-
throw new Error("Settings not found in respPluginDocs");
|
|
171
|
-
}
|
|
172
|
-
respPluginDocs.settings.plugins = [
|
|
173
|
-
...respPluginDocs.settings?.plugins || [],
|
|
174
|
-
...preloadSettings.plugins || []
|
|
175
|
-
];
|
|
176
|
-
globalThis.__xydBasePath = respPluginDocs.basePath;
|
|
177
|
-
globalThis.__xydSettings = respPluginDocs.settings;
|
|
178
|
-
globalThis.__xydPagePathMapping = respPluginDocs.pagePathMapping;
|
|
179
|
-
return {
|
|
180
|
-
respPluginDocs,
|
|
181
|
-
resolvedPlugins
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function virtualComponentsPlugin() {
|
|
185
|
-
return {
|
|
186
|
-
name: "xyd-plugin-virtual-components",
|
|
187
|
-
enforce: "pre",
|
|
188
|
-
config: () => {
|
|
189
|
-
const componentsDist = path.resolve(getHostPath(), "./node_modules/@xyd-js/components/dist");
|
|
190
|
-
return {
|
|
191
|
-
resolve: {
|
|
192
|
-
alias: {
|
|
193
|
-
// TODO: type-safe virtual-components
|
|
194
|
-
"virtual-component:Search": path.resolve(componentsDist, "system.js")
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
function virtualProvidersPlugin(settings) {
|
|
202
|
-
return {
|
|
203
|
-
name: "xyd-plugin-virtual-providers",
|
|
204
|
-
enforce: "pre",
|
|
205
|
-
resolveId(id) {
|
|
206
|
-
if (id === "virtual:xyd-analytics-providers") {
|
|
207
|
-
return id;
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
async load(id) {
|
|
211
|
-
if (id === "virtual:xyd-analytics-providers") {
|
|
212
|
-
const providers = Object.keys(settings?.integrations?.analytics || {});
|
|
213
|
-
const imports = providers.map(
|
|
214
|
-
(provider) => `import { default as ${provider}Provider } from '@pluganalytics/provider-${provider}'`
|
|
215
|
-
).join("\n");
|
|
216
|
-
const cases = providers.map(
|
|
217
|
-
(provider) => `case '${provider}': return ${provider}Provider`
|
|
218
|
-
).join("\n");
|
|
219
|
-
return `
|
|
220
|
-
${imports}
|
|
221
|
-
|
|
222
|
-
export const loadProvider = async (provider) => {
|
|
223
|
-
switch (provider) {
|
|
224
|
-
${cases}
|
|
225
|
-
default:
|
|
226
|
-
console.error(\`Provider \${provider} not found\`)
|
|
227
|
-
return null
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
`;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function commonVitePlugins(respPluginDocs, resolvedPlugins) {
|
|
236
|
-
const userVitePlugins = resolvedPlugins.map((p) => p.vite).flat() || [];
|
|
237
|
-
return [
|
|
238
|
-
...xydContentVitePlugins({
|
|
239
|
-
toc: {
|
|
240
|
-
maxDepth: respPluginDocs.settings.theme?.maxTocDepth || 2
|
|
241
|
-
},
|
|
242
|
-
settings: respPluginDocs.settings
|
|
243
|
-
}),
|
|
244
|
-
...respPluginDocs.vitePlugins,
|
|
245
|
-
reactRouter(),
|
|
246
|
-
virtualComponentsPlugin(),
|
|
247
|
-
virtualProvidersPlugin(respPluginDocs.settings),
|
|
248
|
-
pluginIconSet(respPluginDocs.settings),
|
|
249
|
-
...userVitePlugins
|
|
250
|
-
];
|
|
251
|
-
}
|
|
252
|
-
function pluginIconSet(settings) {
|
|
253
|
-
const DEFAULT_ICON_SET = "lucide";
|
|
254
|
-
async function fetchIconSet(name, version) {
|
|
255
|
-
if (name.startsWith("http://") || name.startsWith("https://")) {
|
|
256
|
-
try {
|
|
257
|
-
const iconsResp = await fetch(name);
|
|
258
|
-
const iconsData = await iconsResp.json();
|
|
259
|
-
const iconSet = new IconSet(iconsData);
|
|
260
|
-
return { icons: iconsData, iconSet };
|
|
261
|
-
} catch (error) {
|
|
262
|
-
console.warn(`Failed to fetch from URL ${name}:`, error);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const tryReadFile = (filePath) => {
|
|
266
|
-
try {
|
|
267
|
-
if (!fs.existsSync(filePath)) {
|
|
268
|
-
console.warn(`File does not exist: ${filePath}`);
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
272
|
-
try {
|
|
273
|
-
const iconsData = JSON.parse(fileContent);
|
|
274
|
-
const iconSet = new IconSet(iconsData);
|
|
275
|
-
return { icons: iconsData, iconSet };
|
|
276
|
-
} catch (parseError) {
|
|
277
|
-
console.warn(`Invalid JSON in file ${filePath}:`, parseError);
|
|
278
|
-
return null;
|
|
279
|
-
}
|
|
280
|
-
} catch (error) {
|
|
281
|
-
console.warn(`Failed to read file ${filePath}:`, error);
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
if (path.isAbsolute(name)) {
|
|
286
|
-
const result = tryReadFile(name);
|
|
287
|
-
if (result) return result;
|
|
288
|
-
}
|
|
289
|
-
if (name.startsWith(".")) {
|
|
290
|
-
const fullPath = path.join(process.cwd(), name);
|
|
291
|
-
const result = tryReadFile(fullPath);
|
|
292
|
-
if (result) return result;
|
|
293
|
-
}
|
|
294
|
-
const cdnUrl = version ? `https://cdn.jsdelivr.net/npm/@iconify-json/${name}@${version}/icons.json` : `https://cdn.jsdelivr.net/npm/@iconify-json/${name}/icons.json`;
|
|
295
|
-
try {
|
|
296
|
-
const iconsResp = await fetch(cdnUrl);
|
|
297
|
-
const iconsData = await iconsResp.json();
|
|
298
|
-
const iconSet = new IconSet(iconsData);
|
|
299
|
-
return { icons: iconsData, iconSet };
|
|
300
|
-
} catch (error) {
|
|
301
|
-
throw new Error(`Failed to load icon set from any source (file or CDN): ${name}`);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
async function processIconSet(iconSet, icons, noPrefix) {
|
|
305
|
-
const resp = /* @__PURE__ */ new Map();
|
|
306
|
-
for (const icon of Object.keys(icons.icons)) {
|
|
307
|
-
const svg = iconSet.toSVG(icon);
|
|
308
|
-
if (!svg) continue;
|
|
309
|
-
let prefix = noPrefix ? void 0 : iconSet.prefix;
|
|
310
|
-
const iconName = prefix ? `${prefix}:${icon}` : icon;
|
|
311
|
-
resp.set(iconName, { svg: svg.toString() });
|
|
312
|
-
}
|
|
313
|
-
return resp;
|
|
314
|
-
}
|
|
315
|
-
async function addIconsToMap(resp, name, version, noPrefix) {
|
|
316
|
-
const { icons, iconSet } = await fetchIconSet(name, version);
|
|
317
|
-
const newIcons = await processIconSet(iconSet, icons, noPrefix);
|
|
318
|
-
newIcons.forEach((value, key) => resp.set(key, value));
|
|
319
|
-
}
|
|
320
|
-
async function processIconLibrary(library) {
|
|
321
|
-
const resp = /* @__PURE__ */ new Map();
|
|
322
|
-
if (typeof library === "string") {
|
|
323
|
-
await addIconsToMap(resp, library);
|
|
324
|
-
} else if (Array.isArray(library)) {
|
|
325
|
-
for (const item of library) {
|
|
326
|
-
if (typeof item === "string") {
|
|
327
|
-
await addIconsToMap(resp, item);
|
|
328
|
-
} else {
|
|
329
|
-
const { name, version, default: isDefault, noprefix } = item;
|
|
330
|
-
const noPrefix = isDefault || noprefix;
|
|
331
|
-
await addIconsToMap(resp, name, version, noPrefix);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
} else {
|
|
335
|
-
const { name, version, default: isDefault, noprefix } = library;
|
|
336
|
-
const prefix = isDefault || noprefix ? void 0 : name;
|
|
337
|
-
await addIconsToMap(resp, name, version, prefix);
|
|
338
|
-
}
|
|
339
|
-
return resp;
|
|
340
|
-
}
|
|
341
|
-
return {
|
|
342
|
-
name: "xyd-plugin-icon-set",
|
|
343
|
-
enforce: "pre",
|
|
344
|
-
resolveId(id) {
|
|
345
|
-
if (id === "virtual:xyd-icon-set") {
|
|
346
|
-
return id;
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
async load(id) {
|
|
350
|
-
if (id === "virtual:xyd-icon-set") {
|
|
351
|
-
let resp;
|
|
352
|
-
if (settings.theme?.icons?.library) {
|
|
353
|
-
resp = await processIconLibrary(settings.theme.icons.library);
|
|
354
|
-
} else {
|
|
355
|
-
resp = await processIconLibrary([
|
|
356
|
-
{
|
|
357
|
-
name: DEFAULT_ICON_SET,
|
|
358
|
-
default: true
|
|
359
|
-
}
|
|
360
|
-
]);
|
|
361
|
-
}
|
|
362
|
-
return `
|
|
363
|
-
export const iconSet = ${JSON.stringify(Object.fromEntries(resp))};
|
|
364
|
-
`;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
function getHostPath() {
|
|
370
|
-
if (process.env.XYD_DEV_MODE) {
|
|
371
|
-
if (process.env.XYD_HOST) {
|
|
372
|
-
return path.resolve(process.env.XYD_HOST);
|
|
373
|
-
}
|
|
374
|
-
return path.join(__dirname, "../../../", HOST_FOLDER_PATH);
|
|
375
|
-
}
|
|
376
|
-
return path.join(process.cwd(), HOST_FOLDER_PATH);
|
|
377
|
-
}
|
|
378
|
-
function getAppRoot() {
|
|
379
|
-
return getHostPath();
|
|
380
|
-
}
|
|
381
|
-
function getPublicPath() {
|
|
382
|
-
return path.join(process.cwd(), "public");
|
|
383
|
-
}
|
|
384
|
-
function getBuildPath() {
|
|
385
|
-
return path.join(
|
|
386
|
-
process.cwd(),
|
|
387
|
-
BUILD_FOLDER_PATH
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
function getDocsPluginBasePath() {
|
|
391
|
-
return path.join(getHostPath(), "./plugins/xyd-plugin-docs");
|
|
392
|
-
}
|
|
393
|
-
async function loadPlugins(settings) {
|
|
394
|
-
const resolvedPlugins = [];
|
|
395
|
-
for (const plugin of settings.plugins || []) {
|
|
396
|
-
let pluginName;
|
|
397
|
-
let pluginArgs = [];
|
|
398
|
-
if (typeof plugin === "string") {
|
|
399
|
-
pluginName = plugin;
|
|
400
|
-
pluginArgs = [];
|
|
401
|
-
} else if (Array.isArray(plugin)) {
|
|
402
|
-
pluginName = plugin[0];
|
|
403
|
-
pluginArgs = plugin.slice(1);
|
|
404
|
-
} else {
|
|
405
|
-
console.error(`Currently only string and array plugins are supported, got: ${plugin}`);
|
|
406
|
-
return [];
|
|
407
|
-
}
|
|
408
|
-
let mod;
|
|
409
|
-
try {
|
|
410
|
-
mod = await import(pluginName);
|
|
411
|
-
} catch (e) {
|
|
412
|
-
pluginName = path.join(process.cwd(), pluginName);
|
|
413
|
-
const pluginPreview = await createServer({
|
|
414
|
-
optimizeDeps: {
|
|
415
|
-
include: []
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
mod = await pluginPreview.ssrLoadModule(pluginName);
|
|
419
|
-
}
|
|
420
|
-
if (!mod.default) {
|
|
421
|
-
console.error(`Plugin ${plugin} has no default export`);
|
|
422
|
-
continue;
|
|
423
|
-
}
|
|
424
|
-
let pluginInstance = mod.default(...pluginArgs);
|
|
425
|
-
if (typeof pluginInstance === "function") {
|
|
426
|
-
const plug = pluginInstance(settings);
|
|
427
|
-
resolvedPlugins.push(plug);
|
|
428
|
-
continue;
|
|
429
|
-
}
|
|
430
|
-
resolvedPlugins.push(pluginInstance);
|
|
431
|
-
}
|
|
432
|
-
return resolvedPlugins;
|
|
433
|
-
}
|
|
434
|
-
function integrationsToPlugins(integrations) {
|
|
435
|
-
const plugins = [];
|
|
436
|
-
let foundSearchIntegation = 0;
|
|
437
|
-
if (integrations?.search?.orama) {
|
|
438
|
-
if (typeof integrations.search.orama === "boolean") {
|
|
439
|
-
plugins.push("@xyd-js/plugin-orama");
|
|
440
|
-
} else {
|
|
441
|
-
plugins.push(["@xyd-js/plugin-orama", integrations.search.orama]);
|
|
442
|
-
}
|
|
443
|
-
foundSearchIntegation++;
|
|
444
|
-
}
|
|
445
|
-
if (integrations?.search?.algolia) {
|
|
446
|
-
plugins.push(["@xyd-js/plugin-algolia", integrations.search.algolia]);
|
|
447
|
-
foundSearchIntegation++;
|
|
448
|
-
}
|
|
449
|
-
if (foundSearchIntegation > 1) {
|
|
450
|
-
throw new Error("Only one search integration is allowed");
|
|
451
|
-
}
|
|
452
|
-
return plugins;
|
|
453
|
-
}
|
|
454
|
-
async function preWorkspaceSetup(options = {}) {
|
|
455
|
-
await ensureFoldersExist();
|
|
456
|
-
if (!options.force) {
|
|
457
|
-
if (await shouldSkipHostSetup()) {
|
|
458
|
-
return true;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
const hostTemplate = process.env.XYD_DEV_MODE ? path.resolve(__dirname, "../../xyd-host") : path.resolve(__dirname, "../node_modules/@xyd-js/host");
|
|
462
|
-
const hostPath = getHostPath();
|
|
463
|
-
await copyHostTemplate(hostTemplate, hostPath);
|
|
464
|
-
let pluginDocsPath;
|
|
465
|
-
if (process.env.XYD_DEV_MODE) {
|
|
466
|
-
pluginDocsPath = path.resolve(__dirname, "../../xyd-plugin-docs");
|
|
467
|
-
} else {
|
|
468
|
-
pluginDocsPath = path.resolve(__dirname, "../node_modules/@xyd-js/plugin-docs");
|
|
469
|
-
}
|
|
470
|
-
const pagesSourcePath = path.join(pluginDocsPath, "src/pages");
|
|
471
|
-
const pagesTargetPath = path.join(hostPath, "plugins/xyd-plugin-docs/src/pages");
|
|
472
|
-
if (fs.existsSync(pagesSourcePath)) {
|
|
473
|
-
await copyHostTemplate(pagesSourcePath, pagesTargetPath);
|
|
474
|
-
} else {
|
|
475
|
-
console.warn(`Pages source path does not exist: ${pagesSourcePath}`);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
function calculateFolderChecksum(folderPath) {
|
|
479
|
-
const hash = crypto.createHash("sha256");
|
|
480
|
-
const ignorePatterns = [...getGitignorePatterns(folderPath), ".xydchecksum"];
|
|
481
|
-
function processFile(filePath) {
|
|
482
|
-
const relativePath = path.relative(folderPath, filePath);
|
|
483
|
-
const content = fs.readFileSync(filePath);
|
|
484
|
-
hash.update(relativePath);
|
|
485
|
-
hash.update(content);
|
|
486
|
-
}
|
|
487
|
-
function processDirectory(dirPath) {
|
|
488
|
-
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
489
|
-
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
490
|
-
for (const entry of entries) {
|
|
491
|
-
const sourceEntry = path.join(dirPath, entry.name);
|
|
492
|
-
if (shouldIgnoreEntry(entry.name, ignorePatterns)) {
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
if (entry.name === ".git") {
|
|
496
|
-
continue;
|
|
497
|
-
}
|
|
498
|
-
if (entry.isDirectory()) {
|
|
499
|
-
processDirectory(sourceEntry);
|
|
500
|
-
} else {
|
|
501
|
-
processFile(sourceEntry);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
processDirectory(folderPath);
|
|
506
|
-
return hash.digest("hex");
|
|
507
|
-
}
|
|
508
|
-
function getGitignorePatterns(folderPath) {
|
|
509
|
-
const gitignorePath = path.join(folderPath, ".gitignore");
|
|
510
|
-
if (fs.existsSync(gitignorePath)) {
|
|
511
|
-
const gitignoreContent = fs.readFileSync(gitignorePath, "utf-8");
|
|
512
|
-
return gitignoreContent.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
513
|
-
}
|
|
514
|
-
return [];
|
|
515
|
-
}
|
|
516
|
-
function shouldIgnoreEntry(entryName, ignorePatterns) {
|
|
517
|
-
return ignorePatterns.some((pattern) => {
|
|
518
|
-
const regex = new RegExp(pattern.replace(/\*/g, ".*"));
|
|
519
|
-
return regex.test(entryName);
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
async function copyHostTemplate(sourcePath, targetPath) {
|
|
523
|
-
if (!fs.existsSync(sourcePath)) {
|
|
524
|
-
throw new Error(`Host template source path does not exist: ${sourcePath}`);
|
|
525
|
-
}
|
|
526
|
-
if (fs.existsSync(targetPath)) {
|
|
527
|
-
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
528
|
-
}
|
|
529
|
-
fs.mkdirSync(targetPath, { recursive: true });
|
|
530
|
-
const ignorePatterns = getGitignorePatterns(sourcePath);
|
|
531
|
-
const entries = fs.readdirSync(sourcePath, { withFileTypes: true });
|
|
532
|
-
for (const entry of entries) {
|
|
533
|
-
const sourceEntry = path.join(sourcePath, entry.name);
|
|
534
|
-
const targetEntry = path.join(targetPath, entry.name);
|
|
535
|
-
if (shouldIgnoreEntry(entry.name, ignorePatterns)) {
|
|
536
|
-
continue;
|
|
537
|
-
}
|
|
538
|
-
if (entry.name === ".git") {
|
|
539
|
-
continue;
|
|
540
|
-
}
|
|
541
|
-
if (entry.isDirectory()) {
|
|
542
|
-
await copyHostTemplate(sourceEntry, targetEntry);
|
|
543
|
-
} else {
|
|
544
|
-
fs.copyFileSync(sourceEntry, targetEntry);
|
|
545
|
-
if (entry.name === "package.json" && process.env.XYD_DEV_MODE) {
|
|
546
|
-
const packageJsonPath = targetEntry;
|
|
547
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
548
|
-
packageJson.name = "xyd-host-dev";
|
|
549
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
async function ensureFoldersExist() {
|
|
555
|
-
const folders = [CACHE_FOLDER_PATH];
|
|
556
|
-
for (const folder of folders) {
|
|
557
|
-
const fullPath = path.resolve(process.cwd(), folder);
|
|
558
|
-
if (!fs.existsSync(fullPath)) {
|
|
559
|
-
fs.mkdirSync(fullPath, { recursive: true });
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
async function postWorkspaceSetup(settings) {
|
|
564
|
-
const spinner = new CLI("dots");
|
|
565
|
-
try {
|
|
566
|
-
spinner.startSpinner("Installing xyd framework...");
|
|
567
|
-
const hostPath = getHostPath();
|
|
568
|
-
const packageJsonPath = path.join(hostPath, "package.json");
|
|
569
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
570
|
-
console.warn("No package.json found in host path");
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
574
|
-
if (!packageJson.dependencies) {
|
|
575
|
-
packageJson.dependencies = {};
|
|
576
|
-
}
|
|
577
|
-
for (const plugin of settings.plugins || []) {
|
|
578
|
-
let pluginName;
|
|
579
|
-
if (typeof plugin === "string") {
|
|
580
|
-
pluginName = plugin;
|
|
581
|
-
} else if (Array.isArray(plugin)) {
|
|
582
|
-
pluginName = plugin[0];
|
|
583
|
-
} else {
|
|
584
|
-
continue;
|
|
585
|
-
}
|
|
586
|
-
if (pluginName.startsWith("@xyd-js/")) {
|
|
587
|
-
continue;
|
|
588
|
-
}
|
|
589
|
-
const isValidNpmPackage = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(pluginName);
|
|
590
|
-
if (isValidNpmPackage) {
|
|
591
|
-
const hostPackageJsonPath = path.join(hostPath, "package.json");
|
|
592
|
-
if (fs.existsSync(hostPackageJsonPath)) {
|
|
593
|
-
const hostPackageJson = JSON.parse(fs.readFileSync(hostPackageJsonPath, "utf-8"));
|
|
594
|
-
const deps = hostPackageJson.dependencies || {};
|
|
595
|
-
const matchingDep = Object.entries(deps).find(([depName]) => {
|
|
596
|
-
return depName === pluginName;
|
|
597
|
-
});
|
|
598
|
-
if (matchingDep) {
|
|
599
|
-
packageJson.dependencies[pluginName] = matchingDep[1];
|
|
600
|
-
} else {
|
|
601
|
-
console.warn(`no matching dependency found for: ${pluginName} in: ${hostPackageJsonPath}`);
|
|
602
|
-
}
|
|
603
|
-
} else {
|
|
604
|
-
console.warn(`no host package.json found in: ${hostPath}`);
|
|
605
|
-
}
|
|
606
|
-
} else if (!pluginName.startsWith(".") && !pluginName.startsWith("/")) {
|
|
607
|
-
console.warn(`invalid plugin name: ${pluginName}`);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
611
|
-
await nodeInstallPackages(hostPath);
|
|
612
|
-
spinner.stopSpinner();
|
|
613
|
-
spinner.log("\u2714 Local xyd framework installed successfully");
|
|
614
|
-
} catch (error) {
|
|
615
|
-
spinner.stopSpinner();
|
|
616
|
-
spinner.error("\u274C Failed to install xyd framework");
|
|
617
|
-
throw error;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
function nodeInstallPackages(hostPath) {
|
|
621
|
-
const cmd = process.env.XYD_DEV_MODE ? "pnpm i" : "npm i";
|
|
622
|
-
const execOptions = {
|
|
623
|
-
cwd: hostPath,
|
|
624
|
-
env: {
|
|
625
|
-
...process.env,
|
|
626
|
-
NODE_ENV: ""
|
|
627
|
-
// since 'production' does not install it well
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
if (process.env.XYD_VERBOSE) {
|
|
631
|
-
execOptions.stdio = "inherit";
|
|
632
|
-
}
|
|
633
|
-
execSync(cmd, execOptions);
|
|
634
|
-
}
|
|
635
|
-
async function shouldSkipHostSetup() {
|
|
636
|
-
const hostPath = getHostPath();
|
|
637
|
-
if (!fs.existsSync(hostPath)) {
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
const currentChecksum = calculateFolderChecksum(hostPath);
|
|
641
|
-
const storedChecksum = getStoredChecksum();
|
|
642
|
-
if (!storedChecksum || storedChecksum !== currentChecksum) {
|
|
643
|
-
return false;
|
|
644
|
-
}
|
|
645
|
-
return true;
|
|
646
|
-
}
|
|
647
|
-
function getStoredChecksum() {
|
|
648
|
-
const checksumPath = path.join(getHostPath(), ".xydchecksum");
|
|
649
|
-
if (!fs.existsSync(checksumPath)) {
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
try {
|
|
653
|
-
return fs.readFileSync(checksumPath, "utf-8").trim();
|
|
654
|
-
} catch (error) {
|
|
655
|
-
console.error("Error reading checksum file:", error);
|
|
656
|
-
return null;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
function storeChecksum(checksum) {
|
|
660
|
-
const checksumPath = path.join(getHostPath(), ".xydchecksum");
|
|
661
|
-
try {
|
|
662
|
-
fs.writeFileSync(checksumPath, checksum);
|
|
663
|
-
} catch (error) {
|
|
664
|
-
console.error("Error writing checksum file:", error);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// src/build.ts
|
|
669
|
-
async function build() {
|
|
670
|
-
const skip = await preWorkspaceSetup({
|
|
671
|
-
force: true
|
|
672
|
-
});
|
|
673
|
-
const { respPluginDocs, resolvedPlugins } = await appInit();
|
|
674
|
-
const commonRunVitePlugins = commonVitePlugins(respPluginDocs, resolvedPlugins);
|
|
675
|
-
const appRoot = getAppRoot();
|
|
676
|
-
if (!skip) {
|
|
677
|
-
await postWorkspaceSetup(respPluginDocs.settings);
|
|
678
|
-
const newChecksum = calculateFolderChecksum(getHostPath());
|
|
679
|
-
storeChecksum(newChecksum);
|
|
680
|
-
}
|
|
681
|
-
{
|
|
682
|
-
setupInstallableEnvironmentV2();
|
|
683
|
-
}
|
|
684
|
-
try {
|
|
685
|
-
await viteBuild({
|
|
686
|
-
mode: "production",
|
|
687
|
-
root: appRoot,
|
|
688
|
-
plugins: [
|
|
689
|
-
...commonRunVitePlugins,
|
|
690
|
-
tsconfigPaths()
|
|
691
|
-
],
|
|
692
|
-
optimizeDeps: {
|
|
693
|
-
include: ["react/jsx-runtime"]
|
|
694
|
-
},
|
|
695
|
-
define: {
|
|
696
|
-
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
697
|
-
"process.env": {}
|
|
698
|
-
},
|
|
699
|
-
resolve: {
|
|
700
|
-
alias: {
|
|
701
|
-
process: "process/browser"
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
});
|
|
705
|
-
await viteBuild({
|
|
706
|
-
mode: "production",
|
|
707
|
-
root: appRoot,
|
|
708
|
-
build: {
|
|
709
|
-
ssr: true
|
|
710
|
-
},
|
|
711
|
-
plugins: [
|
|
712
|
-
fixManifestPlugin(appRoot),
|
|
713
|
-
...commonRunVitePlugins
|
|
714
|
-
],
|
|
715
|
-
optimizeDeps: {
|
|
716
|
-
include: ["react/jsx-runtime"]
|
|
717
|
-
},
|
|
718
|
-
define: {
|
|
719
|
-
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
720
|
-
"process.env": {}
|
|
721
|
-
},
|
|
722
|
-
resolve: {
|
|
723
|
-
alias: {
|
|
724
|
-
process: "process/browser"
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
} catch (error) {
|
|
729
|
-
console.error("Build failed:", error);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
function setupInstallableEnvironmentV2() {
|
|
733
|
-
const buildDir = getBuildPath();
|
|
734
|
-
const packageJsonPath = path2.join(buildDir, "package.json");
|
|
735
|
-
const packageJsonContent = {
|
|
736
|
-
type: "module",
|
|
737
|
-
scripts: {},
|
|
738
|
-
dependencies: {
|
|
739
|
-
// "@react-router/node": "^7.5.0",
|
|
740
|
-
// "isbot": "^5"
|
|
741
|
-
},
|
|
742
|
-
devDependencies: {}
|
|
743
|
-
};
|
|
744
|
-
if (!fs2.existsSync(buildDir)) {
|
|
745
|
-
fs2.mkdirSync(buildDir, { recursive: true });
|
|
746
|
-
}
|
|
747
|
-
fs2.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), "utf8");
|
|
748
|
-
}
|
|
749
|
-
function fixManifestPlugin(appRoot) {
|
|
750
|
-
const manifestPath = path2.join(
|
|
751
|
-
getBuildPath(),
|
|
752
|
-
"./server/.vite/manifest.json"
|
|
753
|
-
);
|
|
754
|
-
return {
|
|
755
|
-
name: "xyd-fix-rr-manifest",
|
|
756
|
-
apply: "build",
|
|
757
|
-
// run after manifest is generated
|
|
758
|
-
// 2) after bundle is written, compute prefix and strip it
|
|
759
|
-
writeBundle(_, bundle) {
|
|
760
|
-
const cwdDir = process.cwd();
|
|
761
|
-
let prefix = path2.relative(appRoot, cwdDir).replace(/\\/g, "/");
|
|
762
|
-
if (prefix) prefix += "/";
|
|
763
|
-
const esc = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
764
|
-
const stripRe = new RegExp(`^${esc}`);
|
|
765
|
-
for (const fileName in bundle) {
|
|
766
|
-
const asset = bundle[fileName];
|
|
767
|
-
if (asset.type !== "asset") continue;
|
|
768
|
-
if (fileName.endsWith("manifest.json")) {
|
|
769
|
-
const manifest = JSON.parse(asset.source.toString());
|
|
770
|
-
const fixed = {};
|
|
771
|
-
for (const key of Object.keys(manifest)) {
|
|
772
|
-
const entry = manifest[key];
|
|
773
|
-
const newKey = key.replace(stripRe, "");
|
|
774
|
-
if (typeof entry.src === "string") {
|
|
775
|
-
entry.src = entry.src.replace(stripRe, "");
|
|
776
|
-
}
|
|
777
|
-
fixed[newKey] = entry;
|
|
778
|
-
}
|
|
779
|
-
asset.source = JSON.stringify(fixed, null, 2);
|
|
780
|
-
fs2.writeFileSync(manifestPath, asset.source, "utf8");
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
// src/dev.ts
|
|
788
|
-
import path3 from "path";
|
|
789
|
-
import fs3 from "fs";
|
|
790
|
-
import { createServer as createServer2, searchForWorkspaceRoot } from "vite";
|
|
791
|
-
if (!process.env.ENABLE_TIMERS) {
|
|
792
|
-
["time", "timeLog", "timeEnd"].forEach((method) => {
|
|
793
|
-
console[method] = () => {
|
|
794
|
-
};
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
async function dev(options) {
|
|
798
|
-
const spinner = new CLI("dots");
|
|
799
|
-
spinner.startSpinner("Preparing local xyd instance... \n");
|
|
800
|
-
const skip = await preWorkspaceSetup();
|
|
801
|
-
const { respPluginDocs, resolvedPlugins } = await appInit();
|
|
802
|
-
const allowCwd = searchForWorkspaceRoot(process.cwd());
|
|
803
|
-
const appRoot = getAppRoot();
|
|
804
|
-
const commonRunVitePlugins = commonVitePlugins(respPluginDocs, resolvedPlugins);
|
|
805
|
-
spinner.stopSpinner();
|
|
806
|
-
if (!skip) {
|
|
807
|
-
await postWorkspaceSetup(respPluginDocs.settings);
|
|
808
|
-
const newChecksum = calculateFolderChecksum(getHostPath());
|
|
809
|
-
storeChecksum(newChecksum);
|
|
810
|
-
}
|
|
811
|
-
spinner.log("\u2714 Local xyd instance is ready");
|
|
812
|
-
let server = null;
|
|
813
|
-
const port = options?.port ?? parseInt(process.env.XYD_PORT ?? "5175");
|
|
814
|
-
const preview = await createServer2({
|
|
815
|
-
root: appRoot,
|
|
816
|
-
publicDir: "/public",
|
|
817
|
-
server: {
|
|
818
|
-
allowedHosts: [],
|
|
819
|
-
port,
|
|
820
|
-
fs: {
|
|
821
|
-
allow: [
|
|
822
|
-
allowCwd,
|
|
823
|
-
appRoot
|
|
824
|
-
]
|
|
825
|
-
}
|
|
826
|
-
},
|
|
827
|
-
define: {
|
|
828
|
-
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
|
829
|
-
"process.env": {}
|
|
830
|
-
},
|
|
831
|
-
resolve: {
|
|
832
|
-
alias: {
|
|
833
|
-
process: "process/browser"
|
|
834
|
-
}
|
|
835
|
-
},
|
|
836
|
-
build: {
|
|
837
|
-
rollupOptions: {
|
|
838
|
-
external: []
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
ssr: {
|
|
842
|
-
external: []
|
|
843
|
-
},
|
|
844
|
-
optimizeDeps: {
|
|
845
|
-
include: ["react/jsx-runtime"]
|
|
846
|
-
},
|
|
847
|
-
plugins: [
|
|
848
|
-
...commonRunVitePlugins,
|
|
849
|
-
{
|
|
850
|
-
name: "xyd-configureServer",
|
|
851
|
-
configureServer(s) {
|
|
852
|
-
server = s;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
]
|
|
856
|
-
});
|
|
857
|
-
const watcher = fs3.watch(allowCwd, { recursive: true }, async (eventType, filename) => {
|
|
858
|
-
if (!filename) {
|
|
859
|
-
console.log("[xyd:dev] Received empty filename");
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
const filePath = path3.join(allowCwd, filename);
|
|
863
|
-
if (filePath.includes(CACHE_FOLDER_PATH)) {
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
let apiPaths = {};
|
|
867
|
-
if (respPluginDocs?.settings?.api) {
|
|
868
|
-
apiPaths = resolveApiFilePaths(process.cwd(), respPluginDocs.settings.api);
|
|
869
|
-
}
|
|
870
|
-
const apiChanged = !!apiPaths[filePath];
|
|
871
|
-
if (filePath.includes(getPublicPath())) {
|
|
872
|
-
const relativePath = path3.relative(allowCwd, filePath);
|
|
873
|
-
const urlPath = "/" + relativePath.replace(/\\/g, "/");
|
|
874
|
-
preview.ws.send({
|
|
875
|
-
type: "full-reload",
|
|
876
|
-
path: urlPath
|
|
877
|
-
});
|
|
878
|
-
return;
|
|
879
|
-
}
|
|
880
|
-
if (SUPPORTED_WATCH_FILES.some((ext) => filePath.endsWith(ext)) || apiChanged) {
|
|
881
|
-
const relativePath = path3.relative(allowCwd, filePath);
|
|
882
|
-
const urlPath = "/" + relativePath.replace(/\\/g, "/");
|
|
883
|
-
if (respPluginDocs?.settings.engine?.uniform?.store) {
|
|
884
|
-
await appInit({
|
|
885
|
-
disableFSWrite: true
|
|
886
|
-
});
|
|
887
|
-
} else {
|
|
888
|
-
await appInit();
|
|
889
|
-
}
|
|
890
|
-
if (server) {
|
|
891
|
-
const docsPluginBasePath = getDocsPluginBasePath();
|
|
892
|
-
const layoutPath = path3.join(docsPluginBasePath, "./src/pages/layout.tsx");
|
|
893
|
-
const layoutModule = server.moduleGraph.getModuleById(layoutPath);
|
|
894
|
-
const pagePath = path3.join(docsPluginBasePath, "./src/pages/page.tsx");
|
|
895
|
-
const pageModule = server.moduleGraph.getModuleById(pagePath);
|
|
896
|
-
if (layoutModule && pageModule) {
|
|
897
|
-
server.moduleGraph.invalidateModule(layoutModule);
|
|
898
|
-
server.moduleGraph.invalidateModule(pageModule);
|
|
899
|
-
try {
|
|
900
|
-
const hostPath = getHostPath();
|
|
901
|
-
const hostReactRouterConfig = path3.join(hostPath, "react-router.config.ts");
|
|
902
|
-
await fs3.promises.utimes(hostReactRouterConfig, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
903
|
-
} catch (e) {
|
|
904
|
-
console.error("config update error");
|
|
905
|
-
console.error(e);
|
|
906
|
-
}
|
|
907
|
-
server.ws.send({ type: "full-reload" });
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
preview.ws.send({
|
|
912
|
-
type: "full-reload",
|
|
913
|
-
path: urlPath
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
watcher.on("error", (error) => {
|
|
918
|
-
console.error("[xyd:dev] File watcher error:", error);
|
|
919
|
-
});
|
|
920
|
-
await preview.listen(port);
|
|
921
|
-
preview.printUrls();
|
|
922
|
-
preview.bindCLIShortcuts({ print: true });
|
|
923
|
-
preview.httpServer?.once("close", () => {
|
|
924
|
-
watcher.close();
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
function resolveApiFilePaths(basePath, api) {
|
|
928
|
-
const result = {};
|
|
929
|
-
const apis = [api.openapi, api.graphql, api.sources].filter((s) => s !== void 0);
|
|
930
|
-
apis.forEach((section) => {
|
|
931
|
-
flattenApiFile(section).forEach((p) => {
|
|
932
|
-
const apiAbsPath = path3.resolve(basePath, p);
|
|
933
|
-
result[apiAbsPath] = true;
|
|
934
|
-
});
|
|
935
|
-
});
|
|
936
|
-
return result;
|
|
937
|
-
}
|
|
938
|
-
function flattenApiFile(file) {
|
|
939
|
-
if (!file) return [];
|
|
940
|
-
if (typeof file === "string") {
|
|
941
|
-
return [file];
|
|
942
|
-
}
|
|
943
|
-
if (Array.isArray(file)) {
|
|
944
|
-
return file.flatMap(flattenApiFile);
|
|
945
|
-
}
|
|
946
|
-
if (typeof file === "object") {
|
|
947
|
-
const obj = file;
|
|
948
|
-
if (typeof obj.source === "string") {
|
|
949
|
-
return [obj.source];
|
|
950
|
-
}
|
|
951
|
-
return Object.values(obj).flatMap(flattenApiFile);
|
|
952
|
-
}
|
|
953
|
-
return [];
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
// src/install.ts
|
|
957
|
-
import fs4 from "fs";
|
|
958
|
-
import { readSettings as readSettings2 } from "@xyd-js/plugin-docs";
|
|
959
|
-
async function install() {
|
|
960
|
-
const settings = await readSettings2();
|
|
961
|
-
if (!settings) {
|
|
962
|
-
throw new Error("cannot preload settings");
|
|
963
|
-
}
|
|
964
|
-
if (typeof settings === "string") {
|
|
965
|
-
throw new Error("install does not support string settings");
|
|
966
|
-
}
|
|
967
|
-
const hostPath = getHostPath();
|
|
968
|
-
if (fs4.existsSync(hostPath)) {
|
|
969
|
-
fs4.rmSync(hostPath, { recursive: true, force: true });
|
|
970
|
-
}
|
|
971
|
-
await preWorkspaceSetup({
|
|
972
|
-
force: true
|
|
973
|
-
});
|
|
974
|
-
await postWorkspaceSetup(settings);
|
|
975
|
-
}
|
|
976
|
-
export {
|
|
977
|
-
build,
|
|
978
|
-
dev,
|
|
979
|
-
install
|
|
980
|
-
};
|
|
981
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/build.ts","../src/utils.ts","../../xyd-host/package.json","../src/const.ts","../src/cli.ts","../src/dev.ts","../src/install.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\n\nimport { build as viteBuild, Plugin as VitePlugin } from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport { appInit, calculateFolderChecksum, commonVitePlugins, getAppRoot, getBuildPath, getHostPath, postWorkspaceSetup, preWorkspaceSetup, storeChecksum } from \"./utils\";\n\n// Define the main function to run the builds\nexport async function build() {\n const skip = await preWorkspaceSetup({\n force: true\n })\n\n const { respPluginDocs, resolvedPlugins } = await appInit()\n const commonRunVitePlugins = commonVitePlugins(respPluginDocs, resolvedPlugins)\n const appRoot = getAppRoot();\n\n if (!skip) {\n await postWorkspaceSetup(respPluginDocs.settings)\n\n const newChecksum = calculateFolderChecksum(getHostPath());\n storeChecksum(newChecksum);\n }\n\n {\n setupInstallableEnvironmentV2() // TODO: fix in the future\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n mode: \"production\",\n root: appRoot,\n plugins: [\n ...commonRunVitePlugins,\n\n tsconfigPaths(),\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n define: {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n 'process.env': {}\n },\n resolve: {\n alias: {\n process: 'process/browser'\n }\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n mode: \"production\",\n root: appRoot,\n build: {\n ssr: true\n },\n plugins: [\n fixManifestPlugin(appRoot),\n ...commonRunVitePlugins,\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n define: {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n 'process.env': {}\n },\n resolve: {\n alias: {\n process: 'process/browser'\n }\n },\n });\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\nfunction setupInstallableEnvironmentV2() {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const buildDir = getBuildPath()\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {\n // \"@react-router/node\": \"^7.5.0\",\n // \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, { recursive: true });\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n}\n\n// TODO: not so good solution\n// fixManifestPlugin is needed for fixing server manifest for react-router cuz we use different `root` and output\nfunction fixManifestPlugin(\n appRoot: string\n): VitePlugin {\n const manifestPath = path.join(\n getBuildPath(),\n \"./server/.vite/manifest.json\"\n );\n\n return {\n name: \"xyd-fix-rr-manifest\",\n apply: 'build', // run after manifest is generated\n // 2) after bundle is written, compute prefix and strip it\n writeBundle(_, bundle) {\n const cwdDir = process.cwd();\n let prefix = path.relative(appRoot, cwdDir).replace(/\\\\/g, \"/\");\n if (prefix) prefix += \"/\";\n\n // escape for RegExp\n const esc = prefix.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const stripRe = new RegExp(`^${esc}`);\n\n for (const fileName in bundle) {\n const asset = bundle[fileName];\n\n if (asset.type !== \"asset\") continue;\n\n // A) fix manifest.json (client or SSR) keys + entry.src\n if (fileName.endsWith(\"manifest.json\")) {\n const manifest = JSON.parse(asset.source.toString());\n const fixed: Record<string, any> = {};\n\n for (const key of Object.keys(manifest)) {\n const entry = manifest[key];\n const newKey = key.replace(stripRe, \"\");\n if (typeof entry.src === \"string\") {\n entry.src = entry.src.replace(stripRe, \"\");\n }\n fixed[newKey] = entry;\n }\n\n asset.source = JSON.stringify(fixed, null, 2);\n fs.writeFileSync(manifestPath, asset.source, 'utf8');\n\n }\n\n // B) fix any CSS asset metadata (originalFileNames)\n // TODO: FINISH if it will be needed\n // if (fileName.endsWith(\".css\") && Array.isArray(asset.originalFileNames)) {\n // asset.originalFileNames = asset.originalFileNames.map((orig) =>\n // orig.replace(stripRe, \"\")\n // );\n // }\n }\n\n },\n }\n}","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { execSync, ExecSyncOptions } from \"node:child_process\";\nimport crypto from \"node:crypto\";\n\nimport { createServer, PluginOption as VitePluginOption, Plugin as VitePlugin } from \"vite\";\nimport { reactRouter } from \"@react-router/dev/vite\";\nimport { IconSet } from '@iconify/tools';\n\nimport { readSettings, pluginDocs, type PluginDocsOptions, PluginOutput } from \"@xyd-js/plugin-docs\";\nimport { vitePlugins as xydContentVitePlugins } from \"@xyd-js/content/vite\";\nimport { Integrations, Plugins, Settings } from \"@xyd-js/core\";\nimport type { IconLibrary } from \"@xyd-js/core\";\nimport type { Plugin, PluginConfig } from \"@xyd-js/plugins\";\nimport { type UniformPlugin } from \"@xyd-js/uniform\";\n\nimport hostPackageJson from \"../../xyd-host/package.json\"\n\nimport { BUILD_FOLDER_PATH, CACHE_FOLDER_PATH, HOST_FOLDER_PATH } from \"./const\";\nimport { CLI } from './cli';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst HOST_VERSION = hostPackageJson?.version\n\nexport async function appInit(options?: PluginDocsOptions) {\n const readPreloadSettings = await readSettings() // TODO: in the future better solution - currently we load settings twice (pluginDocs and here)\n if (!readPreloadSettings) {\n throw new Error(\"cannot preload settings\")\n }\n\n const preloadSettings = typeof readPreloadSettings === \"string\" ? JSON.parse(readPreloadSettings) : readPreloadSettings\n\n {\n if (!preloadSettings.integrations?.search) {\n preloadSettings.integrations = {\n ...(preloadSettings.integrations || {}),\n search: {\n orama: true\n }\n }\n }\n\n const plugins = integrationsToPlugins(preloadSettings.integrations)\n if (preloadSettings.plugins) {\n preloadSettings.plugins = [...plugins, ...preloadSettings.plugins]\n } else {\n preloadSettings.plugins = plugins\n }\n }\n\n let resolvedPlugins: PluginConfig[] = []\n {\n resolvedPlugins = await loadPlugins(preloadSettings) || []\n const userUniformVitePlugins: UniformPlugin<any>[] = []\n\n resolvedPlugins?.forEach(p => {\n if (p.uniform) {\n userUniformVitePlugins.push(...p.uniform)\n }\n })\n globalThis.__xydUserUniformVitePlugins = userUniformVitePlugins\n }\n\n const respPluginDocs = await pluginDocs(options)\n if (!respPluginDocs) {\n throw new Error(\"PluginDocs not found\")\n }\n if (!respPluginDocs.settings) {\n throw new Error(\"Settings not found in respPluginDocs\")\n }\n respPluginDocs.settings.plugins = [\n ...(respPluginDocs.settings?.plugins || []),\n ...(preloadSettings.plugins || [])\n ]\n\n globalThis.__xydBasePath = respPluginDocs.basePath\n globalThis.__xydSettings = respPluginDocs.settings\n globalThis.__xydPagePathMapping = respPluginDocs.pagePathMapping\n\n return {\n respPluginDocs,\n resolvedPlugins\n }\n}\n\nexport function virtualComponentsPlugin(): VitePluginOption {\n return {\n name: 'xyd-plugin-virtual-components',\n enforce: 'pre',\n config: () => {\n const componentsDist = path.resolve(getHostPath(), \"./node_modules/@xyd-js/components/dist\")\n\n return {\n resolve: {\n alias: {\n // TODO: type-safe virtual-components\n 'virtual-component:Search': path.resolve(componentsDist, \"system.js\")\n }\n }\n }\n },\n }\n}\n\nexport function virtualProvidersPlugin(\n settings: Settings\n): VitePluginOption {\n return {\n name: 'xyd-plugin-virtual-providers',\n enforce: 'pre',\n resolveId(id) {\n if (id === 'virtual:xyd-analytics-providers') {\n return id\n }\n },\n async load(id) {\n if (id === 'virtual:xyd-analytics-providers') {\n const providers = Object.keys(settings?.integrations?.analytics || {})\n const imports = providers.map(provider =>\n `import { default as ${provider}Provider } from '@pluganalytics/provider-${provider}'`\n ).join('\\n')\n\n const cases = providers.map(provider =>\n `case '${provider}': return ${provider}Provider`\n ).join('\\n')\n\n return `\n ${imports}\n\n export const loadProvider = async (provider) => {\n switch (provider) {\n ${cases}\n default:\n console.error(\\`Provider \\${provider} not found\\`)\n return null\n }\n }\n `\n }\n }\n }\n}\n\nexport function commonVitePlugins(\n respPluginDocs: PluginOutput,\n resolvedPlugins: PluginConfig[],\n) {\n const userVitePlugins = resolvedPlugins.map(p => p.vite).flat() || []\n\n return [\n ...(xydContentVitePlugins({\n toc: {\n maxDepth: respPluginDocs.settings.theme?.maxTocDepth || 2,\n },\n settings: respPluginDocs.settings,\n }) as VitePlugin[]),\n ...respPluginDocs.vitePlugins,\n\n reactRouter(),\n\n virtualComponentsPlugin(),\n virtualProvidersPlugin(respPluginDocs.settings),\n pluginIconSet(respPluginDocs.settings),\n\n ...userVitePlugins,\n ]\n}\n\nexport function pluginIconSet(settings: Settings): VitePluginOption {\n const DEFAULT_ICON_SET = \"lucide\";\n\n async function fetchIconSet(name: string, version?: string): Promise<{ icons: any, iconSet: IconSet }> {\n // If it's a URL, use it directly\n if (name.startsWith('http://') || name.startsWith('https://')) {\n try {\n const iconsResp = await fetch(name);\n const iconsData = await iconsResp.json();\n const iconSet = new IconSet(iconsData);\n return { icons: iconsData, iconSet };\n } catch (error) {\n console.warn(`Failed to fetch from URL ${name}:`, error);\n }\n }\n\n // Try to read from file system\n const tryReadFile = (filePath: string) => {\n try {\n if (!fs.existsSync(filePath)) {\n console.warn(`File does not exist: ${filePath}`);\n return null;\n }\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n try {\n const iconsData = JSON.parse(fileContent);\n const iconSet = new IconSet(iconsData);\n return { icons: iconsData, iconSet };\n } catch (parseError) {\n console.warn(`Invalid JSON in file ${filePath}:`, parseError);\n return null;\n }\n } catch (error) {\n console.warn(`Failed to read file ${filePath}:`, error);\n return null;\n }\n };\n\n\n if (path.isAbsolute(name)) {\n const result = tryReadFile(name);\n if (result) return result;\n }\n\n if (name.startsWith(\".\")) {\n const fullPath = path.join(process.cwd(), name);\n const result = tryReadFile(fullPath);\n if (result) return result;\n }\n\n // Fallback to CDN\n const cdnUrl = version\n ? `https://cdn.jsdelivr.net/npm/@iconify-json/${name}@${version}/icons.json`\n : `https://cdn.jsdelivr.net/npm/@iconify-json/${name}/icons.json`;\n\n try {\n const iconsResp = await fetch(cdnUrl);\n const iconsData = await iconsResp.json();\n const iconSet = new IconSet(iconsData);\n return { icons: iconsData, iconSet };\n } catch (error) {\n throw new Error(`Failed to load icon set from any source (file or CDN): ${name}`);\n }\n }\n\n async function processIconSet(iconSet: IconSet, icons: any, noPrefix?: boolean): Promise<Map<string, { svg: string }>> {\n const resp = new Map<string, { svg: string }>();\n\n for (const icon of Object.keys(icons.icons)) {\n const svg = iconSet.toSVG(icon);\n if (!svg) continue;\n\n let prefix = noPrefix ? undefined : iconSet.prefix;\n // If prefix is undefined, it means this is the default set and should not have a prefix\n const iconName = prefix ? `${prefix}:${icon}` : icon;\n resp.set(iconName, { svg: svg.toString() });\n }\n\n return resp;\n }\n\n async function addIconsToMap(resp: Map<string, { svg: string }>, name: string, version?: string, noPrefix?: boolean): Promise<void> {\n const { icons, iconSet } = await fetchIconSet(name, version);\n const newIcons = await processIconSet(iconSet, icons, noPrefix);\n newIcons.forEach((value, key) => resp.set(key, value));\n }\n\n async function processIconLibrary(library: string | IconLibrary | (string | IconLibrary)[]): Promise<Map<string, { svg: string }>> {\n const resp = new Map<string, { svg: string }>();\n\n if (typeof library === 'string') {\n // Single icon set as default\n await addIconsToMap(resp, library);\n } else if (Array.isArray(library)) {\n // Multiple icon sets\n for (const item of library) {\n if (typeof item === 'string') {\n // String items are treated as default set\n await addIconsToMap(resp, item);\n } else {\n // IconLibrary configuration\n const { name, version, default: isDefault, noprefix } = item;\n const noPrefix = isDefault || noprefix;\n await addIconsToMap(resp, name, version, noPrefix);\n }\n }\n } else {\n // Single IconLibrary configuration\n const { name, version, default: isDefault, noprefix } = library;\n const prefix = (isDefault || noprefix) ? undefined : name;\n await addIconsToMap(resp, name, version, prefix);\n }\n\n return resp;\n }\n\n return {\n name: 'xyd-plugin-icon-set',\n enforce: 'pre',\n resolveId(id) {\n if (id === 'virtual:xyd-icon-set') {\n return id;\n }\n },\n async load(id) {\n if (id === 'virtual:xyd-icon-set') {\n let resp: Map<string, { svg: string }>;\n\n // Handle theme icons configuration\n if (settings.theme?.icons?.library) {\n resp = await processIconLibrary(settings.theme.icons.library);\n } else {\n resp = await processIconLibrary([\n {\n name: DEFAULT_ICON_SET,\n default: true,\n }\n ]);\n }\n\n return `\n export const iconSet = ${JSON.stringify(Object.fromEntries(resp))};\n `;\n }\n }\n } as VitePlugin\n}\n\nexport function getHostPath() {\n if (process.env.XYD_DEV_MODE) {\n if (process.env.XYD_HOST) {\n return path.resolve(process.env.XYD_HOST)\n }\n\n\n return path.join(__dirname, \"../../../\", HOST_FOLDER_PATH)\n }\n\n return path.join(process.cwd(), HOST_FOLDER_PATH)\n}\n\nexport function getAppRoot() {\n return getHostPath()\n}\n\n// TODO: in the future get from settings\nexport function getPublicPath() {\n return path.join(process.cwd(), 'public')\n}\n\nexport function getBuildPath() {\n return path.join(\n process.cwd(),\n BUILD_FOLDER_PATH\n );\n}\n\nexport function getDocsPluginBasePath() {\n return path.join(getHostPath(), \"./plugins/xyd-plugin-docs\")\n}\n\nasync function loadPlugins(\n settings: Settings,\n) {\n const resolvedPlugins: PluginConfig[] = []\n\n for (const plugin of settings.plugins || []) {\n let pluginName: string\n let pluginArgs: any[] = []\n\n if (typeof plugin === \"string\") {\n pluginName = plugin\n pluginArgs = []\n } else if (Array.isArray(plugin)) {\n pluginName = plugin[0]\n pluginArgs = plugin.slice(1)\n } else {\n console.error(`Currently only string and array plugins are supported, got: ${plugin}`)\n return []\n }\n\n let mod: any // TODO: fix type\n try {\n mod = await import(pluginName)\n } catch (e) {\n pluginName = path.join(process.cwd(), pluginName)\n\n // TODO: find better solution? use this every time?\n const pluginPreview = await createServer({\n optimizeDeps: {\n include: [],\n },\n });\n mod = await pluginPreview.ssrLoadModule(pluginName);\n }\n\n if (!mod.default) {\n console.error(`Plugin ${plugin} has no default export`)\n continue\n }\n\n let pluginInstance = mod.default(...pluginArgs) as (PluginConfig | Plugin)\n if (typeof pluginInstance === \"function\") {\n const plug = pluginInstance(settings)\n\n resolvedPlugins.push(plug)\n\n continue\n }\n\n resolvedPlugins.push(pluginInstance);\n\n }\n\n return resolvedPlugins\n}\n\nfunction integrationsToPlugins(integrations: Integrations) {\n const plugins: Plugins = []\n let foundSearchIntegation = 0\n\n if (integrations?.search?.orama) {\n if (typeof integrations.search.orama === \"boolean\") {\n plugins.push(\"@xyd-js/plugin-orama\")\n } else {\n plugins.push([\"@xyd-js/plugin-orama\", integrations.search.orama])\n }\n foundSearchIntegation++\n }\n\n if (integrations?.search?.algolia) {\n plugins.push([\"@xyd-js/plugin-algolia\", integrations.search.algolia])\n foundSearchIntegation++\n }\n\n if (foundSearchIntegation > 1) {\n throw new Error(\"Only one search integration is allowed\")\n }\n\n return plugins\n}\n\nexport async function preWorkspaceSetup(options: {\n force?: boolean\n} = {}) {\n await ensureFoldersExist()\n\n // Check if we can skip the setup\n if (!options.force) {\n if (await shouldSkipHostSetup()) {\n return true\n }\n }\n\n const hostTemplate = process.env.XYD_DEV_MODE\n ? path.resolve(__dirname, \"../../xyd-host\")\n : path.resolve(__dirname, \"../node_modules/@xyd-js/host\")\n // : await downloadPackage(\"@xyd-js/host\", HOST_VERSION)\n\n // if (hostTemplate instanceof Error) {\n // throw hostTemplate\n // }\n\n const hostPath = getHostPath()\n\n await copyHostTemplate(hostTemplate, hostPath)\n\n // Calculate and store new checksum after setup\n\n // Handle plugin-docs pages\n let pluginDocsPath: string | Error\n if (process.env.XYD_DEV_MODE) {\n pluginDocsPath = path.resolve(__dirname, \"../../xyd-plugin-docs\")\n } else {\n pluginDocsPath = path.resolve(__dirname, \"../node_modules/@xyd-js/plugin-docs\")\n\n // // Get plugin-docs version from host's package.json\n // const hostPackageJsonPath = path.join(hostPath, 'package.json')\n // if (fs.existsSync(hostPackageJsonPath)) {\n // const hostPackageJson = JSON.parse(fs.readFileSync(hostPackageJsonPath, 'utf-8'))\n // const pluginDocsVersion = hostPackageJson.dependencies?.['@xyd-js/plugin-docs']\n\n // if (pluginDocsVersion) {\n // pluginDocsPath = path.resolve(__dirname, \"../node_modules/@xyd-js/plugin-docs\")\n // // pluginDocsPath = await downloadPackage('@xyd-js/plugin-docs', pluginDocsVersion)\n // } else {\n // console.warn('No @xyd-js/plugin-docs dependency found in host package.json')\n // return\n // }\n // } else {\n // console.warn('No host package.json found')\n // return\n // }\n }\n\n // if (pluginDocsPath instanceof Error) {\n // throw pluginDocsPath\n // }\n\n const pagesSourcePath = path.join(pluginDocsPath, \"src/pages\")\n const pagesTargetPath = path.join(hostPath, \"plugins/xyd-plugin-docs/src/pages\")\n\n if (fs.existsSync(pagesSourcePath)) {\n await copyHostTemplate(pagesSourcePath, pagesTargetPath)\n } else {\n console.warn(`Pages source path does not exist: ${pagesSourcePath}`)\n }\n}\n\nexport function calculateFolderChecksum(folderPath: string): string {\n const hash = crypto.createHash('sha256');\n const ignorePatterns = [...getGitignorePatterns(folderPath), '.xydchecksum'];\n\n function processFile(filePath: string) {\n const relativePath = path.relative(folderPath, filePath);\n const content = fs.readFileSync(filePath);\n hash.update(relativePath);\n hash.update(content);\n }\n\n function processDirectory(dirPath: string) {\n const entries = fs.readdirSync(dirPath, { withFileTypes: true });\n\n // Sort entries to ensure consistent order\n entries.sort((a, b) => a.name.localeCompare(b.name));\n\n for (const entry of entries) {\n const sourceEntry = path.join(dirPath, entry.name)\n\n // Skip if the entry matches any ignore pattern\n if (shouldIgnoreEntry(entry.name, ignorePatterns)) {\n continue\n }\n\n // Skip .git directory\n if (entry.name === '.git') {\n continue\n }\n\n if (entry.isDirectory()) {\n processDirectory(sourceEntry)\n } else {\n processFile(sourceEntry)\n }\n }\n }\n\n processDirectory(folderPath);\n return hash.digest('hex');\n}\n\nfunction getGitignorePatterns(folderPath: string): string[] {\n const gitignorePath = path.join(folderPath, '.gitignore')\n if (fs.existsSync(gitignorePath)) {\n const gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8')\n return gitignoreContent\n .split('\\n')\n .map(line => line.trim())\n .filter(line => line && !line.startsWith('#'))\n }\n return []\n}\n\nfunction shouldIgnoreEntry(entryName: string, ignorePatterns: string[]): boolean {\n return ignorePatterns.some(pattern => {\n const regex = new RegExp(pattern.replace(/\\*/g, '.*'))\n return regex.test(entryName)\n })\n}\n\n// async function downloadPackage(packageName: string, version: string): Promise<string | Error> {\n// const tempDir = path.join(process.cwd(), CACHE_FOLDER_PATH, 'temp')\n// const packageDir = path.join(tempDir, packageName.replace('/', '-'))\n\n// // Clean up existing temp directory if it exists\n// if (fs.existsSync(packageDir)) {\n// fs.rmSync(packageDir, { recursive: true, force: true })\n// }\n\n// // Create temp directory\n// fs.mkdirSync(packageDir, { recursive: true })\n\n// try {\n// nodeDownloadPackage(packageName, version, tempDir, packageDir)\n\n// return packageDir\n// } catch (error) {\n// console.error(`Failed to download ${packageName}@${version}:`, error)\n// return new Error(`Failed to download ${packageName}@${version}`)\n// }\n// }\n\nasync function copyHostTemplate(sourcePath: string, targetPath: string) {\n if (!fs.existsSync(sourcePath)) {\n throw new Error(`Host template source path does not exist: ${sourcePath}`)\n }\n\n // Clean target directory if it exists\n if (fs.existsSync(targetPath)) {\n fs.rmSync(targetPath, { recursive: true, force: true })\n }\n\n // Create target directory\n fs.mkdirSync(targetPath, { recursive: true })\n\n const ignorePatterns = getGitignorePatterns(sourcePath)\n\n // Copy all files and directories recursively\n const entries = fs.readdirSync(sourcePath, { withFileTypes: true })\n\n for (const entry of entries) {\n const sourceEntry = path.join(sourcePath, entry.name)\n const targetEntry = path.join(targetPath, entry.name)\n\n // Skip if the entry matches any ignore pattern\n if (shouldIgnoreEntry(entry.name, ignorePatterns)) {\n continue\n }\n\n // Skip .git directory\n if (entry.name === '.git') {\n continue\n }\n\n if (entry.isDirectory()) {\n await copyHostTemplate(sourceEntry, targetEntry)\n } else {\n fs.copyFileSync(sourceEntry, targetEntry)\n\n // Handle package.json modifications for local development\n if (entry.name === 'package.json' && process.env.XYD_DEV_MODE) {\n const packageJsonPath = targetEntry\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n packageJson.name = \"xyd-host-dev\"\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))\n }\n }\n }\n}\n\nasync function ensureFoldersExist() {\n const folders = [CACHE_FOLDER_PATH]\n for (const folder of folders) {\n const fullPath = path.resolve(process.cwd(), folder)\n if (!fs.existsSync(fullPath)) {\n fs.mkdirSync(fullPath, { recursive: true })\n }\n }\n}\n\n// TODO: in the future buil-in xyd plugins should be installable via code\nexport async function postWorkspaceSetup(settings: Settings) {\n const spinner = new CLI('dots');\n\n try {\n spinner.startSpinner('Installing xyd framework...');\n\n const hostPath = getHostPath()\n const packageJsonPath = path.join(hostPath, 'package.json')\n\n if (!fs.existsSync(packageJsonPath)) {\n console.warn('No package.json found in host path')\n return\n }\n\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n\n // Initialize dependencies if they don't exist\n if (!packageJson.dependencies) {\n packageJson.dependencies = {}\n }\n for (const plugin of settings.plugins || []) {\n let pluginName: string\n\n if (typeof plugin === \"string\") {\n pluginName = plugin\n } else if (Array.isArray(plugin)) {\n pluginName = plugin[0]\n } else {\n continue\n }\n\n if (pluginName.startsWith(\"@xyd-js/\")) {\n continue // TODO: currently we don't install built-in xyd plugins - they are defined in host\n }\n\n // Check if it's a valid npm package name\n // Valid formats: name or @scope/name\n // Invalid: ./path/to/file.js or /absolute/path\n const isValidNpmPackage = /^(@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(pluginName)\n\n if (isValidNpmPackage) {\n // Search for matching dependencies in host's package.json\n const hostPackageJsonPath = path.join(hostPath, 'package.json')\n if (fs.existsSync(hostPackageJsonPath)) {\n const hostPackageJson = JSON.parse(fs.readFileSync(hostPackageJsonPath, 'utf-8'))\n const deps = hostPackageJson.dependencies || {}\n\n // Find matching dependency\n const matchingDep = Object.entries(deps).find(([depName]) => {\n return depName === pluginName\n })\n\n if (matchingDep) {\n packageJson.dependencies[pluginName] = matchingDep[1]\n } else {\n console.warn(`no matching dependency found for: ${pluginName} in: ${hostPackageJsonPath}`)\n }\n } else {\n console.warn(`no host package.json found in: ${hostPath}`)\n }\n } else if (!pluginName.startsWith('.') && !pluginName.startsWith('/')) {\n // Only warn if it's not a local file path (doesn't start with . or /)\n console.warn(`invalid plugin name: ${pluginName}`)\n }\n }\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))\n\n await nodeInstallPackages(hostPath)\n\n spinner.stopSpinner();\n spinner.log('✔ Local xyd framework installed successfully');\n } catch(error) {\n spinner.stopSpinner();\n spinner.error('❌ Failed to install xyd framework');\n throw error;\n }\n}\n\nfunction nodeInstallPackages(hostPath: string) {\n const cmd = process.env.XYD_DEV_MODE ? 'pnpm i' : 'npm i'\n const execOptions: ExecSyncOptions = {\n cwd: hostPath,\n env: {\n ...process.env,\n NODE_ENV: \"\" // since 'production' does not install it well\n }\n }\n if (process.env.XYD_VERBOSE) {\n execOptions.stdio = 'inherit'\n }\n execSync(cmd, execOptions)\n}\n\n// function nodeDownloadPackage(\n// packageName: string,\n// version: string,\n// extractDir: string,\n// finalOutputDir: string,\n// ) {\n// const cmd = process.env.XYD_DEV_MODE\n// ? `pnpm pack ${packageName}@${version} --pack-destination ${extractDir}`\n// : `npm pack ${packageName}@${version} --pack-destination ${extractDir}`\n\n// const execOptions: ExecSyncOptions = {}\n// if (process.env.XYD_VERBOSE) {\n// execOptions.stdio = 'inherit'\n// }\n// execSync(cmd, execOptions)\n\n// const tarball = fs.readdirSync(extractDir).find(file => file.endsWith('.tgz'))\n// if (!tarball) {\n// throw new Error(`No tarball found for ${packageName}@${version}`)\n// }\n// execSync(`tar -xzf ${path.join(extractDir, tarball)} -C ${extractDir}`, execOptions)\n\n// // Move package contents to outputDir\n// const extractedDir = path.join(extractDir, 'package')\n// if (fs.existsSync(extractedDir)) {\n// fs.renameSync(extractedDir, finalOutputDir)\n// }\n\n// // Clean up tarball\n// fs.unlinkSync(path.join(extractDir, tarball))\n// }\n\nasync function shouldSkipHostSetup(): Promise<boolean> {\n const hostPath = getHostPath();\n\n // If host folder doesn't exist, we need to set it up\n if (!fs.existsSync(hostPath)) {\n return false;\n }\n\n const currentChecksum = calculateFolderChecksum(hostPath);\n const storedChecksum = getStoredChecksum();\n\n // If no stored checksum or checksums don't match, we need to set up\n if (!storedChecksum || storedChecksum !== currentChecksum) {\n return false;\n }\n\n return true;\n}\n\nfunction getStoredChecksum(): string | null {\n const checksumPath = path.join(getHostPath(), '.xydchecksum');\n if (!fs.existsSync(checksumPath)) {\n return null;\n }\n try {\n return fs.readFileSync(checksumPath, 'utf-8').trim();\n } catch (error) {\n console.error('Error reading checksum file:', error);\n return null;\n }\n}\n\nexport function storeChecksum(checksum: string): void {\n const checksumPath = path.join(getHostPath(), '.xydchecksum');\n try {\n fs.writeFileSync(checksumPath, checksum);\n } catch (error) {\n console.error('Error writing checksum file:', error);\n }\n}\n\n","{\n \"name\": \"@xyd-js/host\",\n \"version\": \"0.1.0-xyd.0\",\n \"type\": \"module\",\n \"scripts\": {},\n \"dependencies\": {\n \"@xyd-js/core\": \"workspace:*\",\n \"@xyd-js/components\": \"workspace:*\",\n \"@xyd-js/framework\": \"workspace:*\",\n \"@xyd-js/composer\": \"workspace:*\",\n \"@xyd-js/themes\": \"workspace:*\",\n \"@xyd-js/atlas\": \"workspace:*\",\n \"@xyd-js/theme-poetry\": \"workspace:*\",\n \"@xyd-js/theme-cosmo\": \"workspace:*\",\n \"@xyd-js/theme-opener\": \"workspace:*\",\n \"@xyd-js/theme-picasso\": \"workspace:*\",\n \"@xyd-js/plugin-orama\": \"workspace:*\",\n \"@xyd-js/plugin-algolia\": \"workspace:*\",\n \"@react-router/dev\": \"^7.5.0\",\n \"@react-router/node\": \"^7.5.0\",\n \"@react-router/serve\": \"^7.5.0\",\n \"isbot\": \"^5\",\n \"react-router\": \"^7.5.0\"\n },\n \"devDependencies\": {\n \"autoprefixer\": \"^10.4.20\",\n \"postcss\": \"^8.4.47\",\n \"semver\": \"^7.6.3\",\n \"vite\": \"^6.1.0\",\n \"vite-tsconfig-paths\": \"^5.1.4\"\n }\n}","export const HOST_FOLDER_PATH = \".xyd/host\"\nexport const CACHE_FOLDER_PATH = \".xyd/.cache\"\nexport const BUILD_FOLDER_PATH = \".xyd/build\"\n\nexport const SUPPORTED_SETTINGS_FILES = [\n 'docs.json',\n 'docs.ts',\n 'docs.tsx'\n]\n\nexport const SUPPORTED_WATCH_FILES = [\n '.md',\n '.mdx',\n ...SUPPORTED_SETTINGS_FILES\n]","import readline from 'node:readline';\nimport cliSpinners from 'cli-spinners';\n\ninterface Spinner {\n frames: string[];\n interval: number;\n}\n\ntype SpinnerName = keyof typeof cliSpinners;\n\nexport class CLI {\n private spinner: Spinner;\n private spinnerInterval: NodeJS.Timeout | null = null;\n private currentFrame = 0;\n private currentMessage = '';\n private isSpinning = false;\n\n constructor(spinnerType: SpinnerName = 'dots') {\n this.spinner = cliSpinners[spinnerType] as Spinner;\n }\n\n public startSpinner(message: string) {\n if (this.isSpinning) {\n this.stopSpinner();\n }\n\n this.currentMessage = message;\n this.isSpinning = true;\n this.currentFrame = 0;\n\n // Write initial message\n this.write(`${this.spinner.frames[0]} ${this.currentMessage}`);\n\n this.spinnerInterval = setInterval(() => {\n const frame = this.spinner.frames[this.currentFrame];\n this.write(`${frame} ${this.currentMessage}`);\n this.currentFrame = (this.currentFrame + 1) % this.spinner.frames.length;\n }, this.spinner.interval);\n }\n\n public stopSpinner() {\n if (this.spinnerInterval) {\n clearInterval(this.spinnerInterval);\n this.spinnerInterval = null;\n }\n this.isSpinning = false;\n this.clearLine();\n }\n\n private clearLine() {\n readline.clearLine(process.stdout, 0);\n readline.cursorTo(process.stdout, 0);\n }\n\n private write(message: string) {\n this.clearLine();\n process.stdout.write(message);\n }\n\n public log(message: string) {\n if (this.isSpinning) {\n this.stopSpinner();\n }\n console.log(message);\n }\n\n public error(message: string) {\n if (this.isSpinning) {\n this.stopSpinner();\n }\n console.error(message);\n }\n\n private updateMessage(message: string) {\n this.currentMessage = message;\n }\n\n}\n\n// Export a singleton instance\nexport const cli = new CLI(); ","import path from \"node:path\";\nimport fs from \"node:fs\";\n\nimport { createServer, searchForWorkspaceRoot, ViteDevServer } from \"vite\";\n\nimport { API, APIFile, } from \"@xyd-js/core\";\n\nimport { appInit, calculateFolderChecksum, commonVitePlugins, getAppRoot, getDocsPluginBasePath, getHostPath, getPublicPath, postWorkspaceSetup, preWorkspaceSetup, storeChecksum } from \"./utils\";\nimport { CACHE_FOLDER_PATH, SUPPORTED_WATCH_FILES } from \"./const\";\nimport {CLI} from \"./cli\";\n\n// TODO: !!! BETTER TIMER / DEBUG API !!!\nif (!process.env.ENABLE_TIMERS) {\n ['time', 'timeLog', 'timeEnd'].forEach(method => {\n console[method] = () => {\n };\n });\n}\n\ninterface DevOptions {\n port?: number\n}\nexport async function dev(options?: DevOptions) {\n const spinner = new CLI('dots');\n spinner.startSpinner('Preparing local xyd instance... \\n');\n\n const skip = await preWorkspaceSetup()\n\n const { respPluginDocs, resolvedPlugins } = await appInit()\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n const appRoot = getAppRoot()\n const commonRunVitePlugins = commonVitePlugins(respPluginDocs, resolvedPlugins)\n spinner.stopSpinner();\n\n if (!skip) {\n await postWorkspaceSetup(respPluginDocs.settings)\n\n const newChecksum = calculateFolderChecksum(getHostPath());\n storeChecksum(newChecksum);\n }\n\n // ⚠️ \n spinner.log('✔ Local xyd instance is ready');\n\n let server: ViteDevServer | null = null\n\n const port = options?.port ?? parseInt(process.env.XYD_PORT ?? \"5175\")\n\n const preview = await createServer({\n root: appRoot,\n publicDir: '/public',\n server: {\n allowedHosts: [],\n port: port,\n fs: {\n allow: [\n allowCwd,\n appRoot,\n ]\n }\n },\n define: {\n 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),\n 'process.env': {}\n },\n resolve: {\n alias: {\n process: 'process/browser'\n }\n },\n build: {\n rollupOptions: {\n external: []\n },\n },\n ssr: {\n external: [],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"]\n },\n plugins: [\n ...commonRunVitePlugins,\n\n {\n name: 'xyd-configureServer',\n configureServer(s) {\n server = s\n }\n },\n ],\n });\n\n // Set up manual file watcher for markdown files TODO: better way? + HMR only for specific components instead or reload a pag\n const watcher = fs.watch(allowCwd, { recursive: true }, async (eventType, filename) => {\n if (!filename) {\n console.log(\"[xyd:dev] Received empty filename\");\n return;\n }\n\n const filePath = path.join(allowCwd, filename);\n if (filePath.includes(CACHE_FOLDER_PATH)) {\n return\n }\n\n let apiPaths: { [path: string]: boolean } = {}\n if (respPluginDocs?.settings?.api) {\n apiPaths = resolveApiFilePaths(process.cwd(), respPluginDocs.settings.api)\n }\n\n const apiChanged = !!apiPaths[filePath]\n\n if (filePath.includes(getPublicPath())) {\n const relativePath = path.relative(allowCwd, filePath);\n const urlPath = '/' + relativePath.replace(/\\\\/g, '/');\n\n preview.ws.send({\n type: 'full-reload',\n path: urlPath,\n });\n return\n }\n\n if (SUPPORTED_WATCH_FILES.some(ext => filePath.endsWith(ext)) || apiChanged) {\n const relativePath = path.relative(allowCwd, filePath);\n const urlPath = '/' + relativePath.replace(/\\\\/g, '/');\n\n // TODO: better way to handle that - we need this cuz otherwise its inifiite reloads\n if (respPluginDocs?.settings.engine?.uniform?.store) {\n await appInit({\n disableFSWrite: true,\n })\n } else {\n await appInit() // TODO: !!! IN THE FUTURE MORE EFFICIENT WAY !!!\n }\n\n // TODO: !!! BETTER HMR !!!\n\n if (server) {\n const docsPluginBasePath = getDocsPluginBasePath()\n\n const layoutPath = path.join(docsPluginBasePath, \"./src/pages/layout.tsx\")\n const layoutModule = server.moduleGraph.getModuleById(layoutPath);\n\n const pagePath = path.join(docsPluginBasePath, \"./src/pages/page.tsx\")\n const pageModule = server.moduleGraph.getModuleById(pagePath);\n\n if (layoutModule && pageModule) {\n server.moduleGraph.invalidateModule(layoutModule);\n server.moduleGraph.invalidateModule(pageModule);\n try {\n const hostPath = getHostPath()\n const hostReactRouterConfig = path.join(hostPath, \"react-router.config.ts\")\n\n await fs.promises.utimes(hostReactRouterConfig, new Date(), new Date());\n } catch (e) {\n console.error(\"config update error\")\n console.error(e)\n }\n\n server.ws.send({ type: 'full-reload' });\n\n return\n }\n }\n\n preview.ws.send({\n type: 'full-reload',\n path: urlPath,\n });\n }\n });\n\n // Log any watcher errors\n watcher.on('error', (error) => {\n console.error(\"[xyd:dev] File watcher error:\", error);\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({ print: true });\n\n // Clean up watcher when server is closed\n preview.httpServer?.once('close', () => {\n watcher.close();\n });\n}\n\n\n/**\n * @todo: !!! in the future it should be created at different level !!!\n * \n * Walks api.*, \n * resolves all referenced files under `basePath`,\n * and returns a set of absolute paths.\n */\nexport function resolveApiFilePaths(\n basePath: string,\n api: API\n): Record<string, true> {\n const result: Record<string, true> = {}\n\n const apis = [api.openapi, api.graphql, api.sources].filter((s): s is APIFile => s !== undefined)\n\n apis.forEach(section => {\n flattenApiFile(section).forEach(p => {\n const apiAbsPath = path.resolve(basePath, p)\n result[apiAbsPath] = true\n })\n })\n\n return result\n}\n\n\n/**\n * Given any APIFile-ish value, returns an array of the raw source-paths.\n */\nfunction flattenApiFile(file?: APIFile): string[] {\n if (!file) return []\n\n // single string\n if (typeof file === 'string') {\n return [file]\n }\n\n // array of anything\n if (Array.isArray(file)) {\n return file.flatMap(flattenApiFile)\n }\n\n // object: either a nested config, or a map of name→file\n if (typeof file === 'object') {\n const obj = file as Record<string, any>\n\n // explicit nested entry\n if (typeof obj.source === 'string') {\n return [obj.source]\n }\n\n // fallback: treat as { key: APIFile } map\n return Object.values(obj).flatMap(flattenApiFile)\n }\n\n // everything else (e.g. numbers, booleans) gets dropped\n return []\n}","import fs from 'node:fs';\n\nimport { preWorkspaceSetup, postWorkspaceSetup, getHostPath } from './utils';\nimport { readSettings } from '@xyd-js/plugin-docs';\n\n\nexport async function install() {\n const settings = await readSettings() // TODO: in the future better solution - currently we load settings twice (pluginDocs and here)\n if (!settings) {\n throw new Error(\"cannot preload settings\")\n }\n if (typeof settings === \"string\") {\n throw new Error(\"install does not support string settings\")\n }\n\n // Clear the host folder if it exists\n const hostPath = getHostPath();\n if (fs.existsSync(hostPath)) {\n fs.rmSync(hostPath, { recursive: true, force: true });\n }\n\n // Run pre-workspace setup\n await preWorkspaceSetup({\n force: true,\n });\n\n // Run post-workspace setup with empty settings\n // The actual settings will be loaded during the build/dev process\n await postWorkspaceSetup(settings);\n}"],"mappings":";AAAA,OAAOA,WAAU;AACjB,OAAOC,SAAQ;AAEf,SAAS,SAAS,iBAAuC;AACzD,OAAO,mBAAmB;;;ACJ1B,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,SAAS,gBAAiC;AAC1C,OAAO,YAAY;AAEnB,SAAS,oBAA4E;AACrF,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AAExB,SAAS,cAAc,kBAAwD;AAC/E,SAAS,eAAe,6BAA6B;;;ACXrD;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,SAAW,CAAC;AAAA,EACZ,cAAgB;AAAA,IACd,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,IACtB,qBAAqB;AAAA,IACrB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,0BAA0B;AAAA,IAC1B,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,uBAAuB;AAAA,IACvB,OAAS;AAAA,IACT,gBAAgB;AAAA,EAClB;AAAA,EACA,iBAAmB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