xanix 1.0.12 → 1.0.14

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.
@@ -15,7 +15,7 @@ const BuildServer = async ({ rootEntry, onBuildEnd }) => {
15
15
  fs.mkdirSync(outdirs.server, {
16
16
  recursive: true,
17
17
  });
18
- const entries = await generateClientEntries();
18
+ const entries = await generateClientEntries({ rootEntry });
19
19
  await createManifest(entries);
20
20
  const input = {
21
21
  index: path.resolve(root, rootEntry),
@@ -1,13 +1,10 @@
1
1
  import path from "node:path";
2
2
  import { rollup } from "rollup";
3
- import { nodeResolve } from "@rollup/plugin-node-resolve";
4
3
  import { build } from "esbuild";
5
4
  import { createRequire } from "node:module";
6
5
  import { getClientRuntimeFile } from "../include/utils.js";
7
- import esbuild from "rollup-plugin-esbuild";
8
- import url from "@rollup/plugin-url";
9
- import XanixDocument from "./plugins/XanixDocument/index.js";
10
6
  import outdirs from "../../outdirs.js";
7
+ import { xanixDefaultPlugins } from "./plugins/plugins.js";
11
8
  const require = createRequire(import.meta.url);
12
9
  const GenerateGraph = async (entries) => {
13
10
  const collector = new Map();
@@ -19,33 +16,10 @@ const GenerateGraph = async (entries) => {
19
16
  const bundle = await rollup({
20
17
  input,
21
18
  plugins: [
22
- nodeResolve({
23
- extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
24
- }),
25
- url({
26
- include: [
27
- "**/*.jpg",
28
- "**/*.jpeg",
29
- "**/*.png",
30
- "**/*.gif",
31
- "**/*.webp",
32
- "**/*.svg",
33
- "**/*.ico",
34
- "**/*.woff",
35
- "**/*.woff2",
36
- "**/*.ttf",
37
- "**/*.eot",
38
- "**/*.css",
39
- ],
40
- limit: 0,
41
- fileName: "assets/[name]-[hash][extname]",
42
- emitFiles: false,
43
- }),
44
- XanixDocument(),
45
- esbuild({
46
- target: "es2022",
47
- jsx: "automatic",
48
- tsconfig: false,
19
+ ...xanixDefaultPlugins({
20
+ target: "client",
21
+ development: true,
22
+ assetExternal: true,
49
23
  }),
50
24
  ],
51
25
  external(id) {
@@ -1,3 +1,5 @@
1
1
  import { type XanixClientEntry } from "../types.js";
2
- declare const generateClientEntries: () => Promise<XanixClientEntry[]>;
2
+ declare const generateClientEntries: ({ rootEntry, }: {
3
+ rootEntry: string;
4
+ }) => Promise<XanixClientEntry[]>;
3
5
  export default generateClientEntries;
@@ -1,46 +1,20 @@
1
1
  import { rollup } from "rollup";
2
2
  import path from "node:path";
3
3
  import { XanixEntryFinder } from "./plugins/XanixEntryFinder/index.js";
4
- import url from "@rollup/plugin-url";
5
- import esbuild from "rollup-plugin-esbuild";
6
- import XanixTsconfigAlias from "./plugins/XanixTsconfigAlias.js";
7
- import { nodeResolve } from "@rollup/plugin-node-resolve";
4
+ import { xanixDefaultPlugins } from "./plugins/plugins.js";
8
5
  const root = process.cwd();
9
- const generateClientEntries = async () => {
6
+ const generateClientEntries = async ({ rootEntry, }) => {
10
7
  const entries = new Map();
11
8
  const bundle = await rollup({
12
- input: path.resolve(root, "index.tsx"),
9
+ input: path.resolve(root, rootEntry),
13
10
  plugins: [
14
- XanixTsconfigAlias(),
15
- nodeResolve({
16
- extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
17
- }),
18
11
  XanixEntryFinder({
19
12
  entries,
20
13
  }),
21
- url({
22
- include: [
23
- "**/*.jpg",
24
- "**/*.jpeg",
25
- "**/*.png",
26
- "**/*.gif",
27
- "**/*.webp",
28
- "**/*.svg",
29
- "**/*.ico",
30
- "**/*.woff",
31
- "**/*.woff2",
32
- "**/*.ttf",
33
- "**/*.eot",
34
- "**/*.css",
35
- ],
36
- limit: 0,
37
- fileName: "assets/[name]-[hash][extname]",
38
- emitFiles: true,
39
- }),
40
- esbuild({
41
- target: "es2022",
42
- jsx: "automatic",
43
- tsconfig: false,
14
+ ...xanixDefaultPlugins({
15
+ target: "server",
16
+ development: true,
17
+ assetExternal: true,
44
18
  }),
45
19
  ],
46
20
  external(id) {
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import alias from "@rollup/plugin-alias";
4
+ import ts from "typescript";
4
5
  export default function xanixTsconfigAlias() {
5
6
  const root = process.cwd();
6
7
  const tsconfigPath = path.resolve(root, "tsconfig.json");
@@ -9,14 +10,11 @@ export default function xanixTsconfigAlias() {
9
10
  name: "xanix-tsconfig-alias",
10
11
  };
11
12
  }
12
- let config;
13
- try {
14
- const content = fs.readFileSync(tsconfigPath, "utf8");
15
- config = parseJsonc(content);
16
- }
17
- catch (error) {
18
- throw new Error(`[xanix] Failed to read tsconfig.json:\n${error.message}`);
13
+ const result = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
14
+ if (result.error) {
15
+ throw new Error(`[xanix] Failed to read tsconfig.json:\n${ts.flattenDiagnosticMessageText(result.error.messageText, "\n")}`);
19
16
  }
17
+ const config = result.config;
20
18
  const compilerOptions = config.compilerOptions ?? {};
21
19
  const baseUrl = compilerOptions.baseUrl ?? ".";
22
20
  const basePath = path.resolve(path.dirname(tsconfigPath), baseUrl);
@@ -26,12 +24,14 @@ export default function xanixTsconfigAlias() {
26
24
  const replacement = replacements?.[0];
27
25
  if (!replacement)
28
26
  return null;
29
- if (find.includes("*")) {
30
- const findPrefix = find.replace(/\/?\*$/, "");
31
- const replacementPrefix = replacement.replace(/\/?\*$/, "");
27
+ if (find.endsWith("/*")) {
28
+ const findPrefix = find.slice(0, -2);
29
+ const replacementPrefix = replacement.endsWith("/*")
30
+ ? replacement.slice(0, -2)
31
+ : replacement;
32
32
  return {
33
33
  find: new RegExp(`^${escapeRegExp(findPrefix)}/(.+)$`),
34
- replacement: `${path.resolve(basePath, replacementPrefix)}/$1`,
34
+ replacement: path.resolve(basePath, replacementPrefix) + "/$1",
35
35
  };
36
36
  }
37
37
  return {
@@ -41,19 +41,10 @@ export default function xanixTsconfigAlias() {
41
41
  })
42
42
  .filter(Boolean);
43
43
  return alias({
44
+ customResolver: undefined,
44
45
  entries,
45
46
  });
46
47
  }
47
48
  function escapeRegExp(value) {
48
49
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
49
50
  }
50
- function parseJsonc(content) {
51
- const withoutComments = content
52
- // Remove /* block comments */
53
- .replace(/\/\*[\s\S]*?\*\//g, "")
54
- // Remove // comments
55
- .replace(/\/\/.*$/gm, "");
56
- // Remove trailing commas
57
- const withoutTrailingCommas = withoutComments.replace(/,\s*([}\]])/g, "$1");
58
- return JSON.parse(withoutTrailingCommas);
59
- }
@@ -27,6 +27,7 @@ export function xanixDefaultPlugins(options = {}) {
27
27
  }
28
28
  }
29
29
  return [
30
+ XanixTsconfigAlias(),
30
31
  {
31
32
  name: "watch",
32
33
  async watchChange(id, change) {
@@ -53,7 +54,6 @@ export function xanixDefaultPlugins(options = {}) {
53
54
  fileName: "assets/[name]-[hash][extname]",
54
55
  emitFiles: !(options?.assetExternal ?? false),
55
56
  }),
56
- XanixTsconfigAlias(),
57
57
  XanixEnvPlugin({
58
58
  mode: development ? "development" : "production",
59
59
  isClient,
@@ -16,7 +16,7 @@ const watchServer = async ({ rootEntry, onChange, onBuildEnd, onServerChange, on
16
16
  fs.mkdirSync(outdirs.server, {
17
17
  recursive: true,
18
18
  });
19
- const entries = await generateClientEntries();
19
+ const entries = await generateClientEntries({ rootEntry });
20
20
  await createManifest(entries);
21
21
  const input = {
22
22
  index: path.resolve(root, rootEntry),
@@ -62,7 +62,7 @@ const watchServer = async ({ rootEntry, onChange, onBuildEnd, onServerChange, on
62
62
  for (const entry of changedFiles) {
63
63
  const isClientEntry = Array.from(manifest.entries.values()).find((e) => e.file === entry);
64
64
  if (!isClientEntry) {
65
- const entries = await generateClientEntries();
65
+ const entries = await generateClientEntries({ rootEntry });
66
66
  const isEqual = await entriesEqual(entries);
67
67
  if (!isEqual) {
68
68
  await createManifest(entries);
@@ -0,0 +1,3 @@
1
+ declare const lightTheme: import("@xanui/core").ThemeOptions;
2
+ declare const darkTheme: import("@xanui/core").ThemeOptions;
3
+ export { lightTheme, darkTheme };
package/dist/theme.js ADDED
@@ -0,0 +1,10 @@
1
+ import { createTheme } from "@xanui/core";
2
+ const lightTheme = createTheme({
3
+ mode: "light",
4
+ name: "light",
5
+ });
6
+ const darkTheme = createTheme({
7
+ mode: "dark",
8
+ name: "dark",
9
+ });
10
+ export { lightTheme, darkTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xanix",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -52,7 +52,8 @@
52
52
  "rollup": "^4.62.5",
53
53
  "rollup-plugin-esbuild": "^6.2.1",
54
54
  "tslib": "^2.8.1",
55
- "ws": "^8.21.3"
55
+ "ws": "^8.21.3",
56
+ "typescript": "^5.9.3"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@types/babel__core": "^7.20.5",
@@ -67,7 +68,6 @@
67
68
  "@xanui/icons": "^1.1.14",
68
69
  "@xanui/ui": "^1.2.24",
69
70
  "react": "^19.2.8",
70
- "react-dom": "^19.2.8",
71
- "typescript": "^5.9.3"
71
+ "react-dom": "^19.2.8"
72
72
  }
73
73
  }
@@ -1,11 +0,0 @@
1
- import { XanixClientEntry } from "../types";
2
- export type DependencyInfo = {
3
- source: string;
4
- resolved: string;
5
- packageName: string;
6
- };
7
- export type CacheMetadata = Map<string, {
8
- file: string;
9
- }>;
10
- declare const BuildCache: (entries: XanixClientEntry[]) => Promise<CacheMetadata>;
11
- export default BuildCache;
@@ -1,162 +0,0 @@
1
- import path from "node:path";
2
- import { rollup } from "rollup";
3
- import { nodeResolve } from "@rollup/plugin-node-resolve";
4
- import { build } from "esbuild";
5
- import { createRequire } from "node:module";
6
- import { getClientRuntimeFile, getDocumentFile } from "../include/utils.js";
7
- import esbuild from "rollup-plugin-esbuild";
8
- import url from "@rollup/plugin-url";
9
- import XanixDocument from "./plugins/XanixDocument/index.js";
10
- const require = createRequire(import.meta.url);
11
- const GenerateGraph = async (entries) => {
12
- const collector = new Map();
13
- const input = [];
14
- for (const entry of entries) {
15
- input.push(entry.file);
16
- }
17
- input.push(getClientRuntimeFile());
18
- input.push(await getDocumentFile());
19
- const bundle = await rollup({
20
- input,
21
- plugins: [
22
- nodeResolve({
23
- extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
24
- }),
25
- url({
26
- include: [
27
- "**/*.jpg",
28
- "**/*.jpeg",
29
- "**/*.png",
30
- "**/*.gif",
31
- "**/*.webp",
32
- "**/*.svg",
33
- "**/*.ico",
34
- "**/*.woff",
35
- "**/*.woff2",
36
- "**/*.ttf",
37
- "**/*.eot",
38
- "**/*.css",
39
- ],
40
- limit: 0,
41
- fileName: "assets/[name]-[hash][extname]",
42
- emitFiles: false,
43
- }),
44
- XanixDocument(),
45
- esbuild({
46
- target: "es2022",
47
- jsx: "automatic",
48
- tsconfig: false,
49
- }),
50
- ],
51
- external(id) {
52
- if (id.startsWith(".") ||
53
- path.isAbsolute(id) ||
54
- id === "@" ||
55
- id.startsWith("@/") ||
56
- id === "virtual:xanix-document") {
57
- return false;
58
- }
59
- collector.set(id, {
60
- source: id,
61
- resolved: require.resolve(id, {
62
- paths: [process.cwd()],
63
- }),
64
- packageName: id,
65
- });
66
- return true;
67
- },
68
- });
69
- await bundle.close();
70
- return collector;
71
- };
72
- // Wraps each CJS dep in a virtual ESM file that re-exports named exports detected via require()
73
- const makeCjsWrapperPlugin = (wrappers) => ({
74
- name: "cjs-named-exports",
75
- setup(build) {
76
- build.onResolve({ filter: /\?cjs-wrapper$/ }, (args) => ({
77
- path: args.path,
78
- namespace: "cjs-wrapper",
79
- }));
80
- build.onLoad({ filter: /.*/, namespace: "cjs-wrapper" }, (args) => {
81
- const contents = wrappers.get(args.path);
82
- return { contents, resolveDir: process.cwd() };
83
- });
84
- },
85
- });
86
- const buildWrappers = (input) => {
87
- const wrappers = new Map();
88
- const wrappedInput = {};
89
- for (const [name, resolved] of Object.entries(input)) {
90
- const key = `${name}?cjs-wrapper`;
91
- let namedExports = [];
92
- let hasDefault = false;
93
- try {
94
- const mod = require(resolved);
95
- hasDefault =
96
- mod &&
97
- (typeof mod === "object" || typeof mod === "function") &&
98
- "default" in mod;
99
- namedExports = Object.keys(mod).filter((key) => key !== "__esModule" && key !== "default");
100
- }
101
- catch (err) {
102
- // console.log(err);
103
- }
104
- const lines = [`import * as __mod from ${JSON.stringify(resolved)};`];
105
- if (hasDefault) {
106
- lines.push(`export default __mod.default;`);
107
- }
108
- else {
109
- lines.push(`export default __mod;`);
110
- }
111
- lines.push("");
112
- for (const exportName of namedExports) {
113
- if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(exportName)) {
114
- lines.push(`export const ${exportName} = __mod[${JSON.stringify(exportName)}];`);
115
- }
116
- }
117
- wrappers.set(key, lines.join("\n"));
118
- wrappedInput[name] = key;
119
- }
120
- return {
121
- wrappers,
122
- wrappedInput,
123
- };
124
- };
125
- const bundleDeps = async (input, outdir) => {
126
- const { wrappers, wrappedInput } = buildWrappers(input);
127
- await build({
128
- entryPoints: wrappedInput,
129
- bundle: true,
130
- splitting: true,
131
- format: "esm",
132
- target: "es2022",
133
- outdir,
134
- entryNames: "[name]",
135
- chunkNames: "chunks/[hash]",
136
- platform: "browser",
137
- sourcemap: true,
138
- define: {
139
- __XANIX_CLIENT__: "true",
140
- __XANIX_SERVER__: "false",
141
- __XANIX_DEV__: "true",
142
- __XANIX_PROD__: "false",
143
- },
144
- plugins: [makeCjsWrapperPlugin(wrappers)],
145
- });
146
- };
147
- const metadata = new Map();
148
- const BuildCache = async (entries) => {
149
- const input = {};
150
- const dependencies = await GenerateGraph(entries);
151
- for (const dependency of dependencies.values()) {
152
- const entryName = dependency.source.replace(/^@/, "").replace(/\//g, "-");
153
- input[entryName] = dependency.resolved;
154
- metadata.set(dependency.source, {
155
- file: `${entryName}.js`,
156
- });
157
- }
158
- const cacheDir = path.resolve(process.cwd(), ".xanix/cache");
159
- await bundleDeps(input, cacheDir);
160
- return metadata;
161
- };
162
- export default BuildCache;
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- import type { Plugin } from "rollup";
2
- export declare function XanixTransform(): Plugin;
@@ -1,19 +0,0 @@
1
- import { transformer } from "./transformer.js";
2
- export function XanixTransform() {
3
- return {
4
- name: "xanix-transform",
5
- async transform(code, id) {
6
- if (id.includes("node_modules") || !/\.(tsx?|jsx?)$/.test(id)) {
7
- return null;
8
- }
9
- const result = transformer(code, id);
10
- if (!result) {
11
- return null;
12
- }
13
- return {
14
- code: result.code,
15
- map: result.map,
16
- };
17
- },
18
- };
19
- }
@@ -1,16 +0,0 @@
1
- import * as t from "@babel/types";
2
- export interface XanixTransformResult {
3
- code: string;
4
- map: any;
5
- }
6
- export declare function resolveFile(file: string): string;
7
- export declare function resolveComponentFile(importer: string, importPath: string): string;
8
- export declare function createPageId(file: string): string;
9
- export declare function getJSXComponentName(node: t.JSXElement): string | null;
10
- export declare function findComponentImport(ast: t.File, componentName: string): {
11
- file: string;
12
- export: string;
13
- declaration: t.ImportDeclaration;
14
- specifier: t.ImportSpecifier | t.ImportDefaultSpecifier;
15
- } | null;
16
- export declare function transformer(code: string, id: string, mode: "watch" | "start"): XanixTransformResult | null;