@ethereal-nexus/vite-plugin-ethereal-nexus 0.3.3 → 0.3.4
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/client/index.d.mts +9 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +190 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +152 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +16 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +408 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +405 -5
- package/dist/index.mjs.map +1 -1
- package/dist/manifest/index.d.mts +7 -0
- package/dist/manifest/index.d.ts +7 -0
- package/dist/manifest/index.js +161 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/index.mjs +124 -0
- package/dist/manifest/index.mjs.map +1 -0
- package/dist/options/index.d.mts +7 -0
- package/dist/options/index.d.ts +7 -0
- package/dist/options/index.js +55 -0
- package/dist/options/index.js.map +1 -0
- package/dist/options/index.mjs +20 -0
- package/dist/options/index.mjs.map +1 -0
- package/dist/server/index.d.mts +5 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +127 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +92 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/types.d.mts +32 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.d.mts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +63 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +25 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/virtual.d.mts +4 -0
- package/dist/virtual.d.ts +4 -0
- package/dist/virtual.js +39 -0
- package/dist/virtual.js.map +1 -0
- package/dist/virtual.mjs +13 -0
- package/dist/virtual.mjs.map +1 -0
- package/package.json +24 -14
- package/LICENSE.md +0 -201
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProgramNode, EmitFile, OutputBundle, RenderedChunk, ParseAst } from 'rollup';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
|
|
4
|
+
declare function createClientCode(code: string, name: string, id: string, ast: ProgramNode): MagicString;
|
|
5
|
+
declare function bundleClient(code: string, exposed: Map<string, string>, id: string, ast: ProgramNode, name: string, emitFile: EmitFile): void;
|
|
6
|
+
declare function copyChunkFiles(bundle: OutputBundle): void;
|
|
7
|
+
declare function adjustChunkImport(chunk: RenderedChunk, code: string, parse: ParseAst): string | null;
|
|
8
|
+
|
|
9
|
+
export { adjustChunkImport, bundleClient, copyChunkFiles, createClientCode };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProgramNode, EmitFile, OutputBundle, RenderedChunk, ParseAst } from 'rollup';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
|
|
4
|
+
declare function createClientCode(code: string, name: string, id: string, ast: ProgramNode): MagicString;
|
|
5
|
+
declare function bundleClient(code: string, exposed: Map<string, string>, id: string, ast: ProgramNode, name: string, emitFile: EmitFile): void;
|
|
6
|
+
declare function copyChunkFiles(bundle: OutputBundle): void;
|
|
7
|
+
declare function adjustChunkImport(chunk: RenderedChunk, code: string, parse: ParseAst): string | null;
|
|
8
|
+
|
|
9
|
+
export { adjustChunkImport, bundleClient, copyChunkFiles, createClientCode };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/client/index.ts
|
|
31
|
+
var client_exports = {};
|
|
32
|
+
__export(client_exports, {
|
|
33
|
+
adjustChunkImport: () => adjustChunkImport,
|
|
34
|
+
bundleClient: () => bundleClient,
|
|
35
|
+
copyChunkFiles: () => copyChunkFiles,
|
|
36
|
+
createClientCode: () => createClientCode
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(client_exports);
|
|
39
|
+
var import_magic_string = __toESM(require("magic-string"));
|
|
40
|
+
var import_acorn_walk = require("acorn-walk");
|
|
41
|
+
var import_crypto = require("crypto");
|
|
42
|
+
var import_node_fs = __toESM(require("fs"));
|
|
43
|
+
var import_node_path = __toESM(require("path"));
|
|
44
|
+
|
|
45
|
+
// src/config.ts
|
|
46
|
+
var state = {
|
|
47
|
+
outDir: "dist",
|
|
48
|
+
esbuildConfig: {}
|
|
49
|
+
};
|
|
50
|
+
function getConfig(key) {
|
|
51
|
+
return state[key];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/virtual.ts
|
|
55
|
+
var modules = {};
|
|
56
|
+
function setVirtual(key, code) {
|
|
57
|
+
modules[key] = code;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/client/index.ts
|
|
61
|
+
function createClientCode(code, name, id, ast) {
|
|
62
|
+
let magic = new import_magic_string.default(code);
|
|
63
|
+
let importsNexus = false;
|
|
64
|
+
let hasSchema = false;
|
|
65
|
+
(0, import_acorn_walk.simple)(ast, {
|
|
66
|
+
VariableDeclaration(node) {
|
|
67
|
+
for (const declaration of node.declarations) {
|
|
68
|
+
if (declaration.id.type === "Identifier" && declaration.id.name === "schema" && declaration.init?.type === "CallExpression") {
|
|
69
|
+
hasSchema = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
ImportDeclaration(node) {
|
|
74
|
+
if (node.type === "ImportDeclaration") {
|
|
75
|
+
const { source: { value, start, end } } = node;
|
|
76
|
+
if (value === "@ethereal-nexus/core") {
|
|
77
|
+
const last = node.specifiers.pop();
|
|
78
|
+
if (last?.type === "ImportSpecifier") {
|
|
79
|
+
magic.appendLeft(last.end, `,
|
|
80
|
+
webcomponent`);
|
|
81
|
+
}
|
|
82
|
+
importsNexus = true;
|
|
83
|
+
} else if (typeof value === "string" && value.startsWith(".")) {
|
|
84
|
+
const resolvedPath = import_node_path.default.join(import_node_path.default.dirname(id), value);
|
|
85
|
+
magic.update(start + 1, end - 1, resolvedPath);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
ExportNamedDeclaration(node) {
|
|
90
|
+
if (node.declaration?.type === "VariableDeclaration" && node.declaration) {
|
|
91
|
+
for (const declaration of node.declaration.declarations) {
|
|
92
|
+
if (declaration.id.type === "Identifier" && declaration.id.name === name) {
|
|
93
|
+
if (!importsNexus) {
|
|
94
|
+
magic.prepend(`import { webcomponent } from "@ethereal-nexus/core";
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
magic.append(`${name}.displayName = '${name}';
|
|
98
|
+
`);
|
|
99
|
+
magic.append(`webcomponent(${hasSchema ? "schema" : ""})(${name});
|
|
100
|
+
`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return magic;
|
|
107
|
+
}
|
|
108
|
+
function bundleClient(code, exposed, id, ast, name, emitFile) {
|
|
109
|
+
const clientCode = createClientCode(code, exposed.get(id), id, ast);
|
|
110
|
+
const fileId = `.ethereal/tmp/__etherealHelper__${name}`;
|
|
111
|
+
setVirtual(fileId, clientCode.toString());
|
|
112
|
+
const hash = (0, import_crypto.createHash)("sha256").update(code).digest("hex").slice(0, 16);
|
|
113
|
+
emitFile({
|
|
114
|
+
type: "chunk",
|
|
115
|
+
fileName: `.ethereal/${name}/${hash}-index.js`,
|
|
116
|
+
id: fileId
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function readJSDeps(chunk, bundle, js = /* @__PURE__ */ new Set()) {
|
|
120
|
+
if (chunk?.imports) {
|
|
121
|
+
for (const jsFileName of chunk?.imports) {
|
|
122
|
+
js.add(jsFileName);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (chunk.imports.length > 0) {
|
|
126
|
+
for (const nestedChunk of chunk.imports) {
|
|
127
|
+
readJSDeps(bundle[nestedChunk], bundle, js);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return js;
|
|
131
|
+
}
|
|
132
|
+
function readCssDeps(chunk, bundle, css = /* @__PURE__ */ new Set()) {
|
|
133
|
+
if (chunk?.viteMetadata) {
|
|
134
|
+
for (const cssFileName of chunk.viteMetadata.importedCss.values()) {
|
|
135
|
+
css.add(cssFileName);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (chunk.imports.length > 0) {
|
|
139
|
+
for (const nestedChunk of chunk.imports) {
|
|
140
|
+
readCssDeps(bundle[nestedChunk], bundle, css);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return css;
|
|
144
|
+
}
|
|
145
|
+
function copyChunkFiles(bundle) {
|
|
146
|
+
const outDir = getConfig("outDir");
|
|
147
|
+
for (const chunk of Object.values(bundle)) {
|
|
148
|
+
if (chunk.type === "chunk" && chunk.facadeModuleId?.includes("__etherealHelper__")) {
|
|
149
|
+
const chunkPath = import_node_path.default.dirname(chunk.preliminaryFileName);
|
|
150
|
+
const js = readJSDeps(chunk, bundle);
|
|
151
|
+
for (const imports of js.values()) {
|
|
152
|
+
const importPath = import_node_path.default.parse(imports);
|
|
153
|
+
import_node_fs.default.copyFileSync(`./${outDir}/${imports}`, `./${outDir}/${chunkPath}/${importPath.base}`);
|
|
154
|
+
}
|
|
155
|
+
if (chunk.hasOwnProperty("viteMetadata")) {
|
|
156
|
+
const cssMap = readCssDeps(chunk, bundle);
|
|
157
|
+
for (const css of cssMap.values()) {
|
|
158
|
+
const cssPath = import_node_path.default.parse(css);
|
|
159
|
+
import_node_fs.default.copyFileSync(`./${outDir}/${css}`, `./${outDir}/${chunkPath}/${cssPath.base}`);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
console.warn("CSS bundling for ethereal nexus only works on vite.");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function adjustChunkImport(chunk, code, parse) {
|
|
168
|
+
if (chunk.facadeModuleId?.includes("__etherealHelper__")) {
|
|
169
|
+
const ast = parse(code);
|
|
170
|
+
const magic = new import_magic_string.default(code);
|
|
171
|
+
(0, import_acorn_walk.simple)(ast, {
|
|
172
|
+
ImportDeclaration(node) {
|
|
173
|
+
const { value, start, end } = node.source;
|
|
174
|
+
if (value && typeof value === "string") {
|
|
175
|
+
magic.update(start + 1, end - 1, `./${value.split("/").pop()}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return magic.toString();
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
+
0 && (module.exports = {
|
|
185
|
+
adjustChunkImport,
|
|
186
|
+
bundleClient,
|
|
187
|
+
copyChunkFiles,
|
|
188
|
+
createClientCode
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts","../../src/config.ts","../../src/virtual.ts"],"sourcesContent":["import { EmitFile, OutputBundle, OutputChunk, ParseAst, ProgramNode, RenderedChunk } from 'rollup';\nimport MagicString from 'magic-string';\nimport { simple } from 'acorn-walk';\nimport { createHash } from 'crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfig } from '../config';\nimport { setVirtual } from '../virtual';\n\nexport function createClientCode(code: string, name: string, id: string, ast: ProgramNode) {\n let magic = new MagicString(code);\n let importsNexus = false;\n let hasSchema = false\n\n simple(ast, {\n VariableDeclaration(node) {\n for (const declaration of node.declarations) {\n if (declaration.id.type === 'Identifier' && declaration.id.name === 'schema' && declaration.init?.type === 'CallExpression') {\n hasSchema = true;\n }\n }\n },\n ImportDeclaration(node) {\n if (node.type === 'ImportDeclaration') {\n const { source: { value, start, end } } = node;\n\n if (value === '@ethereal-nexus/core') {\n const last = node.specifiers.pop();\n if (last?.type === 'ImportSpecifier') {\n magic.appendLeft(last.end, `,\\n webcomponent`);\n }\n importsNexus = true;\n } else if (typeof value === 'string' && value.startsWith('.')) {\n const resolvedPath = path.join(path.dirname(id), value);\n magic.update(start + 1, end - 1, resolvedPath);\n }\n }\n },\n ExportNamedDeclaration(node) {\n if(node.declaration?.type === 'VariableDeclaration' && node.declaration){\n for(const declaration of node.declaration.declarations) {\n if(declaration.id.type === 'Identifier' && declaration.id.name === name) {\n if(!importsNexus) {\n magic.prepend(`import { webcomponent } from \"@ethereal-nexus/core\";\\n`);\n }\n magic.append(`${name}.displayName = '${name}';\\n`)\n magic.append(`webcomponent(${hasSchema ? 'schema' : ''})(${name});\\n`)\n }\n }\n }\n }\n });\n\n return magic;\n}\n\nexport function bundleClient(code: string, exposed: Map<string, string>, id: string, ast: ProgramNode, name: string, emitFile: EmitFile) {\n const clientCode = createClientCode(code, exposed.get(id)!, id, ast);\n const fileId = `.ethereal/tmp/__etherealHelper__${name}`;\n\n setVirtual(fileId, clientCode.toString())\n\n const hash = createHash('sha256')\n .update(code)\n .digest('hex')\n .slice(0, 16);\n\n emitFile({\n type: 'chunk',\n fileName: `.ethereal/${name}/${hash}-index.js`,\n id: fileId\n });\n}\n\nfunction readJSDeps(chunk: OutputChunk, bundle: OutputBundle, js = new Set<string>()) {\n if(chunk?.imports) {\n for (const jsFileName of chunk?.imports) {\n js.add(jsFileName)\n }\n }\n if(chunk.imports.length > 0) {\n for(const nestedChunk of chunk.imports) {\n readJSDeps(bundle[nestedChunk] as OutputChunk, bundle, js)\n }\n }\n\n return js;\n}\n\ntype ViteOutputChunk = OutputChunk & {viteMetadata: {importedCss: Set<string>}}\n\nfunction readCssDeps(chunk: ViteOutputChunk, bundle: OutputBundle, css = new Set<string>()) {\n if(chunk?.viteMetadata) {\n for (const cssFileName of chunk.viteMetadata.importedCss.values()) {\n css.add(cssFileName)\n }\n }\n if(chunk.imports.length > 0) {\n for(const nestedChunk of chunk.imports) {\n readCssDeps(bundle[nestedChunk] as ViteOutputChunk, bundle, css)\n }\n }\n\n return css;\n}\n\nexport function copyChunkFiles(bundle: OutputBundle) {\n const outDir = getConfig('outDir');\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type === 'chunk' && chunk.facadeModuleId?.includes('__etherealHelper__')) {\n const chunkPath = path.dirname(chunk.preliminaryFileName);\n\n const js = readJSDeps(chunk, bundle)\n for (const imports of js.values()) {\n const importPath = path.parse(imports);\n fs.copyFileSync(`./${outDir}/${imports}`, `./${outDir}/${chunkPath}/${importPath.base}`);\n }\n\n //only works on vite\n if(chunk.hasOwnProperty('viteMetadata') ) {\n const cssMap = readCssDeps(chunk as ViteOutputChunk, bundle);\n for(const css of cssMap.values()) {\n const cssPath = path.parse(css)\n fs.copyFileSync(`./${outDir}/${css}`, `./${outDir}/${chunkPath}/${cssPath.base}`);\n }\n } else {\n console.warn('CSS bundling for ethereal nexus only works on vite.')\n }\n }\n }\n}\n\nexport function adjustChunkImport(chunk: RenderedChunk, code: string, parse: ParseAst) {\n if (chunk.facadeModuleId?.includes('__etherealHelper__')) {\n const ast = parse(code);\n const magic = new MagicString(code);\n\n simple(ast, {\n ImportDeclaration(node) {\n const { value, start, end } = node.source;\n if (value && typeof value === 'string') {\n magic.update(start + 1, end - 1, `./${value.split('/').pop()}`);\n }\n }\n });\n\n return magic.toString();\n }\n\n return null;\n}","import { BuildOptions } from 'esbuild';\n\ntype Config = {\n outDir: string;\n esbuildConfig: BuildOptions\n}\n\nlet state = {\n outDir: 'dist',\n esbuildConfig: {},\n};\n\nexport function setConfig<T extends keyof Config>(key: T, value: Config[T]) {\n state[key] = value;\n}\n\nexport function getConfig<T extends keyof Config>(key: T): Config[T] {\n return state[key];\n}","type Config = {\n [k: string]: string\n}\n\nlet modules: Config = {\n};\n\nexport function setVirtual(key: string, code: string) {\n modules[key] = code;\n}\n\nexport function getVirtual(key: string) {\n return modules[key];\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAwB;AACxB,wBAAuB;AACvB,oBAA2B;AAC3B,qBAAe;AACf,uBAAiB;;;ACEjB,IAAI,QAAQ;AAAA,EACV,QAAQ;AAAA,EACR,eAAe,C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AAC,EAAE;AAAA,QAChE;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,MAAM,SAAS;AAAA,EACxB;AAEA,SAAO;AACT;","names":["MagicString","path","fs"]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/client/index.ts
|
|
2
|
+
import MagicString from "magic-string";
|
|
3
|
+
import { simple } from "acorn-walk";
|
|
4
|
+
import { createHash } from "crypto";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
|
|
8
|
+
// src/config.ts
|
|
9
|
+
var state = {
|
|
10
|
+
outDir: "dist",
|
|
11
|
+
esbuildConfig: {}
|
|
12
|
+
};
|
|
13
|
+
function getConfig(key) {
|
|
14
|
+
return state[key];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/virtual.ts
|
|
18
|
+
var modules = {};
|
|
19
|
+
function setVirtual(key, code) {
|
|
20
|
+
modules[key] = code;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/client/index.ts
|
|
24
|
+
function createClientCode(code, name, id, ast) {
|
|
25
|
+
let magic = new MagicString(code);
|
|
26
|
+
let importsNexus = false;
|
|
27
|
+
let hasSchema = false;
|
|
28
|
+
simple(ast, {
|
|
29
|
+
VariableDeclaration(node) {
|
|
30
|
+
for (const declaration of node.declarations) {
|
|
31
|
+
if (declaration.id.type === "Identifier" && declaration.id.name === "schema" && declaration.init?.type === "CallExpression") {
|
|
32
|
+
hasSchema = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
ImportDeclaration(node) {
|
|
37
|
+
if (node.type === "ImportDeclaration") {
|
|
38
|
+
const { source: { value, start, end } } = node;
|
|
39
|
+
if (value === "@ethereal-nexus/core") {
|
|
40
|
+
const last = node.specifiers.pop();
|
|
41
|
+
if (last?.type === "ImportSpecifier") {
|
|
42
|
+
magic.appendLeft(last.end, `,
|
|
43
|
+
webcomponent`);
|
|
44
|
+
}
|
|
45
|
+
importsNexus = true;
|
|
46
|
+
} else if (typeof value === "string" && value.startsWith(".")) {
|
|
47
|
+
const resolvedPath = path.join(path.dirname(id), value);
|
|
48
|
+
magic.update(start + 1, end - 1, resolvedPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
ExportNamedDeclaration(node) {
|
|
53
|
+
if (node.declaration?.type === "VariableDeclaration" && node.declaration) {
|
|
54
|
+
for (const declaration of node.declaration.declarations) {
|
|
55
|
+
if (declaration.id.type === "Identifier" && declaration.id.name === name) {
|
|
56
|
+
if (!importsNexus) {
|
|
57
|
+
magic.prepend(`import { webcomponent } from "@ethereal-nexus/core";
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
magic.append(`${name}.displayName = '${name}';
|
|
61
|
+
`);
|
|
62
|
+
magic.append(`webcomponent(${hasSchema ? "schema" : ""})(${name});
|
|
63
|
+
`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return magic;
|
|
70
|
+
}
|
|
71
|
+
function bundleClient(code, exposed, id, ast, name, emitFile) {
|
|
72
|
+
const clientCode = createClientCode(code, exposed.get(id), id, ast);
|
|
73
|
+
const fileId = `.ethereal/tmp/__etherealHelper__${name}`;
|
|
74
|
+
setVirtual(fileId, clientCode.toString());
|
|
75
|
+
const hash = createHash("sha256").update(code).digest("hex").slice(0, 16);
|
|
76
|
+
emitFile({
|
|
77
|
+
type: "chunk",
|
|
78
|
+
fileName: `.ethereal/${name}/${hash}-index.js`,
|
|
79
|
+
id: fileId
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function readJSDeps(chunk, bundle, js = /* @__PURE__ */ new Set()) {
|
|
83
|
+
if (chunk?.imports) {
|
|
84
|
+
for (const jsFileName of chunk?.imports) {
|
|
85
|
+
js.add(jsFileName);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (chunk.imports.length > 0) {
|
|
89
|
+
for (const nestedChunk of chunk.imports) {
|
|
90
|
+
readJSDeps(bundle[nestedChunk], bundle, js);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return js;
|
|
94
|
+
}
|
|
95
|
+
function readCssDeps(chunk, bundle, css = /* @__PURE__ */ new Set()) {
|
|
96
|
+
if (chunk?.viteMetadata) {
|
|
97
|
+
for (const cssFileName of chunk.viteMetadata.importedCss.values()) {
|
|
98
|
+
css.add(cssFileName);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (chunk.imports.length > 0) {
|
|
102
|
+
for (const nestedChunk of chunk.imports) {
|
|
103
|
+
readCssDeps(bundle[nestedChunk], bundle, css);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return css;
|
|
107
|
+
}
|
|
108
|
+
function copyChunkFiles(bundle) {
|
|
109
|
+
const outDir = getConfig("outDir");
|
|
110
|
+
for (const chunk of Object.values(bundle)) {
|
|
111
|
+
if (chunk.type === "chunk" && chunk.facadeModuleId?.includes("__etherealHelper__")) {
|
|
112
|
+
const chunkPath = path.dirname(chunk.preliminaryFileName);
|
|
113
|
+
const js = readJSDeps(chunk, bundle);
|
|
114
|
+
for (const imports of js.values()) {
|
|
115
|
+
const importPath = path.parse(imports);
|
|
116
|
+
fs.copyFileSync(`./${outDir}/${imports}`, `./${outDir}/${chunkPath}/${importPath.base}`);
|
|
117
|
+
}
|
|
118
|
+
if (chunk.hasOwnProperty("viteMetadata")) {
|
|
119
|
+
const cssMap = readCssDeps(chunk, bundle);
|
|
120
|
+
for (const css of cssMap.values()) {
|
|
121
|
+
const cssPath = path.parse(css);
|
|
122
|
+
fs.copyFileSync(`./${outDir}/${css}`, `./${outDir}/${chunkPath}/${cssPath.base}`);
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
console.warn("CSS bundling for ethereal nexus only works on vite.");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function adjustChunkImport(chunk, code, parse) {
|
|
131
|
+
if (chunk.facadeModuleId?.includes("__etherealHelper__")) {
|
|
132
|
+
const ast = parse(code);
|
|
133
|
+
const magic = new MagicString(code);
|
|
134
|
+
simple(ast, {
|
|
135
|
+
ImportDeclaration(node) {
|
|
136
|
+
const { value, start, end } = node.source;
|
|
137
|
+
if (value && typeof value === "string") {
|
|
138
|
+
magic.update(start + 1, end - 1, `./${value.split("/").pop()}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return magic.toString();
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
adjustChunkImport,
|
|
148
|
+
bundleClient,
|
|
149
|
+
copyChunkFiles,
|
|
150
|
+
createClientCode
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts","../../src/config.ts","../../src/virtual.ts"],"sourcesContent":["import { EmitFile, OutputBundle, OutputChunk, ParseAst, ProgramNode, RenderedChunk } from 'rollup';\nimport MagicString from 'magic-string';\nimport { simple } from 'acorn-walk';\nimport { createHash } from 'crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfig } from '../config';\nimport { setVirtual } from '../virtual';\n\nexport function createClientCode(code: string, name: string, id: string, ast: ProgramNode) {\n let magic = new MagicString(code);\n let importsNexus = false;\n let hasSchema = false\n\n simple(ast, {\n VariableDeclaration(node) {\n for (const declaration of node.declarations) {\n if (declaration.id.type === 'Identifier' && declaration.id.name === 'schema' && declaration.init?.type === 'CallExpression') {\n hasSchema = true;\n }\n }\n },\n ImportDeclaration(node) {\n if (node.type === 'ImportDeclaration') {\n const { source: { value, start, end } } = node;\n\n if (value === '@ethereal-nexus/core') {\n const last = node.specifiers.pop();\n if (last?.type === 'ImportSpecifier') {\n magic.appendLeft(last.end, `,\\n webcomponent`);\n }\n importsNexus = true;\n } else if (typeof value === 'string' && value.startsWith('.')) {\n const resolvedPath = path.join(path.dirname(id), value);\n magic.update(start + 1, end - 1, resolvedPath);\n }\n }\n },\n ExportNamedDeclaration(node) {\n if(node.declaration?.type === 'VariableDeclaration' && node.declaration){\n for(const declaration of node.declaration.declarations) {\n if(declaration.id.type === 'Identifier' && declaration.id.name === name) {\n if(!importsNexus) {\n magic.prepend(`import { webcomponent } from \"@ethereal-nexus/core\";\\n`);\n }\n magic.append(`${name}.displayName = '${name}';\\n`)\n magic.append(`webcomponent(${hasSchema ? 'schema' : ''})(${name});\\n`)\n }\n }\n }\n }\n });\n\n return magic;\n}\n\nexport function bundleClient(code: string, exposed: Map<string, string>, id: string, ast: ProgramNode, name: string, emitFile: EmitFile) {\n const clientCode = createClientCode(code, exposed.get(id)!, id, ast);\n const fileId = `.ethereal/tmp/__etherealHelper__${name}`;\n\n setVirtual(fileId, clientCode.toString())\n\n const hash = createHash('sha256')\n .update(code)\n .digest('hex')\n .slice(0, 16);\n\n emitFile({\n type: 'chunk',\n fileName: `.ethereal/${name}/${hash}-index.js`,\n id: fileId\n });\n}\n\nfunction readJSDeps(chunk: OutputChunk, bundle: OutputBundle, js = new Set<string>()) {\n if(chunk?.imports) {\n for (const jsFileName of chunk?.imports) {\n js.add(jsFileName)\n }\n }\n if(chunk.imports.length > 0) {\n for(const nestedChunk of chunk.imports) {\n readJSDeps(bundle[nestedChunk] as OutputChunk, bundle, js)\n }\n }\n\n return js;\n}\n\ntype ViteOutputChunk = OutputChunk & {viteMetadata: {importedCss: Set<string>}}\n\nfunction readCssDeps(chunk: ViteOutputChunk, bundle: OutputBundle, css = new Set<string>()) {\n if(chunk?.viteMetadata) {\n for (const cssFileName of chunk.viteMetadata.importedCss.values()) {\n css.add(cssFileName)\n }\n }\n if(chunk.imports.length > 0) {\n for(const nestedChunk of chunk.imports) {\n readCssDeps(bundle[nestedChunk] as ViteOutputChunk, bundle, css)\n }\n }\n\n return css;\n}\n\nexport function copyChunkFiles(bundle: OutputBundle) {\n const outDir = getConfig('outDir');\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type === 'chunk' && chunk.facadeModuleId?.includes('__etherealHelper__')) {\n const chunkPath = path.dirname(chunk.preliminaryFileName);\n\n const js = readJSDeps(chunk, bundle)\n for (const imports of js.values()) {\n const importPath = path.parse(imports);\n fs.copyFileSync(`./${outDir}/${imports}`, `./${outDir}/${chunkPath}/${importPath.base}`);\n }\n\n //only works on vite\n if(chunk.hasOwnProperty('viteMetadata') ) {\n const cssMap = readCssDeps(chunk as ViteOutputChunk, bundle);\n for(const css of cssMap.values()) {\n const cssPath = path.parse(css)\n fs.copyFileSync(`./${outDir}/${css}`, `./${outDir}/${chunkPath}/${cssPath.base}`);\n }\n } else {\n console.warn('CSS bundling for ethereal nexus only works on vite.')\n }\n }\n }\n}\n\nexport function adjustChunkImport(chunk: RenderedChunk, code: string, parse: ParseAst) {\n if (chunk.facadeModuleId?.includes('__etherealHelper__')) {\n const ast = parse(code);\n const magic = new MagicString(code);\n\n simple(ast, {\n ImportDeclaration(node) {\n const { value, start, end } = node.source;\n if (value && typeof value === 'string') {\n magic.update(start + 1, end - 1, `./${value.split('/').pop()}`);\n }\n }\n });\n\n return magic.toString();\n }\n\n return null;\n}","import { BuildOptions } from 'esbuild';\n\ntype Config = {\n outDir: string;\n esbuildConfig: BuildOptions\n}\n\nlet state = {\n outDir: 'dist',\n esbuildConfig: {},\n};\n\nexport function setConfig<T extends keyof Config>(key: T, value: Config[T]) {\n state[key] = value;\n}\n\nexport function getConfig<T extends keyof Config>(key: T): Config[T] {\n return state[key];\n}","type Config = {\n [k: string]: string\n}\n\nlet modules: Config = {\n};\n\nexport function setVirtual(key: string, code: string) {\n modules[key] = code;\n}\n\nexport function getVirtual(key: string) {\n return modules[key];\n}"],"mappings":";AACA,OAAO,iBAAiB;AACxB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACEjB,IAAI,QAAQ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F,CAAC;AAED,WAAO,MAAM,SAAS;AAAA,EACxB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuildOptions } from 'esbuild';
|
|
2
|
+
|
|
3
|
+
type Config = {
|
|
4
|
+
outDir: string;
|
|
5
|
+
esbuildConfig: BuildOptions;
|
|
6
|
+
};
|
|
7
|
+
declare function setConfig<T extends keyof Config>(key: T, value: Config[T]): void;
|
|
8
|
+
declare function getConfig<T extends keyof Config>(key: T): Config[T];
|
|
9
|
+
|
|
10
|
+
export { getConfig, setConfig };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuildOptions } from 'esbuild';
|
|
2
|
+
|
|
3
|
+
type Config = {
|
|
4
|
+
outDir: string;
|
|
5
|
+
esbuildConfig: BuildOptions;
|
|
6
|
+
};
|
|
7
|
+
declare function setConfig<T extends keyof Config>(key: T, value: Config[T]): void;
|
|
8
|
+
declare function getConfig<T extends keyof Config>(key: T): Config[T];
|
|
9
|
+
|
|
10
|
+
export { getConfig, setConfig };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
getConfig: () => getConfig,
|
|
24
|
+
setConfig: () => setConfig
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(config_exports);
|
|
27
|
+
var state = {
|
|
28
|
+
outDir: "dist",
|
|
29
|
+
esbuildConfig: {}
|
|
30
|
+
};
|
|
31
|
+
function setConfig(key, value) {
|
|
32
|
+
state[key] = value;
|
|
33
|
+
}
|
|
34
|
+
function getConfig(key) {
|
|
35
|
+
return state[key];
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
getConfig,
|
|
40
|
+
setConfig
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { BuildOptions } from 'esbuild';\n\ntype Config = {\n outDir: string;\n esbuildConfig: BuildOptions\n}\n\nlet state = {\n outDir: 'dist',\n esbuildConfig: {},\n};\n\nexport function setConfig<T extends keyof Config>(key: T, value: Config[T]) {\n state[key] = value;\n}\n\nexport function getConfig<T extends keyof Config>(key: T): Config[T] {\n return state[key];\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,IAAI,QAAQ;AAAA,EACV,QAAQ;AAAA,EACR,eAAe,CAAC;AAClB;AAEO,SAAS,UAAkC,KAAQ,OAAkB;AAC1E,QAAM,GAAG,IAAI;AACf;AAEO,SAAS,UAAkC,KAAmB;AACnE,SAAO,MAAM,GAAG;AAClB;","names":[]}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
var state = {
|
|
3
|
+
outDir: "dist",
|
|
4
|
+
esbuildConfig: {}
|
|
5
|
+
};
|
|
6
|
+
function setConfig(key, value) {
|
|
7
|
+
state[key] = value;
|
|
8
|
+
}
|
|
9
|
+
function getConfig(key) {
|
|
10
|
+
return state[key];
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getConfig,
|
|
14
|
+
setConfig
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { BuildOptions } from 'esbuild';\n\ntype Config = {\n outDir: string;\n esbuildConfig: BuildOptions\n}\n\nlet state = {\n outDir: 'dist',\n esbuildConfig: {},\n};\n\nexport function setConfig<T extends keyof Config>(key: T, value: Config[T]) {\n state[key] = value;\n}\n\nexport function getConfig<T extends keyof Config>(key: T): Config[T] {\n return state[key];\n}"],"mappings":";AAOA,IAAI,QAAQ;AAAA,EACV,QAAQ;AAAA,EACR,eAAe,CAAC;AAClB;AAEO,SAAS,UAAkC,KAAQ,OAAkB;AAC1E,QAAM,GAAG,IAAI;AACf;AAEO,SAAS,UAAkC,KAAmB;AACnE,SAAO,MAAM,GAAG;AAClB;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EtherealPluginOptions } from '@ethereal-nexus/rollup-plugin-ethereal-nexus';
|
|
2
1
|
import { Plugin } from 'vite';
|
|
2
|
+
import { EtherealPluginOptions } from './types.mjs';
|
|
3
|
+
import 'esbuild';
|
|
3
4
|
|
|
4
|
-
declare function
|
|
5
|
+
declare function rollupEthereal(opts: EtherealPluginOptions): Plugin;
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export { EtherealPluginOptions, rollupEthereal as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EtherealPluginOptions } from '@ethereal-nexus/rollup-plugin-ethereal-nexus';
|
|
2
1
|
import { Plugin } from 'vite';
|
|
2
|
+
import { EtherealPluginOptions } from './types.js';
|
|
3
|
+
import 'esbuild';
|
|
3
4
|
|
|
4
|
-
declare function
|
|
5
|
+
declare function rollupEthereal(opts: EtherealPluginOptions): Plugin;
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export { EtherealPluginOptions, rollupEthereal as default };
|