@xyd-js/host 0.0.0-build

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.
@@ -0,0 +1,39 @@
1
+ (function () {
2
+ const xhr = new XMLHttpRequest();
3
+ xhr.open('GET', 'https://cdn.growthbook.io/api/features/sdk-k5zXBj4EjEi1SI', false);
4
+ xhr.send(null);
5
+ if (xhr.status === 200) {
6
+ try {
7
+ const resp = JSON.parse(xhr.responseText);
8
+ const features = resp.features || {};
9
+
10
+ // Create dynamic CSS for feature flags
11
+ let cssRules = [];
12
+
13
+ // Default rule: hide all feature elements
14
+ cssRules.push('feature[data-feature] { display: none !important; }');
15
+
16
+ // Generate rules for each feature flag
17
+ Object.entries(features).forEach(([featureKey, featureData]) => {
18
+ if (featureData && typeof featureData === 'object') {
19
+ // Get the current value of the feature flag
20
+ const currentValue = featureData.defaultValue;
21
+
22
+ if (currentValue !== undefined) {
23
+ // Create rule to show elements when feature flag matches the expected value
24
+ cssRules.push(`feature[data-feature="${featureKey}"][data-match="${currentValue}"] { display: block !important; }`);
25
+ }
26
+ }
27
+ });
28
+
29
+ // Apply the CSS rules
30
+ if (cssRules.length > 0) {
31
+ const style = document.createElement('style');
32
+ style.textContent = cssRules.join('\n');
33
+ document.head.appendChild(style);
34
+ }
35
+ } catch (e) {
36
+ console.error('Error processing feature flags:', e);
37
+ }
38
+ }
39
+ })();
package/app/sitemap.ts ADDED
@@ -0,0 +1,40 @@
1
+ import {docPaths} from "./docPaths";
2
+
3
+ const navigation = __xydSettings?.navigation || {sidebar: []};
4
+
5
+
6
+ // TODO: support lastmod and other advanced features
7
+
8
+ export async function loader({request}: { request: Request }) {
9
+ if (!navigation?.sidebar) {
10
+ return new Response('', {
11
+ status: 404,
12
+ headers: {
13
+ 'Content-Type': 'text/plain'
14
+ }
15
+ });
16
+ }
17
+
18
+ const routes: string[] = docPaths(navigation);
19
+ const baseUrl = __xydSettings?.seo?.domain || new URL(request.url).origin;
20
+
21
+ // Generate XML sitemap
22
+ const xml = `<?xml version="1.0" encoding="UTF-8"?>
23
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
24
+ ${routes.map(route => {
25
+ const fullUrl = `${baseUrl}${route}`.replace(/([^:]\/)\/+/g, "$1"); // Remove duplicate slashes
26
+ return ` <url>
27
+ <loc>${fullUrl}</loc>
28
+ <changefreq>daily</changefreq>
29
+ <priority>0.7</priority>
30
+ </url>`;
31
+ }).join('\n')}
32
+ </urlset>`;
33
+
34
+ return new Response(xml, {
35
+ headers: {
36
+ 'Content-Type': 'application/xml',
37
+ 'Cache-Control': 'public, max-age=3600'
38
+ }
39
+ });
40
+ }
@@ -0,0 +1,4 @@
1
+ declare module "*?raw" {
2
+ const content: string;
3
+ export default content;
4
+ }
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // noinspection JSUnusedGlobalSymbols
5
+ // Generated by unplugin-auto-import
6
+ // biome-ignore lint: disable
7
+ export {}
8
+ declare global {
9
+
10
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@xyd-js/host",
3
+ "version": "0.0.0-build+6952c2c-20250813013245",
4
+ "type": "module",
5
+ "dependencies": {
6
+ "katex": "^0.16.22",
7
+ "isbot": "^5",
8
+ "react-router": "^7.7.1",
9
+ "react": "^19.1.0",
10
+ "react-dom": "^19.1.0",
11
+ "@react-router/dev": "^7.7.1",
12
+ "@react-router/node": "^7.7.1",
13
+ "@react-router/serve": "^7.7.1",
14
+ "openux-js": "0.0.0-pre.1",
15
+ "pluganalytics": "0.0.0-pre.3",
16
+ "@xyd-js/analytics": "0.0.0-build+6952c2c-20250813013245",
17
+ "@xyd-js/core": "0.0.0-build+6952c2c-20250813013245",
18
+ "@xyd-js/components": "0.0.0-build+6952c2c-20250813013245",
19
+ "@xyd-js/content": "0.0.0-build+6952c2c-20250813013245",
20
+ "@xyd-js/framework": "0.0.0-build+6952c2c-20250813013245",
21
+ "@xyd-js/composer": "0.0.0-build+6952c2c-20250813013245",
22
+ "@xyd-js/themes": "0.0.0-build+6952c2c-20250813013245",
23
+ "@xyd-js/theme-poetry": "0.0.0-build+6952c2c-20250813013245",
24
+ "@xyd-js/atlas": "0.0.0-build+6952c2c-20250813013245",
25
+ "@xyd-js/theme-cosmo": "0.0.0-build+6952c2c-20250813013245",
26
+ "@xyd-js/theme-opener": "0.0.0-build+6952c2c-20250813013245",
27
+ "@xyd-js/theme-picasso": "0.0.0-build+6952c2c-20250813013245",
28
+ "@xyd-js/theme-gusto": "0.0.0-build+6952c2c-20250813013245",
29
+ "@xyd-js/theme-solar": "0.0.0-build+6952c2c-20250813013245",
30
+ "@xyd-js/plugin-orama": "0.0.0-build+6952c2c-20250813013245",
31
+ "@xyd-js/plugin-algolia": "0.0.0-build+6952c2c-20250813013245"
32
+ },
33
+ "devDependencies": {
34
+ "autoprefixer": "^10.4.20",
35
+ "postcss": "^8.4.47",
36
+ "semver": "^7.6.3",
37
+ "vite": "^7.0.0",
38
+ "vite-tsconfig-paths": "^5.1.4"
39
+ },
40
+ "scripts": {}
41
+ }
@@ -0,0 +1 @@
1
+ xyd plugins
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ plugins: {
3
+ autoprefixer: {},
4
+ },
5
+ }
@@ -0,0 +1,94 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs/promises";
3
+
4
+ import type {Config} from "@react-router/dev/config";
5
+
6
+ import {Settings} from "@xyd-js/core";
7
+ import {docPaths} from "./app/docPaths";
8
+
9
+ declare global {
10
+ var __xydSettings: Settings;
11
+ var __xydStaticFiles: string[];
12
+ }
13
+
14
+ // Function to get all static files from the public directory
15
+ async function getStaticFiles() {
16
+ const publicDir = path.join(process.cwd(), "public");
17
+ const paths: string[] = [];
18
+
19
+ try {
20
+ await fs.access(publicDir);
21
+ } catch (e) {
22
+ return paths;
23
+ }
24
+
25
+ async function scanDirectory(dir: string, basePath: string = "") {
26
+ const entries = await fs.readdir(dir, {withFileTypes: true});
27
+
28
+ for (const entry of entries) {
29
+ const fullPath = path.join(dir, entry.name);
30
+ const relativePath = path.join(basePath, entry.name);
31
+
32
+ if (entry.isDirectory()) {
33
+ await scanDirectory(fullPath, relativePath);
34
+ } else {
35
+ paths.push(`/public/${relativePath}`);
36
+ }
37
+ }
38
+ }
39
+
40
+ await scanDirectory(publicDir);
41
+ return paths;
42
+ }
43
+
44
+ // Function to find documentation files for navigation paths
45
+ // async function findDocFiles(navigationPaths: string[]) {
46
+ // const docFiles: string[] = [];
47
+ //
48
+ // for (const navPath of navigationPaths) {
49
+ // // Try .mdx first, then .md
50
+ // const mdxPath = path.join(process.cwd(), navPath + '.mdx');
51
+ // const mdPath = path.join(process.cwd(), navPath + '.md');
52
+ //
53
+ // try {
54
+ // await fs.access(mdxPath);
55
+ // docFiles.push(navPath + ".mdx");
56
+ // } catch {
57
+ // try {
58
+ // await fs.access(mdPath);
59
+ // docFiles.push(navPath + ".md");
60
+ // } catch {
61
+ // }
62
+ // }
63
+ // }
64
+ //
65
+ // return docFiles;
66
+ // }
67
+
68
+ // Use settings.navigation if it exists, otherwise use an empty object
69
+ const navigation = __xydSettings?.navigation || {sidebar: []};
70
+ const navigationPaths = docPaths(navigation);
71
+
72
+ // Get static files and documentation files
73
+ const staticFiles = await getStaticFiles();
74
+ // const docFiles = await findDocFiles(navigationPaths);
75
+
76
+ globalThis.__xydStaticFiles = staticFiles
77
+
78
+ // Combine all paths for prerendering
79
+ const prerenderPaths = [
80
+ ...navigationPaths,
81
+ ...staticFiles,
82
+
83
+ "/sitemap.xml",
84
+ "/robots.txt",
85
+ // ...docFiles,
86
+ ];
87
+ const cwd = process.cwd();
88
+
89
+ export default {
90
+ ssr: false,
91
+ prerender: prerenderPaths,
92
+ buildDirectory: path.join(cwd, ".xyd/build"),
93
+ // return a list of URLs to prerender at build time
94
+ } satisfies Config;
@@ -0,0 +1,29 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // noinspection JSUnusedGlobalSymbols
5
+ // Generated by unplugin-auto-import
6
+ // biome-ignore lint: disable
7
+ export {}
8
+ declare global {
9
+ const createRef: typeof import('react')['createRef']
10
+ const forwardRef: typeof import('react')['forwardRef']
11
+ const lazy: typeof import('react')['lazy']
12
+ const memo: typeof import('react')['memo']
13
+ const startTransition: typeof import('react')['startTransition']
14
+ const useCallback: typeof import('react')['useCallback']
15
+ const useContext: typeof import('react')['useContext']
16
+ const useDebugValue: typeof import('react')['useDebugValue']
17
+ const useDeferredValue: typeof import('react')['useDeferredValue']
18
+ const useEffect: typeof import('react')['useEffect']
19
+ const useId: typeof import('react')['useId']
20
+ const useImperativeHandle: typeof import('react')['useImperativeHandle']
21
+ const useInsertionEffect: typeof import('react')['useInsertionEffect']
22
+ const useLayoutEffect: typeof import('react')['useLayoutEffect']
23
+ const useMemo: typeof import('react')['useMemo']
24
+ const useReducer: typeof import('react')['useReducer']
25
+ const useRef: typeof import('react')['useRef']
26
+ const useState: typeof import('react')['useState']
27
+ const useSyncExternalStore: typeof import('react')['useSyncExternalStore']
28
+ const useTransition: typeof import('react')['useTransition']
29
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": [
7
+ "ES2020",
8
+ "DOM",
9
+ "DOM.Iterable"
10
+ ],
11
+ "typeRoots": [
12
+ "./types.d.ts"
13
+ ],
14
+ "skipLibCheck": true,
15
+ "moduleResolution": "bundler",
16
+ "resolveJsonModule": true,
17
+ "isolatedModules": true,
18
+ "noEmit": false,
19
+ "strict": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "jsx": "react-jsx",
24
+ "include": [
25
+ "./types.d.ts"
26
+ ]
27
+ }
28
+ }
package/types.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ // declarations.d.ts
2
+
3
+ declare global {
4
+ var __xydBasePath: string;
5
+
6
+ var __xydSettings: Settings;
7
+ }
8
+
package/vite.config.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ // DO NOT DELETE
4
+ // This file is needed for host `vite` to run
5
+ export default defineConfig({
6
+ plugins: [
7
+ ],
8
+ });