crankscript 0.11.2 → 0.11.4
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/assets/index.d.ts +1 -1
- package/assets/transformNewExpression/isBuiltinNewExpression.d.ts +2 -0
- package/assets/transformNewExpression/isBuiltinNewExpression.js +24 -0
- package/assets/transformNewExpression/isBuiltinNewExpression.js.map +1 -0
- package/assets/transformNewExpression/transformNewExpression.d.ts +1 -1
- package/assets/transformNewExpression/transformNewExpression.js +4 -0
- package/assets/transformNewExpression/transformNewExpression.js.map +1 -1
- package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js +1 -5
- package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/CompileCommand/hooks/task/compile.d.ts +7 -0
- package/src/commands/CompileCommand/hooks/task/compile.js +23 -0
- package/src/commands/CompileCommand/hooks/task/compile.js.map +1 -0
- package/src/commands/CompileCommand/hooks/useCompileTasks.js +4 -17
- package/src/commands/CompileCommand/hooks/useCompileTasks.js.map +1 -1
- package/src/commands/TranspileCommand/fn/_tests/test-builtins/src/index.js +4 -0
- package/src/commands/TranspileCommand/fn/_tests/test-builtins/src/index.js.map +1 -0
- package/src/components/CheckList/Item.js +0 -1
- package/src/components/CheckList/Item.js.map +1 -1
package/assets/index.d.ts
CHANGED
@@ -6,7 +6,7 @@ declare const _default: {
|
|
6
6
|
108: (expression: ts.SuperExpression, context: import("typescript-to-lua").TransformationContext & {
|
7
7
|
classSuperInfos?: import("./types").ClassSuperInfo[];
|
8
8
|
}) => import("typescript-to-lua").Identifier | import("typescript-to-lua").TableIndexExpression;
|
9
|
-
214: (node: ts.NewExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").
|
9
|
+
214: (node: ts.NewExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Expression;
|
10
10
|
211: (node: ts.PropertyAccessExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Expression;
|
11
11
|
213: (node: ts.CallExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Expression;
|
12
12
|
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "isBuiltinNewExpression", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return isBuiltinNewExpression;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const isBuiltinNewExpression = (node, typeChecker)=>{
|
12
|
+
if (!node.expression) return false;
|
13
|
+
const type = typeChecker.getTypeAtLocation(node.expression);
|
14
|
+
const symbol = type.getSymbol();
|
15
|
+
if (!symbol) return false;
|
16
|
+
const declarations = symbol.getDeclarations();
|
17
|
+
if (!declarations || declarations.length === 0) return false;
|
18
|
+
return declarations.some((decl)=>{
|
19
|
+
const sourceFile = decl.getSourceFile();
|
20
|
+
return sourceFile.fileName.includes('node_modules/typescript/lib');
|
21
|
+
});
|
22
|
+
};
|
23
|
+
|
24
|
+
//# sourceMappingURL=isBuiltinNewExpression.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformNewExpression/isBuiltinNewExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\n\nexport const isBuiltinNewExpression = (\n node: ts.NewExpression,\n typeChecker: ts.TypeChecker\n) => {\n if (!node.expression) return false;\n\n const type = typeChecker.getTypeAtLocation(node.expression);\n\n const symbol = type.getSymbol();\n if (!symbol) return false;\n\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) return false;\n\n return declarations.some((decl) => {\n const sourceFile = decl.getSourceFile();\n return sourceFile.fileName.includes('node_modules/typescript/lib');\n });\n};\n"],"names":["isBuiltinNewExpression","node","typeChecker","expression","type","getTypeAtLocation","symbol","getSymbol","declarations","getDeclarations","length","some","decl","sourceFile","getSourceFile","fileName","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,yBAAyB,CAClCC,MACAC;IAEA,IAAI,CAACD,KAAKE,UAAU,EAAE,OAAO;IAE7B,MAAMC,OAAOF,YAAYG,iBAAiB,CAACJ,KAAKE,UAAU;IAE1D,MAAMG,SAASF,KAAKG,SAAS;IAC7B,IAAI,CAACD,QAAQ,OAAO;IAEpB,MAAME,eAAeF,OAAOG,eAAe;IAC3C,IAAI,CAACD,gBAAgBA,aAAaE,MAAM,KAAK,GAAG,OAAO;IAEvD,OAAOF,aAAaG,IAAI,CAAC,CAACC;QACtB,MAAMC,aAAaD,KAAKE,aAAa;QACrC,OAAOD,WAAWE,QAAQ,CAACC,QAAQ,CAAC;IACxC;AACJ"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import * as ts from 'typescript';
|
2
2
|
import * as tstl from 'typescript-to-lua';
|
3
|
-
export declare const transformNewExpression: (node: ts.NewExpression, context: tstl.TransformationContext) => tstl.
|
3
|
+
export declare const transformNewExpression: (node: ts.NewExpression, context: tstl.TransformationContext) => tstl.Expression;
|
@@ -12,7 +12,11 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
12
12
|
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
13
|
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
14
14
|
const _call = require("typescript-to-lua/dist/transformation/visitors/call");
|
15
|
+
const _isBuiltinNewExpression = require("./isBuiltinNewExpression");
|
15
16
|
const transformNewExpression = (node, context)=>{
|
17
|
+
if ((0, _isBuiltinNewExpression.isBuiltinNewExpression)(node, context.checker)) {
|
18
|
+
return context.superTransformExpression(node);
|
19
|
+
}
|
16
20
|
const signature = context.checker.getResolvedSignature(node);
|
17
21
|
var _node_arguments;
|
18
22
|
const [name, params] = (0, _call.transformCallAndArguments)(context, node.expression, (_node_arguments = node.arguments) != null ? _node_arguments : [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformNewExpression/transformNewExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor } from 'typescript-to-lua';\nimport * as tstl from 'typescript-to-lua';\nimport { transformCallAndArguments } from 'typescript-to-lua/dist/transformation/visitors/call';\n\nexport const transformNewExpression = ((node, context) => {\n const signature = context.checker.getResolvedSignature(node);\n const [name, params] = transformCallAndArguments(\n context,\n node.expression,\n node.arguments ?? [ts.factory.createTrue()],\n signature\n );\n return tstl.createCallExpression(name, params);\n}) satisfies FunctionVisitor<ts.NewExpression>;\n"],"names":["transformNewExpression","node","context","
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformNewExpression/transformNewExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor } from 'typescript-to-lua';\nimport * as tstl from 'typescript-to-lua';\nimport { transformCallAndArguments } from 'typescript-to-lua/dist/transformation/visitors/call';\nimport { isBuiltinNewExpression } from './isBuiltinNewExpression';\n\nexport const transformNewExpression = ((node, context) => {\n if (isBuiltinNewExpression(node, context.checker)) {\n return context.superTransformExpression(node);\n }\n\n const signature = context.checker.getResolvedSignature(node);\n const [name, params] = transformCallAndArguments(\n context,\n node.expression,\n node.arguments ?? [ts.factory.createTrue()],\n signature\n );\n return tstl.createCallExpression(name, params);\n}) satisfies FunctionVisitor<ts.NewExpression>;\n"],"names":["transformNewExpression","node","context","isBuiltinNewExpression","checker","superTransformExpression","signature","getResolvedSignature","name","params","transformCallAndArguments","expression","arguments","ts","factory","createTrue","tstl","createCallExpression"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAMaA;;;eAAAA;;;;sEANO;2EAEE;sBACoB;wCACH;AAEhC,MAAMA,yBAA0B,CAACC,MAAMC;IAC1C,IAAIC,IAAAA,8CAAsB,EAACF,MAAMC,QAAQE,OAAO,GAAG;QAC/C,OAAOF,QAAQG,wBAAwB,CAACJ;IAC5C;IAEA,MAAMK,YAAYJ,QAAQE,OAAO,CAACG,oBAAoB,CAACN;QAInDA;IAHJ,MAAM,CAACO,MAAMC,OAAO,GAAGC,IAAAA,+BAAyB,EAC5CR,SACAD,KAAKU,UAAU,EACfV,CAAAA,kBAAAA,KAAKW,SAAS,YAAdX,kBAAkB;QAACY,YAAGC,OAAO,CAACC,UAAU;KAAG,EAC3CT;IAEJ,OAAOU,iBAAKC,oBAAoB,CAACT,MAAMC;AAC3C"}
|
@@ -8,13 +8,9 @@ Object.defineProperty(exports, "getTransformPropertyAccessExpression", {
|
|
8
8
|
return getTransformPropertyAccessExpression;
|
9
9
|
}
|
10
10
|
});
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
-
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
11
|
const getTransformPropertyAccessExpression = (importMap)=>{
|
14
12
|
return (node, context)=>{
|
15
|
-
|
16
|
-
importMap.processName(node.name.text);
|
17
|
-
}
|
13
|
+
importMap.processName(node.name.text);
|
18
14
|
return context.superTransformExpression(node);
|
19
15
|
};
|
20
16
|
};
|
package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformPropertyAccessExpression/getTransformPropertyAccessExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor } from 'typescript-to-lua';\nimport { ImportMap } from '../ImportMap';\n\nexport const getTransformPropertyAccessExpression = (importMap: ImportMap) => {\n return ((node, context) => {\n
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformPropertyAccessExpression/getTransformPropertyAccessExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor } from 'typescript-to-lua';\nimport { ImportMap } from '../ImportMap';\n\nexport const getTransformPropertyAccessExpression = (importMap: ImportMap) => {\n return ((node, context) => {\n importMap.processName(node.name.text);\n\n return context.superTransformExpression(node);\n }) satisfies FunctionVisitor<ts.PropertyAccessExpression>;\n};\n"],"names":["getTransformPropertyAccessExpression","importMap","node","context","processName","name","text","superTransformExpression"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;AAAN,MAAMA,uCAAuC,CAACC;IACjD,OAAQ,CAACC,MAAMC;QACXF,UAAUG,WAAW,CAACF,KAAKG,IAAI,CAACC,IAAI;QAEpC,OAAOH,QAAQI,wBAAwB,CAACL;IAC5C;AACJ"}
|
package/package.json
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
import { exec } from 'child_process';
|
2
|
+
import { join } from 'node:path';
|
3
|
+
import { promisify } from 'util';
|
4
|
+
const execPromise = promisify(exec);
|
5
|
+
const hasStderr = (e)=>{
|
6
|
+
return e !== null && typeof e === 'object' && 'stderr' in e;
|
7
|
+
};
|
8
|
+
export const compile = async ({ pdcPath, target })=>{
|
9
|
+
const args = [
|
10
|
+
join(target, 'Source'),
|
11
|
+
join(target, 'Game.pdx')
|
12
|
+
];
|
13
|
+
try {
|
14
|
+
return execPromise(`${pdcPath} ${args.join(' ')}`);
|
15
|
+
} catch (error) {
|
16
|
+
if (hasStderr(error)) {
|
17
|
+
throw new Error(`Lua compilation failed: ${error.stderr}`);
|
18
|
+
}
|
19
|
+
throw error;
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
//# sourceMappingURL=compile.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/cli/src/commands/CompileCommand/hooks/task/compile.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { join } from 'node:path';\nimport { promisify } from 'util';\n\nconst execPromise = promisify(exec);\n\nconst hasStderr = (e: unknown): e is { stderr: string } => {\n return e !== null && typeof e === 'object' && 'stderr' in e;\n};\n\nexport const compile = async ({\n pdcPath,\n target,\n}: {\n pdcPath: string;\n target: string;\n}) => {\n const args = [join(target, 'Source'), join(target, 'Game.pdx')];\n\n try {\n return execPromise(`${pdcPath} ${args.join(' ')}`);\n } catch (error) {\n if (hasStderr(error)) {\n throw new Error(`Lua compilation failed: ${error.stderr}`);\n }\n\n throw error;\n }\n};\n"],"names":["exec","join","promisify","execPromise","hasStderr","e","compile","pdcPath","target","args","error","Error","stderr"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,gBAAgB;AACrC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,SAAS,QAAQ,OAAO;AAEjC,MAAMC,cAAcD,UAAUF;AAE9B,MAAMI,YAAY,CAACC;IACf,OAAOA,MAAM,QAAQ,OAAOA,MAAM,YAAY,YAAYA;AAC9D;AAEA,OAAO,MAAMC,UAAU,OAAO,EAC1BC,OAAO,EACPC,MAAM,EAIT;IACG,MAAMC,OAAO;QAACR,KAAKO,QAAQ;QAAWP,KAAKO,QAAQ;KAAY;IAE/D,IAAI;QACA,OAAOL,YAAY,CAAC,EAAEI,QAAQ,CAAC,EAAEE,KAAKR,IAAI,CAAC,KAAK,CAAC;IACrD,EAAE,OAAOS,OAAO;QACZ,IAAIN,UAAUM,QAAQ;YAClB,MAAM,IAAIC,MAAM,CAAC,wBAAwB,EAAED,MAAME,MAAM,CAAC,CAAC;QAC7D;QAEA,MAAMF;IACV;AACJ,EAAE"}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import { existsSync } from 'node:fs';
|
2
|
-
import { join } from 'node:path';
|
3
|
-
import open from 'open';
|
4
2
|
import { useMemo } from 'react';
|
5
|
-
import {
|
3
|
+
import { compile } from '../../../commands/CompileCommand/hooks/task/compile.js';
|
6
4
|
export const useCompileTasks = (pdcPath)=>{
|
7
5
|
return useMemo(()=>[
|
8
6
|
{
|
@@ -24,21 +22,10 @@ export const useCompileTasks = (pdcPath)=>{
|
|
24
22
|
runningDescription: 'Compiling lua code...',
|
25
23
|
finishedDescription: ()=>'Lua code compiled',
|
26
24
|
runner: async ()=>{
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
name: pdcPath,
|
31
|
-
arguments: [
|
32
|
-
join(currentDirectory, 'Source'),
|
33
|
-
join(currentDirectory, 'Game.pdx')
|
34
|
-
]
|
35
|
-
}
|
25
|
+
await compile({
|
26
|
+
pdcPath,
|
27
|
+
target: process.cwd()
|
36
28
|
});
|
37
|
-
if (isWindows) {
|
38
|
-
// Wait for pdc.exe to compile
|
39
|
-
// See https://github.com/sindresorhus/open/issues/298
|
40
|
-
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
41
|
-
}
|
42
29
|
},
|
43
30
|
ready: true
|
44
31
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport {
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport { compile } from '@/cli/commands/CompileCommand/hooks/task/compile.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useCompileTasks = (pdcPath: string) => {\n return useMemo(\n () => [\n {\n waitingDescription: 'Waiting to check for pdc binary...',\n errorDescription: 'Could not find pdc binary',\n runningDescription: 'Checking for pdc binary...',\n finishedDescription: (result) =>\n `Found pdc binary at \"${result}\"`,\n runner: async () => {\n if (!existsSync(pdcPath)) {\n throw new Error('Could not find pdc binary');\n }\n\n return pdcPath;\n },\n ready: true,\n } satisfies CheckListItem<string>,\n {\n waitingDescription: 'Waiting for pdc binary path...',\n errorDescription: 'Could not compile lua code',\n runningDescription: 'Compiling lua code...',\n finishedDescription: () => 'Lua code compiled',\n runner: async () => {\n await compile({ pdcPath, target: process.cwd() });\n },\n ready: true,\n },\n ],\n []\n ) as CheckListItem<unknown>[];\n};\n"],"names":["existsSync","useMemo","compile","useCompileTasks","pdcPath","waitingDescription","errorDescription","runningDescription","finishedDescription","result","runner","Error","ready","target","process","cwd"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,OAAO,QAAQ,sDAAsD;AAG9E,OAAO,MAAMC,kBAAkB,CAACC;IAC5B,OAAOH,QACH,IAAM;YACF;gBACII,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,CAACC,SAClB,CAAC,qBAAqB,EAAEA,OAAO,CAAC,CAAC;gBACrCC,QAAQ;oBACJ,IAAI,CAACV,WAAWI,UAAU;wBACtB,MAAM,IAAIO,MAAM;oBACpB;oBAEA,OAAOP;gBACX;gBACAQ,OAAO;YACX;YACA;gBACIP,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BE,QAAQ;oBACJ,MAAMR,QAAQ;wBAAEE;wBAASS,QAAQC,QAAQC,GAAG;oBAAG;gBACnD;gBACAH,OAAO;YACX;SACH,EACD,EAAE;AAEV,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../libs/cli/src/commands/TranspileCommand/fn/_tests/test-builtins/src/index.ts"],"sourcesContent":["const test = new Map();\nconsole.log(test);\n"],"names":["test","Map","console","log"],"rangeMappings":";","mappings":"AAAA,MAAMA,OAAO,IAAIC;AACjBC,QAAQC,GAAG,CAACH"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import { StatusMessage, StatusMessageProps } from '@inkjs/ui';\nimport { Text } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Spinner } from '@/cli/components/Spinner.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport interface ItemProps<TResult> {\n item: CheckListItem<TResult>;\n start: boolean;\n}\n\nexport const Item = <TResult,>({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n runner,\n onFinish,\n ready,\n },\n start,\n}: ItemProps<TResult>) => {\n const executed = useRef(false);\n const interval = useRef<NodeJS.Timeout | null>(null);\n const [dotCount, setDotCount] = useState(0);\n const [result, setResult] = useState<TResult | null>(null);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const hasResult = !failedReason && result !== null;\n const isRunning = !failedReason && !hasResult && start && ready !== false;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason) {\n process.exit();\n }\n }, [failedReason]);\n\n useEffect(() => {\n if (couldStartButNotReady) {\n interval.current = setInterval(() => {\n setDotCount((count) => (count + 1) % 4);\n }, 250);\n } else {\n if (interval.current) {\n clearInterval(interval.current);\n }\n }\n\n return () => {\n if (interval.current) {\n clearInterval(interval.current);\n }\n };\n }, [couldStartButNotReady]);\n\n useEffect(() => {\n if (!start || executed.current || ready === false) {\n return;\n }\n\n runner()\n .then((result) => {\n executed.current = true;\n\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResult(result);\n onFinish?.(result);\n })\n .catch((reason) => {\n
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import { StatusMessage, StatusMessageProps } from '@inkjs/ui';\nimport { Text } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Spinner } from '@/cli/components/Spinner.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport interface ItemProps<TResult> {\n item: CheckListItem<TResult>;\n start: boolean;\n}\n\nexport const Item = <TResult,>({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n runner,\n onFinish,\n ready,\n },\n start,\n}: ItemProps<TResult>) => {\n const executed = useRef(false);\n const interval = useRef<NodeJS.Timeout | null>(null);\n const [dotCount, setDotCount] = useState(0);\n const [result, setResult] = useState<TResult | null>(null);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const hasResult = !failedReason && result !== null;\n const isRunning = !failedReason && !hasResult && start && ready !== false;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason) {\n process.exit();\n }\n }, [failedReason]);\n\n useEffect(() => {\n if (couldStartButNotReady) {\n interval.current = setInterval(() => {\n setDotCount((count) => (count + 1) % 4);\n }, 250);\n } else {\n if (interval.current) {\n clearInterval(interval.current);\n }\n }\n\n return () => {\n if (interval.current) {\n clearInterval(interval.current);\n }\n };\n }, [couldStartButNotReady]);\n\n useEffect(() => {\n if (!start || executed.current || ready === false) {\n return;\n }\n\n runner()\n .then((result) => {\n executed.current = true;\n\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResult(result);\n onFinish?.(result);\n })\n .catch((reason) => {\n setfailedReason(reason.message);\n });\n }, [errorDescription, onFinish, runner, start]);\n\n let message = waitingDescription;\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (failedReason) {\n message = ` ${failedReason}`;\n variant = 'error';\n } else if (isRunning) {\n message = runningDescription;\n variant = 'warning';\n } else if (hasResult) {\n message = finishedDescription(result);\n variant = 'success';\n }\n\n if (isRunning) {\n return <Spinner label={message} />;\n }\n\n return (\n <StatusMessage variant={variant}>\n <Text\n bold={!isWaiting}\n color={\n isRunning\n ? 'yellow'\n : isWaiting\n ? 'gray'\n : failedReason\n ? 'red'\n : 'green'\n }\n >\n {message}{' '}\n {couldStartButNotReady &&\n `— not ready yet${'.'.repeat(dotCount)}`}\n </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Text","React","useEffect","useRef","useState","Spinner","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","runner","onFinish","ready","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","message","variant","label","bold","color","repeat"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAA4B,YAAY;AAC9D,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC3D,SAASC,OAAO,QAAQ,8BAA8B;AAQtD,OAAO,MAAMC,OAAO,CAAW,EAC3BC,MAAM,EACFC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACR,EACDC,KAAK,EACY;IACjB,MAAMC,WAAWb,OAAO;IACxB,MAAMc,WAAWd,OAA8B;IAC/C,MAAM,CAACe,UAAUC,YAAY,GAAGf,SAAS;IACzC,MAAM,CAACgB,QAAQC,UAAU,GAAGjB,SAAyB;IACrD,MAAM,CAACkB,cAAcC,gBAAgB,GAAGnB,SAAwB;IAChE,MAAMoB,YAAY,CAACF,gBAAgBF,WAAW;IAC9C,MAAMK,YAAY,CAACH,gBAAgB,CAACE,aAAaT,SAASD,UAAU;IACpE,MAAMY,YAAY,CAACJ,gBAAgB,CAACE,aAAc,CAAA,CAACT,SAAS,CAACD,KAAI;IACjE,MAAMa,wBACF,CAACL,gBAAgB,CAACE,aAAaT,SAASD,UAAU;IAEtDZ,UAAU;QACN,IAAIoB,cAAc;YACdM,QAAQC,IAAI;QAChB;IACJ,GAAG;QAACP;KAAa;IAEjBpB,UAAU;QACN,IAAIyB,uBAAuB;YACvBV,SAASa,OAAO,GAAGC,YAAY;gBAC3BZ,YAAY,CAACa,QAAU,AAACA,CAAAA,QAAQ,CAAA,IAAK;YACzC,GAAG;QACP,OAAO;YACH,IAAIf,SAASa,OAAO,EAAE;gBAClBG,cAAchB,SAASa,OAAO;YAClC;QACJ;QAEA,OAAO;YACH,IAAIb,SAASa,OAAO,EAAE;gBAClBG,cAAchB,SAASa,OAAO;YAClC;QACJ;IACJ,GAAG;QAACH;KAAsB;IAE1BzB,UAAU;QACN,IAAI,CAACa,SAASC,SAASc,OAAO,IAAIhB,UAAU,OAAO;YAC/C;QACJ;QAEAF,SACKsB,IAAI,CAAC,CAACd;YACHJ,SAASc,OAAO,GAAG;YAEnB,IAAIV,WAAW,OAAO;gBAClBG,gBAAgBb;gBAEhB;YACJ;YAEAW,UAAUD;YACVP,4BAAAA,SAAWO;QACf,GACCe,KAAK,CAAC,CAACC;YACJb,gBAAgBa,OAAOC,OAAO;QAClC;IACR,GAAG;QAAC3B;QAAkBG;QAAUD;QAAQG;KAAM;IAE9C,IAAIsB,UAAU5B;IACd,IAAI6B,UAAyC;IAE7C,IAAIhB,cAAc;QACde,UAAU,CAAC,CAAC,EAAEf,aAAa,CAAC;QAC5BgB,UAAU;IACd,OAAO,IAAIb,WAAW;QAClBY,UAAU7B;QACV8B,UAAU;IACd,OAAO,IAAId,WAAW;QAClBa,UAAU1B,oBAAoBS;QAC9BkB,UAAU;IACd;IAEA,IAAIb,WAAW;QACX,qBAAO,oBAACpB;YAAQkC,OAAOF;;IAC3B;IAEA,qBACI,oBAACtC;QAAcuC,SAASA;qBACpB,oBAACtC;QACGwC,MAAM,CAACd;QACPe,OACIhB,YACM,WACAC,YACA,SACAJ,eACA,QACA;OAGTe,SAAS,KACTV,yBACG,CAAC,eAAe,EAAE,IAAIe,MAAM,CAACxB,UAAU,CAAC;AAI5D,EAAE"}
|