@akanjs/cli 0.9.21 → 0.9.23

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.
Files changed (192) hide show
  1. package/cjs/index.js +282 -296
  2. package/esm/index.js +282 -296
  3. package/esm/src/templates/__scalar/__model__/__model__.constant.js +1 -0
  4. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -0
  5. package/esm/src/templates/__scalar/__model__/__model__.document.js +1 -0
  6. package/esm/src/templates/app/akan.config.js +1 -0
  7. package/esm/src/templates/app/app/[lang]/(__appName__)/(public)/page.js +1 -0
  8. package/esm/src/templates/app/app/[lang]/(__appName__)/(public)/unknown/page.js +1 -0
  9. package/esm/src/templates/app/app/[lang]/(__appName__)/layout.js +1 -0
  10. package/esm/src/templates/app/app/[lang]/admin/layout.js +1 -0
  11. package/esm/src/templates/app/app/[lang]/admin/page.js +1 -0
  12. package/esm/src/templates/app/app/csr.js +1 -0
  13. package/esm/src/templates/app/app/layout.js +1 -0
  14. package/esm/src/templates/app/app/robots.js +1 -0
  15. package/esm/src/templates/app/app/sitemap.js +1 -0
  16. package/esm/src/templates/app/base/baseLogic.js +1 -0
  17. package/esm/src/templates/app/base/index.js +1 -0
  18. package/esm/src/templates/app/common/commonLogic.js +1 -0
  19. package/esm/src/templates/app/common/index.js +1 -0
  20. package/esm/src/templates/app/env/env.client.debug.ts.template +0 -0
  21. package/esm/src/templates/app/env/env.client.develop.ts.template +0 -0
  22. package/esm/src/templates/app/env/env.client.js +1 -0
  23. package/esm/src/templates/app/env/env.client.local.ts.template +0 -0
  24. package/esm/src/templates/app/env/env.client.main.ts.template +0 -0
  25. package/esm/src/templates/app/env/env.client.testing.ts.template +0 -0
  26. package/esm/src/templates/app/env/env.client.type.js +1 -0
  27. package/esm/src/templates/app/env/env.server.debug.ts.template +0 -0
  28. package/esm/src/templates/app/env/env.server.develop.ts.template +0 -0
  29. package/esm/src/templates/app/env/env.server.js +1 -0
  30. package/esm/src/templates/app/env/env.server.local.ts.template +0 -0
  31. package/esm/src/templates/app/env/env.server.main.ts.template +0 -0
  32. package/esm/src/templates/app/env/env.server.testing.ts.template +0 -0
  33. package/esm/src/templates/app/jest.config.js +1 -0
  34. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +1 -0
  35. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +1 -0
  36. package/esm/src/templates/app/lib/___appName__/__appName__.store.js +1 -0
  37. package/esm/src/templates/app/lib/___appName__/_server.js +1 -0
  38. package/esm/src/templates/app/lib/option.js +1 -0
  39. package/esm/src/templates/app/lib/setting/Setting.Template.js +1 -0
  40. package/esm/src/templates/app/lib/setting/Setting.Unit.js +1 -0
  41. package/esm/src/templates/app/lib/setting/Setting.Util.js +1 -0
  42. package/esm/src/templates/app/lib/setting/Setting.View.js +1 -0
  43. package/esm/src/templates/app/lib/setting/Setting.Zone.js +1 -0
  44. package/esm/src/templates/app/lib/setting/_server.js +1 -0
  45. package/esm/src/templates/app/lib/setting/index.js +1 -0
  46. package/esm/src/templates/app/lib/setting/setting.constant.js +1 -0
  47. package/esm/src/templates/app/lib/setting/setting.dictionary.js +1 -0
  48. package/esm/src/templates/app/lib/setting/setting.document.js +1 -0
  49. package/esm/src/templates/app/lib/setting/setting.service.js +1 -0
  50. package/esm/src/templates/app/lib/setting/setting.signal.js +1 -0
  51. package/esm/src/templates/app/lib/setting/setting.store.js +1 -0
  52. package/esm/src/templates/app/lib/summary/Summary.Template.js +1 -0
  53. package/esm/src/templates/app/lib/summary/Summary.Unit.js +1 -0
  54. package/esm/src/templates/app/lib/summary/Summary.Util.js +1 -0
  55. package/esm/src/templates/app/lib/summary/Summary.View.js +1 -0
  56. package/esm/src/templates/app/lib/summary/Summary.Zone.js +1 -0
  57. package/esm/src/templates/app/lib/summary/_server.js +1 -0
  58. package/esm/src/templates/app/lib/summary/index.js +1 -0
  59. package/esm/src/templates/app/lib/summary/summary.constant.js +1 -0
  60. package/esm/src/templates/app/lib/summary/summary.dictionary.js +1 -0
  61. package/esm/src/templates/app/lib/summary/summary.document.js +1 -0
  62. package/esm/src/templates/app/lib/summary/summary.service.js +1 -0
  63. package/esm/src/templates/app/lib/summary/summary.signal.js +1 -0
  64. package/esm/src/templates/app/lib/summary/summary.store.js +1 -0
  65. package/esm/src/templates/app/lib/user/User.Template.js +1 -0
  66. package/esm/src/templates/app/lib/user/User.Unit.js +1 -0
  67. package/esm/src/templates/app/lib/user/User.Util.js +1 -0
  68. package/esm/src/templates/app/lib/user/User.View.js +1 -0
  69. package/esm/src/templates/app/lib/user/User.Zone.js +1 -0
  70. package/esm/src/templates/app/lib/user/_server.js +1 -0
  71. package/esm/src/templates/app/lib/user/index.js +1 -0
  72. package/esm/src/templates/app/lib/user/user.constant.js +1 -0
  73. package/esm/src/templates/app/lib/user/user.dictionary.js +1 -0
  74. package/esm/src/templates/app/lib/user/user.document.js +1 -0
  75. package/esm/src/templates/app/lib/user/user.service.js +1 -0
  76. package/esm/src/templates/app/lib/user/user.signal.js +1 -0
  77. package/esm/src/templates/app/lib/user/user.signal.spec.js +1 -0
  78. package/esm/src/templates/app/lib/user/user.signal.test.js +1 -0
  79. package/esm/src/templates/app/lib/user/user.store.js +1 -0
  80. package/esm/src/templates/app/main.js +1 -0
  81. package/esm/src/templates/app/middleware.js +1 -0
  82. package/esm/src/templates/app/nest/backendLogic.js +1 -0
  83. package/esm/src/templates/app/nest/index.js +1 -0
  84. package/esm/src/templates/app/next/frontendLogic.js +1 -0
  85. package/esm/src/templates/app/next/index.js +1 -0
  86. package/esm/src/templates/app/ui/UiComponent.js +1 -0
  87. package/esm/src/templates/app/ui/index.js +1 -0
  88. package/esm/src/templates/client.js +2 -1
  89. package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -0
  90. package/esm/src/templates/crudPages/[__model__Id]/page.js +1 -0
  91. package/esm/src/templates/crudPages/new/page.js +1 -0
  92. package/esm/src/templates/crudPages/page.js +1 -0
  93. package/esm/src/templates/index.js +1 -0
  94. package/esm/src/templates/lib/__lib/extends/summary.constant.js +2 -1
  95. package/esm/src/templates/lib/__lib/lib.constant.js +1 -0
  96. package/esm/src/templates/lib/__lib/lib.dictionary.js +1 -0
  97. package/esm/src/templates/lib/__lib/lib.document.js +1 -0
  98. package/esm/src/templates/lib/__lib/lib.service.js +2 -1
  99. package/esm/src/templates/lib/__lib/lib.signal.js +1 -0
  100. package/esm/src/templates/lib/__lib/lib.store.js +1 -0
  101. package/esm/src/templates/lib/__scalar/_server.js +2 -1
  102. package/esm/src/templates/lib/cnst.js +1 -0
  103. package/esm/src/templates/lib/cnst_.js +1 -0
  104. package/esm/src/templates/lib/db.js +1 -0
  105. package/esm/src/templates/lib/dict.js +1 -0
  106. package/esm/src/templates/lib/fetch.js +2 -1
  107. package/esm/src/templates/lib/sig.js +2 -1
  108. package/esm/src/templates/lib/srv.js +2 -1
  109. package/esm/src/templates/lib/st.js +1 -0
  110. package/esm/src/templates/lib/store.js +2 -1
  111. package/esm/src/templates/lib/usePage.js +1 -0
  112. package/esm/src/templates/libRoot/akan.config.js +1 -0
  113. package/esm/src/templates/libRoot/base/baseLogic.js +1 -0
  114. package/esm/src/templates/libRoot/base/index.js +1 -0
  115. package/esm/src/templates/libRoot/common/commonLogic.js +1 -0
  116. package/esm/src/templates/libRoot/common/index.js +1 -0
  117. package/esm/src/templates/libRoot/jest.config.js +1 -0
  118. package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -0
  119. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -0
  120. package/esm/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -0
  121. package/esm/src/templates/libRoot/lib/___libName__/_server.js +1 -0
  122. package/esm/src/templates/libRoot/lib/option.js +1 -0
  123. package/esm/src/templates/libRoot/lib/setting/Setting.Template.js +1 -0
  124. package/esm/src/templates/libRoot/lib/setting/Setting.Unit.js +1 -0
  125. package/esm/src/templates/libRoot/lib/setting/Setting.Util.js +1 -0
  126. package/esm/src/templates/libRoot/lib/setting/Setting.View.js +1 -0
  127. package/esm/src/templates/libRoot/lib/setting/Setting.Zone.js +1 -0
  128. package/esm/src/templates/libRoot/lib/setting/_server.js +1 -0
  129. package/esm/src/templates/libRoot/lib/setting/index.js +1 -0
  130. package/esm/src/templates/libRoot/lib/setting/setting.constant.js +1 -0
  131. package/esm/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -0
  132. package/esm/src/templates/libRoot/lib/setting/setting.document.js +1 -0
  133. package/esm/src/templates/libRoot/lib/setting/setting.service.js +1 -0
  134. package/esm/src/templates/libRoot/lib/setting/setting.signal.js +1 -0
  135. package/esm/src/templates/libRoot/lib/setting/setting.store.js +1 -0
  136. package/esm/src/templates/libRoot/lib/summary/Summary.Template.js +1 -0
  137. package/esm/src/templates/libRoot/lib/summary/Summary.Unit.js +1 -0
  138. package/esm/src/templates/libRoot/lib/summary/Summary.Util.js +1 -0
  139. package/esm/src/templates/libRoot/lib/summary/Summary.View.js +1 -0
  140. package/esm/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -0
  141. package/esm/src/templates/libRoot/lib/summary/_server.js +1 -0
  142. package/esm/src/templates/libRoot/lib/summary/index.js +1 -0
  143. package/esm/src/templates/libRoot/lib/summary/summary.constant.js +1 -0
  144. package/esm/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -0
  145. package/esm/src/templates/libRoot/lib/summary/summary.document.js +1 -0
  146. package/esm/src/templates/libRoot/lib/summary/summary.service.js +1 -0
  147. package/esm/src/templates/libRoot/lib/summary/summary.signal.js +1 -0
  148. package/esm/src/templates/libRoot/lib/summary/summary.store.js +1 -0
  149. package/esm/src/templates/libRoot/lib/user/User.Template.js +1 -0
  150. package/esm/src/templates/libRoot/lib/user/User.Unit.js +1 -0
  151. package/esm/src/templates/libRoot/lib/user/User.Util.js +1 -0
  152. package/esm/src/templates/libRoot/lib/user/User.View.js +1 -0
  153. package/esm/src/templates/libRoot/lib/user/User.Zone.js +1 -0
  154. package/esm/src/templates/libRoot/lib/user/_server.js +1 -0
  155. package/esm/src/templates/libRoot/lib/user/index.js +1 -0
  156. package/esm/src/templates/libRoot/lib/user/user.constant.js +1 -0
  157. package/esm/src/templates/libRoot/lib/user/user.dictionary.js +1 -0
  158. package/esm/src/templates/libRoot/lib/user/user.document.js +1 -0
  159. package/esm/src/templates/libRoot/lib/user/user.service.js +1 -0
  160. package/esm/src/templates/libRoot/lib/user/user.signal.js +1 -0
  161. package/esm/src/templates/libRoot/lib/user/user.signal.spec.js +1 -0
  162. package/esm/src/templates/libRoot/lib/user/user.signal.test.js +1 -0
  163. package/esm/src/templates/libRoot/lib/user/user.store.js +1 -0
  164. package/esm/src/templates/libRoot/nest/backendLogic.js +1 -0
  165. package/esm/src/templates/libRoot/nest/index.js +1 -0
  166. package/esm/src/templates/libRoot/next/frontendLogic.js +1 -0
  167. package/esm/src/templates/libRoot/next/index.js +1 -0
  168. package/esm/src/templates/libRoot/ui/index.js +1 -0
  169. package/esm/src/templates/module/__Model__.Template.js +1 -0
  170. package/esm/src/templates/module/__Model__.Unit.js +1 -0
  171. package/esm/src/templates/module/__Model__.Util.js +1 -0
  172. package/esm/src/templates/module/__Model__.View.js +1 -0
  173. package/esm/src/templates/module/__Model__.Zone.js +1 -0
  174. package/esm/src/templates/module/__model__.constant.js +1 -0
  175. package/esm/src/templates/module/__model__.dictionary.js +1 -0
  176. package/esm/src/templates/module/__model__.document.js +1 -0
  177. package/esm/src/templates/module/__model__.service.js +1 -0
  178. package/esm/src/templates/module/__model__.signal.js +1 -0
  179. package/esm/src/templates/module/__model__.signal.spec.js +1 -0
  180. package/esm/src/templates/module/__model__.signal.test.js +1 -0
  181. package/esm/src/templates/module/__model__.store.js +1 -0
  182. package/esm/src/templates/module/_server.js +1 -0
  183. package/esm/src/templates/module/index.js +1 -0
  184. package/esm/src/templates/server.js +2 -1
  185. package/package.json +1 -1
  186. package/src/application/application.interface.d.ts +40 -0
  187. package/src/application/application.runner.d.ts +14 -7
  188. package/src/application/application.script.d.ts +12 -6
  189. package/ui/MultiScrollList.d.ts +2 -1
  190. package/src/application/appilcation.interface.d.ts +0 -11
  191. package/ui/ScrollList.d.ts +0 -7
  192. package/ui/index.d.ts +0 -1
package/esm/index.js CHANGED
@@ -3523,115 +3523,35 @@ var LibraryScript = class {
3523
3523
  }
3524
3524
  };
3525
3525
 
3526
- // pkgs/@akanjs/cli/src/application/application.runner.ts
3527
- import { confirm as confirm2, input as input4, select as select5 } from "@inquirer/prompts";
3528
- import { StringOutputParser } from "@langchain/core/output_parsers";
3529
- import { PromptTemplate as PromptTemplate2 } from "@langchain/core/prompts";
3530
- import { RunnableSequence as RunnableSequence2 } from "@langchain/core/runnables";
3531
- import { ChatOpenAI as ChatOpenAI3 } from "@langchain/openai";
3532
- import react from "@vitejs/plugin-react";
3533
- import dotenv3 from "dotenv";
3534
- import * as esbuild2 from "esbuild";
3535
- import fs14 from "fs";
3536
- import fsPromise3 from "fs/promises";
3537
- import yaml2 from "js-yaml";
3538
- import openBrowser from "open";
3539
- import ora3 from "ora";
3540
- import path7 from "path";
3541
- import * as vite from "vite";
3542
- import commonjs from "vite-plugin-commonjs";
3543
- import { nodePolyfills } from "vite-plugin-node-polyfills";
3544
- import tsconfigPaths from "vite-tsconfig-paths";
3545
-
3546
- // pkgs/@akanjs/cli/src/application/appilcation.interface.tsx
3547
- import { Box as Box3, render, Text as Text3 } from "ink";
3548
- import React3, { useEffect as useEffect4, useState as useState4 } from "react";
3526
+ // pkgs/@akanjs/cli/src/application/application.interface.tsx
3527
+ import { Box as Box2, render, Text as Text2, useApp } from "ink";
3528
+ import React2, { useEffect as useEffect3, useState as useState3 } from "react";
3549
3529
 
3550
- // pkgs/@akanjs/cli/ui/ScrollList.tsx
3530
+ // pkgs/@akanjs/cli/ui/MultiScrollList.tsx
3551
3531
  import { Box, Newline, Text, useInput } from "ink";
3552
3532
  import React, { useEffect as useEffect2, useState as useState2 } from "react";
3553
- var ScrollList = ({ list, ...props }) => {
3554
- const [renderLogs, setRenderLogs] = useState2(list);
3533
+ var HEADER_HEIGHT = 1;
3534
+ var FOOTER_HEIGHT = 5;
3535
+ var BORDER_HEIGHT = 2;
3536
+ var MultiScrollList = ({ logList, maxLength = 100 }) => {
3555
3537
  const [width, height] = useStdoutDimensions();
3538
+ const [focusLog, setFocusLog] = useState2([]);
3539
+ const [lengthMap, setLengthMap] = useState2(/* @__PURE__ */ new Map());
3556
3540
  const [scrollPos, setScrollPos] = useState2(0);
3541
+ const [tabIndex, setTabIndex] = useState2(0);
3557
3542
  const [isRunning, setIsRunning] = useState2(false);
3558
- const [boxHeight, setBoxHeight] = useState2(height - 3);
3543
+ const [boxHeight, setBoxHeight] = useState2(height - HEADER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT);
3544
+ const getLimitedLogs = (logs) => {
3545
+ return logs.length > maxLength ? logs.slice(logs.length - maxLength) : logs;
3546
+ };
3559
3547
  useInput((input6, key) => {
3560
- if (key.escape) {
3561
- setIsRunning(false);
3562
- setScrollPos(0);
3563
- }
3564
- if (input6 === " " && isRunning) {
3565
- setIsRunning(false);
3548
+ if (key.tab) {
3549
+ setTabIndex((prev) => (prev + 1) % logList.length);
3566
3550
  setScrollPos(0);
3567
- }
3568
- if (key.downArrow && scrollPos > 0) {
3569
- if (key.shift) {
3570
- setScrollPos(scrollPos - 10);
3571
- } else {
3572
- setScrollPos(scrollPos - 1);
3573
- }
3574
- }
3575
- if (key.upArrow && scrollPos < list.length - boxHeight) {
3576
- if (key.shift) {
3577
- setScrollPos(scrollPos + 10);
3578
- } else {
3579
- setScrollPos(scrollPos + 1);
3580
- }
3581
- }
3582
- });
3583
- useEffect2(() => {
3584
- if (isRunning) {
3585
- setScrollPos(scrollPos + 1);
3586
- return;
3587
- }
3588
- if (list.length > boxHeight) {
3589
- setRenderLogs(list.slice(list.length - boxHeight, list.length));
3590
- } else {
3591
- setRenderLogs(list);
3592
- }
3593
- }, [list, isRunning]);
3594
- useEffect2(() => {
3595
- setBoxHeight(Math.floor(height * 0.9));
3596
- }, [height]);
3597
- useEffect2(() => {
3598
- if (scrollPos > 0) {
3599
- setRenderLogs(list.slice(list.length - boxHeight - scrollPos, list.length - scrollPos));
3600
- setIsRunning(true);
3601
- } else {
3602
- setRenderLogs(list.slice(list.length - boxHeight, list.length));
3603
3551
  setIsRunning(false);
3604
3552
  }
3605
- }, [scrollPos]);
3606
- return /* @__PURE__ */ React.createElement(Box, { ...props, width, height: "100%", flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, { borderStyle: "round", width, height: height - 3 }, /* @__PURE__ */ React.createElement(Newline, null), /* @__PURE__ */ React.createElement(Text, null, isRunning ? /* @__PURE__ */ React.createElement(React.Fragment, null, renderLogs.slice(0, renderLogs.length - 1).map((log, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { key: index }, log), /* @__PURE__ */ React.createElement(Newline, null))), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "scrolling... + ", scrollPos)) : /* @__PURE__ */ React.createElement(React.Fragment, null, renderLogs.map((log, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { key: index }, log), /* @__PURE__ */ React.createElement(Newline, null)))))), /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "You can use the following shortcuts:", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3607
- };
3608
-
3609
- // pkgs/@akanjs/cli/ui/MultiScrollList.tsx
3610
- import { Box as Box2, Newline as Newline2, Text as Text2, useInput as useInput2 } from "ink";
3611
- import React2, { useEffect as useEffect3, useState as useState3 } from "react";
3612
- var MultiScrollList = ({ logList }) => {
3613
- const [width, height] = useStdoutDimensions();
3614
- const [renderMultiLogs, setRenderMultiLogs] = useState3(
3615
- Array.from({ length: logList.length }, () => [])
3616
- );
3617
- const [lengthMap, setLengthMap] = useState3(/* @__PURE__ */ new Map());
3618
- const [scrollPos, setScrollPos] = useState3(0);
3619
- const [tabIndex, setTabIndex] = useState3(null);
3620
- const [isRunning, setIsRunning] = useState3(false);
3621
- const [boxHeight, setBoxHeight] = useState3(height - 7);
3622
- useInput2((input6, key) => {
3623
- if (key.tab) {
3624
- if (tabIndex === null) {
3625
- setTabIndex(0);
3626
- } else {
3627
- setTabIndex((prev) => (prev + 1) % logList.length);
3628
- setIsRunning(false);
3629
- }
3630
- }
3631
3553
  if (key.escape) {
3632
3554
  setScrollPos(0);
3633
- if (tabIndex !== null)
3634
- setTabIndex(null);
3635
3555
  setIsRunning(false);
3636
3556
  }
3637
3557
  if (input6 === " ") {
@@ -3651,231 +3571,285 @@ var MultiScrollList = ({ logList }) => {
3651
3571
  setScrollPos(newScrollPos);
3652
3572
  }
3653
3573
  }
3654
- if (key.upArrow && tabIndex !== null && scrollPos < logList[tabIndex].logs.length - boxHeight) {
3655
- if (key.shift) {
3656
- const newScrollPos = scrollPos + 10;
3657
- if (newScrollPos > logList[tabIndex].logs.length - boxHeight) {
3658
- setScrollPos(logList[tabIndex].logs.length - boxHeight);
3574
+ if (key.upArrow && scrollPos < logList[tabIndex].logs.length - boxHeight) {
3575
+ const limitedLogs = getLimitedLogs(logList[tabIndex].logs);
3576
+ if (scrollPos < limitedLogs.length - boxHeight) {
3577
+ if (key.shift) {
3578
+ const newScrollPos = scrollPos + 10;
3579
+ if (newScrollPos > limitedLogs.length - boxHeight) {
3580
+ setScrollPos(limitedLogs.length - boxHeight);
3581
+ } else {
3582
+ setScrollPos(newScrollPos);
3583
+ }
3659
3584
  } else {
3660
- setScrollPos(newScrollPos);
3585
+ setScrollPos(scrollPos + 1);
3661
3586
  }
3662
- } else {
3663
- setScrollPos(scrollPos + 1);
3587
+ if (!isRunning)
3588
+ setIsRunning(true);
3664
3589
  }
3665
- if (!isRunning)
3666
- setIsRunning(true);
3667
3590
  }
3668
3591
  });
3669
- useEffect3(() => {
3592
+ useEffect2(() => {
3670
3593
  const getLogsToRender = (logs, index) => {
3594
+ const limitedLogs = getLimitedLogs(logs);
3671
3595
  if (scrollPos > 0 && tabIndex === index) {
3672
- return logs.slice(logs.length - boxHeight - scrollPos, logs.length - scrollPos);
3673
- } else if (logs.length > boxHeight) {
3674
- return logs.slice(logs.length - boxHeight, logs.length);
3596
+ return limitedLogs.slice(limitedLogs.length - boxHeight - scrollPos, limitedLogs.length - scrollPos);
3597
+ } else if (limitedLogs.length > boxHeight) {
3598
+ return limitedLogs.slice(limitedLogs.length - boxHeight, limitedLogs.length);
3675
3599
  } else {
3676
- return logs;
3600
+ return limitedLogs;
3677
3601
  }
3678
3602
  };
3679
3603
  if (isRunning) {
3680
- if (tabIndex !== null && lengthMap.has(tabIndex)) {
3604
+ if (lengthMap.has(tabIndex)) {
3681
3605
  const tabLength = lengthMap.get(tabIndex);
3682
- if (tabLength && tabLength < logList[tabIndex].logs.length) {
3606
+ const limitedLogsLength = Math.min(logList[tabIndex].logs.length, maxLength);
3607
+ if (tabLength && tabLength < limitedLogsLength) {
3683
3608
  setScrollPos(scrollPos + 1);
3684
- lengthMap.set(tabIndex, logList[tabIndex].logs.length);
3609
+ lengthMap.set(tabIndex, limitedLogsLength);
3685
3610
  }
3686
3611
  }
3687
- setRenderMultiLogs((prev) => {
3688
- const newState = [...prev];
3689
- logList.forEach((logData, index) => {
3690
- newState[index] = getLogsToRender(logData.logs, index);
3691
- });
3692
- return newState;
3693
- });
3612
+ setFocusLog(getLogsToRender(logList[tabIndex].logs, tabIndex));
3694
3613
  } else {
3695
- setRenderMultiLogs((prev) => {
3696
- const newState = [...prev];
3697
- logList.forEach((logData, index) => {
3698
- lengthMap.set(index, logData.logs.length);
3699
- newState[index] = getLogsToRender(logData.logs, index);
3700
- });
3701
- return newState;
3702
- });
3614
+ setFocusLog(getLogsToRender(logList[tabIndex].logs, tabIndex));
3703
3615
  }
3704
- }, [logList, isRunning, scrollPos, tabIndex, boxHeight]);
3705
- useEffect3(() => {
3706
- setBoxHeight(height - 7);
3616
+ }, [logList, isRunning, scrollPos, tabIndex, boxHeight, maxLength]);
3617
+ useEffect2(() => {
3618
+ setBoxHeight(height - HEADER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT);
3707
3619
  }, [height]);
3708
- useEffect3(() => {
3709
- setLengthMap(new Map(logList.map((log, index) => [index, log.logs.length])));
3710
- }, []);
3711
- return /* @__PURE__ */ React2.createElement(Box2, { width, height, flexDirection: "column" }, /* @__PURE__ */ React2.createElement(Box2, { width, height: "100%" }, renderMultiLogs.map((logData, index) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Box2, { width, height: "100%", flexDirection: "column", key: index }, /* @__PURE__ */ React2.createElement(Box2, null, /* @__PURE__ */ React2.createElement(Text2, { color: logList[index].color }, logList[index].title)), /* @__PURE__ */ React2.createElement(
3712
- Box2,
3620
+ useEffect2(() => {
3621
+ setLengthMap(new Map(logList.map((log, index) => [index, Math.min(log.logs.length, maxLength)])));
3622
+ }, [logList, maxLength]);
3623
+ return /* @__PURE__ */ React.createElement(Box, { width, height, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, { width, height: "80%", flexDirection: "row" }, /* @__PURE__ */ React.createElement(Box, { width: 30, height: "100%", flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, null, "List ", tabIndex + 1, "/", logList.length)), /* @__PURE__ */ React.createElement(Box, { borderStyle: "round", borderColor: "blackBright", width: "100%", height: "100%", flexDirection: "column" }, logList.map((log, index) => {
3624
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { color: index === tabIndex ? "green" : "white" }, /* @__PURE__ */ React.createElement(Text, null, "\u25CF"), "\xA0", log.title.length > 25 ? log.title.slice(0, 25) + "..." : log.title));
3625
+ }))), /* @__PURE__ */ React.createElement(Box, { width, height: boxHeight + 3, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, logList[tabIndex].title), /* @__PURE__ */ React.createElement(
3626
+ Box,
3713
3627
  {
3714
- flexWrap: "wrap",
3715
- height,
3716
- borderStyle: index === tabIndex ? "double" : "round",
3717
- borderDimColor: index !== tabIndex,
3718
- borderColor: index === tabIndex && isRunning ? "green" : logList[index].color
3628
+ borderStyle: isRunning ? "double" : "round",
3629
+ flexDirection: "column",
3630
+ borderColor: logList[tabIndex].color,
3631
+ width: "100%",
3632
+ height: "100%"
3719
3633
  },
3720
- /* @__PURE__ */ React2.createElement(Text2, null, isRunning && tabIndex === index ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, logData.slice(0, logData.length - 1).map((log, index2) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text2, { key: index2 }, log), /* @__PURE__ */ React2.createElement(Newline2, null))), /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "scrolling... +", scrollPos)) : /* @__PURE__ */ React2.createElement(React2.Fragment, null, logData.map((data, index2) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text2, { key: index2 }, data), /* @__PURE__ */ React2.createElement(Newline2, null)))))
3721
- ))))), /* @__PURE__ */ React2.createElement(Box2, { width, height: "auto" }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, /* @__PURE__ */ React2.createElement(Text2, null, "You can use the following shortcuts:"), /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3634
+ scrollPos > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, focusLog.slice(0, focusLog.length - 1).map((log, index) => {
3635
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { key: index }, index, ": ", log));
3636
+ }), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "Scrolling... +", scrollPos)) : focusLog.map((log, index) => {
3637
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { key: index }, index, ": ", log));
3638
+ })
3639
+ ))), /* @__PURE__ */ React.createElement(Box, { width }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, /* @__PURE__ */ React.createElement(Text, null, "You can use the following shortcuts:"), /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3722
3640
  };
3723
3641
 
3724
- // pkgs/@akanjs/cli/src/application/appilcation.interface.tsx
3725
- var Backend = ({ app, env }) => {
3726
- const [logs, setLogs] = useState4([]);
3642
+ // pkgs/@akanjs/cli/src/application/application.interface.tsx
3643
+ var Backend = ({ appName, childProcess, onExit }) => {
3644
+ const [logs, setLogs] = useState3([]);
3727
3645
  const [width, height] = useStdoutDimensions();
3728
- useEffect4(() => {
3729
- const proc = app.dist.spawnSync("node", ["--watch", "main.js"], {
3730
- env,
3731
- stdio: "pipe",
3732
- cwd: `${app.dist.cwdPath}/backend`
3733
- });
3734
- proc.stdout?.on("data", (data) => {
3646
+ useEffect3(() => {
3647
+ childProcess.stdout?.on("data", (data) => {
3735
3648
  const newOutput = data.toString().split("\n");
3736
3649
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3737
3650
  });
3738
- proc.stderr?.on("data", (data) => {
3651
+ childProcess.stderr?.on("data", (data) => {
3739
3652
  const newOutput = data.toString().split("\n");
3740
3653
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3741
3654
  });
3742
3655
  return () => {
3743
- proc.kill();
3656
+ childProcess.kill();
3657
+ onExit();
3744
3658
  };
3745
3659
  }, []);
3746
- return /* @__PURE__ */ React3.createElement(Box3, { width, height }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "Akan.JS Backend"));
3660
+ return /* @__PURE__ */ React2.createElement(Box2, { width, height }, /* @__PURE__ */ React2.createElement(Text2, { bold: true }, "Akan.JS Backend"));
3747
3661
  };
3748
- var Frontend = ({ app, env }) => {
3749
- const [logs, setLogs] = useState4([]);
3662
+ var Frontend = ({ appName, childProcess, onExit }) => {
3663
+ const [logs, setLogs] = useState3([]);
3750
3664
  const [width, height] = useStdoutDimensions();
3751
- useEffect4(() => {
3752
- const proc = app.spawnSync("npx", ["next", "dev", "-p", "4200"], {
3753
- env,
3754
- stdio: ["ignore", "pipe", "pipe"],
3755
- detached: true
3756
- });
3757
- proc.stdout?.on("data", (data) => {
3665
+ useEffect3(() => {
3666
+ childProcess.stdout?.on("data", (data) => {
3758
3667
  const newOutput = data.toString().split("\n");
3759
3668
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3760
3669
  });
3761
- proc.stderr?.on("data", (data) => {
3670
+ childProcess.stderr?.on("data", (data) => {
3762
3671
  const newOutput = data.toString().split("\n");
3763
3672
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3764
3673
  });
3765
3674
  return () => {
3766
- proc.kill();
3675
+ childProcess.kill();
3676
+ onExit();
3767
3677
  };
3768
3678
  }, []);
3769
- return /* @__PURE__ */ React3.createElement(Box3, { width, height, flexDirection: "column" }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "Akan.JS Frontend"), logs.map((log) => /* @__PURE__ */ React3.createElement(Text3, { key: log }, log)));
3679
+ return /* @__PURE__ */ React2.createElement(Box2, { width, height, flexDirection: "column" }, /* @__PURE__ */ React2.createElement(Text2, { bold: true }, appName, " Frontend"), logs.map((log) => /* @__PURE__ */ React2.createElement(Text2, { key: log }, log)));
3770
3680
  };
3771
- var Csr = ({
3772
- app,
3773
- onLoad
3774
- }) => {
3775
- const [logs, setLogs] = useState4([]);
3681
+ var Csr = ({ app, event, onExit }) => {
3682
+ const [logs, setLogs] = useState3([]);
3776
3683
  const [width, height] = useStdoutDimensions();
3777
- useEffect4(() => {
3778
- void onLoad({
3779
- onLog: (log) => {
3780
- setLogs((prevLogs) => [...prevLogs, log]);
3781
- }
3684
+ const [test, setTest] = useState3(false);
3685
+ useEffect3(() => {
3686
+ event.on("info", (msg) => {
3687
+ setLogs((prevLogs) => [...prevLogs, msg]);
3688
+ });
3689
+ event.on("warn", (msg) => {
3690
+ setLogs((prevLogs) => [...prevLogs, msg]);
3691
+ });
3692
+ event.on("warnOnce", (msg) => {
3693
+ setLogs((prevLogs) => [...prevLogs, msg]);
3694
+ });
3695
+ event.on("error", (msg) => {
3696
+ setLogs((prevLogs) => [...prevLogs, msg]);
3697
+ });
3698
+ event.on("clearScreen", (type) => {
3699
+ setLogs((prevLogs) => [...prevLogs, type]);
3782
3700
  });
3783
3701
  }, []);
3784
- return /* @__PURE__ */ React3.createElement(Box3, { width, height, flexDirection: "column" }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "Akan.JS CSR"), /* @__PURE__ */ React3.createElement(ScrollList, { list: logs }));
3702
+ return /* @__PURE__ */ React2.createElement(Box2, { width, height, flexDirection: "column" }, /* @__PURE__ */ React2.createElement(Text2, null, test ? "true" : "false"), /* @__PURE__ */ React2.createElement(Text2, { bold: true }, "Akan.JS CSR"), /* @__PURE__ */ React2.createElement(Text2, null, logs));
3785
3703
  };
3786
- var Start = ({
3787
- app,
3788
- backendEnv,
3789
- frontendEnv,
3790
- onLoadCsr
3791
- }) => {
3704
+ var Start = ({ appName, bcp, fcp, csr, onExit, maxLength = 100 }) => {
3792
3705
  const [width, height] = useStdoutDimensions();
3793
- const [csrLogs, setCsrLogs] = useState4([]);
3794
- const [backendLogs, setBackendLogs] = useState4([]);
3795
- const [frontendLogs, setFrontendLogs] = useState4([]);
3796
- useEffect4(() => {
3797
- const backend = app.dist.spawnSync("node", ["--watch", "main.js"], {
3798
- stdio: ["ignore", "pipe", "pipe"],
3799
- // stdin은 무시
3800
- env: backendEnv,
3801
- detached: true,
3802
- cwd: `${app.dist.cwdPath}/backend`
3706
+ const [csrLogs, setCsrLogs] = useState3([]);
3707
+ const [backendLogs, setBackendLogs] = useState3([]);
3708
+ const [frontendLogs, setFrontendLogs] = useState3([]);
3709
+ const { exit } = useApp();
3710
+ const filterLogData = (data) => {
3711
+ return typeof data === "string" ? data.split(/\r?\n/).filter((line) => line !== "") : data.toString().split(/\r?\n/).filter((line) => line !== "");
3712
+ };
3713
+ const saveLog = (type, data, setLog) => {
3714
+ const newOutput = filterLogData(data);
3715
+ const logs = newOutput.map((line) => ({ type, content: line }));
3716
+ setLog((currentLogs) => {
3717
+ if (currentLogs.length >= maxLength) {
3718
+ return [...currentLogs.slice(logs.length, maxLength), ...logs];
3719
+ } else if (currentLogs.length < maxLength && currentLogs.length + logs.length > maxLength) {
3720
+ return [...currentLogs.slice(Math.abs(maxLength - currentLogs.length - logs.length), maxLength), ...logs];
3721
+ } else
3722
+ return [...currentLogs, ...logs];
3803
3723
  });
3804
- const frontend = app.spawnSync("npx", ["next", "dev", "-p", "4200"], {
3805
- stdio: ["ignore", "pipe", "pipe"],
3806
- // stdin은 무시
3807
- env: frontendEnv,
3808
- detached: true
3724
+ };
3725
+ useEffect3(() => {
3726
+ bcp.stdout?.on("data", (data) => {
3727
+ saveLog("stdout", data, setBackendLogs);
3809
3728
  });
3810
- backend.stdout?.on("data", (data) => {
3811
- const newOutput = data.toString().split("\n");
3812
- setBackendLogs((currentLogs) => [
3813
- ...currentLogs,
3814
- ...newOutput.map((line) => ({ type: "stdout", content: line }))
3815
- ]);
3729
+ bcp.stderr?.on("data", (data) => {
3730
+ saveLog("stderr", data, setBackendLogs);
3816
3731
  });
3817
- backend.stderr?.on("data", (data) => {
3818
- const newOutput = data.toString().split("\n");
3819
- setBackendLogs((currentLogs) => [
3820
- ...currentLogs,
3821
- ...newOutput.map((line) => ({ type: "stderr", content: line }))
3822
- ]);
3732
+ fcp.stdout?.on("data", (data) => {
3733
+ saveLog("stdout", data, setFrontendLogs);
3823
3734
  });
3824
- frontend.stdout?.on("data", (data) => {
3825
- const newOutput = data.toString().split("\n");
3826
- setFrontendLogs((currentLogs) => [
3827
- ...currentLogs,
3828
- ...newOutput.map((line) => ({ type: "stdout", content: line }))
3829
- ]);
3735
+ fcp.stderr?.on("data", (data) => {
3736
+ saveLog("stderr", data, setFrontendLogs);
3830
3737
  });
3831
- frontend.stderr?.on("data", (data) => {
3832
- const newOutput = data.toString().split("\n");
3833
- setFrontendLogs((currentLogs) => [
3834
- ...currentLogs,
3835
- ...newOutput.map((line) => ({ type: "stderr", content: line }))
3836
- ]);
3738
+ csr.on("info", (msg) => {
3739
+ saveLog("info", msg, setCsrLogs);
3837
3740
  });
3838
- void onLoadCsr({
3839
- onLog: (log) => {
3840
- setCsrLogs((prevLogs) => [...prevLogs, { type: "stdout", content: log }]);
3841
- }
3741
+ csr.on("warn", (msg) => {
3742
+ saveLog("warn", msg, setCsrLogs);
3743
+ });
3744
+ csr.on("error", (msg) => {
3745
+ saveLog("error", msg, setCsrLogs);
3746
+ });
3747
+ csr.on("clearScreen", (type) => {
3748
+ saveLog("clearScreen", type, setCsrLogs);
3749
+ });
3750
+ const destroy = async () => {
3751
+ bcp.kill();
3752
+ fcp.kill();
3753
+ bcp.stdin?.end();
3754
+ fcp.stdin?.end();
3755
+ csr.removeAllListeners();
3756
+ await onExit();
3757
+ exit();
3758
+ process.exit(0);
3759
+ };
3760
+ process.on("SIGINT", () => {
3761
+ void destroy();
3842
3762
  });
3843
3763
  return () => {
3844
- backend.kill();
3845
- frontend.kill();
3764
+ void destroy();
3846
3765
  };
3847
3766
  }, []);
3848
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Box3, { borderColor: "#ff493b", height, width, flexDirection: "row" }, /* @__PURE__ */ React3.createElement(
3767
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Box2, { borderColor: "#ff493b", height, width, flexDirection: "row" }, /* @__PURE__ */ React2.createElement(
3849
3768
  MultiScrollList,
3850
3769
  {
3851
3770
  logList: [
3852
3771
  {
3853
- title: `${app.name} frontend`,
3772
+ title: `${appName} frontend`,
3854
3773
  logs: frontendLogs.map((log) => log.content),
3855
3774
  color: "#ff493b"
3856
3775
  },
3857
3776
  {
3858
- title: `${app.name} backend`,
3777
+ title: `${appName} backend`,
3859
3778
  logs: backendLogs.map((log) => log.content),
3860
3779
  color: "#e535ab"
3861
3780
  },
3862
3781
  {
3863
- title: `${app.name} react`,
3782
+ title: `${appName} react`,
3864
3783
  logs: csrLogs.map((log) => log.content),
3865
3784
  color: "#7cc5d9"
3866
3785
  }
3867
- ]
3786
+ ],
3787
+ maxLength
3868
3788
  }
3869
3789
  )));
3870
3790
  };
3871
3791
  var Interface = {
3872
- Csr: (app, onLoad) => render(/* @__PURE__ */ React3.createElement(Csr, { app, onLoad })),
3873
- Backend: (app, env) => render(/* @__PURE__ */ React3.createElement(Backend, { app, env })),
3874
- Frontend: (app, env) => render(/* @__PURE__ */ React3.createElement(Frontend, { app, env })),
3875
- Start: (app, backendEnv, frontendEnv, onLoadCsr) => render(/* @__PURE__ */ React3.createElement(Start, { app, backendEnv, frontendEnv, onLoadCsr }))
3792
+ /**
3793
+ * Akan CSR 실행 컴포넌트
3794
+ *
3795
+ * @param app 정보
3796
+ * @param event CSR 이벤트 발생기
3797
+ * @param onExit 종료 함수
3798
+ */
3799
+ Csr: (app, event, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Csr, { app, event, onExit })),
3800
+ /**
3801
+ * Akan Backend 실행 컴포넌트
3802
+ *
3803
+ * @param appName 앱 이름
3804
+ * @param childProcess 백엔드 차일드 프로세스
3805
+ * @param onExit 종료 함수
3806
+ */
3807
+ Backend: (appName, childProcess, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Backend, { appName, childProcess, onExit })),
3808
+ /**
3809
+ * Akan Frontend 실행 컴포넌트
3810
+ *
3811
+ * @param appName 앱 이름
3812
+ * @param childProcess 프론트엔드 차일드 프로세스
3813
+ * @param onExit 종료 함수
3814
+ */
3815
+ Frontend: (appName, childProcess, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Frontend, { appName, childProcess, onExit })),
3816
+ /**
3817
+ * Akan application 통합 실행 컴포넌트 (백엔드, 프론트엔드, React(CSR))
3818
+ *
3819
+ * @param maxLength 로그 최대 길이
3820
+ * @param appName 앱 이름
3821
+ * @param bcp 백엔드 차일드 프로세스
3822
+ * @param fcp 프론트엔드 차일드 프로세스
3823
+ * @param csr CSR 이벤트 발생기
3824
+ * @param onExit 종료 함수
3825
+ */
3826
+ Start: (appName, bcp, fcp, csr, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Start, { appName, bcp, fcp, csr, onExit }))
3827
+ };
3828
+ var renderManager = (component) => {
3829
+ const renderFn = render(component);
3830
+ return renderFn;
3876
3831
  };
3877
3832
 
3878
3833
  // pkgs/@akanjs/cli/src/application/application.runner.ts
3834
+ import EventEmitter from "node:events";
3835
+ import { confirm as confirm2, input as input4, select as select5 } from "@inquirer/prompts";
3836
+ import { StringOutputParser } from "@langchain/core/output_parsers";
3837
+ import { PromptTemplate as PromptTemplate2 } from "@langchain/core/prompts";
3838
+ import { RunnableSequence as RunnableSequence2 } from "@langchain/core/runnables";
3839
+ import { ChatOpenAI as ChatOpenAI3 } from "@langchain/openai";
3840
+ import react from "@vitejs/plugin-react";
3841
+ import dotenv3 from "dotenv";
3842
+ import * as esbuild2 from "esbuild";
3843
+ import fs14 from "fs";
3844
+ import fsPromise3 from "fs/promises";
3845
+ import yaml2 from "js-yaml";
3846
+ import openBrowser from "open";
3847
+ import ora3 from "ora";
3848
+ import path7 from "path";
3849
+ import * as vite from "vite";
3850
+ import commonjs from "vite-plugin-commonjs";
3851
+ import { nodePolyfills } from "vite-plugin-node-polyfills";
3852
+ import tsconfigPaths from "vite-tsconfig-paths";
3879
3853
  var ApplicationRunner = class {
3880
3854
  async createApplication(appName, workspace) {
3881
3855
  await workspace.applyTemplate({
@@ -3903,34 +3877,6 @@ var ApplicationRunner = class {
3903
3877
  await app.syncAssets(scanResult.akanConfig.libs);
3904
3878
  return scanResult;
3905
3879
  }
3906
- async start(app) {
3907
- const { env: frontendEnv } = await this.#prepareCommand(app, "start", "frontend");
3908
- const { env: backendEnv } = await this.#prepareCommand(app, "start", "backend");
3909
- Interface.Start(app, backendEnv, frontendEnv, async ({ onLog }) => {
3910
- const config = await this.#getViteConfig(app, "start", {
3911
- customLogger: {
3912
- info: (msg) => {
3913
- onLog(msg);
3914
- },
3915
- warn: (msg) => {
3916
- },
3917
- warnOnce: (msg) => {
3918
- },
3919
- error: (msg) => {
3920
- onLog(msg);
3921
- },
3922
- clearScreen: (type) => {
3923
- },
3924
- hasErrorLogged: (error) => {
3925
- return false;
3926
- },
3927
- hasWarned: false
3928
- }
3929
- });
3930
- const server = await vite.createServer(config);
3931
- await server.listen(4201);
3932
- });
3933
- }
3934
3880
  async getScriptFilename(app) {
3935
3881
  if (!app.exists("scripts")) {
3936
3882
  app.mkdir("scripts");
@@ -4010,7 +3956,7 @@ var ApplicationRunner = class {
4010
3956
  app.dist.writeJson("backend/package.json", appPackageJson);
4011
3957
  app.dist.writeFile(path7.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
4012
3958
  }
4013
- async startBackend(app, { open: open2 = false, onStart } = {}) {
3959
+ async startBackend(app, { open: open2 = false, onStart, withInk = false } = {}) {
4014
3960
  const { env } = await this.#prepareCommand(app, "start", "backend");
4015
3961
  const ctx = await esbuild2.context({
4016
3962
  write: true,
@@ -4027,7 +3973,11 @@ var ApplicationRunner = class {
4027
3973
  onStart?.();
4028
3974
  if (open2)
4029
3975
  setTimeout(() => openBrowser("http://localhost:8080/backend/graphql"), 3e3);
4030
- await app.dist.spawn("node", ["--watch", "main.js"], { env, stdio: "inherit", cwd: `${app.dist.cwdPath}/backend` });
3976
+ return app.dist.spawnSync("node", ["--watch", "main.js"], {
3977
+ env,
3978
+ stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit",
3979
+ cwd: `${app.dist.cwdPath}/backend`
3980
+ });
4031
3981
  }
4032
3982
  async buildFrontend(app, { spawnOptions } = {}) {
4033
3983
  const { env } = await this.#prepareCommand(app, "build", "frontend");
@@ -4061,12 +4011,20 @@ var ApplicationRunner = class {
4061
4011
  ]);
4062
4012
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
4063
4013
  }
4064
- async startFrontend(app, { open: open2 = false, turbo = true, onStart } = {}) {
4014
+ async startFrontend(app, {
4015
+ open: open2 = false,
4016
+ turbo = true,
4017
+ onStart,
4018
+ withInk = false
4019
+ } = {}) {
4065
4020
  const { env } = await this.#prepareCommand(app, "start", "frontend");
4066
4021
  if (open2)
4067
4022
  setTimeout(() => openBrowser("http://localhost:4200"), 3e3);
4068
4023
  onStart?.();
4069
- await app.spawn("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], { env, stdio: "inherit" });
4024
+ return app.spawnSync("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], {
4025
+ env,
4026
+ stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit"
4027
+ });
4070
4028
  }
4071
4029
  async #getViteConfig(app, command, viteConfig = {}) {
4072
4030
  const { env } = await this.#prepareCommand(app, command, "csr");
@@ -4154,38 +4112,41 @@ var ApplicationRunner = class {
4154
4112
  const config = await this.#getViteConfig(app, "build");
4155
4113
  await vite.build(config);
4156
4114
  }
4157
- startCsr(app, { open: open2 = false, onStart } = {}) {
4158
- Interface.Csr(app, async ({ onLog }) => {
4159
- const config = await this.#getViteConfig(app, "start", {
4115
+ async startCsr(app, { open: open2 = false, onStart, withInk = false } = {}) {
4116
+ const eventEmitter = new EventEmitter();
4117
+ const config = await this.#getViteConfig(
4118
+ app,
4119
+ "start",
4120
+ withInk ? {
4160
4121
  customLogger: {
4161
4122
  info: (msg) => {
4162
- onLog(msg);
4123
+ eventEmitter.emit("info", msg);
4163
4124
  },
4164
4125
  warn: (msg) => {
4165
- onLog(msg);
4126
+ eventEmitter.emit("warn", msg);
4166
4127
  },
4167
4128
  warnOnce: (msg) => {
4168
- onLog(msg);
4129
+ eventEmitter.emit("warnOnce", msg);
4169
4130
  },
4170
4131
  error: (msg) => {
4171
- onLog(msg);
4132
+ eventEmitter.emit("error", msg);
4172
4133
  },
4173
4134
  clearScreen: (type) => {
4174
- onLog(type);
4135
+ eventEmitter.emit("clearScreen", type);
4175
4136
  },
4176
4137
  hasErrorLogged: (error) => {
4177
4138
  return false;
4178
4139
  },
4179
4140
  hasWarned: false
4180
4141
  }
4181
- });
4182
- const env = this.#prepareCommand(app, "start", "csr");
4183
- const server = await vite.createServer(config);
4184
- await server.listen(4201);
4185
- });
4142
+ } : {}
4143
+ );
4144
+ const server = await vite.createServer(config);
4145
+ await server.listen(4201);
4186
4146
  onStart?.();
4187
4147
  if (open2)
4188
4148
  setTimeout(() => openBrowser("http://localhost:4201"), 3e3);
4149
+ return { server, eventEmitter };
4189
4150
  }
4190
4151
  async buildIos(app) {
4191
4152
  const capacitorApp = await new CapacitorApp(app).init();
@@ -4479,7 +4440,16 @@ var ApplicationScript = class {
4479
4440
  await this.syncApplication(app);
4480
4441
  if (app.workspace.getBaseDevEnv().env === "local")
4481
4442
  await this.dbup(app.workspace);
4482
- await this.#runner.start(app);
4443
+ const backend = await this.startBackend(app, { open: open2, withInk: true });
4444
+ const frontend = await this.startFrontend(app, { open: open2, withInk: true });
4445
+ const { server: csrServer, eventEmitter: csr } = await this.startCsr(app, { open: open2, withInk: true });
4446
+ Interface.Start(app.name, backend, frontend, csr, async () => {
4447
+ await csrServer.close();
4448
+ backend.kill();
4449
+ frontend.kill();
4450
+ csr.removeAllListeners();
4451
+ process.exit(0);
4452
+ });
4483
4453
  }
4484
4454
  async buildBackend(app, { sync = true } = {}) {
4485
4455
  if (sync)
@@ -4488,7 +4458,12 @@ var ApplicationScript = class {
4488
4458
  await this.#runner.buildBackend(app);
4489
4459
  spinner.succeed(`Backend built in dist/apps/${app.name}/backend`);
4490
4460
  }
4491
- async startBackend(app, { open: open2 = false, dbup = true, sync = true } = {}) {
4461
+ async startBackend(app, {
4462
+ open: open2 = false,
4463
+ dbup = true,
4464
+ sync = true,
4465
+ withInk = false
4466
+ } = {}) {
4492
4467
  if (app.getEnv() === "local" && dbup) {
4493
4468
  await this.dbup(app.workspace);
4494
4469
  process.on("SIGINT", async () => {
@@ -4499,12 +4474,14 @@ var ApplicationScript = class {
4499
4474
  if (sync)
4500
4475
  await this.syncApplication(app);
4501
4476
  const spinner = app.spinning("Preparing backend...");
4502
- await this.#runner.startBackend(app, {
4477
+ const childProcess = await this.#runner.startBackend(app, {
4503
4478
  open: open2,
4504
4479
  onStart: () => {
4505
4480
  spinner.succeed(`Backend prepared, ready to start`);
4506
- }
4481
+ },
4482
+ withInk
4507
4483
  });
4484
+ return childProcess;
4508
4485
  }
4509
4486
  async buildFrontend(app, { sync = true, standalone = false } = {}) {
4510
4487
  if (sync)
@@ -4517,17 +4494,24 @@ var ApplicationScript = class {
4517
4494
  spinner.succeed(`Frontend built in dist/apps/${app.name}/frontend`);
4518
4495
  }
4519
4496
  }
4520
- async startFrontend(app, { open: open2 = false, turbo = false, sync = true } = {}) {
4497
+ async startFrontend(app, {
4498
+ open: open2 = false,
4499
+ turbo = false,
4500
+ sync = true,
4501
+ withInk = false
4502
+ } = {}) {
4521
4503
  if (sync)
4522
4504
  await this.syncApplication(app);
4523
4505
  const spinner = app.spinning("Preparing frontend...");
4524
- await this.#runner.startFrontend(app, {
4506
+ const childProcess = await this.#runner.startFrontend(app, {
4525
4507
  open: open2,
4526
4508
  turbo,
4527
4509
  onStart: () => {
4528
4510
  spinner.succeed(`Frontend prepared, ready to start`);
4529
- }
4511
+ },
4512
+ withInk
4530
4513
  });
4514
+ return childProcess;
4531
4515
  }
4532
4516
  async buildCsr(app, { sync = true } = {}) {
4533
4517
  if (sync)
@@ -4536,14 +4520,16 @@ var ApplicationScript = class {
4536
4520
  await this.#runner.buildCsr(app);
4537
4521
  spinner.succeed(`Successfully built in dist/apps/${app.name}/csr`);
4538
4522
  }
4539
- async startCsr(app, { open: open2 = false, sync = true } = {}) {
4523
+ async startCsr(app, { open: open2 = false, sync = true, withInk = false } = {}) {
4540
4524
  if (sync)
4541
4525
  await this.syncApplication(app);
4542
- this.#runner.startCsr(app, {
4526
+ const { eventEmitter, server } = await this.#runner.startCsr(app, {
4543
4527
  open: open2,
4544
4528
  onStart: () => {
4545
- }
4529
+ },
4530
+ withInk
4546
4531
  });
4532
+ return { eventEmitter, server };
4547
4533
  }
4548
4534
  async buildIos(app, { sync = true } = {}) {
4549
4535
  if (sync)