@teambit/api-server 0.0.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.
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const ApiServerAspect: Aspect;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ApiServerAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const ApiServerAspect = _harmony().Aspect.create({
15
+ id: 'teambit.harmony/api-server'
16
+ });
17
+ exports.ApiServerAspect = ApiServerAspect;
18
+
19
+ //# sourceMappingURL=api-server.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApiServerAspect","Aspect","create","id"],"sources":["api-server.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const ApiServerAspect = Aspect.create({\n id: 'teambit.harmony/api-server',\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,eAAe,GAAGC,iBAAM,CAACC,MAAM,CAAC;EAC3CC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
@@ -0,0 +1,25 @@
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { ExpressMain } from '@teambit/express';
3
+ import { Logger, LoggerMain } from '@teambit/logger';
4
+ import { WatcherMain } from '@teambit/watcher';
5
+ import { Workspace } from '@teambit/workspace';
6
+ export declare class ApiServerMain {
7
+ private workspace;
8
+ private logger;
9
+ private express;
10
+ private watcher;
11
+ constructor(workspace: Workspace, logger: Logger, express: ExpressMain, watcher: WatcherMain);
12
+ runApiServer(options: {
13
+ port: number;
14
+ }): Promise<unknown>;
15
+ static dependencies: import("@teambit/harmony").Aspect[];
16
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
17
+ static provider([cli, workspace, loggerMain, express, watcher]: [
18
+ CLIMain,
19
+ Workspace,
20
+ LoggerMain,
21
+ ExpressMain,
22
+ WatcherMain
23
+ ]): Promise<ApiServerMain>;
24
+ }
25
+ export default ApiServerMain;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.array.iterator.js");
5
+ require("core-js/modules/es.promise.js");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.default = exports.ApiServerMain = void 0;
10
+ function _defineProperty2() {
11
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ _defineProperty2 = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _cli() {
18
+ const data = require("@teambit/cli");
19
+ _cli = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _express() {
25
+ const data = require("@teambit/express");
26
+ _express = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _logger() {
32
+ const data = require("@teambit/logger");
33
+ _logger = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+ function _watcher() {
39
+ const data = _interopRequireDefault(require("@teambit/watcher"));
40
+ _watcher = function () {
41
+ return data;
42
+ };
43
+ return data;
44
+ }
45
+ function _workspace() {
46
+ const data = _interopRequireDefault(require("@teambit/workspace"));
47
+ _workspace = function () {
48
+ return data;
49
+ };
50
+ return data;
51
+ }
52
+ function _apiServer() {
53
+ const data = require("./api-server.aspect");
54
+ _apiServer = function () {
55
+ return data;
56
+ };
57
+ return data;
58
+ }
59
+ function _cli2() {
60
+ const data = require("./cli.route");
61
+ _cli2 = function () {
62
+ return data;
63
+ };
64
+ return data;
65
+ }
66
+ function _server() {
67
+ const data = require("./server.cmd");
68
+ _server = function () {
69
+ return data;
70
+ };
71
+ return data;
72
+ }
73
+ class ApiServerMain {
74
+ constructor(workspace, logger, express, watcher) {
75
+ this.workspace = workspace;
76
+ this.logger = logger;
77
+ this.express = express;
78
+ this.watcher = watcher;
79
+ }
80
+ async runApiServer(options) {
81
+ const port = options.port || 3000;
82
+ await this.express.listen(port);
83
+ this.watcher.watch({
84
+ preCompile: false
85
+ }).catch(err => {
86
+ // don't throw an error, we don't want to break the "run" process
87
+ this.logger.error('watcher found an error', err);
88
+ });
89
+
90
+ // never ending promise to not exit the process (is there a better way?)
91
+ return new Promise(() => {
92
+ this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);
93
+ });
94
+ }
95
+ static async provider([cli, workspace, loggerMain, express, watcher]) {
96
+ const logger = loggerMain.createLogger(_apiServer().ApiServerAspect.id);
97
+ const apiServer = new ApiServerMain(workspace, logger, express, watcher);
98
+ cli.register(new (_server().ServerCmd)(apiServer));
99
+ const cliRoute = new (_cli2().CLIRoute)(logger, cli);
100
+ // register only when the workspace is available. don't register this on a remote-scope, for security reasons.
101
+ if (workspace) {
102
+ express.register([cliRoute]);
103
+ }
104
+ return apiServer;
105
+ }
106
+ }
107
+ exports.ApiServerMain = ApiServerMain;
108
+ (0, _defineProperty2().default)(ApiServerMain, "dependencies", [_cli().CLIAspect, _workspace().default, _logger().LoggerAspect, _express().ExpressAspect, _watcher().default]);
109
+ (0, _defineProperty2().default)(ApiServerMain, "runtime", _cli().MainRuntime);
110
+ _apiServer().ApiServerAspect.addRuntime(ApiServerMain);
111
+ var _default = ApiServerMain;
112
+ exports.default = _default;
113
+
114
+ //# sourceMappingURL=api-server.main.runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApiServerMain","constructor","workspace","logger","express","watcher","runApiServer","options","port","listen","watch","preCompile","catch","err","error","Promise","consoleSuccess","provider","cli","loggerMain","createLogger","ApiServerAspect","id","apiServer","register","ServerCmd","cliRoute","CLIRoute","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","MainRuntime","addRuntime"],"sources":["api-server.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain } from '@teambit/express';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\n\nexport class ApiServerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain\n ) {}\n\n async runApiServer(options: { port: number }) {\n const port = options.port || 3000;\n await this.express.listen(port);\n\n this.watcher\n .watch({\n preCompile: false,\n })\n .catch((err) => {\n // don't throw an error, we don't want to break the \"run\" process\n this.logger.error('watcher found an error', err);\n });\n\n // never ending promise to not exit the process (is there a better way?)\n return new Promise(() => {\n this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);\n });\n }\n\n static dependencies = [CLIAspect, WorkspaceAspect, LoggerAspect, ExpressAspect, WatcherAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, loggerMain, express, watcher]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher);\n cli.register(new ServerCmd(apiServer));\n\n const cliRoute = new CLIRoute(logger, cli);\n // register only when the workspace is available. don't register this on a remote-scope, for security reasons.\n if (workspace) {\n express.register([cliRoute]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA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AMG,QAAQ,GAAG,KAAIC,gBAAQ,EAACxB,MAAM,EAAEe,GAAG,CAAC;IAC1C;IACA,IAAIhB,SAAS,EAAE;MACbE,OAAO,CAACoB,QAAQ,CAAC,CAACE,QAAQ,CAAC,CAAC;IAC9B;IAEA,OAAOH,SAAS;EAClB;AACF;AAAC;AAAA,gCAhDYvB,aAAa,kBA2BF,CAAC4B,gBAAS,EAAEC,oBAAe,EAAEC,sBAAY,EAAEC,wBAAa,EAAEC,kBAAa,CAAC;AAAA,gCA3BnFhC,aAAa,aA4BPiC,kBAAW;AAsB9BZ,4BAAe,CAACa,UAAU,CAAClC,aAAa,CAAC;AAAC,eAE3BA,aAAa;AAAA"}
@@ -0,0 +1,23 @@
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { Route, Request, Response } from '@teambit/express';
3
+ import { Logger } from '@teambit/logger';
4
+ /**
5
+ * example usage:
6
+ * post to http://localhost:3000/api/cli/list
7
+ * with the following json as the body
8
+ *
9
+ {
10
+ "args": ["teambit.workspace"],
11
+ "options": {
12
+ "ids": true
13
+ }
14
+ }
15
+ */
16
+ export declare class CLIRoute implements Route {
17
+ private logger;
18
+ private cli;
19
+ constructor(logger: Logger, cli: CLIMain);
20
+ method: string;
21
+ route: string;
22
+ middlewares: ((req: Request, res: Response, next: any) => Promise<void>)[];
23
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CLIRoute = void 0;
9
+ function _defineProperty2() {
10
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ _defineProperty2 = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function _prettyTime() {
17
+ const data = _interopRequireDefault(require("pretty-time"));
18
+ _prettyTime = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ /**
24
+ * example usage:
25
+ * post to http://localhost:3000/api/cli/list
26
+ * with the following json as the body
27
+ *
28
+ {
29
+ "args": ["teambit.workspace"],
30
+ "options": {
31
+ "ids": true
32
+ }
33
+ }
34
+ */
35
+ class CLIRoute {
36
+ constructor(logger, cli) {
37
+ this.logger = logger;
38
+ this.cli = cli;
39
+ (0, _defineProperty2().default)(this, "method", 'post');
40
+ (0, _defineProperty2().default)(this, "route", '/cli/:cmd');
41
+ (0, _defineProperty2().default)(this, "middlewares", [async (req, res, next) => {
42
+ this.logger.debug(`cli server: got request for ${req.params.cmd}`);
43
+ try {
44
+ const command = this.cli.getCommand(req.params.cmd);
45
+ if (!command) throw new Error(`command "${req.params.cmd}" was not found`);
46
+ if (!command.json) throw new Error(`command "${req.params.cmd}" does not have a json method`);
47
+ const body = req.body;
48
+ const {
49
+ args,
50
+ options
51
+ } = body;
52
+ const optsToString = Object.keys(options || {}).map(key => `--${key}`).join(' ');
53
+ this.logger.console(`started a new command: ${req.params.cmd} ${args.join(' ')} ${optsToString}`);
54
+ const startTask = process.hrtime();
55
+ const result = await (command === null || command === void 0 ? void 0 : command.json(args || [], options || {}));
56
+ const duration = (0, _prettyTime().default)(process.hrtime(startTask));
57
+ this.logger.consoleSuccess(`command "${req.params.cmd}" had been completed in ${duration}`);
58
+ res.json(result);
59
+ } catch (err) {
60
+ this.logger.consoleFailure(`command "${req.params.cmd}" had failed`);
61
+ next(err);
62
+ }
63
+ }]);
64
+ }
65
+ }
66
+ exports.CLIRoute = CLIRoute;
67
+
68
+ //# sourceMappingURL=cli.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CLIRoute","constructor","logger","cli","req","res","next","debug","params","cmd","command","getCommand","Error","json","body","args","options","optsToString","Object","keys","map","key","join","console","startTask","process","hrtime","result","duration","prettyTime","consoleSuccess","err","consoleFailure"],"sources":["cli.route.ts"],"sourcesContent":["import { CLIMain } from '@teambit/cli';\nimport prettyTime from 'pretty-time';\nimport { Route, Request, Response } from '@teambit/express';\nimport { Logger } from '@teambit/logger';\n\n/**\n * example usage:\n * post to http://localhost:3000/api/cli/list\n * with the following json as the body\n *\n{\n \"args\": [\"teambit.workspace\"],\n \"options\": {\n \"ids\": true\n }\n}\n */\nexport class CLIRoute implements Route {\n constructor(private logger: Logger, private cli: CLIMain) {}\n\n method = 'post';\n route = '/cli/:cmd';\n\n middlewares = [\n async (req: Request, res: Response, next) => {\n this.logger.debug(`cli server: got request for ${req.params.cmd}`);\n try {\n const command = this.cli.getCommand(req.params.cmd);\n if (!command) throw new Error(`command \"${req.params.cmd}\" was not found`);\n if (!command.json) throw new Error(`command \"${req.params.cmd}\" does not have a json method`);\n const body = req.body;\n const { args, options } = body;\n const optsToString = Object.keys(options || {})\n .map((key) => `--${key}`)\n .join(' ');\n this.logger.console(`started a new command: ${req.params.cmd} ${args.join(' ')} ${optsToString}`);\n const startTask = process.hrtime();\n const result = await command?.json(args || [], options || {});\n const duration = prettyTime(process.hrtime(startTask));\n this.logger.consoleSuccess(`command \"${req.params.cmd}\" had been completed in ${duration}`);\n res.json(result);\n } catch (err) {\n this.logger.consoleFailure(`command \"${req.params.cmd}\" had failed`);\n next(err);\n }\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,CAAkB;EACrCC,WAAW,CAASC,MAAc,EAAUC,GAAY,EAAE;IAAA,KAAtCD,MAAc,GAAdA,MAAc;IAAA,KAAUC,GAAY,GAAZA,GAAY;IAAA,gDAE/C,MAAM;IAAA,+CACP,WAAW;IAAA,qDAEL,CACZ,OAAOC,GAAY,EAAEC,GAAa,EAAEC,IAAI,KAAK;MAC3C,IAAI,CAACJ,MAAM,CAACK,KAAK,CAAE,+BAA8BH,GAAG,CAACI,MAAM,CAACC,GAAI,EAAC,CAAC;MAClE,IAAI;QACF,MAAMC,OAAO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AAC7B,MAAM,CAAC8B,cAAc,CAAE,YAAW5B,GAAG,CAACI,MAAM,CAACC,GAAI,cAAa,CAAC;QACpEH,IAAI,CAACyB,GAAG,CAAC;MACX;IACF,CAAC,CACF;EA5B0D;AA6B7D;AAAC"}
@@ -0,0 +1,4 @@
1
+ import { ApiServerAspect } from './api-server.aspect';
2
+ export type { ApiServerMain } from './api-server.main.runtime';
3
+ export default ApiServerAspect;
4
+ export { ApiServerAspect };
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ApiServerAspect", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _apiServer().ApiServerAspect;
10
+ }
11
+ });
12
+ exports.default = void 0;
13
+ function _apiServer() {
14
+ const data = require("./api-server.aspect");
15
+ _apiServer = function () {
16
+ return data;
17
+ };
18
+ return data;
19
+ }
20
+ var _default = _apiServer().ApiServerAspect;
21
+ exports.default = _default;
22
+
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApiServerAspect"],"sources":["index.ts"],"sourcesContent":["import { ApiServerAspect } from './api-server.aspect';\n\nexport type { ApiServerMain } from './api-server.main.runtime';\nexport default ApiServerAspect;\nexport { ApiServerAspect };\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAsD,eAGvCA,4BAAe;AAAA"}
@@ -0,0 +1,7 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
@@ -0,0 +1,15 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ApiServerMain } from './api-server.main.runtime';
3
+ export declare class ServerCmd implements Command {
4
+ private apiServer;
5
+ name: string;
6
+ description: string;
7
+ alias: string;
8
+ commands: Command[];
9
+ group: string;
10
+ options: CommandOptions;
11
+ constructor(apiServer: ApiServerMain);
12
+ report(args: any, options: {
13
+ port: number;
14
+ }): Promise<string>;
15
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ServerCmd = void 0;
9
+ function _defineProperty2() {
10
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ _defineProperty2 = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ // eslint-disable-next-line max-classes-per-file
17
+
18
+ class ServerCmd {
19
+ constructor(apiServer) {
20
+ this.apiServer = apiServer;
21
+ (0, _defineProperty2().default)(this, "name", 'server');
22
+ (0, _defineProperty2().default)(this, "description", 'EXPERIMENTAL. communicate with bit cli program via http requests');
23
+ (0, _defineProperty2().default)(this, "alias", '');
24
+ (0, _defineProperty2().default)(this, "commands", []);
25
+ (0, _defineProperty2().default)(this, "group", 'general');
26
+ (0, _defineProperty2().default)(this, "options", [['p', 'port [port]', 'port to run the server on']]);
27
+ }
28
+ async report(args, options) {
29
+ await this.apiServer.runApiServer(options);
30
+ return 'server is running successfully'; // should never get here, the previous line is blocking
31
+ }
32
+ }
33
+ exports.ServerCmd = ServerCmd;
34
+
35
+ //# sourceMappingURL=server.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ServerCmd","constructor","apiServer","report","args","options","runApiServer"],"sources":["server.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ApiServerMain } from './api-server.main.runtime';\n\nexport class ServerCmd implements Command {\n name = 'server';\n description = 'EXPERIMENTAL. communicate with bit cli program via http requests';\n alias = '';\n commands: Command[] = [];\n group = 'general';\n options = [['p', 'port [port]', 'port to run the server on']] as CommandOptions;\n\n constructor(private apiServer: ApiServerMain) {}\n\n async report(args, options: { port: number }): Promise<string> {\n await this.apiServer.runApiServer(options);\n return 'server is running successfully'; // should never get here, the previous line is blocking\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAIO,MAAMA,SAAS,CAAoB;EAQxCC,WAAW,CAASC,SAAwB,EAAE;IAAA,KAA1BA,SAAwB,GAAxBA,SAAwB;IAAA,8CAPrC,QAAQ;IAAA,qDACD,kEAAkE;IAAA,+CACxE,EAAE;IAAA,kDACY,EAAE;IAAA,+CAChB,SAAS;IAAA,iDACP,CAAC,CAAC,GAAG,EAAE,aAAa,EAAE,2BAA2B,CAAC,CAAC;EAEd;EAE/C,MAAMC,MAAM,CAACC,IAAI,EAAEC,OAAyB,EAAmB;IAC7D,MAAM,IAAI,CAACH,SAAS,CAACI,YAAY,CAACD,OAAO,CAAC;IAC1C,OAAO,gCAAgC,CAAC,CAAC;EAC3C;AACF;AAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@teambit/api-server",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "componentId": {
6
+ "scope": "teambit.harmony",
7
+ "name": "api-server",
8
+ "version": "0.0.1"
9
+ },
10
+ "dependencies": {
11
+ "pretty-time": "1.1.0",
12
+ "core-js": "^3.0.0",
13
+ "@babel/runtime": "7.20.0",
14
+ "@teambit/harmony": "0.4.6",
15
+ "@teambit/cli": "0.0.664",
16
+ "@teambit/express": "0.0.762",
17
+ "@teambit/logger": "0.0.757",
18
+ "@teambit/watcher": "0.0.1",
19
+ "@teambit/workspace": "0.0.989"
20
+ },
21
+ "devDependencies": {
22
+ "@types/mocha": "9.1.0",
23
+ "@types/node": "12.20.4",
24
+ "@types/react": "^17.0.8",
25
+ "@types/react-dom": "^17.0.5",
26
+ "@types/jest": "^26.0.0",
27
+ "@types/testing-library__jest-dom": "5.9.5"
28
+ },
29
+ "peerDependencies": {
30
+ "@teambit/legacy": "1.0.445",
31
+ "react": "^16.8.0 || ^17.0.0",
32
+ "react-dom": "^16.8.0 || ^17.0.0"
33
+ },
34
+ "license": "Apache-2.0",
35
+ "private": false,
36
+ "engines": {
37
+ "node": ">=12.22.0"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/teambit/bit"
42
+ },
43
+ "keywords": [
44
+ "bit",
45
+ "bit-aspect",
46
+ "components",
47
+ "collaboration",
48
+ "web",
49
+ "react",
50
+ "react-components",
51
+ "angular",
52
+ "angular-components"
53
+ ]
54
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": [
4
+ "es2019",
5
+ "DOM",
6
+ "ES6",
7
+ "DOM.Iterable",
8
+ "ScriptHost"
9
+ ],
10
+ "target": "es2015",
11
+ "module": "commonjs",
12
+ "jsx": "react",
13
+ "allowJs": true,
14
+ "composite": true,
15
+ "declaration": true,
16
+ "sourceMap": true,
17
+ "skipLibCheck": true,
18
+ "experimentalDecorators": true,
19
+ "outDir": "dist",
20
+ "moduleResolution": "node",
21
+ "esModuleInterop": true,
22
+ "rootDir": ".",
23
+ "resolveJsonModule": true,
24
+ "emitDeclarationOnly": true,
25
+ "emitDecoratorMetadata": true,
26
+ "allowSyntheticDefaultImports": true,
27
+ "strictPropertyInitialization": false,
28
+ "strict": true,
29
+ "noImplicitAny": false,
30
+ "preserveConstEnums": true
31
+ },
32
+ "exclude": [
33
+ "dist",
34
+ "package.json"
35
+ ],
36
+ "include": [
37
+ "**/*",
38
+ "**/*.json"
39
+ ]
40
+ }
@@ -0,0 +1,29 @@
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<SVGProps<SVGSVGElement> & { title?: string }>;
9
+ const src: string;
10
+ export default src;
11
+ }
12
+
13
+ // @TODO Gilad
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
+ }
@@ -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
+ }