@ethereal-nexus/vite-plugin-ethereal-nexus 1.3.0 → 1.3.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.
@@ -1,8 +1,8 @@
1
1
  // src/client/index.ts
2
2
  import MagicString from "magic-string";
3
3
  import { simple } from "acorn-walk";
4
- import fs from "node:fs";
5
- import path from "node:path";
4
+ import fs from "fs";
5
+ import path from "path";
6
6
 
7
7
  // src/config.ts
8
8
  var state = {
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/server/index.ts
2
2
  import { build } from "esbuild";
3
- import fs from "node:fs";
3
+ import fs from "fs";
4
4
  import MagicString from "magic-string";
5
5
  import { simple } from "acorn-walk";
6
- import path from "node:path";
6
+ import path from "path";
7
7
 
8
8
  // src/config.ts
9
9
  var state = {
@@ -19,7 +19,7 @@ function getConfig(key) {
19
19
 
20
20
  // src/server/index.ts
21
21
  import svgr from "esbuild-plugin-svgr";
22
- import { createHash } from "node:crypto";
22
+ import { createHash } from "crypto";
23
23
  var ignoreCssPlugin = {
24
24
  name: "empty-css-imports",
25
25
  setup(build2) {
@@ -93,12 +93,13 @@ async function bundleSSR(code, id, ast, name, emitFile) {
93
93
  }
94
94
 
95
95
  // src/manifest/index.ts
96
+ import vm from "vm";
96
97
  import { simple as simple2 } from "acorn-walk";
97
98
 
98
99
  // src/utils.ts
99
100
  import fs2 from "fs-extra";
100
- import { join } from "node:path";
101
- import { cwd } from "node:process";
101
+ import { join } from "path";
102
+ import { cwd } from "process";
102
103
  function cleanTemporary(buildDir) {
103
104
  fs2.rmSync(`./${buildDir}/.ethereal/tmp`, { force: true, recursive: true });
104
105
  fs2.rmSync(`./.ethereal`, { force: true, recursive: true });
@@ -116,8 +117,8 @@ function getPackageInfo() {
116
117
 
117
118
  // src/manifest/index.ts
118
119
  import MagicString2 from "magic-string";
119
- import path2 from "node:path";
120
- import fs3 from "node:fs";
120
+ import path2 from "path";
121
+ import fs3 from "fs";
121
122
 
122
123
  // src/virtual.ts
123
124
  var modules = {};
@@ -129,7 +130,7 @@ function getVirtual(key) {
129
130
  }
130
131
 
131
132
  // src/manifest/index.ts
132
- import { cwd as cwd2 } from "node:process";
133
+ import { cwd as cwd2 } from "process";
133
134
  function extractDialog(ast, code, name, id, emitFile) {
134
135
  const magic = new MagicString2(code);
135
136
  let importsNexus = false;
@@ -201,8 +202,8 @@ async function generateManifest(name, id) {
201
202
  // src/client/index.ts
202
203
  import MagicString3 from "magic-string";
203
204
  import { simple as simple3 } from "acorn-walk";
204
- import fs4 from "node:fs";
205
- import path3 from "node:path";
205
+ import fs4 from "fs";
206
+ import path3 from "path";
206
207
  function createClientCode(code, name, id, ast) {
207
208
  let magic = new MagicString3(code);
208
209
  let importsNexus = false;
@@ -339,7 +340,7 @@ function moveNexusFileToFolder(bundle) {
339
340
  }
340
341
 
341
342
  // src/options/index.ts
342
- import path4 from "node:path";
343
+ import path4 from "path";
343
344
  function extractExposeInto(exposed, opts, emitFile) {
344
345
  for (const [name, component] of Object.entries(opts.exposes)) {
345
346
  if (typeof component === "string") {
@@ -356,8 +357,8 @@ function extractExposeInto(exposed, opts, emitFile) {
356
357
  }
357
358
 
358
359
  // src/index.ts
359
- import { cwd as cwd3 } from "node:process";
360
- import path5 from "node:path";
360
+ import { cwd as cwd3 } from "process";
361
+ import path5 from "path";
361
362
  function rollupEthereal(opts) {
362
363
  const exposed = /* @__PURE__ */ new Map();
363
364
  let ssr = !!opts.server;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/index.ts","../src/config.ts","../src/manifest/index.ts","../src/utils.ts","../src/virtual.ts","../src/client/index.ts","../src/options/index.ts","../src/index.ts"],"sourcesContent":["import { EmitFile, ProgramNode } from 'rollup';\nimport { build, Plugin as EsbuildPlugin } from 'esbuild';\nimport fs from 'node:fs';\nimport MagicString from 'magic-string';\nimport { simple } from 'acorn-walk';\nimport path from 'node:path';\nimport { getConfig } from '../config';\nimport svgr from 'esbuild-plugin-svgr'\nimport { createHash } from 'node:crypto';\n\nconst ignoreCssPlugin: EsbuildPlugin = {\n name: 'empty-css-imports',\n setup(build) {\n build.onLoad({ filter: /\\.(c|sc|sa|le)ss$/i }, () => ({ contents: '' }))\n },\n}\n\nfunction createServerCode(code: string, name: string, id: string, ast: ProgramNode) {\n let serverCode = new MagicString(code);\n let componentsExists = false;\n simple(ast, {\n ImportDeclaration(node) {\n if (node.type === 'ImportDeclaration') {\n const { source: { value, start, end } } = node;\n\n if (typeof value === 'string' && value.startsWith('.')) {\n const resolvedPath = path.join(path.dirname(id), value);\n serverCode.update(start + 1, end - 1, resolvedPath);\n }\n }\n },\n VariableDeclaration(node) {\n if(node.declarations.length ===1) {\n if(node.declarations[0].id.type === 'Identifier' && node.declarations[0].id.name === name) {\n serverCode.prepend('import { renderToString } from \"react-dom/server\";');\n serverCode.append(`if (ethereal?.props != void 0) {\n if(typeof getServerSideProps === 'function') {\n const data = await getServerSideProps(ethereal.props);\n ethereal.serverSideProps = { ...data.props };\n }\n const combinedProps = { ...ethereal.props, ...ethereal.serverSideProps }\n ethereal.output = renderToString(/* @__PURE__ */ jsx(${name}, { ...combinedProps }));\n}`);\n componentsExists = true\n }\n }\n }\n });\n if(!componentsExists) {\n throw new Error(`No component with the name ${name} exists in the file: ${id}`)\n }\n return serverCode;\n}\n\nexport async function bundleSSR(code: string, id: string, ast: ProgramNode, name: string, emitFile: EmitFile) {\n const options = getConfig('esbuildConfig');\n\n if (!fs.existsSync(`./.ethereal/tmp`)) {\n fs.mkdirSync(`./.ethereal/tmp`, {recursive: true});\n }\n const serverCode = createServerCode(code,name, id, ast);\n fs.writeFileSync(`.ethereal/tmp/__etherealHelper__server__${name}`, serverCode.toString());\n\n const result = await build({\n ...options,\n entryPoints: [`.ethereal/tmp/__etherealHelper__server__${name}`],\n format: 'esm',\n target: 'es2022',\n plugins: [\n svgr(),\n ignoreCssPlugin,\n ...options.plugins ? options.plugins : [],\n ],\n bundle: true,\n allowOverwrite: true,\n legalComments: 'none',\n write: false, // Do not write to disk\n });\n\n const hash = createHash('sha256')\n .update(code)\n .digest('hex')\n .slice(0, 16);\n\n\n emitFile({\n type: 'prebuilt-chunk',\n fileName: `.ethereal/${name}/${hash}-server.js`,\n code: result.outputFiles[0].text\n });\n}\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}","import vm from 'node:vm';\nimport { EmitFile, ProgramNode } from 'rollup';\nimport { simple } from 'acorn-walk';\nimport type { Identifier, ImportSpecifier } from 'acorn';\nimport { convertCamelCaseToDashCase, convertCamelCaseToSpaceCase, getPackageInfo } from '../utils';\nimport MagicString from 'magic-string';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { setVirtual } from '../virtual';\nimport { cwd } from 'node:process';\nimport { getConfig } from '../config';\n\nexport function extractDialog(ast: ProgramNode, code: string, name: string, id: string, emitFile: EmitFile) {\n const magic = new MagicString(code)\n let importsNexus = false;\n\n // Walk through the AST to find the schema\n simple(ast, {\n ImportDeclaration(node) {\n if (node.type === 'ImportDeclaration') {\n const { source: { value, start, end } } = node;\n if (value === '@ethereal-nexus/core') {\n const last = node.specifiers.pop();\n if (last?.type === 'ImportSpecifier') {\n magic.appendLeft(last.end, `, parse`);\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 });\n if(!importsNexus) {\n magic.prepend(`import { parse } from \"@ethereal-nexus/core\";\\n`);\n }\n magic.append(`export const __dialog = parse(schema)\\n`)\n\n const fileId = `__etherealHelper__dialog__${name}.js`;\n setVirtual(fileId, magic.toString())\n\n emitFile({\n type: 'chunk',\n fileName: fileId,\n id: fileId,\n preserveSignature: 'strict'\n });\n}\n\nexport async function parseDialog(schemaCode: string) {\n const ctx = vm.createContext({\n modules: {\n '@ethereal-nexus/core': await import('@ethereal-nexus/core')\n }\n });\n\n return vm.runInNewContext(schemaCode, ctx);\n}\n\nfunction extractReadme(id: string) {\n const componentPath = path.parse(id)\n let filePath = `${componentPath.dir}/${componentPath.name}.md`\n\n if(!fs.existsSync(filePath)){\n filePath = `${componentPath.dir}/README.md`\n }\n if(!fs.existsSync(filePath)){\n return '';\n }\n\n return fs.readFileSync(filePath, 'utf-8')\n}\n\nexport async function generateManifest(name: string, id: string) {\n let dialog = { dialog: [] };\n const outDir = getConfig('outDir');\n\n const fileId = `${cwd()}/${outDir}/__etherealHelper__dialog__${name}.js`;\n const { __dialog } = await import(fileId)\n const readme = extractReadme(id);\n const packageJson = getPackageInfo();\n\n if (__dialog) {\n dialog = __dialog;\n }\n\n const manifest = {\n name,\n readme,\n title: convertCamelCaseToSpaceCase(name),\n slug: convertCamelCaseToDashCase(name),\n version: packageJson.version,\n ...dialog,\n }\n const json = JSON.stringify(manifest, undefined, 2)\n\n fs.writeFileSync(`./${outDir}/.ethereal/${name}/manifest.json`, json);\n}","import fs from \"fs-extra\"\nimport { type PackageJson } from \"type-fest\"\nimport { join } from 'node:path';\nimport { cwd } from 'node:process';\nimport { getConfig } from './config';\n\nexport function cleanTemporary(buildDir: string) {\n fs.rmSync(`./${buildDir}/.ethereal/tmp`, { force: true, recursive: true });\n fs.rmSync(`./.ethereal`, { force: true, recursive: true });\n}\n\nexport function convertCamelCaseToSpaceCase(str: string) {\n return str\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2');\n}\n\nexport function convertCamelCaseToDashCase(str: string) {\n return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n}\n\nexport function getPackageInfo() {\n const packageJsonPath = join(cwd(), \"package.json\")\n\n return fs.readJSONSync(packageJsonPath) as PackageJson\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}","import { EmitFile, OutputBundle, OutputChunk, ParseAst, ProgramNode, RenderedChunk } from 'rollup';\nimport MagicString from 'magic-string';\nimport { simple } from 'acorn-walk';\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__client__${name}`;\n\n setVirtual(fileId, clientCode.toString())\n\n emitFile({\n type: 'chunk',\n name: 'index',\n id: fileId,\n });\n}\n\nfunction readJSDeps(chunk: ViteOutputChunk & {key: string}, bundle: OutputBundle, js = new Set<string>()) {\n const queue = [chunk.key];\n while (queue.length > 0) {\n const chunk = queue.shift();\n const chunkData = bundle[chunk!];\n\n if (!chunkData || chunkData.type !== 'chunk') continue;\n\n for (const dep of [...chunkData.imports, ...chunkData.dynamicImports]) {\n if (!js.has(dep)) {\n js.add(dep);\n queue.push(dep);\n }\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 const etherealChunks = Object.entries(bundle)\n .filter(([,value]) => value.type === 'chunk' && value.type === 'chunk' && value.facadeModuleId?.includes('__etherealHelper__client__'))\n .map(([key, value]) => ({\n ...value,\n key,\n })) as (ViteOutputChunk & {key: string})[]\n\n for (const chunk of Object.values(etherealChunks)) {\n const componentName = chunk.facadeModuleId?.split('__etherealHelper__client__').at(-1);\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}/.ethereal/${componentName}/${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}/.ethereal/${componentName}/${cssPath.base}`);\n }\n } else {\n console.warn('CSS bundling for ethereal nexus only works on vite.')\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}\n\nexport function moveNexusFileToFolder(bundle: OutputBundle) {\n Object.values(bundle)\n .filter(value => value.type === 'chunk' && value.facadeModuleId?.includes('.ethereal/tmp/__etherealHelper__client__'))\n .forEach(value => {\n const chunk = bundle[value.fileName];\n if (chunk.type === 'chunk' && chunk.facadeModuleId?.includes('__etherealHelper__client__')) {\n const name = chunk.facadeModuleId.split('.ethereal/tmp/__etherealHelper__client__')[1];\n chunk.fileName = `.ethereal/${name}/${chunk.fileName}`;\n }\n });\n}","import { EtherealPluginOptions } from '../types';\nimport { EmitFile } from 'rollup';\nimport path from 'node:path';\n\nexport function extractExposeInto(exposed: Map<string, string>, opts: EtherealPluginOptions, emitFile: EmitFile) {\n for (const [name, component] of Object.entries(opts.exposes)) {\n if (typeof component === 'string') {\n const id = path.resolve(component);\n\n exposed.set(id, name);\n emitFile({\n type: 'chunk',\n fileName: path.resolve(component).substring(1),\n id,\n preserveSignature: 'strict'\n });\n }\n }\n}","import { Plugin } from 'vite';\nimport { EtherealPluginOptions } from './types';\nimport { bundleSSR } from './server';\nimport { extractDialog, generateManifest } from './manifest';\nimport { adjustChunkImport, bundleClient, copyChunkFiles, moveNexusFileToFolder } from './client';\nimport { cleanTemporary } from './utils';\nimport { extractExposeInto } from './options';\nimport { getConfig, setConfig } from './config';\nimport { cwd } from 'node:process';\nimport path from 'node:path';\nimport { getVirtual } from './virtual';\n\nexport default function rollupEthereal(opts: EtherealPluginOptions): Plugin {\n const exposed = new Map<string, string>();\n let ssr = !!opts.server;\n\n return {\n name: 'ethereal:compiler',\n apply: 'build',\n async buildStart(_options) {\n console.log('Building ethereal bundles...');\n if (typeof opts.server === 'object') {\n setConfig('esbuildConfig', opts.server || {});\n }\n\n extractExposeInto(exposed, opts, this.emitFile);\n },\n async resolveId(source) {\n if (getVirtual(source)) {\n return source;\n }\n return null;\n },\n async transform(code, id) {\n this.parse;\n if (!exposed.has(id)) {\n return null;\n }\n const name = exposed.get(id)!;\n const ast = this.parse(code);\n\n extractDialog(ast, code, name, id, this.emitFile);\n bundleClient(code, exposed, id, ast, name, this.emitFile);\n if (ssr) {\n await bundleSSR(code, id, ast, name, this.emitFile);\n }\n\n return null;\n },\n async load(id) {\n if (getVirtual(id)) {\n return getVirtual(id);\n }\n return null;\n },\n outputOptions(options) {\n const dir = path.relative(cwd(), options.dir || cwd());\n setConfig('outDir', dir);\n },\n async renderChunk(code, chunk) {\n return adjustChunkImport(chunk, code, this.parse);\n },\n async generateBundle(_, bundle) {\n moveNexusFileToFolder(bundle);\n for (const entry of exposed.keys()) {\n delete bundle[entry.substring(1)];\n }\n },\n async writeBundle(_options, bundle) {\n copyChunkFiles(bundle);\n for (const [id, name] of exposed) {\n await generateManifest(name, id);\n }\n },\n async closeBundle() {\n cleanTemporary(getConfig('outDir'))\n }\n };\n}\n\nexport type { EtherealPluginOptions };"],"mappings":";AACA,SAAS,aAAsC;AAC/C,OAAO,QAAQ;AACf,OAAO,iBAAiB;AACxB,SAAS,cAAc;AACvB,OAAO,UAAU;;;ACEjB,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;;;ADXA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAE3B,IAAM,kBAAkC;AAAA,EACtC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BAAc,KAAK,MAAM,MAAM,IAAI,KAAK,QAAQ;AAChD,mBAAa,MAAM,SAAS,IAAI,KAAK,MAAM,KAAK,QAAQ;AACxD,UAAI,KAAK;AACP,cAAM,UAAU,MAAM,IAAI,KAAK,MAAM,KAAK,QAAQ;AAAA,MACpD;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,KAAK,IAAI;AACb,UAAI,WAAW,EAAE,GAAG;AAClB,eAAO,WAAW,EAAE;AAAA,MACtB;AACA,aAAO;AAAA,IACT;AAAA,IACA,cAAc,SAAS;AACrB,YAAM,MAAMC,MAAK,SAASC,KAAI,GAAG,QAAQ,OAAOA,KAAI,CAAC;AACrD,gBAAU,UAAU,GAAG;AAAA,IACzB;AAAA,IACA,MAAM,YAAY,MAAM,OAAO;AAC7B,aAAO,kBAAkB,OAAO,MAAM,KAAK,KAAK;AAAA,IAClD;AAAA,IACA,MAAM,eAAe,GAAG,QAAQ;AAC9B,4BAAsB,MAAM;AAC5B,iBAAW,SAAS,QAAQ,KAAK,GAAG;AAClC,eAAO,OAAO,MAAM,UAAU,CAAC,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,IACA,MAAM,YAAY,UAAU,QAAQ;AAClC,qBAAe,MAAM;AACrB,iBAAW,CAAC,IAAI,IAAI,KAAK,SAAS;AAChC,cAAM,iBAAiB,MAAM,EAAE;AAAA,MACjC;AAAA,IACF;AAAA,IACA,MAAM,cAAc;AAClB,qBAAe,UAAU,QAAQ,CAAC;AAAA,IACpC;AAAA,EACF;AACF;","names":["build","simple","fs","MagicString","path","fs","cwd","MagicString","simple","path","path","fs","cwd","MagicString","simple","fs","path","MagicString","simple","path","chunk","fs","path","cwd","path","path","cwd"]}
1
+ {"version":3,"sources":["../src/server/index.ts","../src/config.ts","../src/manifest/index.ts","../src/utils.ts","../src/virtual.ts","../src/client/index.ts","../src/options/index.ts","../src/index.ts"],"sourcesContent":["import { EmitFile, ProgramNode } from 'rollup';\nimport { build, Plugin as EsbuildPlugin } from 'esbuild';\nimport fs from 'node:fs';\nimport MagicString from 'magic-string';\nimport { simple } from 'acorn-walk';\nimport path from 'node:path';\nimport { getConfig } from '../config';\nimport svgr from 'esbuild-plugin-svgr'\nimport { createHash } from 'node:crypto';\n\nconst ignoreCssPlugin: EsbuildPlugin = {\n name: 'empty-css-imports',\n setup(build) {\n build.onLoad({ filter: /\\.(c|sc|sa|le)ss$/i }, () => ({ contents: '' }))\n },\n}\n\nfunction createServerCode(code: string, name: string, id: string, ast: ProgramNode) {\n let serverCode = new MagicString(code);\n let componentsExists = false;\n simple(ast, {\n ImportDeclaration(node) {\n if (node.type === 'ImportDeclaration') {\n const { source: { value, start, end } } = node;\n\n if (typeof value === 'string' && value.startsWith('.')) {\n const resolvedPath = path.join(path.dirname(id), value);\n serverCode.update(start + 1, end - 1, resolvedPath);\n }\n }\n },\n VariableDeclaration(node) {\n if(node.declarations.length ===1) {\n if(node.declarations[0].id.type === 'Identifier' && node.declarations[0].id.name === name) {\n serverCode.prepend('import { renderToString } from \"react-dom/server\";');\n serverCode.append(`if (ethereal?.props != void 0) {\n if(typeof getServerSideProps === 'function') {\n const data = await getServerSideProps(ethereal.props);\n ethereal.serverSideProps = { ...data.props };\n }\n const combinedProps = { ...ethereal.props, ...ethereal.serverSideProps }\n ethereal.output = renderToString(/* @__PURE__ */ jsx(${name}, { ...combinedProps }));\n}`);\n componentsExists = true\n }\n }\n }\n });\n if(!componentsExists) {\n throw new Error(`No component with the name ${name} exists in the file: ${id}`)\n }\n return serverCode;\n}\n\nexport async function bundleSSR(code: string, id: string, ast: ProgramNode, name: string, emitFile: EmitFile) {\n const options = getConfig('esbuildConfig');\n\n if (!fs.existsSync(`./.ethereal/tmp`)) {\n fs.mkdirSync(`./.ethereal/tmp`, {recursive: true});\n }\n const serverCode = createServerCode(code,name, id, ast);\n fs.writeFileSync(`.ethereal/tmp/__etherealHelper__server__${name}`, serverCode.toString());\n\n const result = await build({\n ...options,\n entryPoints: [`.ethereal/tmp/__etherealHelper__server__${name}`],\n format: 'esm',\n target: 'es2022',\n plugins: [\n svgr(),\n ignoreCssPlugin,\n ...options.plugins ? options.plugins : [],\n ],\n bundle: true,\n allowOverwrite: true,\n legalComments: 'none',\n write: false, // Do not write to disk\n });\n\n const hash = createHash('sha256')\n .update(code)\n .digest('hex')\n .slice(0, 16);\n\n\n emitFile({\n type: 'prebuilt-chunk',\n fileName: `.ethereal/${name}/${hash}-server.js`,\n code: result.outputFiles[0].text\n });\n}\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}","import vm from 'node:vm';\nimport { EmitFile, ProgramNode } from 'rollup';\nimport { simple } from 'acorn-walk';\nimport type { Identifier, ImportSpecifier } from 'acorn';\nimport { convertCamelCaseToDashCase, convertCamelCaseToSpaceCase, getPackageInfo } from '../utils';\nimport MagicString from 'magic-string';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { setVirtual } from '../virtual';\nimport { cwd } from 'node:process';\nimport { getConfig } from '../config';\n\nexport function extractDialog(ast: ProgramNode, code: string, name: string, id: string, emitFile: EmitFile) {\n const magic = new MagicString(code)\n let importsNexus = false;\n\n // Walk through the AST to find the schema\n simple(ast, {\n ImportDeclaration(node) {\n if (node.type === 'ImportDeclaration') {\n const { source: { value, start, end } } = node;\n if (value === '@ethereal-nexus/core') {\n const last = node.specifiers.pop();\n if (last?.type === 'ImportSpecifier') {\n magic.appendLeft(last.end, `, parse`);\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 });\n if(!importsNexus) {\n magic.prepend(`import { parse } from \"@ethereal-nexus/core\";\\n`);\n }\n magic.append(`export const __dialog = parse(schema)\\n`)\n\n const fileId = `__etherealHelper__dialog__${name}.js`;\n setVirtual(fileId, magic.toString())\n\n emitFile({\n type: 'chunk',\n fileName: fileId,\n id: fileId,\n preserveSignature: 'strict'\n });\n}\n\nexport async function parseDialog(schemaCode: string) {\n const ctx = vm.createContext({\n modules: {\n '@ethereal-nexus/core': await import('@ethereal-nexus/core')\n }\n });\n\n return vm.runInNewContext(schemaCode, ctx);\n}\n\nfunction extractReadme(id: string) {\n const componentPath = path.parse(id)\n let filePath = `${componentPath.dir}/${componentPath.name}.md`\n\n if(!fs.existsSync(filePath)){\n filePath = `${componentPath.dir}/README.md`\n }\n if(!fs.existsSync(filePath)){\n return '';\n }\n\n return fs.readFileSync(filePath, 'utf-8')\n}\n\nexport async function generateManifest(name: string, id: string) {\n let dialog = { dialog: [] };\n const outDir = getConfig('outDir');\n\n const fileId = `${cwd()}/${outDir}/__etherealHelper__dialog__${name}.js`;\n const { __dialog } = await import(fileId)\n const readme = extractReadme(id);\n const packageJson = getPackageInfo();\n\n if (__dialog) {\n dialog = __dialog;\n }\n\n const manifest = {\n name,\n readme,\n title: convertCamelCaseToSpaceCase(name),\n slug: convertCamelCaseToDashCase(name),\n version: packageJson.version,\n ...dialog,\n }\n const json = JSON.stringify(manifest, undefined, 2)\n\n fs.writeFileSync(`./${outDir}/.ethereal/${name}/manifest.json`, json);\n}","import fs from \"fs-extra\"\nimport { type PackageJson } from \"type-fest\"\nimport { join } from 'node:path';\nimport { cwd } from 'node:process';\nimport { getConfig } from './config';\n\nexport function cleanTemporary(buildDir: string) {\n fs.rmSync(`./${buildDir}/.ethereal/tmp`, { force: true, recursive: true });\n fs.rmSync(`./.ethereal`, { force: true, recursive: true });\n}\n\nexport function convertCamelCaseToSpaceCase(str: string) {\n return str\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2');\n}\n\nexport function convertCamelCaseToDashCase(str: string) {\n return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n}\n\nexport function getPackageInfo() {\n const packageJsonPath = join(cwd(), \"package.json\")\n\n return fs.readJSONSync(packageJsonPath) as PackageJson\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}","import { EmitFile, OutputBundle, OutputChunk, ParseAst, ProgramNode, RenderedChunk } from 'rollup';\nimport MagicString from 'magic-string';\nimport { simple } from 'acorn-walk';\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__client__${name}`;\n\n setVirtual(fileId, clientCode.toString())\n\n emitFile({\n type: 'chunk',\n name: 'index',\n id: fileId,\n });\n}\n\nfunction readJSDeps(chunk: ViteOutputChunk & {key: string}, bundle: OutputBundle, js = new Set<string>()) {\n const queue = [chunk.key];\n while (queue.length > 0) {\n const chunk = queue.shift();\n const chunkData = bundle[chunk!];\n\n if (!chunkData || chunkData.type !== 'chunk') continue;\n\n for (const dep of [...chunkData.imports, ...chunkData.dynamicImports]) {\n if (!js.has(dep)) {\n js.add(dep);\n queue.push(dep);\n }\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 const etherealChunks = Object.entries(bundle)\n .filter(([,value]) => value.type === 'chunk' && value.type === 'chunk' && value.facadeModuleId?.includes('__etherealHelper__client__'))\n .map(([key, value]) => ({\n ...value,\n key,\n })) as (ViteOutputChunk & {key: string})[]\n\n for (const chunk of Object.values(etherealChunks)) {\n const componentName = chunk.facadeModuleId?.split('__etherealHelper__client__').at(-1);\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}/.ethereal/${componentName}/${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}/.ethereal/${componentName}/${cssPath.base}`);\n }\n } else {\n console.warn('CSS bundling for ethereal nexus only works on vite.')\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}\n\nexport function moveNexusFileToFolder(bundle: OutputBundle) {\n Object.values(bundle)\n .filter(value => value.type === 'chunk' && value.facadeModuleId?.includes('.ethereal/tmp/__etherealHelper__client__'))\n .forEach(value => {\n const chunk = bundle[value.fileName];\n if (chunk.type === 'chunk' && chunk.facadeModuleId?.includes('__etherealHelper__client__')) {\n const name = chunk.facadeModuleId.split('.ethereal/tmp/__etherealHelper__client__')[1];\n chunk.fileName = `.ethereal/${name}/${chunk.fileName}`;\n }\n });\n}","import { EtherealPluginOptions } from '../types';\nimport { EmitFile } from 'rollup';\nimport path from 'node:path';\n\nexport function extractExposeInto(exposed: Map<string, string>, opts: EtherealPluginOptions, emitFile: EmitFile) {\n for (const [name, component] of Object.entries(opts.exposes)) {\n if (typeof component === 'string') {\n const id = path.resolve(component);\n\n exposed.set(id, name);\n emitFile({\n type: 'chunk',\n fileName: path.resolve(component).substring(1),\n id,\n preserveSignature: 'strict'\n });\n }\n }\n}","import { Plugin } from 'vite';\nimport { EtherealPluginOptions } from './types';\nimport { bundleSSR } from './server';\nimport { extractDialog, generateManifest } from './manifest';\nimport { adjustChunkImport, bundleClient, copyChunkFiles, moveNexusFileToFolder } from './client';\nimport { cleanTemporary } from './utils';\nimport { extractExposeInto } from './options';\nimport { getConfig, setConfig } from './config';\nimport { cwd } from 'node:process';\nimport path from 'node:path';\nimport { getVirtual } from './virtual';\n\nexport default function rollupEthereal(opts: EtherealPluginOptions): Plugin {\n const exposed = new Map<string, string>();\n let ssr = !!opts.server;\n\n return {\n name: 'ethereal:compiler',\n apply: 'build',\n async buildStart(_options) {\n console.log('Building ethereal bundles...');\n if (typeof opts.server === 'object') {\n setConfig('esbuildConfig', opts.server || {});\n }\n\n extractExposeInto(exposed, opts, this.emitFile);\n },\n async resolveId(source) {\n if (getVirtual(source)) {\n return source;\n }\n return null;\n },\n async transform(code, id) {\n this.parse;\n if (!exposed.has(id)) {\n return null;\n }\n const name = exposed.get(id)!;\n const ast = this.parse(code);\n\n extractDialog(ast, code, name, id, this.emitFile);\n bundleClient(code, exposed, id, ast, name, this.emitFile);\n if (ssr) {\n await bundleSSR(code, id, ast, name, this.emitFile);\n }\n\n return null;\n },\n async load(id) {\n if (getVirtual(id)) {\n return getVirtual(id);\n }\n return null;\n },\n outputOptions(options) {\n const dir = path.relative(cwd(), options.dir || cwd());\n setConfig('outDir', dir);\n },\n async renderChunk(code, chunk) {\n return adjustChunkImport(chunk, code, this.parse);\n },\n async generateBundle(_, bundle) {\n moveNexusFileToFolder(bundle);\n for (const entry of exposed.keys()) {\n delete bundle[entry.substring(1)];\n }\n },\n async writeBundle(_options, bundle) {\n copyChunkFiles(bundle);\n for (const [id, name] of exposed) {\n await generateManifest(name, id);\n }\n },\n async closeBundle() {\n cleanTemporary(getConfig('outDir'))\n }\n };\n}\n\nexport type { EtherealPluginOptions };"],"mappings":";AACA,SAAS,aAAsC;AAC/C,OAAO,QAAQ;AACf,OAAO,iBAAiB;AACxB,SAAS,cAAc;AACvB,OAAO,UAAU;;;ACEjB,IAAI,QAAQ;AAAA,EACV,QAAQ;AAAA,EACR,eAAe,CAAC;AAClB;AAEO,SAAS,UAAkC,KAAQ,OAAkB;AAC1E,QAAM,GAAG,IAAI;AACf;AAEO,SAAS,U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,CAAC,QAAQ,IAAI,EAAE,GAAG;AACpB,eAAO;AAAA,MACT;AACA,YAAM,OAAO,QAAQ,IAAI,EAAE;AAC3B,YAAM,MAAM,KAAK,MAAM,IAAI;AAE3B,oBAAc,KAAK,MAAM,MAAM,IAAI,KAAK,QAAQ;AAChD,mBAAa,MAAM,SAAS,IAAI,KAAK,MAAM,KAAK,QAAQ;AACxD,UAAI,KAAK;AACP,cAAM,UAAU,MAAM,IAAI,KAAK,MAAM,KAAK,QAAQ;AAAA,MACpD;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,KAAK,IAAI;AACb,UAAI,WAAW,EAAE,GAAG;AAClB,eAAO,WAAW,EAAE;AAAA,MACtB;AACA,aAAO;AAAA,IACT;AAAA,IACA,cAAc,SAAS;AACrB,YAAM,MAAMC,MAAK,SAASC,KAAI,GAAG,QAAQ,OAAOA,KAAI,CAAC;AACrD,gBAAU,UAAU,GAAG;AAAA,IACzB;AAAA,IACA,MAAM,YAAY,MAAM,OAAO;AAC7B,aAAO,kBAAkB,OAAO,MAAM,KAAK,KAAK;AAAA,IAClD;AAAA,IACA,MAAM,eAAe,GAAG,QAAQ;AAC9B,4BAAsB,MAAM;AAC5B,iBAAW,SAAS,QAAQ,KAAK,GAAG;AAClC,eAAO,OAAO,MAAM,UAAU,CAAC,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,IACA,MAAM,YAAY,UAAU,QAAQ;AAClC,qBAAe,MAAM;AACrB,iBAAW,CAAC,IAAI,IAAI,KAAK,SAAS;AAChC,cAAM,iBAAiB,MAAM,EAAE;AAAA,MACjC;AAAA,IACF;AAAA,IACA,MAAM,cAAc;AAClB,qBAAe,UAAU,QAAQ,CAAC;AAAA,IACpC;AAAA,EACF;AACF;","names":["build","simple","fs","MagicString","path","fs","cwd","MagicString","simple","path","path","fs","cwd","MagicString","simple","fs","path","MagicString","simple","path","chunk","fs","path","cwd","path","path","cwd"]}
@@ -1,11 +1,11 @@
1
1
  // src/manifest/index.ts
2
- import vm from "node:vm";
2
+ import vm from "vm";
3
3
  import { simple } from "acorn-walk";
4
4
 
5
5
  // src/utils.ts
6
6
  import fs from "fs-extra";
7
- import { join } from "node:path";
8
- import { cwd } from "node:process";
7
+ import { join } from "path";
8
+ import { cwd } from "process";
9
9
  function convertCamelCaseToSpaceCase(str) {
10
10
  return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
11
11
  }
@@ -19,8 +19,8 @@ function getPackageInfo() {
19
19
 
20
20
  // src/manifest/index.ts
21
21
  import MagicString from "magic-string";
22
- import path from "node:path";
23
- import fs2 from "node:fs";
22
+ import path from "path";
23
+ import fs2 from "fs";
24
24
 
25
25
  // src/virtual.ts
26
26
  var modules = {};
@@ -29,7 +29,7 @@ function setVirtual(key, code) {
29
29
  }
30
30
 
31
31
  // src/manifest/index.ts
32
- import { cwd as cwd2 } from "node:process";
32
+ import { cwd as cwd2 } from "process";
33
33
 
34
34
  // src/config.ts
35
35
  var state = {
@@ -1,5 +1,5 @@
1
1
  // src/options/index.ts
2
- import path from "node:path";
2
+ import path from "path";
3
3
  function extractExposeInto(exposed, opts, emitFile) {
4
4
  for (const [name, component] of Object.entries(opts.exposes)) {
5
5
  if (typeof component === "string") {
@@ -1,9 +1,9 @@
1
1
  // src/server/index.ts
2
2
  import { build } from "esbuild";
3
- import fs from "node:fs";
3
+ import fs from "fs";
4
4
  import MagicString from "magic-string";
5
5
  import { simple } from "acorn-walk";
6
- import path from "node:path";
6
+ import path from "path";
7
7
 
8
8
  // src/config.ts
9
9
  var state = {
@@ -16,7 +16,7 @@ function getConfig(key) {
16
16
 
17
17
  // src/server/index.ts
18
18
  import svgr from "esbuild-plugin-svgr";
19
- import { createHash } from "node:crypto";
19
+ import { createHash } from "crypto";
20
20
  var ignoreCssPlugin = {
21
21
  name: "empty-css-imports",
22
22
  setup(build2) {
package/dist/utils.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/utils.ts
2
2
  import fs from "fs-extra";
3
- import { join } from "node:path";
4
- import { cwd } from "node:process";
3
+ import { join } from "path";
4
+ import { cwd } from "process";
5
5
  function cleanTemporary(buildDir) {
6
6
  fs.rmSync(`./${buildDir}/.ethereal/tmp`, { force: true, recursive: true });
7
7
  fs.rmSync(`./.ethereal`, { force: true, recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethereal-nexus/vite-plugin-ethereal-nexus",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "rollup-plugin"
@@ -36,7 +36,7 @@
36
36
  "tsup": "^8.3.5",
37
37
  "type-fest": "^4.18.2",
38
38
  "typescript": "^5.6.2",
39
- "vite": "^7.1.9"
39
+ "vite": "^7.1.11"
40
40
  },
41
41
  "dependencies": {
42
42
  "@swc/core": "^1.5.5",
@@ -46,10 +46,10 @@
46
46
  "esbuild-plugin-svgr": "^2.1.0",
47
47
  "fs-extra": "^11.2.0",
48
48
  "magic-string": "^0.30.10",
49
- "@ethereal-nexus/core": "1.16.0"
49
+ "@ethereal-nexus/core": "1.18.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "vite": "^7.1.9"
52
+ "vite": "^7.1.11"
53
53
  },
54
54
  "scripts": {
55
55
  "test": "echo \"Error: no test specified\" && exit 1",