To begin with, your approach appears quite unconventional, which should serve as a clear indication that it may not be the best course of action. There is likely a more suitable alternative available.
Furthermore, it seems that you are considering this from the wrong perspective: Typescript is a programming language, while Angular is a framework. Neither of them inherently supports command line interactions as they are primarily designed to operate within a web browser environment (where allowing websites to access certain functionalities could pose security risks). Although there are frameworks like Node.js that allow JavaScript (and consequently Typescript) to run outside the browser context, this may not align with your current requirements.
Therefore, you will need to identify an external platform to execute your specialized code:
- If your intention is for the application to function as a kiosk, you might consider developing a desktop application that integrates Chromium or another web browser (such as utilizing CEF) instead of relying on a standard web browser. This approach enables you to call desktop functions from JavaScript (including Typescript or Angular), although it might deviate from your initial objective if it bypasses the necessity of Chrome running in kiosk mode.
- An alternative option involves building a standalone desktop application capable of executing specific tasks and establishing a custom protocol handler (e.g., my-app://) that can be triggered from Chrome. Note that Chrome typically prompts a security warning before executing such commands; however, with control over the target device (as assumed in this scenario), it is feasible to disable the prompt for your registered protocol.
- You can also develop a desktop application that operates a background web server and allows requests to be sent from a designated URL (while adhering to cross-site constraints). Upon receiving such requests, your server application can interpret the commands to perform various actions (e.g., exiting the application). This resembles the controversial method by which Zoom was criticized for implementing in the past.
It is important to acknowledge that most of these approaches raise concerns regarding potential invocation by untrusted sources, thus requiring careful consideration during the design phase.