Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
feat(sassloader): export updated interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jul 20, 2018
1 parent 356bf24 commit 88ec0c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/interop/importer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import { SassImportEntry, SassImportEntryInterface } from './importer/sassImportEntry';
import { getFnPtrHandler } from './fnPtrHandler';
import { importCallbackType, SassImportEntry, SassImportEntryInterface } from './importer/sassImportEntry';
import { wrapSassImporter } from './importer/wrapSassImporter';
import { buildInteropUtility } from './interopUtility';

const importEntryFactory = (entry: SassImportEntry) => {
function importEntryFactory(importCallback: importCallbackType): SassImportEntryInterface;
function importEntryFactory(rel: string, abs: string, source: string, sourceMap: string): SassImportEntryInterface;
function importEntryFactory(...args: Array<any>) {
if (args.length === 1) {
entry.makeImport(args[0]);
} else {
const [rel, abs, source, sourceMap] = args;
entry.makeImporter(rel, abs, source, sourceMap);
}
return entry;
}
return importEntryFactory;
};

const buildImporter = (
cwrapImporter: ReturnType<typeof wrapSassImporter>,
interop: ReturnType<typeof buildInteropUtility>
interop: ReturnType<typeof buildInteropUtility>,
fnPtrHandler: ReturnType<typeof getFnPtrHandler>
) => {
return {
importEntry: {
create: ({ rel, abs, source, sourceMap }: { rel: string; abs: string; source: string; sourceMap: string }) =>
new SassImportEntry(cwrapImporter, interop.str, rel, abs, source, sourceMap) as SassImportEntryInterface
create: importEntryFactory(new SassImportEntry(cwrapImporter, interop.str, fnPtrHandler))
}
};
};
Expand Down
4 changes: 3 additions & 1 deletion src/sassLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { buildContext } from './interop/context';
import { getFnPtrHandler } from './interop/fnPtrHandler';
import { buildImporter } from './interop/importer';
import { wrapSassImporter } from './interop/importer/wrapSassImporter';
import { buildInteropUtility } from './interop/interopUtility';
Expand All @@ -21,11 +22,12 @@ export const sassLoader = (asmModule: SassAsmModule): SassFactory => {
const cwrapImporter = wrapSassImporter(cwrap);

const interop = buildInteropUtility(asmModule);
const fnPtrHandler = getFnPtrHandler(asmModule);

return {
getVersion: getVersion(asmModule),
context: buildContext(cwrapCtx, cwrapOptions, cwrapImporter, interop),
importer: buildImporter(cwrapImporter, interop),
importer: buildImporter(cwrapImporter, interop, fnPtrHandler),
interop,
raw: {
context: cwrapCtx,
Expand Down

0 comments on commit 88ec0c6

Please sign in to comment.