@teambit/component.testing.mock-components 0.0.0-7802edf384030648cac749982d11cf340e669709
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/dist/index.d.ts +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/mock-components.d.ts +23 -0
- package/dist/mock-components.js +131 -0
- package/dist/mock-components.js.map +1 -0
- package/index.ts +1 -0
- package/mock-components.ts +71 -0
- package/package.json +45 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mockComponents, modifyMockedComponents } from './mock-components';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "mockComponents", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _mockComponents().mockComponents;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "modifyMockedComponents", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _mockComponents().modifyMockedComponents;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
function _mockComponents() {
|
|
19
|
+
const data = require("./mock-components");
|
|
20
|
+
_mockComponents = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_mockComponents","data","require"],"sources":["index.ts"],"sourcesContent":["export { mockComponents, modifyMockedComponents } from './mock-components';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
type CompDirs = {
|
|
3
|
+
id: ComponentID;
|
|
4
|
+
/**
|
|
5
|
+
* absolute path to the component dir
|
|
6
|
+
*/
|
|
7
|
+
dir: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* create dummy components, add, link and compile them.
|
|
11
|
+
* if `numOfComponents` is more than one, the components will depend on each other. by default, it's one.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mockComponents(workspacePath: string, { numOfComponents, additionalStr }?: {
|
|
14
|
+
numOfComponents?: number | undefined;
|
|
15
|
+
additionalStr?: string | undefined;
|
|
16
|
+
}): Promise<CompDirs[]>;
|
|
17
|
+
/**
|
|
18
|
+
* make the mocked components modified by appending the `additionalStr` to the component files
|
|
19
|
+
*/
|
|
20
|
+
export declare function modifyMockedComponents(workspacePath: string, additionalStr?: string, { numOfComponents }?: {
|
|
21
|
+
numOfComponents?: number | undefined;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mockComponents = mockComponents;
|
|
7
|
+
exports.modifyMockedComponents = modifyMockedComponents;
|
|
8
|
+
function _compiler() {
|
|
9
|
+
const data = require("@teambit/compiler");
|
|
10
|
+
_compiler = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _harmonyTesting() {
|
|
16
|
+
const data = require("@teambit/harmony.testing.load-aspect");
|
|
17
|
+
_harmonyTesting = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _workspace() {
|
|
23
|
+
const data = require("@teambit/workspace");
|
|
24
|
+
_workspace = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function _install() {
|
|
30
|
+
const data = require("@teambit/install");
|
|
31
|
+
_install = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
function _fsExtra() {
|
|
37
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
38
|
+
_fsExtra = function () {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
function _pMapSeries() {
|
|
44
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
45
|
+
_pMapSeries = function () {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function _path() {
|
|
51
|
+
const data = _interopRequireDefault(require("path"));
|
|
52
|
+
_path = function () {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
function _tracker() {
|
|
58
|
+
const data = require("@teambit/tracker");
|
|
59
|
+
_tracker = function () {
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
65
|
+
/**
|
|
66
|
+
* create dummy components, add, link and compile them.
|
|
67
|
+
* if `numOfComponents` is more than one, the components will depend on each other. by default, it's one.
|
|
68
|
+
*/
|
|
69
|
+
async function mockComponents(workspacePath, {
|
|
70
|
+
numOfComponents = 1,
|
|
71
|
+
additionalStr = ''
|
|
72
|
+
} = {}) {
|
|
73
|
+
const compsDirs = await createComponents(workspacePath, {
|
|
74
|
+
numOfComponents,
|
|
75
|
+
additionalStr
|
|
76
|
+
});
|
|
77
|
+
const harmony = await (0, _harmonyTesting().loadManyAspects)([_workspace().WorkspaceAspect, _tracker().TrackerAspect, _install().InstallAspect, _compiler().CompilerAspect], workspacePath);
|
|
78
|
+
const workspace = harmony.get(_workspace().WorkspaceAspect.id);
|
|
79
|
+
const tracker = harmony.get(_tracker().TrackerAspect.id);
|
|
80
|
+
const results = await (0, _pMapSeries().default)(compsDirs, async compDir => {
|
|
81
|
+
const {
|
|
82
|
+
componentId
|
|
83
|
+
} = await tracker.track({
|
|
84
|
+
rootDir: compDir
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
id: componentId,
|
|
88
|
+
dir: compDir
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
await workspace.bitMap.write();
|
|
92
|
+
const install = harmony.get(_install().InstallAspect.id);
|
|
93
|
+
await install.link({
|
|
94
|
+
rewire: true
|
|
95
|
+
});
|
|
96
|
+
const compiler = harmony.get(_compiler().CompilerAspect.id);
|
|
97
|
+
await compiler.compileOnWorkspace();
|
|
98
|
+
return results;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* make the mocked components modified by appending the `additionalStr` to the component files
|
|
103
|
+
*/
|
|
104
|
+
async function modifyMockedComponents(workspacePath, additionalStr = ' ', {
|
|
105
|
+
numOfComponents = 1
|
|
106
|
+
} = {}) {
|
|
107
|
+
await createComponents(workspacePath, {
|
|
108
|
+
numOfComponents,
|
|
109
|
+
additionalStr
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async function createComponents(workspacePath, {
|
|
113
|
+
numOfComponents = 1,
|
|
114
|
+
additionalStr = ''
|
|
115
|
+
} = {}) {
|
|
116
|
+
const getImp = index => {
|
|
117
|
+
if (index === numOfComponents) return `module.exports = () => 'comp${index}${additionalStr}';`;
|
|
118
|
+
const nextComp = `comp${index + 1}`;
|
|
119
|
+
return `const ${nextComp} = require('../${nextComp}');
|
|
120
|
+
module.exports = () => 'comp${index}${additionalStr} and ' + ${nextComp}();`;
|
|
121
|
+
};
|
|
122
|
+
const numOfComponentsArr = Array(numOfComponents).fill(null);
|
|
123
|
+
return (0, _pMapSeries().default)(numOfComponentsArr, async (val, key) => {
|
|
124
|
+
const i = key + 1;
|
|
125
|
+
const compDir = _path().default.join(workspacePath, `comp${i}`);
|
|
126
|
+
await _fsExtra().default.outputFile(_path().default.join(compDir, `index.js`), getImp(i));
|
|
127
|
+
return compDir;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=mock-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_compiler","data","require","_harmonyTesting","_workspace","_install","_fsExtra","_interopRequireDefault","_pMapSeries","_path","_tracker","e","__esModule","default","mockComponents","workspacePath","numOfComponents","additionalStr","compsDirs","createComponents","harmony","loadManyAspects","WorkspaceAspect","TrackerAspect","InstallAspect","CompilerAspect","workspace","get","id","tracker","results","pMapSeries","compDir","componentId","track","rootDir","dir","bitMap","write","install","link","rewire","compiler","compileOnWorkspace","modifyMockedComponents","getImp","index","nextComp","numOfComponentsArr","Array","fill","val","key","i","path","join","fs","outputFile"],"sources":["mock-components.ts"],"sourcesContent":["import { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { loadManyAspects } from '@teambit/harmony.testing.load-aspect';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport { InstallAspect } from '@teambit/install';\nimport type { InstallMain } from '@teambit/install';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { TrackerAspect, TrackerMain } from '@teambit/tracker';\nimport { ComponentID } from '@teambit/component-id';\n\ntype CompDirs = {\n id: ComponentID;\n /**\n * absolute path to the component dir\n */\n dir: string;\n};\n\n/**\n * create dummy components, add, link and compile them.\n * if `numOfComponents` is more than one, the components will depend on each other. by default, it's one.\n */\nexport async function mockComponents(\n workspacePath: string,\n { numOfComponents = 1, additionalStr = '' } = {}\n): Promise<CompDirs[]> {\n const compsDirs = await createComponents(workspacePath, { numOfComponents, additionalStr });\n const harmony = await loadManyAspects([WorkspaceAspect, TrackerAspect, InstallAspect, CompilerAspect], workspacePath);\n const workspace = harmony.get<Workspace>(WorkspaceAspect.id);\n const tracker = harmony.get<TrackerMain>(TrackerAspect.id);\n const results: CompDirs[] = await pMapSeries(compsDirs, async (compDir) => {\n const { componentId } = await tracker.track({ rootDir: compDir });\n return { id: componentId, dir: compDir };\n });\n await workspace.bitMap.write();\n const install = harmony.get<InstallMain>(InstallAspect.id);\n await install.link({ rewire: true });\n\n const compiler = harmony.get<CompilerMain>(CompilerAspect.id);\n await compiler.compileOnWorkspace();\n\n return results;\n}\n\n/**\n * make the mocked components modified by appending the `additionalStr` to the component files\n */\nexport async function modifyMockedComponents(workspacePath: string, additionalStr = ' ', { numOfComponents = 1 } = {}) {\n await createComponents(workspacePath, { numOfComponents, additionalStr });\n}\n\nasync function createComponents(\n workspacePath: string,\n { numOfComponents = 1, additionalStr = '' } = {}\n): Promise<string[]> {\n const getImp = (index) => {\n if (index === numOfComponents) return `module.exports = () => 'comp${index}${additionalStr}';`;\n const nextComp = `comp${index + 1}`;\n return `const ${nextComp} = require('../${nextComp}');\nmodule.exports = () => 'comp${index}${additionalStr} and ' + ${nextComp}();`;\n };\n\n const numOfComponentsArr = Array(numOfComponents).fill(null);\n return pMapSeries(numOfComponentsArr, async (val, key) => {\n const i = key + 1;\n const compDir = path.join(workspacePath, `comp${i}`);\n await fs.outputFile(path.join(compDir, `index.js`), getImp(i));\n return compDir;\n });\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,gBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,eAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAA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AAC,EAC7B;EACnB,MAAM4B,MAAM,GAAIC,KAAK,IAAK;IACxB,IAAIA,KAAK,KAAK9B,eAAe,EAAE,OAAO,+BAA+B8B,KAAK,GAAG7B,aAAa,IAAI;IAC9F,MAAM8B,QAAQ,GAAG,OAAOD,KAAK,GAAG,CAAC,EAAE;IACnC,OAAO,SAASC,QAAQ,kBAAkBA,QAAQ;AACtD,8BAA8BD,KAAK,GAAG7B,aAAa,YAAY8B,QAAQ,KAAK;EAC1E,CAAC;EAED,MAAMC,kBAAkB,GAAGC,KAAK,CAACjC,eAAe,CAAC,CAACkC,IAAI,CAAC,IAAI,CAAC;EAC5D,OAAO,IAAAnB,qBAAU,EAACiB,kBAAkB,EAAE,OAAOG,GAAG,EAAEC,GAAG,KAAK;IACxD,MAAMC,CAAC,GAAGD,GAAG,GAAG,CAAC;IACjB,MAAMpB,OAAO,GAAGsB,eAAI,CAACC,IAAI,CAACxC,aAAa,EAAE,OAAOsC,CAAC,EAAE,CAAC;IACpD,MAAMG,kBAAE,CAACC,UAAU,CAACH,eAAI,CAACC,IAAI,CAACvB,OAAO,EAAE,UAAU,CAAC,EAAEa,MAAM,CAACQ,CAAC,CAAC,CAAC;IAC9D,OAAOrB,OAAO;EAChB,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mockComponents, modifyMockedComponents } from './mock-components';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CompilerAspect, CompilerMain } from '@teambit/compiler';
|
|
2
|
+
import { loadManyAspects } from '@teambit/harmony.testing.load-aspect';
|
|
3
|
+
import { WorkspaceAspect, Workspace } from '@teambit/workspace';
|
|
4
|
+
import { InstallAspect } from '@teambit/install';
|
|
5
|
+
import type { InstallMain } from '@teambit/install';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import pMapSeries from 'p-map-series';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { TrackerAspect, TrackerMain } from '@teambit/tracker';
|
|
10
|
+
import { ComponentID } from '@teambit/component-id';
|
|
11
|
+
|
|
12
|
+
type CompDirs = {
|
|
13
|
+
id: ComponentID;
|
|
14
|
+
/**
|
|
15
|
+
* absolute path to the component dir
|
|
16
|
+
*/
|
|
17
|
+
dir: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* create dummy components, add, link and compile them.
|
|
22
|
+
* if `numOfComponents` is more than one, the components will depend on each other. by default, it's one.
|
|
23
|
+
*/
|
|
24
|
+
export async function mockComponents(
|
|
25
|
+
workspacePath: string,
|
|
26
|
+
{ numOfComponents = 1, additionalStr = '' } = {}
|
|
27
|
+
): Promise<CompDirs[]> {
|
|
28
|
+
const compsDirs = await createComponents(workspacePath, { numOfComponents, additionalStr });
|
|
29
|
+
const harmony = await loadManyAspects([WorkspaceAspect, TrackerAspect, InstallAspect, CompilerAspect], workspacePath);
|
|
30
|
+
const workspace = harmony.get<Workspace>(WorkspaceAspect.id);
|
|
31
|
+
const tracker = harmony.get<TrackerMain>(TrackerAspect.id);
|
|
32
|
+
const results: CompDirs[] = await pMapSeries(compsDirs, async (compDir) => {
|
|
33
|
+
const { componentId } = await tracker.track({ rootDir: compDir });
|
|
34
|
+
return { id: componentId, dir: compDir };
|
|
35
|
+
});
|
|
36
|
+
await workspace.bitMap.write();
|
|
37
|
+
const install = harmony.get<InstallMain>(InstallAspect.id);
|
|
38
|
+
await install.link({ rewire: true });
|
|
39
|
+
|
|
40
|
+
const compiler = harmony.get<CompilerMain>(CompilerAspect.id);
|
|
41
|
+
await compiler.compileOnWorkspace();
|
|
42
|
+
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* make the mocked components modified by appending the `additionalStr` to the component files
|
|
48
|
+
*/
|
|
49
|
+
export async function modifyMockedComponents(workspacePath: string, additionalStr = ' ', { numOfComponents = 1 } = {}) {
|
|
50
|
+
await createComponents(workspacePath, { numOfComponents, additionalStr });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function createComponents(
|
|
54
|
+
workspacePath: string,
|
|
55
|
+
{ numOfComponents = 1, additionalStr = '' } = {}
|
|
56
|
+
): Promise<string[]> {
|
|
57
|
+
const getImp = (index) => {
|
|
58
|
+
if (index === numOfComponents) return `module.exports = () => 'comp${index}${additionalStr}';`;
|
|
59
|
+
const nextComp = `comp${index + 1}`;
|
|
60
|
+
return `const ${nextComp} = require('../${nextComp}');
|
|
61
|
+
module.exports = () => 'comp${index}${additionalStr} and ' + ${nextComp}();`;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const numOfComponentsArr = Array(numOfComponents).fill(null);
|
|
65
|
+
return pMapSeries(numOfComponentsArr, async (val, key) => {
|
|
66
|
+
const i = key + 1;
|
|
67
|
+
const compDir = path.join(workspacePath, `comp${i}`);
|
|
68
|
+
await fs.outputFile(path.join(compDir, `index.js`), getImp(i));
|
|
69
|
+
return compDir;
|
|
70
|
+
});
|
|
71
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/component.testing.mock-components",
|
|
3
|
+
"version": "0.0.0-7802edf384030648cac749982d11cf340e669709",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/component/testing/mock-components",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "teambit.component",
|
|
8
|
+
"name": "testing/mock-components",
|
|
9
|
+
"version": "7802edf384030648cac749982d11cf340e669709"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"fs-extra": "10.0.0",
|
|
13
|
+
"p-map-series": "2.1.0",
|
|
14
|
+
"@teambit/component-id": "1.2.4",
|
|
15
|
+
"@teambit/harmony.testing.load-aspect": "0.0.0-2ed8c1c23152bb044f11190dbb3d391ea0c2cd1a"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/fs-extra": "9.0.7",
|
|
19
|
+
"@types/mocha": "9.1.0",
|
|
20
|
+
"chai": "4.3.0",
|
|
21
|
+
"@teambit/node.envs.node-babel-mocha": "0.1.5"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"optionalDependencies": {},
|
|
26
|
+
"peerDependenciesMeta": {},
|
|
27
|
+
"private": false,
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=12.22.0"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/teambit/bit"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"bit",
|
|
37
|
+
"components",
|
|
38
|
+
"collaboration",
|
|
39
|
+
"web",
|
|
40
|
+
"react",
|
|
41
|
+
"react-components",
|
|
42
|
+
"angular",
|
|
43
|
+
"angular-components"
|
|
44
|
+
]
|
|
45
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|