@qodalis/cli-core 0.0.4 → 0.0.6
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/README.md
CHANGED
|
@@ -121,6 +121,7 @@ root:~$
|
|
|
121
121
|
|
|
122
122
|
- [@qodalis/cli-guid](https://www.npmjs.com/package/@qodalis/cli-guid) - utility for guid
|
|
123
123
|
- [@qodalis/cli-server-logs](https://www.npmjs.com/package/@qodalis/cli-server-logs) - utility for live server logs
|
|
124
|
+
- [@qodalis/cli-text-to-image](https://www.npmjs.com/package/@qodalis/cli-text-to-image) - utility to generate images from text
|
|
124
125
|
|
|
125
126
|
## Extending with Custom Commands
|
|
126
127
|
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
+
import { CliBackgroundColor, CliForegroundColor } from '../models';
|
|
1
2
|
import { constants } from '../constants';
|
|
2
3
|
import { utils } from '../utils';
|
|
3
|
-
const global = window;
|
|
4
4
|
export const initializeBrowserEnvironment = ({ handlers, }) => {
|
|
5
|
-
|
|
5
|
+
window.cliCore = {
|
|
6
6
|
onUmdModuleBoot: handlers || [],
|
|
7
7
|
bootUmdModule: async (module) => {
|
|
8
8
|
console.log('Booting UMD module', module.name);
|
|
9
|
-
|
|
9
|
+
window[module.name] = module;
|
|
10
10
|
handlers.forEach(async (handler) => await handler(module));
|
|
11
11
|
},
|
|
12
|
-
Injectable: () => { },
|
|
13
12
|
...constants,
|
|
14
13
|
...utils,
|
|
14
|
+
CliForegroundColor: CliForegroundColor,
|
|
15
|
+
CliBackgroundColor: CliBackgroundColor,
|
|
15
16
|
};
|
|
16
17
|
window.ngCore = {
|
|
17
18
|
Injectable: () => { },
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
21
|
export const bootUmdModule = async (module) => {
|
|
21
|
-
if (typeof
|
|
22
|
-
await
|
|
22
|
+
if (typeof window !== 'undefined') {
|
|
23
|
+
await window.cliCore.bootUmdModule(module);
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
26
|
console.log('window is undefined');
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9jb3JlL3NyYy9saWIvbW9kdWxlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsa0JBQWtCLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFDbkUsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGNBQWMsQ0FBQztBQUV6QyxPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRWpDLE1BQU0sQ0FBQyxNQUFNLDRCQUE0QixHQUFHLENBQUMsRUFDekMsUUFBUSxHQUdYLEVBQVEsRUFBRTtJQUNOLE1BQWMsQ0FBQyxPQUFPLEdBQUc7UUFDdEIsZUFBZSxFQUFFLFFBQVEsSUFBSSxFQUFFO1FBQy9CLGFBQWEsRUFBRSxLQUFLLEVBQUUsTUFBcUIsRUFBRSxFQUFFO1lBQzNDLE9BQU8sQ0FBQyxHQUFHLENBQUMsb0JBQW9CLEVBQUUsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQzlDLE1BQWMsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsTUFBTSxDQUFDO1lBQ3RDLFFBQVEsQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUMvRCxDQUFDO1FBQ0QsR0FBRyxTQUFTO1FBQ1osR0FBRyxLQUFLO1FBQ1Isa0JBQWtCLEVBQUU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vZHVsZTogYXN5bmMgKG1vZHVsZTogSUNsaVVtZE1vZHVsZSkgPT4ge1xuICAgICAgICAgICAgY29uc29sZS5sb2coJ0Jvb3RpbmcgVU1EIG1vZHVsZScsIG1vZHVsZS5uYW1lKTtcbiAgICAgICAgICAgICh3aW5kb3cgYXMgYW55KVttb2R1bGUubmFtZV0gPSBtb2R1bGU7XG4gICAgICAgICAgICBoYW5kbGVycy5mb3JFYWNoKGFzeW5jIChoYW5kbGVyKSA9PiBhd2FpdCBoYW5kbGVyKG1vZHVsZSkpO1xuICAgICAgICB9LFxuICAgICAgICAuLi5jb25zdGFudHMsXG4gICAgICAgIC4uLnV0aWxzLFxuICAgICAgICBDbGlGb3JlZ3JvdW5kQ29sb3I6IENsaUZvcmVncm91bmRDb2xvcixcbiAgICAgICAgQ2xpQmFja2dyb3VuZENvbG9yOiBDbGlCYWNrZ3JvdW5kQ29sb3IsXG4gICAgfTtcblxuICAgICh3aW5kb3cgYXMgYW55KS5uZ0NvcmUgPSB7XG4gICAgICAgIEluamVjdGFibGU6ICgpID0+IHt9LFxuICAgIH07XG59O1xuXG5leHBvcnQgY29uc3QgYm9vdFVtZE1vZHVsZSA9IGFzeW5jIChtb2R1bGU6IElDbGlVbWRNb2R1bGUpOiBQcm9taXNlPHZvaWQ+ID0+IHtcbiAgICBpZiAodHlwZW9mICh3aW5kb3cgYXMgYW55KSAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgYXdhaXQgKHdpbmRvdyBhcyBhbnkpLmNsaUNvcmUuYm9vdFVtZE1vZHVsZShtb2R1bGUpO1xuICAgIH0gZWxzZSB7XG4gICAgICAgIGNvbnNvbGUubG9nKCd3aW5kb3cgaXMgdW5kZWZpbmVkJyk7XG4gICAgfVxufTtcbiJdfQ==
|
|
@@ -86,26 +86,26 @@ const utils = {
|
|
|
86
86
|
getRightOfWord,
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
const global = window;
|
|
90
89
|
const initializeBrowserEnvironment = ({ handlers, }) => {
|
|
91
|
-
|
|
90
|
+
window.cliCore = {
|
|
92
91
|
onUmdModuleBoot: handlers || [],
|
|
93
92
|
bootUmdModule: async (module) => {
|
|
94
93
|
console.log('Booting UMD module', module.name);
|
|
95
|
-
|
|
94
|
+
window[module.name] = module;
|
|
96
95
|
handlers.forEach(async (handler) => await handler(module));
|
|
97
96
|
},
|
|
98
|
-
Injectable: () => { },
|
|
99
97
|
...constants,
|
|
100
98
|
...utils,
|
|
99
|
+
CliForegroundColor: CliForegroundColor,
|
|
100
|
+
CliBackgroundColor: CliBackgroundColor,
|
|
101
101
|
};
|
|
102
102
|
window.ngCore = {
|
|
103
103
|
Injectable: () => { },
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
const bootUmdModule = async (module) => {
|
|
107
|
-
if (typeof
|
|
108
|
-
await
|
|
107
|
+
if (typeof window !== 'undefined') {
|
|
108
|
+
await window.cliCore.bootUmdModule(module);
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
console.log('window is undefined');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qodalis-cli-core.mjs","sources":["../../../projects/core/src/lib/models/index.ts","../../../projects/core/src/lib/constants/index.ts","../../../projects/core/src/lib/utils/index.ts","../../../projects/core/src/lib/modules/index.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/qodalis-cli-core.ts"],"sourcesContent":["import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm';\n\nexport type CliProcessCommand = {\n /**\n * The command that was entered\n */\n command: string;\n\n /**\n * The chain of commands that were entered\n */\n chainCommands: string[];\n\n /**\n * The raw command that was entered\n */\n rawCommand: string;\n\n /**\n * The value of the command\n */\n value?: string;\n\n /**\n * The arguments that were entered\n */\n args: Record<string, any>;\n};\n\nexport enum CliForegroundColor {\n Black = '\\x1b[30m',\n Red = '\\x1b[31m',\n Green = '\\x1b[32m',\n Yellow = '\\x1b[33m',\n Blue = '\\x1b[34m',\n Magenta = '\\x1b[35m',\n Cyan = '\\x1b[36m',\n White = '\\x1b[37m',\n Reset = '\\x1b[0m',\n}\n\nexport enum CliBackgroundColor {\n Black = '\\x1b[40m',\n Red = '\\x1b[41m',\n Green = '\\x1b[42m',\n Yellow = '\\x1b[43m',\n Blue = '\\x1b[44m',\n Magenta = '\\x1b[45m',\n Cyan = '\\x1b[46m',\n White = '\\x1b[47m',\n}\n\nexport interface ICliUser extends Record<string, any> {\n /**\n * The id of the user\n */\n id: string;\n\n /**\n * The name of the user\n */\n name: string;\n\n /**\n * The email of the user\n */\n email: string;\n}\n\nexport interface ICliUserSession {\n /**\n * The user associated with the session\n */\n user: ICliUser;\n\n /**\n * The data associated with the user session\n */\n data?: Record<string, any>;\n}\n\n/**\n * Options for the CLI\n */\nexport type CliOptions = {\n /**\n * The welcome message to display when the CLI starts\n */\n welcomeMessage?: string;\n\n /**\n * Hide the prompt to display when the CLI is ready to accept input\n */\n hideUserName?: boolean;\n\n /**\n * Custom terminal options\n */\n terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;\n};\n\n/**\n * Represents a package that can be installed\n */\nexport interface Package {\n /**\n * The name of the package\n */\n name: string;\n\n /**\n * The global name used to access the package\n */\n globalName?: string;\n\n /**\n * The version of the package\n */\n version: string;\n\n /**\n * The unpkg url to the package\n */\n url: string;\n\n /**\n * The dependencies for the module\n */\n dependencies?: Package[];\n}\n","import { ICliCommandAuthor } from '../interfaces';\n\nexport const DefaultLibraryAuthor: ICliCommandAuthor = {\n name: 'Nicolae Lupei',\n email: 'nicolae.lupei@qodalis.com',\n};\n\nexport const constants = {\n DefaultLibraryAuthor,\n};\n","import { ICliCommandParameterDescriptor } from '../interfaces';\nimport { CliBackgroundColor, CliForegroundColor } from '../models';\n\nexport const getParameterValue = (\n p: ICliCommandParameterDescriptor,\n args: Record<string, any>,\n): any | undefined => {\n return (\n args[p.name] ??\n (p.aliases?.find((alias) => args[alias]) &&\n args[p.aliases!.find((alias) => args[alias])!])\n );\n};\n\nexport const formatJson = (json: any): string => {\n const identedJson = JSON.stringify(json, null, 2);\n\n return colorizeJson(identedJson.split('\\n').join('\\r\\n'));\n};\n\nexport const colorizeJson = (jsonString: any): string => {\n return jsonString\n .replace(/\"([^\"]+)\":/g, '\\x1b[33m\"$1\":\\x1b[0m') // Keys (yellow)\n .replace(/: \"([^\"]*)\"/g, ': \\x1b[32m\"$1\"\\x1b[0m') // Strings (green)\n .replace(/: (\\d+)/g, ': \\x1b[34m$1\\x1b[0m') // Numbers (blue)\n .replace(/: (true|false)/g, ': \\x1b[35m$1\\x1b[0m') // Booleans (magenta)\n .replace(/: (null)/g, ': \\x1b[36m$1\\x1b[0m'); // Null (cyan)\n};\n\nexport const toQueryString = (params: Record<string, any>): string => {\n const searchParams = new URLSearchParams();\n\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const value = params[key];\n // Handle array and non-primitive values\n if (Array.isArray(value)) {\n value.forEach((v) => searchParams.append(key, v.toString()));\n } else if (value !== null && value !== undefined) {\n searchParams.append(key, value.toString());\n }\n }\n }\n\n return searchParams.toString();\n};\n\nexport const highlightTextWithBg = (\n text: string,\n pattern: RegExp,\n bgColor: CliBackgroundColor = CliBackgroundColor.Yellow,\n): string => {\n // Replace matches with background-colored text\n return text.replace(\n pattern,\n (match) => `${bgColor}${match}${CliForegroundColor.Reset}`,\n );\n};\n\nexport const getRightOfWord = (\n command: string,\n word: string,\n): string | undefined => {\n // Find the position of the word in the command\n const index = command.indexOf(word);\n\n // If the word is found, extract the substring to the right\n if (index !== -1) {\n return command.slice(index + word.length).trim();\n }\n\n // If the word is not found, return null\n return undefined;\n};\n\nexport const utils = {\n getParameterValue,\n formatJson,\n colorizeJson,\n toQueryString,\n highlightTextWithBg,\n getRightOfWord,\n};\n","import { constants } from '../constants';\nimport { ICliUmdModule } from '../interfaces';\nimport { utils } from '../utils';\n\nconst global = window as any;\n\nexport const initializeBrowserEnvironment = ({\n handlers,\n}: {\n handlers: ((module: ICliUmdModule) => Promise<void>)[];\n}): void => {\n global.core = {\n onUmdModuleBoot: handlers || [],\n bootUmdModule: async (module: ICliUmdModule) => {\n console.log('Booting UMD module', module.name);\n global[module.name] = module;\n handlers.forEach(async (handler) => await handler(module));\n },\n Injectable: () => {},\n ...constants,\n ...utils,\n };\n\n (window as any).ngCore = {\n Injectable: () => {},\n };\n};\n\nexport const bootUmdModule = async (module: ICliUmdModule): Promise<void> => {\n if (typeof global !== 'undefined') {\n await global.core.bootUmdModule(module);\n } else {\n console.log('window is undefined');\n }\n};\n","/*\n * Public API Surface of core\n */\n\nexport * from './lib/models';\n\nexport * from './lib/interfaces';\n\nexport * from './lib/modules';\n\nexport * from './lib/utils';\n\nexport * from './lib/constants';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IA6BY,mBAUX;AAVD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,YAAgB,CAAA;AAChB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,YAAmB,CAAA;AACnB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,YAAoB,CAAA;AACpB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,WAAiB,CAAA;AACrB,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,GAU7B,EAAA,CAAA,CAAA,CAAA;IAEW,mBASX;AATD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;A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AAa,CAAC,MAAM,CAAC,CAAC;AAC3C,KAAA;AAAM,SAAA;AACH,QAAA,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AACtC,KAAA;AACL;;AClCA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"qodalis-cli-core.mjs","sources":["../../../projects/core/src/lib/models/index.ts","../../../projects/core/src/lib/constants/index.ts","../../../projects/core/src/lib/utils/index.ts","../../../projects/core/src/lib/modules/index.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/qodalis-cli-core.ts"],"sourcesContent":["import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm';\n\nexport type CliProcessCommand = {\n /**\n * The command that was entered\n */\n command: string;\n\n /**\n * The chain of commands that were entered\n */\n chainCommands: string[];\n\n /**\n * The raw command that was entered\n */\n rawCommand: string;\n\n /**\n * The value of the command\n */\n value?: string;\n\n /**\n * The arguments that were entered\n */\n args: Record<string, any>;\n};\n\nexport enum CliForegroundColor {\n Black = '\\x1b[30m',\n Red = '\\x1b[31m',\n Green = '\\x1b[32m',\n Yellow = '\\x1b[33m',\n Blue = '\\x1b[34m',\n Magenta = '\\x1b[35m',\n Cyan = '\\x1b[36m',\n White = '\\x1b[37m',\n Reset = '\\x1b[0m',\n}\n\nexport enum CliBackgroundColor {\n Black = '\\x1b[40m',\n Red = '\\x1b[41m',\n Green = '\\x1b[42m',\n Yellow = '\\x1b[43m',\n Blue = '\\x1b[44m',\n Magenta = '\\x1b[45m',\n Cyan = '\\x1b[46m',\n White = '\\x1b[47m',\n}\n\nexport interface ICliUser extends Record<string, any> {\n /**\n * The id of the user\n */\n id: string;\n\n /**\n * The name of the user\n */\n name: string;\n\n /**\n * The email of the user\n */\n email: string;\n}\n\nexport interface ICliUserSession {\n /**\n * The user associated with the session\n */\n user: ICliUser;\n\n /**\n * The data associated with the user session\n */\n data?: Record<string, any>;\n}\n\n/**\n * Options for the CLI\n */\nexport type CliOptions = {\n /**\n * The welcome message to display when the CLI starts\n */\n welcomeMessage?: string;\n\n /**\n * Hide the prompt to display when the CLI is ready to accept input\n */\n hideUserName?: boolean;\n\n /**\n * Custom terminal options\n */\n terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;\n};\n\n/**\n * Represents a package that can be installed\n */\nexport interface Package {\n /**\n * The name of the package\n */\n name: string;\n\n /**\n * The global name used to access the package\n */\n globalName?: string;\n\n /**\n * The version of the package\n */\n version: string;\n\n /**\n * The unpkg url to the package\n */\n url: string;\n\n /**\n * The dependencies for the module\n */\n dependencies?: Package[];\n}\n","import { ICliCommandAuthor } from '../interfaces';\n\nexport const DefaultLibraryAuthor: ICliCommandAuthor = {\n name: 'Nicolae Lupei',\n email: 'nicolae.lupei@qodalis.com',\n};\n\nexport const constants = {\n DefaultLibraryAuthor,\n};\n","import { ICliCommandParameterDescriptor } from '../interfaces';\nimport { CliBackgroundColor, CliForegroundColor } from '../models';\n\nexport const getParameterValue = (\n p: ICliCommandParameterDescriptor,\n args: Record<string, any>,\n): any | undefined => {\n return (\n args[p.name] ??\n (p.aliases?.find((alias) => args[alias]) &&\n args[p.aliases!.find((alias) => args[alias])!])\n );\n};\n\nexport const formatJson = (json: any): string => {\n const identedJson = JSON.stringify(json, null, 2);\n\n return colorizeJson(identedJson.split('\\n').join('\\r\\n'));\n};\n\nexport const colorizeJson = (jsonString: any): string => {\n return jsonString\n .replace(/\"([^\"]+)\":/g, '\\x1b[33m\"$1\":\\x1b[0m') // Keys (yellow)\n .replace(/: \"([^\"]*)\"/g, ': \\x1b[32m\"$1\"\\x1b[0m') // Strings (green)\n .replace(/: (\\d+)/g, ': \\x1b[34m$1\\x1b[0m') // Numbers (blue)\n .replace(/: (true|false)/g, ': \\x1b[35m$1\\x1b[0m') // Booleans (magenta)\n .replace(/: (null)/g, ': \\x1b[36m$1\\x1b[0m'); // Null (cyan)\n};\n\nexport const toQueryString = (params: Record<string, any>): string => {\n const searchParams = new URLSearchParams();\n\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const value = params[key];\n // Handle array and non-primitive values\n if (Array.isArray(value)) {\n value.forEach((v) => searchParams.append(key, v.toString()));\n } else if (value !== null && value !== undefined) {\n searchParams.append(key, value.toString());\n }\n }\n }\n\n return searchParams.toString();\n};\n\nexport const highlightTextWithBg = (\n text: string,\n pattern: RegExp,\n bgColor: CliBackgroundColor = CliBackgroundColor.Yellow,\n): string => {\n // Replace matches with background-colored text\n return text.replace(\n pattern,\n (match) => `${bgColor}${match}${CliForegroundColor.Reset}`,\n );\n};\n\nexport const getRightOfWord = (\n command: string,\n word: string,\n): string | undefined => {\n // Find the position of the word in the command\n const index = command.indexOf(word);\n\n // If the word is found, extract the substring to the right\n if (index !== -1) {\n return command.slice(index + word.length).trim();\n }\n\n // If the word is not found, return null\n return undefined;\n};\n\nexport const utils = {\n getParameterValue,\n formatJson,\n colorizeJson,\n toQueryString,\n highlightTextWithBg,\n getRightOfWord,\n};\n","import { CliBackgroundColor, CliForegroundColor } from '../models';\nimport { constants } from '../constants';\nimport { ICliUmdModule } from '../interfaces';\nimport { utils } from '../utils';\n\nexport const initializeBrowserEnvironment = ({\n handlers,\n}: {\n handlers: ((module: ICliUmdModule) => Promise<void>)[];\n}): void => {\n (window as any).cliCore = {\n onUmdModuleBoot: handlers || [],\n bootUmdModule: async (module: ICliUmdModule) => {\n console.log('Booting UMD module', module.name);\n (window as any)[module.name] = module;\n handlers.forEach(async (handler) => await handler(module));\n },\n ...constants,\n ...utils,\n CliForegroundColor: CliForegroundColor,\n CliBackgroundColor: CliBackgroundColor,\n };\n\n (window as any).ngCore = {\n Injectable: () => {},\n };\n};\n\nexport const bootUmdModule = async (module: ICliUmdModule): Promise<void> => {\n if (typeof (window as any) !== 'undefined') {\n await (window as any).cliCore.bootUmdModule(module);\n } else {\n console.log('window is undefined');\n }\n};\n","/*\n * Public API Surface of core\n */\n\nexport * from './lib/models';\n\nexport * from './lib/interfaces';\n\nexport * from './lib/modules';\n\nexport * from './lib/utils';\n\nexport * from './lib/constants';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IA6BY,mBAUX;AAVD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,YAAgB,CAAA;AAChB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,YAAmB,CAAA;AACnB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,YAAoB,CAAA;AACpB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,WAAiB,CAAA;AACrB,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,GAU7B,EAAA,CAAA,CAAA,CAAA;IAEW,mBASX;AATD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,YAAgB,CAAA;AAChB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,YAAmB,CAAA;AACnB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,YAAoB,CAAA;AACpB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AACtB,CAAC,EATW,kBAAkB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