1
+ import { Syntax } from '../BlockParser' ;
2
+ import { ResolvedConfiguration } from '../configuration' ;
3
+ import { Importer , FileIdentifier , ImportedFile } from './Importer' ;
4
+
5
+ /**
6
+ * The BaseImporter is an abstract class that Importer implementations may extend from.
7
+ * This follows the Importer interface that must be used for interacting with the BlockFactory.
8
+ * We also include additional utility methods that are useful for handling CSS Blocks,
9
+ * Compiled CSS, and Definition Files.
10
+ */
11
+ export abstract class BaseImporter implements Importer {
12
+ /**
13
+ * Compute a unique identifier for a given import path. If `fromIdentifier` is provided,
14
+ * the importPath can be relative to the file that is identified by it.
15
+ */
16
+ abstract identifier ( fromIdentifier : FileIdentifier | null , importPath : string , config : ResolvedConfiguration ) : FileIdentifier ;
17
+ /**
18
+ * Import the file with the given metadata and return a string and meta data for it.
19
+ */
20
+ abstract import ( identifier : FileIdentifier , config : ResolvedConfiguration ) : Promise < ImportedFile > ;
21
+ /**
22
+ * The default name of the block used unless the block specifies one itself.
23
+ */
24
+ abstract defaultName ( identifier : FileIdentifier , configuration : ResolvedConfiguration ) : string ;
25
+ /**
26
+ * If a file identifier has an on-disk representation, return an absolute path to it.
27
+ */
28
+ abstract filesystemPath ( identifier : FileIdentifier , config : ResolvedConfiguration ) : string | null ;
29
+ /**
30
+ * Returns a string meant for human consumption that identifies the file.
31
+ * As is used in debug statements and error reporting. Unlike filesystemPath,
32
+ * this needn't resolve to an actual file or be an absolute path.
33
+ */
34
+ abstract debugIdentifier ( identifier : FileIdentifier , config : ResolvedConfiguration ) : string ;
35
+ /**
36
+ * Returns the syntax the contents are written in.
37
+ */
38
+ abstract syntax ( identifier : FileIdentifier , config : ResolvedConfiguration ) : Syntax ;
39
+ }
0 commit comments