xanix 1.0.5 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/bundler/buildClient.js +3 -3
- package/dist/bin/bundler/buildServer.js +2 -3
- package/dist/bin/bundler/{buildCache.js → cacheNpmModules copy.js } +71 -21
- package/dist/bin/bundler/cacheNpmModules.js +9 -5
- package/dist/bin/bundler/config/output.js +9 -1
- package/dist/bin/bundler/plugins/XanixDocument/index.d.ts +2 -0
- package/dist/bin/bundler/plugins/XanixDocument/index.js +35 -0
- package/dist/bin/bundler/plugins/XanixEnv.js +10 -3
- package/dist/bin/bundler/plugins/XanixReactRefresh.js +29 -36
- package/dist/bin/bundler/plugins/XanixTransform/transformer copy.d.ts +16 -0
- package/dist/bin/bundler/plugins/XanixTransform/transformer copy.js +631 -0
- package/dist/bin/bundler/plugins/plugins.js +3 -1
- package/dist/bin/bundler/watchClient.js +3 -3
- package/dist/bin/bundler/watchServer.js +2 -3
- package/dist/bin/include/utils.d.ts +2 -1
- package/dist/bin/include/utils.js +9 -6
- package/dist/bin/index.js +0 -0
- package/dist/client-runtime.js +15 -15
- package/dist/components/BaseDocument.d.ts +1 -1
- package/dist/components/BaseDocument.js +1 -3
- package/dist/components/Body.js +3 -1
- package/dist/components/Document.js +3 -1
- package/dist/components/Head.d.ts +1 -1
- package/dist/components/Head.js +37 -34
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.js +23 -18
- package/dist/dataLoader.d.ts +1 -1
- package/dist/dataLoader.js +11 -5
- package/dist/hooks/useData.d.ts +2 -6
- package/dist/hooks/useData.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/navigate.js +11 -8
- package/dist/server/runtime/xanixPage.js +1 -4
- package/dist/types/assets.d.ts +34 -0
- package/dist/types/express.d.ts +12 -0
- package/dist/types/globals.d.ts +26 -0
- package/dist/types/xanix-virtual.d.ts +26 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +4 -0
- package/package.json +79 -73
- package/dist/BaseDocument.d.ts +0 -3
- package/dist/BaseDocument.js +0 -8
- package/dist/bin/bundler/plugins/XanixAssets/index.d.ts +0 -4
- package/dist/bin/bundler/plugins/XanixAssets/index.js +0 -22
- package/dist/bin/bundler/plugins/XanixBrowserCodeRemover.d.ts +0 -6
- package/dist/bin/bundler/plugins/XanixBrowserCodeRemover.js +0 -350
- package/dist/bin/bundler/plugins/XanixHydrate.d.ts +0 -3
- package/dist/bin/bundler/plugins/XanixHydrate.js +0 -34
- package/dist/bin/bundler/plugins/commonjs.d.ts +0 -3
- package/dist/bin/bundler/plugins/commonjs.js +0 -10
- package/dist/bin/bundler/plugins/dep-XanixWatchChange.d.ts +0 -9
- package/dist/bin/bundler/plugins/dep-XanixWatchChange.js +0 -27
- package/dist/bin/bundler/plugins/nodeResolve.d.ts +0 -3
- package/dist/bin/bundler/plugins/nodeResolve.js +0 -10
- package/dist/bin/bundler/plugins/rollupEsbuild.d.ts +0 -3
- package/dist/bin/bundler/plugins/rollupEsbuild.js +0 -14
- package/dist/bin/cli/start copy.d.ts +0 -2
- package/dist/bin/cli/start copy.js +0 -34
- package/dist/client/client-runtime.d.ts +0 -10
- package/dist/client/client-runtime.js +0 -98
- package/dist/client/context/RouteContext.d.ts +0 -8
- package/dist/client/context/RouteContext.js +0 -16
- package/dist/client/hooks/usePageProps.d.ts +0 -1
- package/dist/client/hooks/usePageProps.js +0 -2
- package/dist/client/hooks/useRoute.d.ts +0 -1
- package/dist/client/hooks/useRoute.js +0 -2
- package/dist/client/hooks/useSearchParams.d.ts +0 -1
- package/dist/client/hooks/useSearchParams.js +0 -2
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.js +0 -2
- package/dist/client/navigation.d.ts +0 -3
- package/dist/client/navigation.js +0 -27
- package/dist/client/runtime.d.ts +0 -10
- package/dist/client/runtime.js +0 -98
- package/dist/components/Document/context.d.ts +0 -11
- package/dist/components/Document/context.js +0 -14
- package/dist/components/Document/index.d.ts +0 -8
- package/dist/components/Document/index.js +0 -6
- package/dist/document/BaseDocument.d.ts +0 -3
- package/dist/document/BaseDocument.js +0 -8
- package/dist/document/Body.d.ts +0 -5
- package/dist/document/Body.js +0 -8
- package/dist/document/Document.d.ts +0 -7
- package/dist/document/Document.js +0 -9
- package/dist/document/DocumentContext.d.ts +0 -18
- package/dist/document/DocumentContext.js +0 -6
- package/dist/document/Head.d.ts +0 -5
- package/dist/document/Head.js +0 -41
- package/dist/document/Link.d.ts +0 -7
- package/dist/document/Link.js +0 -28
- package/dist/document/Script.d.ts +0 -3
- package/dist/document/Script.js +0 -5
- package/dist/document/index.d.ts +0 -8
- package/dist/document/index.js +0 -7
- package/dist/document/useDocument.d.ts +0 -2
- package/dist/document/useDocument.js +0 -10
- package/dist/hooks/useCookie.d.ts +0 -2
- package/dist/hooks/useCookie.js +0 -13
- package/dist/hooks/useRequest copy.d.ts +0 -2
- package/dist/hooks/useRequest copy.js +0 -8
- package/dist/navigation/index.d.ts +0 -2
- package/dist/navigation/index.js +0 -2
- package/dist/navigation/navigate.d.ts +0 -7
- package/dist/navigation/navigate.js +0 -31
- package/dist/navigation/useLocation.d.ts +0 -1
- package/dist/navigation/useLocation.js +0 -22
- package/dist/router/index.d.ts +0 -3
- package/dist/router/index.js +0 -3
- package/dist/router/useParams.d.ts +0 -1
- package/dist/router/useParams.js +0 -5
- package/dist/router/usePathname.d.ts +0 -1
- package/dist/router/usePathname.js +0 -8
- package/dist/router/useSearchParams.d.ts +0 -11
- package/dist/router/useSearchParams.js +0 -74
- package/dist/runtime/createServer.d.ts +0 -12
- package/dist/runtime/createServer.js +0 -40
- package/dist/runtime/index.d.ts +0 -12
- package/dist/runtime/index.js +0 -40
- package/dist/runtime/readManifest.d.ts +0 -14
- package/dist/runtime/readManifest.js +0 -8
- package/dist/runtime/xanixPage.d.ts +0 -9
- package/dist/runtime/xanixPage.js +0 -62
- package/dist/server/createServer.d.ts +0 -12
- package/dist/server/createServer.js +0 -40
- package/dist/server/page.d.ts +0 -9
- package/dist/server/page.js +0 -62
- package/dist/server/readManifest.d.ts +0 -14
- package/dist/server/readManifest.js +0 -8
- package/dist/server/runtime copy.d.ts +0 -12
- package/dist/server/runtime copy.js +0 -40
- package/dist/server/runtime.d.ts +0 -12
- package/dist/server/runtime.js +0 -40
- package/dist/server/xanixPage.d.ts +0 -9
- package/dist/server/xanixPage.js +0 -62
- package/dist/types.d.ts +0 -12
- package/dist/types.js +0 -7
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/index.js +0 -1
- package/dist/xanix.d.ts +0 -3
- package/dist/xanix.js +0 -40
- package/xanix-env.d.ts +0 -79
- /package/dist/bin/bundler/{buildCache.d.ts → cacheNpmModules copy.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,73 +1,79 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xanix",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"bin": "./dist/bin/index.js",
|
|
9
|
-
"type": "module",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"@babel/
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@rollup/plugin-
|
|
45
|
-
"@rollup/plugin-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"@types/
|
|
65
|
-
"@types/
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"react": "^19.2.
|
|
70
|
-
"react-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "xanix",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": "./dist/bin/index.js",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./page": {
|
|
19
|
+
"import": "./dist/server/page.js",
|
|
20
|
+
"require": "./dist/server/page.js"
|
|
21
|
+
},
|
|
22
|
+
"./runtime": {
|
|
23
|
+
"import": "./dist/server/runtime/index.js",
|
|
24
|
+
"require": "./dist/server/runtime/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./BaseDocument": {
|
|
27
|
+
"types": "./dist/components/BaseDocument.d.ts",
|
|
28
|
+
"import": "./dist/components/BaseDocument.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "tsc --watch --preserveWatchOutput",
|
|
33
|
+
"build": "tsc && node scripts/build-types.js"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [],
|
|
36
|
+
"author": "Naxrul Ahmed",
|
|
37
|
+
"license": "ISC",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@babel/generator": "^8.0.0",
|
|
40
|
+
"@babel/parser": "^8.0.4",
|
|
41
|
+
"@babel/preset-react": "^8.0.1",
|
|
42
|
+
"@babel/preset-typescript": "^8.0.1",
|
|
43
|
+
"@babel/traverse": "^8.0.4",
|
|
44
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
45
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
46
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
47
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
48
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
49
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
50
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
51
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
52
|
+
"commander": "^15.0.0",
|
|
53
|
+
"dotenv": "^17.4.2",
|
|
54
|
+
"esbuild": "^0.28.2",
|
|
55
|
+
"express": "^5.2.1",
|
|
56
|
+
"picocolors": "^1.1.1",
|
|
57
|
+
"react-refresh": "^0.18.0",
|
|
58
|
+
"rollup": "^4.62.5",
|
|
59
|
+
"rollup-plugin-esbuild": "^6.2.1",
|
|
60
|
+
"tslib": "^2.8.1",
|
|
61
|
+
"ws": "^8.21.3"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/babel__core": "^7.20.5",
|
|
65
|
+
"@types/express": "^5.0.6",
|
|
66
|
+
"@types/node": "^26.2.0",
|
|
67
|
+
"@types/prompts": "^2.4.9",
|
|
68
|
+
"@types/react": "^19.2.17",
|
|
69
|
+
"@types/react-dom": "^19.2.3",
|
|
70
|
+
"@types/react-refresh": "^0.14.7",
|
|
71
|
+
"@types/ws": "^8.18.1",
|
|
72
|
+
"@xanui/core": "^1.3.38",
|
|
73
|
+
"@xanui/icons": "^1.1.14",
|
|
74
|
+
"@xanui/ui": "^1.2.24",
|
|
75
|
+
"react": "^19.2.8",
|
|
76
|
+
"react-dom": "^19.2.8",
|
|
77
|
+
"typescript": "^5.9.3"
|
|
78
|
+
}
|
|
79
|
+
}
|
package/dist/BaseDocument.d.ts
DELETED
package/dist/BaseDocument.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Head from "./components/Head.js";
|
|
3
|
-
import Body from "./components/Body.js";
|
|
4
|
-
import Document from "./components/Document/index.js";
|
|
5
|
-
const BaseDocument = ({ document, children }) => {
|
|
6
|
-
return (_jsxs(Document, { document: document, children: [_jsxs(Head, { children: [_jsx("meta", { charSet: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" })] }), _jsx(Body, { children: children })] }));
|
|
7
|
-
};
|
|
8
|
-
export default BaseDocument;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import url from "@rollup/plugin-url";
|
|
2
|
-
const xanixAssets = (options) => {
|
|
3
|
-
return url({
|
|
4
|
-
include: [
|
|
5
|
-
"**/*.jpg",
|
|
6
|
-
"**/*.jpeg",
|
|
7
|
-
"**/*.png",
|
|
8
|
-
"**/*.gif",
|
|
9
|
-
"**/*.webp",
|
|
10
|
-
"**/*.svg",
|
|
11
|
-
"**/*.ico",
|
|
12
|
-
"**/*.woff",
|
|
13
|
-
"**/*.woff2",
|
|
14
|
-
"**/*.ttf",
|
|
15
|
-
"**/*.eot",
|
|
16
|
-
],
|
|
17
|
-
limit: 0,
|
|
18
|
-
fileName: "assets/[name]-[hash][extname]",
|
|
19
|
-
emitFiles: !(options?.external ?? false),
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
export default xanixAssets;
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { parse } from "@babel/parser";
|
|
2
|
-
import traverse from "@babel/traverse";
|
|
3
|
-
import generate from "@babel/generator";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
const DEFAULT_BROWSER_GLOBALS = [
|
|
6
|
-
"window",
|
|
7
|
-
"document",
|
|
8
|
-
"localStorage",
|
|
9
|
-
"sessionStorage",
|
|
10
|
-
"navigator",
|
|
11
|
-
"location",
|
|
12
|
-
"history",
|
|
13
|
-
"screen",
|
|
14
|
-
"indexedDB",
|
|
15
|
-
"caches",
|
|
16
|
-
"WebSocket",
|
|
17
|
-
"File",
|
|
18
|
-
"FileReader",
|
|
19
|
-
"Blob",
|
|
20
|
-
"FormData",
|
|
21
|
-
"EventSource",
|
|
22
|
-
"Worker",
|
|
23
|
-
"SharedWorker",
|
|
24
|
-
"IntersectionObserver",
|
|
25
|
-
"ResizeObserver",
|
|
26
|
-
"MutationObserver",
|
|
27
|
-
"PerformanceObserver",
|
|
28
|
-
"Notification",
|
|
29
|
-
"BroadcastChannel",
|
|
30
|
-
"MessageChannel",
|
|
31
|
-
"MessageEvent",
|
|
32
|
-
"URL",
|
|
33
|
-
"URLSearchParams",
|
|
34
|
-
"MediaSource",
|
|
35
|
-
"MediaRecorder",
|
|
36
|
-
"Audio",
|
|
37
|
-
"Image",
|
|
38
|
-
"HTMLImageElement",
|
|
39
|
-
];
|
|
40
|
-
export default function xanixBrowserCodeRemover(options = {}) {
|
|
41
|
-
const { target = "server", globals = DEFAULT_BROWSER_GLOBALS } = options;
|
|
42
|
-
const browserGlobals = new Set(globals);
|
|
43
|
-
return {
|
|
44
|
-
name: "xanix-browser-code-remover",
|
|
45
|
-
transform(code, id) {
|
|
46
|
-
if (target !== "server") {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
if (id.includes("/node_modules/") || id.includes("\\node_modules\\")) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
if (!/\.(?:[cm]?[jt]sx?)$/.test(id)) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
const ast = parse(code, {
|
|
56
|
-
sourceType: "module",
|
|
57
|
-
plugins: [
|
|
58
|
-
"jsx",
|
|
59
|
-
"typescript",
|
|
60
|
-
// "decorators-legacy",
|
|
61
|
-
// "classProperties",
|
|
62
|
-
// "classPrivateProperties",
|
|
63
|
-
// "classPrivateMethods",
|
|
64
|
-
// "optionalChaining",
|
|
65
|
-
// "nullishCoalescingOperator",
|
|
66
|
-
// "dynamicImport",
|
|
67
|
-
// "topLevelAwait",
|
|
68
|
-
],
|
|
69
|
-
});
|
|
70
|
-
const removePaths = new Set();
|
|
71
|
-
const replacePaths = new Set();
|
|
72
|
-
function isBrowserGlobal(path) {
|
|
73
|
-
const name = path.node.name;
|
|
74
|
-
if (!browserGlobals.has(name)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (!path.isReferencedIdentifier()) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
// Don't transform locally declared variables.
|
|
81
|
-
if (path.scope.getBinding(name)) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
function containsBrowserGlobal(path) {
|
|
87
|
-
let found = false;
|
|
88
|
-
path.traverse({
|
|
89
|
-
Identifier(innerPath) {
|
|
90
|
-
if (found) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (isBrowserGlobal(innerPath)) {
|
|
94
|
-
found = true;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
return found;
|
|
99
|
-
}
|
|
100
|
-
function getBrowserExpression(path) {
|
|
101
|
-
let current = path;
|
|
102
|
-
while (current.parentPath) {
|
|
103
|
-
const parent = current.parentPath;
|
|
104
|
-
/*
|
|
105
|
-
* window.foo
|
|
106
|
-
* window.foo.bar
|
|
107
|
-
* window["foo"]
|
|
108
|
-
*/
|
|
109
|
-
if (parent.isMemberExpression() ||
|
|
110
|
-
parent.isOptionalMemberExpression()) {
|
|
111
|
-
current = parent;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
/*
|
|
115
|
-
* window.foo()
|
|
116
|
-
* window.foo.bar()
|
|
117
|
-
*/
|
|
118
|
-
if (parent.isCallExpression() || parent.isOptionalCallExpression()) {
|
|
119
|
-
const callee = parent.get("callee");
|
|
120
|
-
if (!Array.isArray(callee) && callee.node === current.node) {
|
|
121
|
-
current = parent;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
/*
|
|
127
|
-
* window.foo!
|
|
128
|
-
*/
|
|
129
|
-
if (parent.isTSNonNullExpression()) {
|
|
130
|
-
current = parent;
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
/*
|
|
134
|
-
* window.foo as Something
|
|
135
|
-
*/
|
|
136
|
-
if (parent.isTSAsExpression()) {
|
|
137
|
-
current = parent;
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
return current;
|
|
143
|
-
}
|
|
144
|
-
function findContainingStatement(path) {
|
|
145
|
-
let current = path;
|
|
146
|
-
while (current.parentPath) {
|
|
147
|
-
const parent = current.parentPath;
|
|
148
|
-
if (parent.isExpressionStatement()) {
|
|
149
|
-
return parent;
|
|
150
|
-
}
|
|
151
|
-
if (parent.isFunctionDeclaration() ||
|
|
152
|
-
parent.isFunctionExpression() ||
|
|
153
|
-
parent.isArrowFunctionExpression()) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
current = parent;
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
function markRemove(path) {
|
|
161
|
-
if (!path.removed) {
|
|
162
|
-
removePaths.add(path);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function markReplace(path) {
|
|
166
|
-
if (!path.removed) {
|
|
167
|
-
replacePaths.add(path);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
traverse(ast, {
|
|
171
|
-
/*
|
|
172
|
-
* ---------------------------------------------------------
|
|
173
|
-
* JSX
|
|
174
|
-
*
|
|
175
|
-
* <div>{window.innerWidth}</div>
|
|
176
|
-
*
|
|
177
|
-
* ->
|
|
178
|
-
*
|
|
179
|
-
* <div>{undefined}</div>
|
|
180
|
-
* ---------------------------------------------------------
|
|
181
|
-
*/
|
|
182
|
-
JSXExpressionContainer(path) {
|
|
183
|
-
const expression = path.get("expression");
|
|
184
|
-
if (!expression || Array.isArray(expression)) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (expression.isJSXEmptyExpression()) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (!expression.isExpression()) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (!containsBrowserGlobal(expression)) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
markReplace(expression);
|
|
197
|
-
},
|
|
198
|
-
/*
|
|
199
|
-
* ---------------------------------------------------------
|
|
200
|
-
* Standalone browser statements
|
|
201
|
-
*
|
|
202
|
-
* window.addEventListener(...)
|
|
203
|
-
* document.title = "Xanix"
|
|
204
|
-
* localStorage.setItem(...)
|
|
205
|
-
*
|
|
206
|
-
* ->
|
|
207
|
-
*
|
|
208
|
-
* removed
|
|
209
|
-
* ---------------------------------------------------------
|
|
210
|
-
*/
|
|
211
|
-
ExpressionStatement(path) {
|
|
212
|
-
if (!containsBrowserGlobal(path)) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
markRemove(path);
|
|
216
|
-
},
|
|
217
|
-
/*
|
|
218
|
-
* ---------------------------------------------------------
|
|
219
|
-
* Variable declarations
|
|
220
|
-
*
|
|
221
|
-
* const width = window.innerWidth;
|
|
222
|
-
*
|
|
223
|
-
* ->
|
|
224
|
-
*
|
|
225
|
-
* const width = undefined;
|
|
226
|
-
* ---------------------------------------------------------
|
|
227
|
-
*/
|
|
228
|
-
VariableDeclarator(path) {
|
|
229
|
-
const init = path.get("init");
|
|
230
|
-
if (!init || Array.isArray(init)) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
if (!init.isExpression()) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (!containsBrowserGlobal(init)) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
markReplace(init);
|
|
240
|
-
},
|
|
241
|
-
/*
|
|
242
|
-
* ---------------------------------------------------------
|
|
243
|
-
* Return
|
|
244
|
-
*
|
|
245
|
-
* return window.innerWidth;
|
|
246
|
-
*
|
|
247
|
-
* ->
|
|
248
|
-
*
|
|
249
|
-
* return undefined;
|
|
250
|
-
* ---------------------------------------------------------
|
|
251
|
-
*/
|
|
252
|
-
ReturnStatement(path) {
|
|
253
|
-
const argument = path.get("argument");
|
|
254
|
-
if (!argument || Array.isArray(argument)) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (!argument.isExpression()) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (!containsBrowserGlobal(argument)) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
markReplace(argument);
|
|
264
|
-
},
|
|
265
|
-
/*
|
|
266
|
-
* ---------------------------------------------------------
|
|
267
|
-
* Identifier
|
|
268
|
-
* ---------------------------------------------------------
|
|
269
|
-
*/
|
|
270
|
-
Identifier(path) {
|
|
271
|
-
if (!isBrowserGlobal(path)) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const browserExpression = getBrowserExpression(path);
|
|
275
|
-
/*
|
|
276
|
-
* JSXExpressionContainer is handled above.
|
|
277
|
-
*/
|
|
278
|
-
if (browserExpression.parentPath?.isJSXExpressionContainer()) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
/*
|
|
282
|
-
* Example:
|
|
283
|
-
*
|
|
284
|
-
* window.addEventListener(...)
|
|
285
|
-
*
|
|
286
|
-
* Remove the complete statement.
|
|
287
|
-
*/
|
|
288
|
-
const statement = findContainingStatement(browserExpression);
|
|
289
|
-
if (statement) {
|
|
290
|
-
markRemove(statement);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const parent = browserExpression.parentPath;
|
|
294
|
-
/*
|
|
295
|
-
* Variable initializer:
|
|
296
|
-
*
|
|
297
|
-
* const x = window.foo;
|
|
298
|
-
*/
|
|
299
|
-
if (parent?.isVariableDeclarator()) {
|
|
300
|
-
markReplace(browserExpression);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
/*
|
|
304
|
-
* Return:
|
|
305
|
-
*
|
|
306
|
-
* return window.foo;
|
|
307
|
-
*/
|
|
308
|
-
if (parent?.isReturnStatement()) {
|
|
309
|
-
markReplace(browserExpression);
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
/*
|
|
313
|
-
* General expression:
|
|
314
|
-
*
|
|
315
|
-
* console.log(window.innerWidth)
|
|
316
|
-
*
|
|
317
|
-
* ->
|
|
318
|
-
*
|
|
319
|
-
* console.log(undefined)
|
|
320
|
-
*/
|
|
321
|
-
markReplace(browserExpression);
|
|
322
|
-
},
|
|
323
|
-
});
|
|
324
|
-
/*
|
|
325
|
-
* Remove first.
|
|
326
|
-
*/
|
|
327
|
-
for (const path of removePaths) {
|
|
328
|
-
if (!path.removed) {
|
|
329
|
-
path.remove();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
/*
|
|
333
|
-
* Replace second.
|
|
334
|
-
*/
|
|
335
|
-
for (const path of replacePaths) {
|
|
336
|
-
if (!path.removed) {
|
|
337
|
-
path.replaceWith(t.identifier("undefined"));
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
const output = generate(ast, {
|
|
341
|
-
sourceMaps: true,
|
|
342
|
-
sourceFileName: id,
|
|
343
|
-
}, code);
|
|
344
|
-
return {
|
|
345
|
-
code: output.code,
|
|
346
|
-
map: output.map,
|
|
347
|
-
};
|
|
348
|
-
},
|
|
349
|
-
};
|
|
350
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export default function xanixHydrate(entries) {
|
|
2
|
-
const entryNames = new Set(entries.map((entry) => entry.name));
|
|
3
|
-
return {
|
|
4
|
-
name: "xanix-hydrate",
|
|
5
|
-
renderChunk(code, chunk) {
|
|
6
|
-
// Only process the entries we explicitly provided.
|
|
7
|
-
if (!chunk.isEntry || !entryNames.has(chunk.name)) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
// Must have a default export.
|
|
11
|
-
if (!chunk.exports.includes("default")) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
// Find Rollup's generated default export variable.
|
|
15
|
-
const match = code.match(/export\s*\{\s*([^,\s]+)\s+as\s+default\s*\}/);
|
|
16
|
-
if (!match) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const component = match[1];
|
|
20
|
-
const hydration = `\nwindow.xanix.hydrate(` +
|
|
21
|
-
`${component}, ` +
|
|
22
|
-
`window.PAGE_PROPS` +
|
|
23
|
-
`);\n`;
|
|
24
|
-
const exportIndex = code.lastIndexOf("export {");
|
|
25
|
-
if (exportIndex === -1) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
code: code.slice(0, exportIndex) + hydration + code.slice(exportIndex),
|
|
30
|
-
map: null,
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "rollup";
|
|
2
|
-
import { XanixClientEntry } from "../../types";
|
|
3
|
-
export type XanixWatchChangeOptions = {
|
|
4
|
-
onClientEntryChange?: (entry: string, entries: XanixClientEntry[]) => Promise<void>;
|
|
5
|
-
onServerChange?: (entry: string, entries: XanixClientEntry[]) => Promise<void>;
|
|
6
|
-
onChange?: (entry: string, event: "update" | "delete" | "create" | undefined) => void;
|
|
7
|
-
};
|
|
8
|
-
declare const XanixWatchChange: (entries: XanixClientEntry[], options: XanixWatchChangeOptions) => Plugin;
|
|
9
|
-
export default XanixWatchChange;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { createManifest, readManifest } from "../../include/manifest.js";
|
|
3
|
-
import generateClientEntries from "../generateClientEntries.js";
|
|
4
|
-
import { entriesEqual } from "../../include/entry.js";
|
|
5
|
-
const XanixWatchChange = (entries, options) => {
|
|
6
|
-
return {
|
|
7
|
-
name: "xanix-watch-server",
|
|
8
|
-
async watchChange(id, change) {
|
|
9
|
-
const entry = path.resolve(id).replaceAll("\\", "/");
|
|
10
|
-
const manifest = await readManifest();
|
|
11
|
-
if (!manifest)
|
|
12
|
-
return;
|
|
13
|
-
const isClientEntry = Array.from(manifest.entries.values()).find((e) => e.file === entry);
|
|
14
|
-
if (!isClientEntry) {
|
|
15
|
-
const entries = await generateClientEntries();
|
|
16
|
-
const isEqual = await entriesEqual(entries);
|
|
17
|
-
if (!isEqual) {
|
|
18
|
-
await createManifest(entries);
|
|
19
|
-
await options.onClientEntryChange?.(entry, entries);
|
|
20
|
-
}
|
|
21
|
-
await options.onServerChange?.(entry, entries);
|
|
22
|
-
}
|
|
23
|
-
options.onChange?.(entry, change?.event);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export default XanixWatchChange;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
2
|
-
const rollupNodeResolve = (browser = true, options) => {
|
|
3
|
-
return nodeResolve({
|
|
4
|
-
extensions: [".mjs", ".js", ".json", ".node", ".ts", ".tsx", ".jsx"],
|
|
5
|
-
browser: browser,
|
|
6
|
-
preferBuiltins: !browser,
|
|
7
|
-
...options,
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export default rollupNodeResolve;
|