@heshammesalam/heshjs 0.1.0 → 0.3.0
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/README.md +19 -4
- package/cli.js +26 -0
- package/dist/architecture/diagnostics.d.ts +12 -0
- package/dist/architecture/diagnostics.js +8 -0
- package/dist/architecture/diagnostics.js.map +1 -0
- package/dist/architecture/html.d.ts +16 -0
- package/dist/architecture/html.js +132 -0
- package/dist/architecture/html.js.map +1 -0
- package/dist/architecture/index.d.ts +42 -0
- package/dist/architecture/index.js +418 -0
- package/dist/architecture/index.js.map +1 -0
- package/dist/compiler/index.js +2 -0
- package/dist/compiler/index.js.map +1 -1
- package/dist/destinations/index.d.ts +63 -0
- package/dist/destinations/index.js +185 -0
- package/dist/destinations/index.js.map +1 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.js +5 -1
- package/dist/dom/index.js.map +1 -1
- package/dist/domains/index.d.ts +24 -0
- package/dist/domains/index.js +110 -0
- package/dist/domains/index.js.map +1 -0
- package/dist/hmvc/index.d.ts +35 -0
- package/dist/hmvc/index.js +49 -0
- package/dist/hmvc/index.js.map +1 -0
- package/dist/parser/index.d.ts +15 -1
- package/dist/parser/index.js +73 -3
- package/dist/parser/index.js.map +1 -1
- package/dist/presentation/index.d.ts +9 -0
- package/dist/presentation/index.js +38 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/router/index.d.ts +24 -0
- package/dist/router/index.js +258 -0
- package/dist/router/index.js.map +1 -0
- package/dist/vite/index.d.ts +4 -1
- package/dist/vite/index.js +37 -2
- package/dist/vite/index.js.map +1 -1
- package/docs/contracts.md +60 -0
- package/docs/domain-graph.md +205 -0
- package/docs/grammar.md +4 -0
- package/docs/hmvc.md +134 -0
- package/package.json +10 -3
- package/src/architecture/diagnostics.ts +11 -0
- package/src/architecture/html.ts +88 -0
- package/src/architecture/index.ts +283 -0
- package/src/compiler/index.ts +1 -0
- package/src/destinations/index.ts +146 -0
- package/src/dom/index.ts +6 -1
- package/src/domains/index.ts +97 -0
- package/src/hmvc/index.ts +71 -0
- package/src/parser/index.ts +55 -4
- package/src/presentation/index.ts +31 -0
- package/src/router/index.ts +171 -0
- package/src/vite/index.ts +25 -2
package/src/vite/index.ts
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import { compile } from '../compiler/index.js';
|
|
3
|
-
|
|
3
|
+
import { createArchitectureCompiler, writeProject, formatDiagnostic, type ProjectOptions } from '../architecture/index.js';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
export function hesh(options: { architecture?: ProjectOptions } = {}): Plugin {
|
|
4
6
|
let production = false;
|
|
7
|
+
const architecture = createArchitectureCompiler();
|
|
8
|
+
let project: ProjectOptions | undefined;
|
|
9
|
+
let watched: string[] = [];
|
|
10
|
+
let warn: ((message: string) => void) | undefined;
|
|
11
|
+
const check = () => {
|
|
12
|
+
if (!project) return;
|
|
13
|
+
const result = architecture.check(project);
|
|
14
|
+
if (result.diagnostics.some(item => item.severity === 'error')) throw new Error(result.diagnostics.map(formatDiagnostic).join('\n'));
|
|
15
|
+
for (const item of result.diagnostics) if (item.severity === 'warning') warn?.(formatDiagnostic(item));
|
|
16
|
+
writeProject(result); watched = result.files;
|
|
17
|
+
};
|
|
5
18
|
return {
|
|
6
19
|
name: 'heshjs', enforce: 'pre',
|
|
7
|
-
|
|
20
|
+
config() { return { appType: 'spa' }; },
|
|
21
|
+
configResolved(config) {
|
|
22
|
+
production = config.command === 'build';
|
|
23
|
+
warn = message => config.logger.warn(message);
|
|
24
|
+
if (options.architecture) { project = { ...options.architecture, root: resolve(config.root, options.architecture.root) }; check(); }
|
|
25
|
+
},
|
|
26
|
+
buildStart() { for (const file of watched) this.addWatchFile(file); },
|
|
8
27
|
transform(source, id) {
|
|
28
|
+
if (project && /(?:^|\/)server(?:\/|$)|\.server\.[cm]?[jt]s$/.test(id.replace(/\\/g, '/'))) throw new Error(`HESH-SEC-001 Server-only module cannot enter the browser bundle: ${id}`);
|
|
9
29
|
if (!id.endsWith('.hesh')) return;
|
|
10
30
|
const result = compile(source, { filename: id, development: !production });
|
|
11
31
|
return { code: result.code, map: null };
|
|
12
32
|
},
|
|
13
33
|
handleHotUpdate(context) {
|
|
34
|
+
if (project && (watched.includes(context.file.replace(/\\/g, '/').toLowerCase()) || watched.includes(context.file.replace(/\\/g, '/')))) {
|
|
35
|
+
check(); context.server.ws.send({ type: 'full-reload' }); return [];
|
|
36
|
+
}
|
|
14
37
|
if (context.file.endsWith('.hesh')) { context.server.ws.send({ type: 'full-reload' }); return []; }
|
|
15
38
|
}
|
|
16
39
|
};
|