crankscript 0.11.13 → 0.12.0
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/package.json +3 -3
- package/src/commands/CompileCommand/components/Compile.js +1 -1
- package/src/commands/CompileCommand/components/Compile.js.map +1 -1
- package/src/commands/GenerateTypes/components/GenerateTypes.js +6 -2
- package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +5 -2
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useFetchHtml.d.ts +1 -1
- package/src/commands/GenerateTypes/hooks/useFetchHtml.js +1 -1
- package/src/commands/GenerateTypes/hooks/useFetchHtml.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.d.ts +11 -0
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js +70 -0
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +11 -4
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +7 -37
- package/src/commands/GenerateTypes/hooks/useGetVersion.js +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +1 -1
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +1 -1
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -1
- package/src/commands/GenerateTypes/types.d.ts +12 -0
- package/src/commands/GenerateTypes/types.js +3 -0
- package/src/commands/GenerateTypes/types.js.map +1 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +7 -37
- package/src/commands/GenerateTypes/utils/createTypeProvider.js +51 -27
- package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
- package/src/commands/NewCommand/components/New.js +1 -1
- package/src/commands/NewCommand/components/New.js.map +1 -1
- package/src/commands/SimulatorCommand/components/Simulator.js +14 -4
- package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -1
- package/src/commands/TranspileCommand/TranspileCommand.d.ts +1 -0
- package/src/commands/TranspileCommand/TranspileCommand.js +10 -1
- package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
- package/src/commands/TranspileCommand/components/Transpile.d.ts +3 -2
- package/src/commands/TranspileCommand/components/Transpile.js +5 -3
- package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/transpile.d.ts +5 -1
- package/src/commands/TranspileCommand/fn/transpile.js +5 -4
- package/src/commands/TranspileCommand/fn/transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/validateEntryPoint.d.ts +5 -0
- package/src/commands/TranspileCommand/fn/validateEntryPoint.js +22 -0
- package/src/commands/TranspileCommand/fn/validateEntryPoint.js.map +1 -0
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +4 -1
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +6 -3
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -1
- package/src/commands/TranspileCommand/model/ValidatedEntryPoint.d.ts +11 -0
- package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js +3 -0
- package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js.map +1 -0
- package/src/components/CheckList/CheckList.d.ts +4 -5
- package/src/components/CheckList/CheckList.js +6 -1
- package/src/components/CheckList/CheckList.js.map +1 -1
- package/src/components/CheckList/Item.d.ts +1 -1
- package/src/components/CheckList/Item.js +24 -6
- package/src/components/CheckList/Item.js.map +1 -1
- package/src/types.d.ts +20 -18
- package/src/types.js.map +1 -1
@@ -74,7 +74,8 @@ export const createTypeProvider = (version)=>{
|
|
74
74
|
const details = {
|
75
75
|
signature: func.signature,
|
76
76
|
parameters: func.parameters.map((p)=>({
|
77
|
-
|
77
|
+
kind: StructureKind.Parameter,
|
78
|
+
name: kebabToCamelCase(p.name),
|
78
79
|
type: 'any'
|
79
80
|
})),
|
80
81
|
returnType: 'any'
|
@@ -99,49 +100,72 @@ export const createTypeProvider = (version)=>{
|
|
99
100
|
return returnType;
|
100
101
|
};
|
101
102
|
const getParameterDetails = (func, parameter)=>{
|
102
|
-
|
103
|
-
const
|
103
|
+
var _details_parameters;
|
104
|
+
const details = getFunctionDetails(func);
|
105
|
+
const param = (_details_parameters = details.parameters) == null ? void 0 : _details_parameters.find((p)=>p.name === parameter);
|
104
106
|
if (!param) {
|
105
107
|
return {
|
106
|
-
|
108
|
+
kind: StructureKind.Parameter,
|
109
|
+
name: kebabToCamelCase(parameter),
|
107
110
|
type: 'any'
|
108
111
|
};
|
109
112
|
}
|
110
|
-
return param
|
113
|
+
return _extends({}, param, {
|
114
|
+
name: kebabToCamelCase(param.name)
|
115
|
+
});
|
111
116
|
};
|
112
117
|
const getParameters = (func)=>{
|
113
|
-
const
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
name: kebabToCamelCase(parameter.name),
|
119
|
-
type: parameter.type
|
120
|
-
}, (_parameter_overrideOptions = parameter.overrideOptions) != null ? _parameter_overrideOptions : {});
|
121
|
-
};
|
122
|
-
if (overrideParameters) {
|
123
|
-
return parameters.map((details)=>{
|
124
|
-
return getParameterFromDetails(details);
|
125
|
-
});
|
118
|
+
const details = getFunctionDetails(func);
|
119
|
+
if (details.overrideParameters && details.parameters) {
|
120
|
+
return details.parameters.map((param)=>_extends({}, param, {
|
121
|
+
name: kebabToCamelCase(param.name)
|
122
|
+
}));
|
126
123
|
}
|
127
124
|
return func.parameters.map((parameter)=>{
|
128
125
|
const details = getParameterDetails(func, parameter.name);
|
129
|
-
return _extends({
|
126
|
+
return _extends({}, details, {
|
127
|
+
name: kebabToCamelCase(details.name),
|
130
128
|
hasQuestionToken: !parameter.required
|
131
|
-
}
|
129
|
+
});
|
132
130
|
});
|
133
131
|
};
|
134
132
|
const getFunctionOverrideOptions = (func)=>{
|
135
|
-
|
136
|
-
const options =
|
137
|
-
if (
|
138
|
-
|
139
|
-
|
133
|
+
const details = getFunctionDetails(func);
|
134
|
+
const options = {};
|
135
|
+
if (details.kind) {
|
136
|
+
options.kind = details.kind;
|
137
|
+
}
|
138
|
+
if (details.typeParameters) {
|
139
|
+
options.typeParameters = details.typeParameters;
|
140
|
+
}
|
141
|
+
if ('overloads' in details && Array.isArray(details.overloads)) {
|
142
|
+
if (details.kind === StructureKind.Method) {
|
143
|
+
options.overloads = details.overloads.map((overload)=>{
|
144
|
+
var _overload_parameters;
|
145
|
+
return _extends({}, overload, {
|
146
|
+
typeParameters: overload.typeParameters,
|
147
|
+
parameters: (_overload_parameters = overload.parameters) == null ? void 0 : _overload_parameters.map((param)=>_extends({}, param, {
|
148
|
+
name: kebabToCamelCase(param.name)
|
149
|
+
})),
|
140
150
|
docs: [
|
141
151
|
func.docs
|
142
152
|
]
|
143
|
-
})
|
144
|
-
|
153
|
+
});
|
154
|
+
});
|
155
|
+
} else {
|
156
|
+
options.overloads = details.overloads.map((overload)=>{
|
157
|
+
var _overload_parameters;
|
158
|
+
return _extends({}, overload, {
|
159
|
+
typeParameters: overload.typeParameters,
|
160
|
+
parameters: (_overload_parameters = overload.parameters) == null ? void 0 : _overload_parameters.map((param)=>_extends({}, param, {
|
161
|
+
name: kebabToCamelCase(param.name)
|
162
|
+
})),
|
163
|
+
docs: [
|
164
|
+
func.docs
|
165
|
+
]
|
166
|
+
});
|
167
|
+
});
|
168
|
+
}
|
145
169
|
}
|
146
170
|
return options;
|
147
171
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\n VariableDeclarationStructure,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n ParameterDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n constants: {},\n statements: [],\n classes: {},\n properties: {},\n dynamicProperties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n constants: fallbackProvider.constants,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n dynamicProperties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getDynamicProperties = (namespace: string) => {\n return (\n provider.dynamicProperties?.[namespace] ??\n fallbackProvider.dynamicProperties?.[namespace] ??\n []\n );\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map(p => ({\n name: p.name,\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string,\n ) => {\n const { parameters } = getFunctionDetails(func);\n const param = parameters.find(p => p.name === parameter);\n\n if (!param) {\n return {\n name: parameter,\n type: 'any',\n } satisfies ParameterDetails;\n }\n\n return param;\n };\n\n const getParameters = (\n func: FunctionDescription,\n ): FunctionDeclarationStructure['parameters'] => {\n const { overrideParameters = false, parameters } =\n getFunctionDetails(func);\n const getParameterFromDetails = (parameter: ParameterDetails) => {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter.name),\n type: parameter.type,\n ...(parameter.overrideOptions ?? {}),\n } satisfies ParameterDeclarationStructure;\n };\n\n if (overrideParameters) {\n return parameters.map(details => {\n return getParameterFromDetails(details);\n });\n }\n\n return func.parameters.map(parameter => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n hasQuestionToken: !parameter.required,\n ...getParameterFromDetails(details),\n } satisfies ParameterDeclarationStructure;\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n const options = getFunctionDetails(func).overrideOptions ?? {};\n\n if ('overloads' in options && Array.isArray(options.overloads)) {\n return {\n overloads: options.overloads.map(overload => ({\n ...overload,\n docs: [func.docs],\n })),\n };\n }\n\n return options;\n };\n\n const getConstants = (fullNamespace: string) => {\n return (provider.constants[fullNamespace] ?? []).map(constant => {\n return {\n kind: StructureKind.VariableDeclaration,\n name: typeof constant === 'string' ? constant : constant.name,\n type: typeof constant === 'string' ? 'number' : constant.type,\n } satisfies VariableDeclarationStructure;\n });\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getDynamicProperties,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n getConstants,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","constants","statements","classes","properties","dynamicProperties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getDynamicProperties","namespace","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","options","Array","isArray","overloads","overload","docs","getConstants","fullNamespace","constant","VariableDeclaration","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,UAAU,EAAEC,aAAa,QAAQ,UAAU;AACpD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAGIC,aAAa,QAEV,WAAW;AAClB,SAASC,UAAU,QAAQ,qBAAqB;AAUhD,SAASC,iBAAiBC,GAAW;IACjC,O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ACHC,MAAM;4BAAC5B,KAAK4B,IAAI;yBAAC;;YAEzB;QACJ;QAEA,OAAOL;IACX;IAEA,MAAMM,eAAe,CAACC;YACVjD;QAAR,OAAO,AAACA,CAAAA,CAAAA,oCAAAA,SAASN,SAAS,CAACuD,cAAc,YAAjCjD,oCAAqC,EAAE,AAAD,EAAGsB,GAAG,CAAC4B,CAAAA;YACjD,OAAO;gBACHd,MAAMzD,cAAcwE,mBAAmB;gBACvC3B,MAAM,OAAO0B,aAAa,WAAWA,WAAWA,SAAS1B,IAAI;gBAC7DV,MAAM,OAAOoC,aAAa,WAAW,WAAWA,SAASpC,IAAI;YACjE;QACJ;IACJ;IAEA,MAAMsC,OAAO;QACT,MAAMC,WAAW9D,KAAK+D,SAAS,CAACtD,UAAU,MAAM,KAAK;QAErDvB,cAAcY,MAAMgE,UAAU;IAClC;IAEA,OAAO;QACH3B;QACAC;QACAvB;QACAE;QACAU;QACAY;QACAC;QACAI;QACAQ;QACAO;QACAI;IACJ;AACJ,EAAE"}
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n ParameterDeclarationStructure,\n StructureKind,\n VariableDeclarationStructure,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n FunctionDeclarationOverloadStructure,\n MethodDeclarationOverloadStructure,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n constants: {},\n statements: [],\n classes: {},\n properties: {},\n dynamicProperties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n constants: fallbackProvider.constants,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n dynamicProperties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getDynamicProperties = (namespace: string) => {\n return (\n provider.dynamicProperties?.[namespace] ??\n fallbackProvider.dynamicProperties?.[namespace] ??\n []\n );\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map(p => ({\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(p.name),\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string,\n ): ParameterDeclarationStructure => {\n const details = getFunctionDetails(func);\n const param = details.parameters?.find(p => p.name === parameter);\n\n if (!param) {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter),\n type: 'any',\n };\n }\n\n return {\n ...param,\n name: kebabToCamelCase(param.name),\n };\n };\n\n const getParameters = (\n func: FunctionDescription,\n ): ParameterDeclarationStructure[] => {\n const details = getFunctionDetails(func);\n\n if (details.overrideParameters && details.parameters) {\n return details.parameters.map(param => ({\n ...param,\n name: kebabToCamelCase(param.name),\n }));\n }\n\n return func.parameters.map(parameter => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n ...details,\n name: kebabToCamelCase(details.name),\n hasQuestionToken: !parameter.required,\n };\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n const details = getFunctionDetails(func);\n const options: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n > = {};\n\n if (details.kind) {\n options.kind = details.kind;\n }\n\n if (details.typeParameters) {\n options.typeParameters = details.typeParameters;\n }\n\n if ('overloads' in details && Array.isArray(details.overloads)) {\n if (details.kind === StructureKind.Method) {\n options.overloads = details.overloads.map(overload => ({\n ...(overload as MethodDeclarationOverloadStructure),\n typeParameters: overload.typeParameters,\n parameters: overload.parameters?.map(param => ({\n ...param,\n name: kebabToCamelCase(param.name),\n })),\n docs: [func.docs],\n }));\n } else {\n options.overloads = details.overloads.map(overload => ({\n ...(overload as FunctionDeclarationOverloadStructure),\n typeParameters: overload.typeParameters,\n parameters: overload.parameters?.map(param => ({\n ...param,\n name: kebabToCamelCase(param.name),\n })),\n docs: [func.docs],\n }));\n }\n }\n\n return options;\n };\n\n const getConstants = (fullNamespace: string) => {\n return (provider.constants[fullNamespace] ?? []).map(constant => {\n return {\n kind: StructureKind.VariableDeclaration,\n name: typeof constant === 'string' ? constant : constant.name,\n type: typeof constant === 'string' ? 'number' : constant.type,\n } satisfies VariableDeclarationStructure;\n });\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getDynamicProperties,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n getConstants,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","constants","statements","classes","properties","dynamicProperties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getDynamicProperties","namespace","getFunctionDetails","func","fn","parameters","map","p","kind","Parameter","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","hasQuestionToken","required","getFunctionOverrideOptions","options","typeParameters","Array","isArray","overloads","Method","overload","docs","getConstants","fullNamespace","constant","VariableDeclaration","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,UAAU,EAAEC,aAAa,QAAQ,UAAU;AACpD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAEIC,aAAa,QAMV,WAAW;AAClB,SAASC,UAAU,QAAQ,qBAAqB;AAShD,SAASC,iBAAiBC,G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;QAErDvB,cAAcY,MAAMgE,UAAU;IAClC;IAEA,OAAO;QACHzB;QACAC;QACAzB;QACAE;QACAU;QACAc;QACAC;QACAI;QACAI;QACAS;QACAI;IACJ;AACJ,EAAE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/NewCommand/components/New.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport tiged from 'tiged';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, TemplateName } from '@/cli/types.js';\n\ninterface Props {\n name: string;\n template: TemplateName;\n}\n\nexport const New = ({ name, template }: Props) => {\n const items = useMemo(() => {\n return [\n {\n ready: true,\n runner: async () => {\n const task = tiged(`crankscript/template-${template}`);\n\n await task.clone(name);\n },\n waitingDescription: `About to create a new project named \"${name}\" using the \"${template}\" template`,\n runningDescription: `Creating a new project named \"${name}\" using the \"${template}\" template`,\n finishedDescription: () =>\n `Created a new project named \"${name}\" using the \"${template}\" template`,\n errorDescription: `Failed to create project named \"${name}\" using the \"${template}\" template`,\n },\n ];\n }, []) satisfies CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["React","useMemo","tiged","CheckList","New","name","template","items","ready","runner","task","clone","waitingDescription","runningDescription","finishedDescription","errorDescription","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,SAAS,QAAQ,sCAAsC;AAQhE,OAAO,MAAMC,MAAM,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAS;IACzC,MAAMC,QAAQN,QAAQ;QAClB,OAAO;YACH;gBACIO,OAAO;gBACPC,QAAQ;oBACJ,MAAMC,OAAOR,MAAM,CAAC,qBAAqB,EAAEI,SAAS,CAAC;oBAErD,MAAMI,KAAKC,KAAK,CAACN;gBACrB;gBACAO,oBAAoB,CAAC,qCAAqC,EAAEP,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBACpGO,oBAAoB,CAAC,8BAA8B,EAAER,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC7FQ,qBAAqB,IACjB,CAAC,6BAA6B,EAAET,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC5ES,kBAAkB,CAAC,gCAAgC,EAAEV,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;YACjG;SACH;IACL,GAAG,EAAE;IAEL,qBAAO,oBAACH;QAAUI,OAAOA;QAAOS,
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/NewCommand/components/New.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport tiged from 'tiged';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, TemplateName } from '@/cli/types.js';\n\ninterface Props {\n name: string;\n template: TemplateName;\n}\n\nexport const New = ({ name, template }: Props) => {\n const items = useMemo(() => {\n return [\n {\n ready: true,\n runner: async () => {\n const task = tiged(`crankscript/template-${template}`);\n\n await task.clone(name);\n },\n waitingDescription: `About to create a new project named \"${name}\" using the \"${template}\" template`,\n runningDescription: `Creating a new project named \"${name}\" using the \"${template}\" template`,\n finishedDescription: () =>\n `Created a new project named \"${name}\" using the \"${template}\" template`,\n errorDescription: `Failed to create project named \"${name}\" using the \"${template}\" template`,\n },\n ];\n }, []) satisfies CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["React","useMemo","tiged","CheckList","New","name","template","items","ready","runner","task","clone","waitingDescription","runningDescription","finishedDescription","errorDescription","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,SAAS,QAAQ,sCAAsC;AAQhE,OAAO,MAAMC,MAAM,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAS;IACzC,MAAMC,QAAQN,QAAQ;QAClB,OAAO;YACH;gBACIO,OAAO;gBACPC,QAAQ;oBACJ,MAAMC,OAAOR,MAAM,CAAC,qBAAqB,EAAEI,SAAS,CAAC;oBAErD,MAAMI,KAAKC,KAAK,CAACN;gBACrB;gBACAO,oBAAoB,CAAC,qCAAqC,EAAEP,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBACpGO,oBAAoB,CAAC,8BAA8B,EAAER,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC7FQ,qBAAqB,IACjB,CAAC,6BAA6B,EAAET,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC5ES,kBAAkB,CAAC,gCAAgC,EAAEV,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;YACjG;SACH;IACL,GAAG,EAAE;IAEL,qBAAO,oBAACH;QAAUI,OAAOA;QAAOS,UAAU,IAAMC,QAAQC,IAAI;;AAChE,EAAE"}
|
@@ -6,6 +6,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
6
6
|
import { getPdcPathFromEnvironment } from '../../../commands/CompileCommand/fn/getPdcPathFromEnvironment.js';
|
7
7
|
import { useCompileTasks } from '../../../commands/CompileCommand/hooks/useCompileTasks.js';
|
8
8
|
import { getSimulatorPathFromEnvironment } from '../../../commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';
|
9
|
+
import { validateEntryPoint } from '../../../commands/TranspileCommand/fn/validateEntryPoint.js';
|
9
10
|
import { useTranspileTasks } from '../../../commands/TranspileCommand/hooks/useTranspileTasks.js';
|
10
11
|
import { CheckList } from '../../../components/CheckList/index.js';
|
11
12
|
import { isMac, isWindows } from '../../../utils/platform.js';
|
@@ -14,9 +15,15 @@ export const Simulator = ({ environment, path, watch = false, recompileOnly = fa
|
|
14
15
|
const [isWatching, setIsWatching] = useState(false);
|
15
16
|
const [hasChanged, setHasChanged] = useState(false);
|
16
17
|
const [hasChangedMessage, setHasChangedMessage] = useState(false);
|
17
|
-
const transpileTasks = useTranspileTasks(
|
18
|
+
const transpileTasks = useTranspileTasks({
|
19
|
+
entryPoint: validateEntryPoint({
|
20
|
+
projectPath: path,
|
21
|
+
entryFile: join(path, 'src', 'index.ts')
|
22
|
+
})
|
23
|
+
});
|
18
24
|
const compileTasks = useCompileTasks(getPdcPathFromEnvironment(environment));
|
19
25
|
const didRun = useRef(false);
|
26
|
+
const [hasFailure, setHasFailure] = useState(false);
|
20
27
|
useEffect(()=>{
|
21
28
|
if (hasChanged) {
|
22
29
|
setHasChanged(false);
|
@@ -25,7 +32,8 @@ export const Simulator = ({ environment, path, watch = false, recompileOnly = fa
|
|
25
32
|
hasChanged,
|
26
33
|
setHasChanged
|
27
34
|
]);
|
28
|
-
const handleFinish = useCallback(()=>{
|
35
|
+
const handleFinish = useCallback((hasFailure)=>{
|
36
|
+
setHasFailure(hasFailure);
|
29
37
|
if (didRun.current && recompileOnly) {
|
30
38
|
return;
|
31
39
|
}
|
@@ -75,9 +83,11 @@ export const Simulator = ({ environment, path, watch = false, recompileOnly = fa
|
|
75
83
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, !hasChanged && /*#__PURE__*/ React.createElement(CheckList, {
|
76
84
|
items: tasks,
|
77
85
|
onFinish: handleFinish
|
78
|
-
}), isWatching && !hasChangedMessage && /*#__PURE__*/ React.createElement(StatusMessage, {
|
86
|
+
}), isWatching && !hasChangedMessage && /*#__PURE__*/ React.createElement(React.Fragment, null, hasFailure && /*#__PURE__*/ React.createElement(StatusMessage, {
|
87
|
+
variant: "warning"
|
88
|
+
}, "Some steps failed."), /*#__PURE__*/ React.createElement(StatusMessage, {
|
79
89
|
variant: "info"
|
80
|
-
}, "Watching for changes..."), hasChangedMessage && /*#__PURE__*/ React.createElement(StatusMessage, {
|
90
|
+
}, "Watching for changes...")), hasChangedMessage && /*#__PURE__*/ React.createElement(StatusMessage, {
|
81
91
|
variant: "info"
|
82
92
|
}, "Change detected"));
|
83
93
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import { FSWatcher, watch as watchDir } from 'node:fs';\nimport { join } from 'node:path';\nimport { StatusMessage } from '@inkjs/ui';\nimport open from 'open';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { getSimulatorPathFromEnvironment } from '@/cli/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { isMac, isWindows } from '@/cli/utils/platform.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n recompileOnly?: boolean;\n background?: boolean;\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = false,\n recompileOnly = false,\n background = false,\n}: Props) => {\n const watcher = useRef<FSWatcher | null>(null);\n const [isWatching, setIsWatching] = useState(false);\n const [hasChanged, setHasChanged] = useState(false);\n const [hasChangedMessage, setHasChangedMessage] = useState(false);\n const transpileTasks = useTranspileTasks(path);\n const compileTasks = useCompileTasks(\n getPdcPathFromEnvironment(environment),\n );\n const didRun = useRef(false);\n\n useEffect(() => {\n if (hasChanged) {\n setHasChanged(false);\n }\n }, [hasChanged, setHasChanged]);\n\n const handleFinish = useCallback((
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import { FSWatcher, watch as watchDir } from 'node:fs';\nimport { join } from 'node:path';\nimport { StatusMessage } from '@inkjs/ui';\nimport open from 'open';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { getSimulatorPathFromEnvironment } from '@/cli/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';\nimport { validateEntryPoint } from '@/cli/commands/TranspileCommand/fn/validateEntryPoint.js';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList, CheckListProps } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { isMac, isWindows } from '@/cli/utils/platform.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n recompileOnly?: boolean;\n background?: boolean;\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = false,\n recompileOnly = false,\n background = false,\n}: Props) => {\n const watcher = useRef<FSWatcher | null>(null);\n const [isWatching, setIsWatching] = useState(false);\n const [hasChanged, setHasChanged] = useState(false);\n const [hasChangedMessage, setHasChangedMessage] = useState(false);\n const transpileTasks = useTranspileTasks({\n entryPoint: validateEntryPoint({\n projectPath: path,\n entryFile: join(path, 'src', 'index.ts'),\n }),\n });\n const compileTasks = useCompileTasks(\n getPdcPathFromEnvironment(environment),\n );\n const didRun = useRef(false);\n const [hasFailure, setHasFailure] = useState(false);\n\n useEffect(() => {\n if (hasChanged) {\n setHasChanged(false);\n }\n }, [hasChanged, setHasChanged]);\n\n const handleFinish = useCallback(\n (hasFailure => {\n setHasFailure(hasFailure);\n if (didRun.current && recompileOnly) {\n return;\n }\n\n didRun.current = true;\n\n open('Game.pdx', {\n background,\n app: isMac\n ? undefined\n : {\n name: getSimulatorPathFromEnvironment(environment),\n },\n }).then(() => {\n if (!watch) {\n if (!isWindows) {\n process.exit();\n }\n\n // Wait for the simulator to start\n // See https://github.com/sindresorhus/open/issues/298\n setTimeout(process.exit, 1000);\n } else {\n setHasChangedMessage(false);\n\n if (watcher.current) {\n watcher.current.close();\n }\n\n setIsWatching(true);\n\n watcher.current = watchDir(\n join(path, 'src'),\n { recursive: true },\n () => {\n setHasChanged(true);\n setHasChangedMessage(true);\n setIsWatching(false);\n },\n );\n }\n });\n }) satisfies CheckListProps['onFinish'],\n [watch, setHasChanged, setIsWatching],\n );\n\n const tasks = useMemo(() => {\n return [...transpileTasks, ...compileTasks];\n }, [transpileTasks, compileTasks]);\n\n return (\n <>\n {!hasChanged && <CheckList items={tasks} onFinish={handleFinish} />}\n {isWatching && !hasChangedMessage && (\n <>\n {hasFailure && (\n <StatusMessage variant=\"warning\">\n Some steps failed.\n </StatusMessage>\n )}\n <StatusMessage variant=\"info\">\n Watching for changes...\n </StatusMessage>\n </>\n )}\n {hasChangedMessage && (\n <StatusMessage variant=\"info\">Change detected</StatusMessage>\n )}\n </>\n );\n};\n"],"names":["watch","watchDir","join","StatusMessage","open","React","useCallback","useEffect","useMemo","useRef","useState","getPdcPathFromEnvironment","useCompileTasks","getSimulatorPathFromEnvironment","validateEntryPoint","useTranspileTasks","CheckList","isMac","isWindows","Simulator","environment","path","recompileOnly","background","watcher","isWatching","setIsWatching","hasChanged","setHasChanged","hasChangedMessage","setHasChangedMessage","transpileTasks","entryPoint","projectPath","entryFile","compileTasks","didRun","hasFailure","setHasFailure","handleFinish","current","app","undefined","name","then","process","exit","setTimeout","close","recursive","tasks","items","onFinish","variant"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAoBA,SAASC,QAAQ,QAAQ,UAAU;AACvD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,aAAa,QAAQ,YAAY;AAC1C,OAAOC,UAAU,OAAO;AACxB,OAAOC,SACHC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,QA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ClC,sDAAsD;gBACtDC,WAAWF,QAAQC,IAAI,EAAE;YAC7B,OAAO;gBACHhB,qBAAqB;gBAErB,IAAIN,QAAQgB,OAAO,EAAE;oBACjBhB,QAAQgB,OAAO,CAACQ,KAAK;gBACzB;gBAEAtB,cAAc;gBAEdF,QAAQgB,OAAO,GAAGvC,SACdC,KAAKmB,MAAM,QACX;oBAAE4B,WAAW;gBAAK,GAClB;oBACIrB,cAAc;oBACdE,qBAAqB;oBACrBJ,cAAc;gBAClB;YAER;QACJ;IACJ,GACA;QAAC1B;QAAO4B;QAAeF;KAAc;IAGzC,MAAMwB,QAAQ1C,QAAQ;QAClB,OAAO;eAAIuB;eAAmBI;SAAa;IAC/C,GAAG;QAACJ;QAAgBI;KAAa;IAEjC,qBACI,0CACK,CAACR,4BAAc,oBAACX;QAAUmC,OAAOD;QAAOE,UAAUb;QAClDd,cAAc,CAACI,mCACZ,0CACKQ,4BACG,oBAAClC;QAAckD,SAAQ;OAAU,qCAIrC,oBAAClD;QAAckD,SAAQ;OAAO,6BAKrCxB,mCACG,oBAAC1B;QAAckD,SAAQ;OAAO;AAI9C,EAAE"}
|
@@ -4,18 +4,27 @@ import React from 'react';
|
|
4
4
|
import * as t from 'typanion';
|
5
5
|
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
6
6
|
import { Transpile } from '../../commands/TranspileCommand/components/Transpile.js';
|
7
|
+
import { validateEntryPoint } from '../../commands/TranspileCommand/fn/validateEntryPoint.js';
|
7
8
|
export const projectPathOption = Option.String('-p,--path', process.cwd(), {
|
8
9
|
description: `Where to find the project. Defaults to the current working directory ("${process.cwd()}")`,
|
9
10
|
validator: t.isString()
|
10
11
|
});
|
11
12
|
export class TranspileCommand extends RenderableCommand {
|
12
13
|
render() {
|
14
|
+
const validatedEntryPoint = validateEntryPoint({
|
15
|
+
projectPath: this.projectPath,
|
16
|
+
entryFile: this.entryFile
|
17
|
+
});
|
13
18
|
return /*#__PURE__*/ React.createElement(Transpile, {
|
14
|
-
|
19
|
+
entryPoint: validatedEntryPoint
|
15
20
|
});
|
16
21
|
}
|
17
22
|
constructor(...args){
|
18
23
|
super(...args);
|
24
|
+
this.entryFile = Option.String('-f,--file', 'src/index.ts', {
|
25
|
+
description: 'The entry point to transpile',
|
26
|
+
validator: t.isString()
|
27
|
+
});
|
19
28
|
this.projectPath = projectPathOption;
|
20
29
|
}
|
21
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { Transpile } from '@/cli/commands/TranspileCommand/components/Transpile.js';\n\nexport const projectPathOption = Option.String('-p,--path', process.cwd(), {\n description: `Where to find the project. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n});\n\nexport class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n static override usage = Command.Usage({\n description: 'Transpile TypeScript files to Lua',\n });\n\n projectPath = projectPathOption;\n\n override render() {\n
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { Transpile } from '@/cli/commands/TranspileCommand/components/Transpile.js';\nimport { validateEntryPoint } from '@/cli/commands/TranspileCommand/fn/validateEntryPoint.js';\n\nexport const projectPathOption = Option.String('-p,--path', process.cwd(), {\n description: `Where to find the project. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n});\n\nexport class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n static override usage = Command.Usage({\n description: 'Transpile TypeScript files to Lua',\n });\n\n entryFile = Option.String('-f,--file', 'src/index.ts', {\n description: 'The entry point to transpile',\n validator: t.isString(),\n });\n\n projectPath = projectPathOption;\n\n override render() {\n const validatedEntryPoint = validateEntryPoint({\n projectPath: this.projectPath,\n entryFile: this.entryFile,\n });\n\n return <Transpile entryPoint={validatedEntryPoint} />;\n }\n}\n"],"names":["process","Command","Option","React","t","RenderableCommand","Transpile","validateEntryPoint","projectPathOption","String","cwd","description","validator","isString","TranspileCommand","render","validatedEntryPoint","projectPath","entryFile","entryPoint","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,SAASC,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,SAAS,QAAQ,0DAA0D;AACpF,SAASC,kBAAkB,QAAQ,2DAA2D;AAE9F,OAAO,MAAMC,oBAAoBN,OAAOO,MAAM,CAAC,aAAaT,QAAQU,GAAG,IAAI;IACvEC,aAAa,CAAC,uEAAuE,EAAEX,QAAQU,GAAG,GAAG,EAAE,CAAC;IACxGE,WAAWR,EAAES,QAAQ;AACzB,GAAG;AAEH,OAAO,MAAMC,yBAAyBT;IAczBU,SAAS;QACd,MAAMC,sBAAsBT,mBAAmB;YAC3CU,aAAa,IAAI,CAACA,WAAW;YAC7BC,WAAW,IAAI,CAACA,SAAS;QAC7B;QAEA,qBAAO,oBAACZ;YAAUa,YAAYH;;IAClC;;;aAdAE,YAAYhB,OAAOO,MAAM,CAAC,aAAa,gBAAgB;YACnDE,aAAa;YACbC,WAAWR,EAAES,QAAQ;QACzB;aAEAI,cAAcT;;AAUlB;AAtBaM,iBACOM,QAAQ;IAAC;QAAC;KAAY;CAAC;AAD9BN,iBAGOO,QAAQpB,QAAQqB,KAAK,CAAC;IAClCX,aAAa;AACjB"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { ValidatedEntryPoint } from '../../../commands/TranspileCommand/model/ValidatedEntryPoint.js';
|
2
3
|
interface Props {
|
3
|
-
|
4
|
+
entryPoint: ValidatedEntryPoint;
|
4
5
|
}
|
5
|
-
export declare const Transpile: ({
|
6
|
+
export declare const Transpile: ({ entryPoint }: Props) => React.JSX.Element;
|
6
7
|
export {};
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useTranspileTasks } from '../../../commands/TranspileCommand/hooks/useTranspileTasks.js';
|
3
3
|
import { CheckList } from '../../../components/CheckList/index.js';
|
4
|
-
export const Transpile = ({
|
5
|
-
const items = useTranspileTasks(
|
4
|
+
export const Transpile = ({ entryPoint })=>{
|
5
|
+
const items = useTranspileTasks({
|
6
|
+
entryPoint
|
7
|
+
});
|
6
8
|
return /*#__PURE__*/ React.createElement(CheckList, {
|
7
9
|
items: items,
|
8
|
-
onFinish: process.exit
|
10
|
+
onFinish: ()=>process.exit
|
9
11
|
});
|
10
12
|
};
|
11
13
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/components/Transpile.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/components/Transpile.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { ValidatedEntryPoint } from '@/cli/commands/TranspileCommand/model/ValidatedEntryPoint.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\ninterface Props {\n entryPoint: ValidatedEntryPoint;\n}\n\nexport const Transpile = ({ entryPoint }: Props) => {\n const items = useTranspileTasks({\n entryPoint,\n });\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["React","useTranspileTasks","CheckList","Transpile","entryPoint","items","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ,6DAA6D;AAE/F,SAASC,SAAS,QAAQ,sCAAsC;AAKhE,OAAO,MAAMC,YAAY,CAAC,EAAEC,UAAU,EAAS;IAC3C,MAAMC,QAAQJ,kBAAkB;QAC5BG;IACJ;IAEA,qBAAO,oBAACF;QAAUG,OAAOA;QAAOC,UAAU,IAAMC,QAAQC,IAAI;;AAChE,EAAE"}
|
@@ -1,2 +1,6 @@
|
|
1
1
|
import * as tstl from 'typescript-to-lua';
|
2
|
-
|
2
|
+
import { ValidatedEntryPoint } from '../model/ValidatedEntryPoint.js';
|
3
|
+
export declare const transpile: ({ entryPoint, buildMode, }: {
|
4
|
+
entryPoint: ValidatedEntryPoint;
|
5
|
+
buildMode?: tstl.BuildMode;
|
6
|
+
}) => tstl.EmitResult;
|
@@ -2,12 +2,13 @@ import { join } from 'node:path';
|
|
2
2
|
import * as tstl from 'typescript-to-lua';
|
3
3
|
import { LuaTarget } from 'typescript-to-lua';
|
4
4
|
import { RootFolder } from '../../../constants.js';
|
5
|
-
export const transpile = (
|
6
|
-
return tstl.transpileProject(join(
|
5
|
+
export const transpile = ({ entryPoint, buildMode = tstl.BuildMode.Default })=>{
|
6
|
+
return tstl.transpileProject(join(entryPoint.projectPath, 'tsconfig.json'), {
|
7
|
+
buildMode,
|
7
8
|
luaTarget: LuaTarget.Lua54,
|
8
|
-
outDir: join(
|
9
|
+
outDir: join(entryPoint.projectPath, 'Source'),
|
9
10
|
luaBundle: 'main.lua',
|
10
|
-
luaBundleEntry: join(
|
11
|
+
luaBundleEntry: join(entryPoint.entryFile),
|
11
12
|
luaPlugins: [
|
12
13
|
{
|
13
14
|
name: join(RootFolder, 'assets', 'index.js')
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/transpile.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as tstl from 'typescript-to-lua';\nimport { LuaTarget } from 'typescript-to-lua';\nimport { RootFolder } from '@/cli/constants.js';\n\nexport const transpile = (
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/transpile.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as tstl from 'typescript-to-lua';\nimport { LuaTarget } from 'typescript-to-lua';\nimport { RootFolder } from '@/cli/constants.js';\nimport { ValidatedEntryPoint } from '../model/ValidatedEntryPoint.js';\n\nexport const transpile = ({\n entryPoint,\n buildMode = tstl.BuildMode.Default,\n}: {\n entryPoint: ValidatedEntryPoint;\n buildMode?: tstl.BuildMode;\n}) => {\n return tstl.transpileProject(\n join(entryPoint.projectPath, 'tsconfig.json'),\n {\n buildMode,\n luaTarget: LuaTarget.Lua54,\n outDir: join(entryPoint.projectPath, 'Source'),\n luaBundle: 'main.lua',\n luaBundleEntry: join(entryPoint.entryFile),\n luaPlugins: [\n {\n name: join(RootFolder, 'assets', 'index.js'),\n },\n ],\n },\n );\n};\n"],"names":["join","tstl","LuaTarget","RootFolder","transpile","entryPoint","buildMode","BuildMode","Default","transpileProject","projectPath","luaTarget","Lua54","outDir","luaBundle","luaBundleEntry","entryFile","luaPlugins","name"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,YAAYC,UAAU,oBAAoB;AAC1C,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,UAAU,QAAQ,qBAAqB;AAGhD,OAAO,MAAMC,YAAY,CAAC,EACtBC,UAAU,EACVC,YAAYL,KAAKM,SAAS,CAACC,OAAO,EAIrC;IACG,OAAOP,KAAKQ,gBAAgB,CACxBT,KAAKK,WAAWK,WAAW,EAAE,kBAC7B;QACIJ;QACAK,WAAWT,UAAUU,KAAK;QAC1BC,QAAQb,KAAKK,WAAWK,WAAW,EAAE;QACrCI,WAAW;QACXC,gBAAgBf,KAAKK,WAAWW,SAAS;QACzCC,YAAY;YACR;gBACIC,MAAMlB,KAAKG,YAAY,UAAU;YACrC;SACH;IACL;AAER,EAAE"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
2
|
+
import { resolve } from 'node:path';
|
3
|
+
export const validateEntryPoint = (input)=>{
|
4
|
+
const resolvedPath = resolve(input.projectPath);
|
5
|
+
const resolvedEntry = resolve(input.entryFile);
|
6
|
+
if (!existsSync(resolvedPath) || !statSync(resolvedPath).isDirectory()) {
|
7
|
+
throw new Error(`"${resolvedPath}" is not a valid project path`);
|
8
|
+
}
|
9
|
+
if (!existsSync(resolvedEntry) || !statSync(resolvedEntry).isFile()) {
|
10
|
+
throw new Error(`"${resolvedEntry}" is not a valid entry file`);
|
11
|
+
}
|
12
|
+
if (!resolvedEntry.startsWith(resolvedPath)) {
|
13
|
+
throw new Error(`Entry must be inside project path`);
|
14
|
+
}
|
15
|
+
return {
|
16
|
+
__validated: true,
|
17
|
+
projectPath: resolvedPath,
|
18
|
+
entryFile: resolvedEntry
|
19
|
+
};
|
20
|
+
};
|
21
|
+
|
22
|
+
//# sourceMappingURL=validateEntryPoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/validateEntryPoint.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { ValidatedEntryPoint } from '../model/ValidatedEntryPoint.js';\n\nexport const validateEntryPoint = (input: {\n projectPath: string;\n entryFile: string;\n}): ValidatedEntryPoint => {\n const resolvedPath = resolve(input.projectPath);\n const resolvedEntry = resolve(input.entryFile);\n\n if (!existsSync(resolvedPath) || !statSync(resolvedPath).isDirectory()) {\n throw new Error(`\"${resolvedPath}\" is not a valid project path`);\n }\n\n if (!existsSync(resolvedEntry) || !statSync(resolvedEntry).isFile()) {\n throw new Error(`\"${resolvedEntry}\" is not a valid entry file`);\n }\n\n if (!resolvedEntry.startsWith(resolvedPath)) {\n throw new Error(`Entry must be inside project path`);\n }\n\n return {\n __validated: true,\n projectPath: resolvedPath,\n entryFile: resolvedEntry,\n } satisfies ValidatedEntryPoint;\n};\n"],"names":["existsSync","statSync","resolve","validateEntryPoint","input","resolvedPath","projectPath","resolvedEntry","entryFile","isDirectory","Error","isFile","startsWith","__validated"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,UAAU;AAC/C,SAASC,OAAO,QAAQ,YAAY;AAGpC,OAAO,MAAMC,qBAAqB,CAACC;IAI/B,MAAMC,eAAeH,QAAQE,MAAME,WAAW;IAC9C,MAAMC,gBAAgBL,QAAQE,MAAMI,SAAS;IAE7C,IAAI,CAACR,WAAWK,iBAAiB,CAACJ,SAASI,cAAcI,WAAW,IAAI;QACpE,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEL,aAAa,6BAA6B,CAAC;IACnE;IAEA,IAAI,CAACL,WAAWO,kBAAkB,CAACN,SAASM,eAAeI,MAAM,IAAI;QACjE,MAAM,IAAID,MAAM,CAAC,CAAC,EAAEH,cAAc,2BAA2B,CAAC;IAClE;IAEA,IAAI,CAACA,cAAcK,UAAU,CAACP,eAAe;QACzC,MAAM,IAAIK,MAAM,CAAC,iCAAiC,CAAC;IACvD;IAEA,OAAO;QACHG,aAAa;QACbP,aAAaD;QACbG,WAAWD;IACf;AACJ,EAAE"}
|
@@ -1,2 +1,5 @@
|
|
1
|
+
import { ValidatedEntryPoint } from '../../../commands/TranspileCommand/model/ValidatedEntryPoint.js';
|
1
2
|
import { CheckListItem } from '../../../types.js';
|
2
|
-
export declare const useTranspileTasks: (
|
3
|
+
export declare const useTranspileTasks: ({ entryPoint, }: {
|
4
|
+
entryPoint: ValidatedEntryPoint;
|
5
|
+
}) => CheckListItem<unknown>[];
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
import { getErrorMessage } from '../../../commands/TranspileCommand/fn/getErrorMessage.js';
|
3
3
|
import { transpile } from '../../../commands/TranspileCommand/fn/transpile.js';
|
4
|
-
export const useTranspileTasks = (
|
4
|
+
export const useTranspileTasks = ({ entryPoint })=>{
|
5
5
|
return useMemo(()=>[
|
6
6
|
{
|
7
7
|
waitingDescription: 'Waiting to transpile code...',
|
@@ -9,13 +9,16 @@ export const useTranspileTasks = (path)=>{
|
|
9
9
|
runningDescription: 'Transpiling code...',
|
10
10
|
finishedDescription: ()=>'Code transpiled',
|
11
11
|
runner: async ()=>{
|
12
|
-
const result = transpile(
|
12
|
+
const result = transpile({
|
13
|
+
entryPoint
|
14
|
+
});
|
13
15
|
if (result.diagnostics.length > 0) {
|
14
16
|
const errors = getErrorMessage(result.diagnostics);
|
15
17
|
throw new Error(`${result.diagnostics.length === 1 ? 'An error' : 'Errors'} occurred while transpiling the code:\n${errors}`);
|
16
18
|
}
|
17
19
|
},
|
18
|
-
ready: true
|
20
|
+
ready: true,
|
21
|
+
quitOnError: false
|
19
22
|
}
|
20
23
|
], []);
|
21
24
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/hooks/useTranspileTasks.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { getErrorMessage } from '@/cli/commands/TranspileCommand/fn/getErrorMessage.js';\nimport { transpile } from '@/cli/commands/TranspileCommand/fn/transpile.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useTranspileTasks = (
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/hooks/useTranspileTasks.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { getErrorMessage } from '@/cli/commands/TranspileCommand/fn/getErrorMessage.js';\nimport { transpile } from '@/cli/commands/TranspileCommand/fn/transpile.js';\nimport { ValidatedEntryPoint } from '@/cli/commands/TranspileCommand/model/ValidatedEntryPoint.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useTranspileTasks = ({\n entryPoint,\n}: {\n entryPoint: ValidatedEntryPoint;\n}) => {\n return useMemo(\n () => [\n {\n waitingDescription: 'Waiting to transpile code...',\n errorDescription: 'Could not transpile code',\n runningDescription: 'Transpiling code...',\n finishedDescription: () => 'Code transpiled',\n runner: async () => {\n const result = transpile({\n entryPoint,\n });\n\n if (result.diagnostics.length > 0) {\n const errors = getErrorMessage(result.diagnostics);\n\n throw new Error(\n `${\n result.diagnostics.length === 1\n ? 'An error'\n : 'Errors'\n } occurred while transpiling the code:\\n${errors}`,\n );\n }\n },\n ready: true,\n quitOnError: false,\n },\n ],\n [],\n ) as CheckListItem<unknown>[];\n};\n"],"names":["useMemo","getErrorMessage","transpile","useTranspileTasks","entryPoint","waitingDescription","errorDescription","runningDescription","finishedDescription","runner","result","diagnostics","length","errors","Error","ready","quitOnError"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,QAAQ;AAChC,SAASC,eAAe,QAAQ,wDAAwD;AACxF,SAASC,SAAS,QAAQ,kDAAkD;AAI5E,OAAO,MAAMC,oBAAoB,CAAC,EAC9BC,UAAU,EAGb;IACG,OAAOJ,QACH,IAAM;YACF;gBACIK,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BC,QAAQ;oBACJ,MAAMC,SAASR,UAAU;wBACrBE;oBACJ;oBAEA,IAAIM,OAAOC,WAAW,CAACC,MAAM,GAAG,GAAG;wBAC/B,MAAMC,SAASZ,gBAAgBS,OAAOC,WAAW;wBAEjD,MAAM,IAAIG,MACN,CAAC,EACGJ,OAAOC,WAAW,CAACC,MAAM,KAAK,IACxB,aACA,SACT,uCAAuC,EAAEC,OAAO,CAAC;oBAE1D;gBACJ;gBACAE,OAAO;gBACPC,aAAa;YACjB;SACH,EACD,EAAE;AAEV,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/model/ValidatedEntryPoint.ts"],"sourcesContent":["export type ValidatedEntryPoint = {\n __validated: true;\n\n /**\n * The path to a directory containing a tsconfig.json file\n */\n projectPath: string;\n /**\n * The entry point to transpile. Must be within the path.\n */\n entryFile: string;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WAWE"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { CheckListItem } from '../../types.js';
|
3
|
-
interface
|
4
|
-
items: CheckListItem<
|
5
|
-
onFinish?: () => void;
|
3
|
+
export interface CheckListProps<TResult = unknown> {
|
4
|
+
items: CheckListItem<TResult>[];
|
5
|
+
onFinish?: (hasFailure: boolean) => void;
|
6
6
|
}
|
7
|
-
export declare const CheckList: ({ items, onFinish }:
|
8
|
-
export {};
|
7
|
+
export declare const CheckList: <TResult>({ items, onFinish, }: CheckListProps<TResult>) => React.JSX.Element;
|
@@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react';
|
|
3
3
|
import { Item } from './Item.js';
|
4
4
|
export const CheckList = ({ items, onFinish })=>{
|
5
5
|
const [currentIndex, setCurrentIndex] = useState(null);
|
6
|
+
const [hasFailure, setHasFailure] = useState(false);
|
6
7
|
useEffect(()=>{
|
7
8
|
if (currentIndex === null && items.length > 0) {
|
8
9
|
setCurrentIndex(0);
|
@@ -15,7 +16,8 @@ export const CheckList = ({ items, onFinish })=>{
|
|
15
16
|
if (index + 1 < items.length) {
|
16
17
|
setCurrentIndex(index + 1);
|
17
18
|
} else {
|
18
|
-
onFinish == null ? void 0 : onFinish();
|
19
|
+
onFinish == null ? void 0 : onFinish(hasFailure);
|
20
|
+
setHasFailure(false);
|
19
21
|
}
|
20
22
|
};
|
21
23
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, items.map((item, index)=>/*#__PURE__*/ React.createElement(Item, {
|
@@ -23,6 +25,9 @@ export const CheckList = ({ items, onFinish })=>{
|
|
23
25
|
item: _extends({}, item, {
|
24
26
|
onFinish: (result)=>{
|
25
27
|
var _item_onFinish;
|
28
|
+
if (result === false) {
|
29
|
+
setHasFailure(true);
|
30
|
+
}
|
26
31
|
item == null ? void 0 : (_item_onFinish = item.onFinish) == null ? void 0 : _item_onFinish.call(item, result);
|
27
32
|
handleFinish(index);
|
28
33
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\nexport interface CheckListProps<TResult = unknown> {\n items: CheckListItem<TResult>[];\n onFinish?: (hasFailure: boolean) => void;\n}\n\nexport const CheckList = <TResult,>({\n items,\n onFinish,\n}: CheckListProps<TResult>) => {\n const [currentIndex, setCurrentIndex] = useState<number | null>(null);\n const [hasFailure, setHasFailure] = useState(false);\n\n useEffect(() => {\n if (currentIndex === null && items.length > 0) {\n setCurrentIndex(0);\n }\n }, [currentIndex, items]);\n\n const handleFinish = (index: number) => {\n if (index + 1 < items.length) {\n setCurrentIndex(index + 1);\n } else {\n onFinish?.(hasFailure);\n setHasFailure(false);\n }\n };\n\n return (\n <>\n {items.map((item, index) => (\n <Item\n key={item.waitingDescription}\n item={{\n ...item,\n onFinish: (result: TResult | false) => {\n if (result === false) {\n setHasFailure(true);\n }\n\n item?.onFinish?.(result);\n handleFinish(index);\n },\n }}\n start={index === currentIndex}\n />\n ))}\n </>\n );\n};\n"],"names":["React","useEffect","useState","Item","CheckList","items","onFinish","currentIndex","setCurrentIndex","hasFailure","setHasFailure","length","handleFinish","index","map","item","key","waitingDescription","result","start"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,IAAI,QAAQ,YAAY;AAOjC,OAAO,MAAMC,YAAY,CAAW,EAChCC,KAAK,EACLC,QAAQ,EACc;IACtB,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,SAAwB;IAChE,MAAM,CAACO,YAAYC,cAAc,GAAGR,SAAS;IAE7CD,UAAU;QACN,IAAIM,iBAAiB,QAAQF,MAAMM,MAAM,GAAG,GAAG;YAC3CH,gBAAgB;QACpB;IACJ,GAAG;QAACD;QAAcF;KAAM;IAExB,MAAMO,eAAe,CAACC;QAClB,IAAIA,QAAQ,IAAIR,MAAMM,MAAM,EAAE;YAC1BH,gBAAgBK,QAAQ;QAC5B,OAAO;YACHP,4BAAAA,SAAWG;YACXC,cAAc;QAClB;IACJ;IAEA,qBACI,0CACKL,MAAMS,GAAG,CAAC,CAACC,MAAMF,sBACd,oBAACV;YACGa,KAAKD,KAAKE,kBAAkB;YAC5BF,MAAM,aACCA;gBACHT,UAAU,CAACY;wBAKPH;oBAJA,IAAIG,WAAW,OAAO;wBAClBR,cAAc;oBAClB;oBAEAK,yBAAAA,iBAAAA,KAAMT,QAAQ,qBAAdS,oBAAAA,MAAiBG;oBACjBN,aAAaC;gBACjB;;YAEJM,OAAON,UAAUN;;AAKrC,EAAE"}
|