evolit 0.3.0 → 0.4.1
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 +62 -0
- package/package.json +7 -1
- package/src/build.js +65 -10
- package/src/client-assets.js +1 -0
- package/src/compiler.js +57 -14
- package/src/deployment-runtime.js +60 -6
- package/src/index.js +3 -0
- package/src/litsx-pipeline.d.ts +138 -0
- package/src/litsx-pipeline.js +713 -0
- package/src/render.js +1 -0
- package/src/server-setup.js +2 -1
- package/src/server.js +40 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TransformLitsxOptions,
|
|
3
|
+
TransformLitsxResult,
|
|
4
|
+
} from "@litsx/compiler";
|
|
5
|
+
|
|
6
|
+
export type EvolitMode = "development" | "production";
|
|
7
|
+
export type EvolitLitsxTarget = "server" | "client";
|
|
8
|
+
|
|
9
|
+
export type EvolitLitsxCompilerOptions = Omit<
|
|
10
|
+
TransformLitsxOptions,
|
|
11
|
+
"filename" | "ssr" | "reactCompat"
|
|
12
|
+
> & {
|
|
13
|
+
/** Evolit always uses native LitSX lowering. */
|
|
14
|
+
reactCompat?: false;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type EvolitLitsxOutput = {
|
|
18
|
+
id: string;
|
|
19
|
+
kind: "asset" | "module" | "style";
|
|
20
|
+
content: string | Uint8Array;
|
|
21
|
+
specifier?: string;
|
|
22
|
+
document?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type EvolitLitsxContribution = Partial<TransformLitsxResult> & {
|
|
26
|
+
dependencies?: string[];
|
|
27
|
+
outputs?: EvolitLitsxOutput[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type EvolitLitsxIntegrationContext = {
|
|
31
|
+
readonly projectRoot: string;
|
|
32
|
+
readonly mode: EvolitMode;
|
|
33
|
+
readonly identity: Readonly<{ id: string }>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type EvolitLitsxModuleContext = {
|
|
37
|
+
readonly sourcePath: string;
|
|
38
|
+
readonly source: string;
|
|
39
|
+
readonly target: EvolitLitsxTarget;
|
|
40
|
+
readonly ssr: boolean;
|
|
41
|
+
readonly sourceMaps: boolean;
|
|
42
|
+
readonly generation: number;
|
|
43
|
+
readonly result: TransformLitsxResult;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type EvolitLitsxIntegrationInstance = {
|
|
47
|
+
compiler?: EvolitLitsxCompilerOptions | ((context: {
|
|
48
|
+
filename: string;
|
|
49
|
+
ssr: boolean;
|
|
50
|
+
sourceMaps: boolean;
|
|
51
|
+
mode: EvolitMode;
|
|
52
|
+
}) => EvolitLitsxCompilerOptions);
|
|
53
|
+
resolveModule?(context: Readonly<{
|
|
54
|
+
specifier: string;
|
|
55
|
+
importer: string;
|
|
56
|
+
target: EvolitLitsxTarget;
|
|
57
|
+
ssr: boolean;
|
|
58
|
+
sourceMaps: boolean;
|
|
59
|
+
generation: number;
|
|
60
|
+
mode: EvolitMode;
|
|
61
|
+
}>): null | void | {
|
|
62
|
+
code: string;
|
|
63
|
+
map?: unknown;
|
|
64
|
+
dependencies?: string[];
|
|
65
|
+
} | Promise<null | void | {
|
|
66
|
+
code: string;
|
|
67
|
+
map?: unknown;
|
|
68
|
+
dependencies?: string[];
|
|
69
|
+
}>;
|
|
70
|
+
processModule?(context: EvolitLitsxModuleContext): EvolitLitsxContribution | void | Promise<EvolitLitsxContribution | void>;
|
|
71
|
+
finalize?(context: Readonly<Record<string, unknown> & {
|
|
72
|
+
generation: number;
|
|
73
|
+
mode: EvolitMode;
|
|
74
|
+
}>): EvolitLitsxContribution | void | Promise<EvolitLitsxContribution | void>;
|
|
75
|
+
invalidate?(context: Readonly<{
|
|
76
|
+
paths: string[] | null;
|
|
77
|
+
affected: boolean;
|
|
78
|
+
generation: number;
|
|
79
|
+
mode: EvolitMode;
|
|
80
|
+
}>): void | Promise<void>;
|
|
81
|
+
forget?(context: Readonly<{
|
|
82
|
+
moduleId: string;
|
|
83
|
+
generation: number;
|
|
84
|
+
mode: EvolitMode;
|
|
85
|
+
}>): void | Promise<void>;
|
|
86
|
+
dispose?(): void | Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type EvolitLitsxIntegration = {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
create(context: EvolitLitsxIntegrationContext): EvolitLitsxIntegrationInstance | Promise<EvolitLitsxIntegrationInstance>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type EvolitLitsxConfig = {
|
|
95
|
+
compiler?: EvolitLitsxCompilerOptions;
|
|
96
|
+
integrations?: EvolitLitsxIntegration[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type EvolitConfig = {
|
|
100
|
+
litsx?: EvolitLitsxConfig;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type EvolitLitsxPipeline = {
|
|
105
|
+
readonly identity: Readonly<{ id: string }>;
|
|
106
|
+
readonly generation: number;
|
|
107
|
+
readonly dependencies: string[];
|
|
108
|
+
getOutputRelativePath(sourcePath: string): string | null;
|
|
109
|
+
getCompilerOptions(context: { filename: string; ssr: boolean; sourceMaps: boolean }): TransformLitsxOptions;
|
|
110
|
+
resolveModule(specifier: string, context: {
|
|
111
|
+
importer: string;
|
|
112
|
+
target: EvolitLitsxTarget;
|
|
113
|
+
ssr: boolean;
|
|
114
|
+
sourceMaps: boolean;
|
|
115
|
+
}): Promise<string | null>;
|
|
116
|
+
registerResolvedModule(specifier: string, sourcePath: string, outputPath: string): void;
|
|
117
|
+
processModule(result: TransformLitsxResult, context: Omit<EvolitLitsxModuleContext, "result" | "generation">): Promise<TransformLitsxResult & { evolitDependencies: string[] }>;
|
|
118
|
+
finalize(context?: Record<string, unknown>): Promise<null | {
|
|
119
|
+
assets: Array<{ integration: string; id: string; kind: string; outputPath: string; hash: string; size: number }>;
|
|
120
|
+
documentStyles: Array<{ integration: string; id: string; kind: string; outputPath: string; hash: string; size: number }>;
|
|
121
|
+
}>;
|
|
122
|
+
invalidate(changedPaths?: string[] | null): Promise<boolean>;
|
|
123
|
+
forget(moduleId: string): Promise<void>;
|
|
124
|
+
dispose(): Promise<void>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export function createLitsxPipeline(options: {
|
|
128
|
+
projectRoot: string;
|
|
129
|
+
mode: EvolitMode;
|
|
130
|
+
config?: EvolitConfig;
|
|
131
|
+
}): Promise<EvolitLitsxPipeline | null>;
|
|
132
|
+
|
|
133
|
+
export function defineEvolitConfig<T extends EvolitConfig>(config: T): T;
|
|
134
|
+
export function defineLitsxIntegration<T extends EvolitLitsxIntegration>(integration: T): T;
|
|
135
|
+
export function mergeLitsxAssetsIntoManifest<T extends Record<string, unknown>>(
|
|
136
|
+
manifest: T,
|
|
137
|
+
integrationManifest: Awaited<ReturnType<EvolitLitsxPipeline["finalize"]>>,
|
|
138
|
+
): T;
|