/
GlimmerProject.ts
75 lines (68 loc) · 2.25 KB
/
GlimmerProject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {
ResolutionMap,
} from "@glimmer/resolution-map-builder";
import Resolver, {
BasicModuleRegistry,
} from "@glimmer/resolver";
import {
SerializedTemplateInfo,
TemplateInfo,
TemplateInfoFactory,
} from "@opticss/template-api";
import { whatever } from "@opticss/util";
import {
BlockFactory,
Importer,
PluginOptions,
} from "css-blocks";
declare module "@opticss/template-api" {
interface TemplateTypes {
"GlimmerTemplates.ResolvedFile": ResolvedFile;
}
}
export interface ResolvedPath {
specifier: string;
fullPath: string;
}
export class ResolvedFile implements TemplateInfo<"GlimmerTemplates.ResolvedFile"> {
identifier: string;
string: string;
fullPath: string;
type: "GlimmerTemplates.ResolvedFile" = "GlimmerTemplates.ResolvedFile";
constructor(templateString: string, specifier: string, fullPath: string) {
this.identifier = specifier;
this.string = templateString;
this.fullPath = fullPath;
}
serialize(): SerializedTemplateInfo<"GlimmerTemplates.ResolvedFile"> {
return {
type: this.type,
identifier: this.identifier,
data: [
this.string,
this.fullPath,
],
};
}
static deserialize(identifier: string, str: whatever, fullPath: whatever): ResolvedFile {
return new ResolvedFile(<string>str, identifier, <string>fullPath);
}
}
TemplateInfoFactory.constructors["GlimmerTemplates.ResolvedFile"] = ResolvedFile.deserialize;
export interface GlimmerProject {
projectDir: string;
map: ResolutionMap;
resolver: Resolver;
registry: BasicModuleRegistry;
blockImporter: Importer;
blockFactory: BlockFactory;
cssBlocksOpts: PluginOptions;
resolveStylesheet(glimmerIdentifier: string, fromGlimmerIdentifier?: string): ResolvedPath | null;
resolveTemplate(glimmerIdentifier: string, fromGlimmerIdentifier?: string): ResolvedPath | null;
resolve(glimmerIdentifier: string, fromGlimmerIdentifier?: string): ResolvedPath | null;
resolveFile(glimmerIdentifier: string, fromGlimmerIdentifier?: string): ResolvedFile | null;
relativize(fullPath: string): string;
stylesheetFor(stylesheetName: string, fromGlimmerIdentifier?: string): ResolvedFile | undefined;
templateFor(templateName: string, fromGlimmerIdentifier?: string): ResolvedFile;
reset(): void;
}