@zeus-js/vite-plugin 0.0.2

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,119 @@
1
+ /**
2
+ * vite-plugin v0.0.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ //#region \0rolldown/runtime.js
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ //#endregion
32
+ let node_module = require("node:module");
33
+ let node_path = require("node:path");
34
+ node_path = __toESM(node_path, 1);
35
+ let _babel_core = require("@babel/core");
36
+ let _zeus_js_compiler = require("@zeus-js/compiler");
37
+ _zeus_js_compiler = __toESM(_zeus_js_compiler, 1);
38
+ //#region packages/vite-plugin/src/index.ts
39
+ function createZeus(options = {}) {
40
+ var _options$include, _options$exclude;
41
+ const include = normalizePatterns((_options$include = options.include) !== null && _options$include !== void 0 ? _options$include : /\.[tj]sx$/);
42
+ const exclude = normalizePatterns((_options$exclude = options.exclude) !== null && _options$exclude !== void 0 ? _options$exclude : /node_modules/);
43
+ return {
44
+ name: "vite-plugin-zeus",
45
+ enforce: "pre",
46
+ async config(userConfig) {
47
+ const runtimeDomEntry = resolveRuntimeDOMEntry(userConfig.root);
48
+ return {
49
+ ...await isRolldownVite() ? { oxc: { jsx: "preserve" } } : { esbuild: { jsx: "preserve" } },
50
+ resolve: {
51
+ alias: runtimeDomEntry ? { "@zeus-js/runtime-dom": runtimeDomEntry } : void 0,
52
+ dedupe: [
53
+ "@zeus-js/signal",
54
+ "@zeus-js/runtime-dom",
55
+ "@zeus-js/zeus"
56
+ ]
57
+ }
58
+ };
59
+ },
60
+ async transform(code, id) {
61
+ var _options$sourcemap, _options$moduleName, _result$map;
62
+ if (!shouldTransform(id, include, exclude)) return null;
63
+ const result = await (0, _babel_core.transformAsync)(code, {
64
+ filename: id,
65
+ sourceMaps: (_options$sourcemap = options.sourcemap) !== null && _options$sourcemap !== void 0 ? _options$sourcemap : true,
66
+ plugins: [[_zeus_js_compiler.default, {
67
+ moduleName: (_options$moduleName = options.moduleName) !== null && _options$moduleName !== void 0 ? _options$moduleName : "@zeus-js/runtime-dom",
68
+ generate: "dom",
69
+ hydratable: false,
70
+ delegateEvents: true
71
+ }]],
72
+ parserOpts: {
73
+ sourceType: "module",
74
+ plugins: ["typescript", "jsx"]
75
+ },
76
+ generatorOpts: {
77
+ retainLines: false,
78
+ compact: false,
79
+ jsescOption: { minimal: true }
80
+ }
81
+ });
82
+ if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
83
+ return {
84
+ code: result.code,
85
+ map: (_result$map = result.map) !== null && _result$map !== void 0 ? _result$map : null
86
+ };
87
+ }
88
+ };
89
+ }
90
+ function normalizePatterns(value) {
91
+ return Array.isArray(value) ? value : [value];
92
+ }
93
+ function shouldTransform(id, include, exclude) {
94
+ if (exclude.some((pattern) => pattern.test(id))) return false;
95
+ return include.some((pattern) => pattern.test(id));
96
+ }
97
+ async function isRolldownVite() {
98
+ try {
99
+ const vite = await import("vite");
100
+ return typeof vite.rolldownVersion === "string" || typeof vite.transformWithOxc === "function";
101
+ } catch {
102
+ return false;
103
+ }
104
+ }
105
+ function resolveRuntimeDOMEntry(root) {
106
+ const projectRoot = node_path.default.resolve(process.cwd(), root !== null && root !== void 0 ? root : ".");
107
+ const requireFromProject = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
108
+ try {
109
+ return requireFromProject.resolve("@zeus-js/runtime-dom/dist/runtime-dom.esm-bundler.js");
110
+ } catch {}
111
+ try {
112
+ return (0, node_module.createRequire)(requireFromProject.resolve("@zeus-js/zeus")).resolve("@zeus-js/runtime-dom/dist/runtime-dom.esm-bundler.js");
113
+ } catch {
114
+ return;
115
+ }
116
+ }
117
+ //#endregion
118
+ exports.default = createZeus;
119
+ exports.zeus = createZeus;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * vite-plugin v0.0.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ //#region \0rolldown/runtime.js
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ //#endregion
32
+ let node_module = require("node:module");
33
+ let node_path = require("node:path");
34
+ node_path = __toESM(node_path, 1);
35
+ let _babel_core = require("@babel/core");
36
+ let _zeus_js_compiler = require("@zeus-js/compiler");
37
+ _zeus_js_compiler = __toESM(_zeus_js_compiler, 1);
38
+ //#region packages/vite-plugin/src/index.ts
39
+ function createZeus(options = {}) {
40
+ var _options$include, _options$exclude;
41
+ const include = normalizePatterns((_options$include = options.include) !== null && _options$include !== void 0 ? _options$include : /\.[tj]sx$/);
42
+ const exclude = normalizePatterns((_options$exclude = options.exclude) !== null && _options$exclude !== void 0 ? _options$exclude : /node_modules/);
43
+ return {
44
+ name: "vite-plugin-zeus",
45
+ enforce: "pre",
46
+ async config(userConfig) {
47
+ const runtimeDomEntry = resolveRuntimeDOMEntry(userConfig.root);
48
+ return {
49
+ ...await isRolldownVite() ? { oxc: { jsx: "preserve" } } : { esbuild: { jsx: "preserve" } },
50
+ resolve: {
51
+ alias: runtimeDomEntry ? { "@zeus-js/runtime-dom": runtimeDomEntry } : void 0,
52
+ dedupe: [
53
+ "@zeus-js/signal",
54
+ "@zeus-js/runtime-dom",
55
+ "@zeus-js/zeus"
56
+ ]
57
+ }
58
+ };
59
+ },
60
+ async transform(code, id) {
61
+ var _options$sourcemap, _options$moduleName, _result$map;
62
+ if (!shouldTransform(id, include, exclude)) return null;
63
+ const result = await (0, _babel_core.transformAsync)(code, {
64
+ filename: id,
65
+ sourceMaps: (_options$sourcemap = options.sourcemap) !== null && _options$sourcemap !== void 0 ? _options$sourcemap : true,
66
+ plugins: [[_zeus_js_compiler.default, {
67
+ moduleName: (_options$moduleName = options.moduleName) !== null && _options$moduleName !== void 0 ? _options$moduleName : "@zeus-js/runtime-dom",
68
+ generate: "dom",
69
+ hydratable: false,
70
+ delegateEvents: true
71
+ }]],
72
+ parserOpts: {
73
+ sourceType: "module",
74
+ plugins: ["typescript", "jsx"]
75
+ },
76
+ generatorOpts: {
77
+ retainLines: false,
78
+ compact: false,
79
+ jsescOption: { minimal: true }
80
+ }
81
+ });
82
+ if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
83
+ return {
84
+ code: result.code,
85
+ map: (_result$map = result.map) !== null && _result$map !== void 0 ? _result$map : null
86
+ };
87
+ }
88
+ };
89
+ }
90
+ function normalizePatterns(value) {
91
+ return Array.isArray(value) ? value : [value];
92
+ }
93
+ function shouldTransform(id, include, exclude) {
94
+ if (exclude.some((pattern) => pattern.test(id))) return false;
95
+ return include.some((pattern) => pattern.test(id));
96
+ }
97
+ async function isRolldownVite() {
98
+ try {
99
+ const vite = await import("vite");
100
+ return typeof vite.rolldownVersion === "string" || typeof vite.transformWithOxc === "function";
101
+ } catch {
102
+ return false;
103
+ }
104
+ }
105
+ function resolveRuntimeDOMEntry(root) {
106
+ const projectRoot = node_path.default.resolve(process.cwd(), root !== null && root !== void 0 ? root : ".");
107
+ const requireFromProject = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
108
+ try {
109
+ return requireFromProject.resolve("@zeus-js/runtime-dom/dist/runtime-dom.esm-bundler.js");
110
+ } catch {}
111
+ try {
112
+ return (0, node_module.createRequire)(requireFromProject.resolve("@zeus-js/zeus")).resolve("@zeus-js/runtime-dom/dist/runtime-dom.esm-bundler.js");
113
+ } catch {
114
+ return;
115
+ }
116
+ }
117
+ //#endregion
118
+ exports.default = createZeus;
119
+ exports.zeus = createZeus;
@@ -0,0 +1,12 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface ZeusVitePluginOptions {
3
+ include?: RegExp | RegExp[];
4
+ exclude?: RegExp | RegExp[];
5
+ moduleName?: string;
6
+ dev?: boolean;
7
+ sourcemap?: boolean;
8
+ }
9
+ export declare function createZeus(options?: ZeusVitePluginOptions): Plugin;
10
+
11
+ export { createZeus as default, createZeus as zeus };
12
+
@@ -0,0 +1,184 @@
1
+ /**
2
+ * vite-plugin v0.0.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { createRequire } from "node:module";
7
+ import path from "node:path";
8
+ import { transformAsync } from "@babel/core";
9
+ import zeusCompiler from "@zeus-js/compiler";
10
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
11
+ function _typeof(o) {
12
+ "@babel/helpers - typeof";
13
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
14
+ return typeof o;
15
+ } : function(o) {
16
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
17
+ }, _typeof(o);
18
+ }
19
+ //#endregion
20
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
21
+ function toPrimitive(t, r) {
22
+ if ("object" != _typeof(t) || !t) return t;
23
+ var e = t[Symbol.toPrimitive];
24
+ if (void 0 !== e) {
25
+ var i = e.call(t, r || "default");
26
+ if ("object" != _typeof(i)) return i;
27
+ throw new TypeError("@@toPrimitive must return a primitive value.");
28
+ }
29
+ return ("string" === r ? String : Number)(t);
30
+ }
31
+ //#endregion
32
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
33
+ function toPropertyKey(t) {
34
+ var i = toPrimitive(t, "string");
35
+ return "symbol" == _typeof(i) ? i : i + "";
36
+ }
37
+ //#endregion
38
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
39
+ function _defineProperty(e, r, t) {
40
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
+ value: t,
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0
45
+ }) : e[r] = t, e;
46
+ }
47
+ //#endregion
48
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
49
+ function ownKeys(e, r) {
50
+ var t = Object.keys(e);
51
+ if (Object.getOwnPropertySymbols) {
52
+ var o = Object.getOwnPropertySymbols(e);
53
+ r && (o = o.filter(function(r) {
54
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
55
+ })), t.push.apply(t, o);
56
+ }
57
+ return t;
58
+ }
59
+ function _objectSpread2(e) {
60
+ for (var r = 1; r < arguments.length; r++) {
61
+ var t = null != arguments[r] ? arguments[r] : {};
62
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
63
+ _defineProperty(e, r, t[r]);
64
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
65
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
66
+ });
67
+ }
68
+ return e;
69
+ }
70
+ //#endregion
71
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/asyncToGenerator.js
72
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
73
+ try {
74
+ var i = n[a](c), u = i.value;
75
+ } catch (n) {
76
+ e(n);
77
+ return;
78
+ }
79
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
80
+ }
81
+ function _asyncToGenerator(n) {
82
+ return function() {
83
+ var t = this, e = arguments;
84
+ return new Promise(function(r, o) {
85
+ var a = n.apply(t, e);
86
+ function _next(n) {
87
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
88
+ }
89
+ function _throw(n) {
90
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
91
+ }
92
+ _next(void 0);
93
+ });
94
+ };
95
+ }
96
+ //#endregion
97
+ //#region packages/vite-plugin/src/index.ts
98
+ function createZeus(options = {}) {
99
+ var _options$include, _options$exclude;
100
+ const include = normalizePatterns((_options$include = options.include) !== null && _options$include !== void 0 ? _options$include : /\.[tj]sx$/);
101
+ const exclude = normalizePatterns((_options$exclude = options.exclude) !== null && _options$exclude !== void 0 ? _options$exclude : /node_modules/);
102
+ return {
103
+ name: "vite-plugin-zeus",
104
+ enforce: "pre",
105
+ config(userConfig) {
106
+ return _asyncToGenerator(function* () {
107
+ const runtimeDomEntry = resolveRuntimeDOMEntry(userConfig.root);
108
+ return _objectSpread2(_objectSpread2({}, (yield isRolldownVite()) ? { oxc: { jsx: "preserve" } } : { esbuild: { jsx: "preserve" } }), {}, { resolve: {
109
+ alias: runtimeDomEntry ? { "@zeus-js/runtime-dom": runtimeDomEntry } : void 0,
110
+ dedupe: [
111
+ "@zeus-js/signal",
112
+ "@zeus-js/runtime-dom",
113
+ "@zeus-js/zeus"
114
+ ]
115
+ } });
116
+ })();
117
+ },
118
+ transform(code, id) {
119
+ return _asyncToGenerator(function* () {
120
+ var _options$sourcemap, _options$moduleName, _result$map;
121
+ if (!shouldTransform(id, include, exclude)) return null;
122
+ const result = yield transformAsync(code, {
123
+ filename: id,
124
+ sourceMaps: (_options$sourcemap = options.sourcemap) !== null && _options$sourcemap !== void 0 ? _options$sourcemap : true,
125
+ plugins: [[zeusCompiler, {
126
+ moduleName: (_options$moduleName = options.moduleName) !== null && _options$moduleName !== void 0 ? _options$moduleName : "@zeus-js/runtime-dom",
127
+ generate: "dom",
128
+ hydratable: false,
129
+ delegateEvents: true
130
+ }]],
131
+ parserOpts: {
132
+ sourceType: "module",
133
+ plugins: ["typescript", "jsx"]
134
+ },
135
+ generatorOpts: {
136
+ retainLines: false,
137
+ compact: false,
138
+ jsescOption: { minimal: true }
139
+ }
140
+ });
141
+ if (!(result === null || result === void 0 ? void 0 : result.code)) return null;
142
+ return {
143
+ code: result.code,
144
+ map: (_result$map = result.map) !== null && _result$map !== void 0 ? _result$map : null
145
+ };
146
+ })();
147
+ }
148
+ };
149
+ }
150
+ function normalizePatterns(value) {
151
+ return Array.isArray(value) ? value : [value];
152
+ }
153
+ function shouldTransform(id, include, exclude) {
154
+ if (exclude.some((pattern) => pattern.test(id))) return false;
155
+ return include.some((pattern) => pattern.test(id));
156
+ }
157
+ function isRolldownVite() {
158
+ return _isRolldownVite.apply(this, arguments);
159
+ }
160
+ function _isRolldownVite() {
161
+ _isRolldownVite = _asyncToGenerator(function* () {
162
+ try {
163
+ const vite = yield import("vite");
164
+ return typeof vite.rolldownVersion === "string" || typeof vite.transformWithOxc === "function";
165
+ } catch (_unused) {
166
+ return false;
167
+ }
168
+ });
169
+ return _isRolldownVite.apply(this, arguments);
170
+ }
171
+ function resolveRuntimeDOMEntry(root) {
172
+ const projectRoot = path.resolve(process.cwd(), root !== null && root !== void 0 ? root : ".");
173
+ const requireFromProject = createRequire(path.join(projectRoot, "package.json"));
174
+ try {
175
+ return requireFromProject.resolve("@zeus-js/runtime-dom/dist/runtime-dom.esm-bundler.js");
176
+ } catch (_unused2) {}
177
+ try {
178
+ return createRequire(requireFromProject.resolve("@zeus-js/zeus")).resolve("@zeus-js/runtime-dom/dist/runtime-dom.esm-bundler.js");
179
+ } catch (_unused3) {
180
+ return;
181
+ }
182
+ }
183
+ //#endregion
184
+ export { createZeus as default, createZeus as zeus };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@zeus-js/vite-plugin",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "description": "Vite plugin for Zeus",
6
+ "main": "index.cjs",
7
+ "module": "dist/vite-plugin.esm-bundler.js",
8
+ "types": "dist/vite-plugin.d.ts",
9
+ "files": [
10
+ "index.cjs",
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/vite-plugin.d.ts",
16
+ "import": "./dist/vite-plugin.esm-bundler.js",
17
+ "require": {
18
+ "types": "./dist/vite-plugin.d.ts",
19
+ "default": "./dist/vite-plugin.cjs.js"
20
+ },
21
+ "default": "./dist/vite-plugin.esm-bundler.js"
22
+ }
23
+ },
24
+ "sideEffects": false,
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/baicie/zeus.git",
28
+ "directory": "packages/vite-plugin"
29
+ },
30
+ "buildOptions": {
31
+ "name": "ZeusVitePlugin",
32
+ "formats": [
33
+ "esm-bundler",
34
+ "cjs"
35
+ ]
36
+ },
37
+ "keywords": [
38
+ "zeus",
39
+ "vite",
40
+ "jsx"
41
+ ],
42
+ "author": "Baicie",
43
+ "license": "MIT",
44
+ "bugs": {
45
+ "url": "https://github.com/baicie/zeus/issues"
46
+ },
47
+ "homepage": "https://github.com/baicie/zeus/tree/main/packages/vite-plugin#readme",
48
+ "dependencies": {
49
+ "@babel/core": "^7.29.0",
50
+ "@zeus-js/compiler": "0.0.2"
51
+ },
52
+ "peerDependencies": {
53
+ "vite": "^8.0.5"
54
+ },
55
+ "devDependencies": {
56
+ "@types/babel__core": "7.20.5"
57
+ }
58
+ }