crankscript 0.10.1 → 0.10.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crankscript",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "scripts": {
5
5
  "dev": "tsx src/index.ts",
6
6
  "post-build": "tsc-alias --project tsconfig.json",
@@ -16,6 +16,7 @@
16
16
  "cheerio": "^1.0.0",
17
17
  "clipanion": "^4.0.0-rc.4",
18
18
  "ink": "^5.0.1",
19
+ "open": "^10.1.0",
19
20
  "react": "^18.3.1",
20
21
  "tiged": "^3.0.0-rc.0",
21
22
  "ts-morph": "^23.0.0",
@@ -1,2 +1,2 @@
1
1
  import { CheckListItem } from '../../../types.js';
2
- export declare const useCompileTasks: (sdkPath: string) => CheckListItem<unknown>[];
2
+ export declare const useCompileTasks: (pdcPath: string) => CheckListItem<unknown>[];
@@ -1,9 +1,7 @@
1
- import { exec } from 'node:child_process';
1
+ import { spawn } from 'node:child_process';
2
2
  import { existsSync } from 'node:fs';
3
- import { promisify } from 'node:util';
4
3
  import { useMemo } from 'react';
5
- const promisifiedExec = promisify(exec);
6
- export const useCompileTasks = (sdkPath)=>{
4
+ export const useCompileTasks = (pdcPath)=>{
7
5
  return useMemo(()=>[
8
6
  {
9
7
  waitingDescription: 'Waiting to check for pdc binary...',
@@ -11,10 +9,10 @@ export const useCompileTasks = (sdkPath)=>{
11
9
  runningDescription: 'Checking for pdc binary...',
12
10
  finishedDescription: (result)=>`Found pdc binary at "${result}"`,
13
11
  runner: async ()=>{
14
- if (!existsSync(sdkPath)) {
12
+ if (!existsSync(pdcPath)) {
15
13
  throw new Error('Could not find pdc binary');
16
14
  }
17
- return sdkPath;
15
+ return pdcPath;
18
16
  },
19
17
  ready: true
20
18
  },
@@ -24,7 +22,35 @@ export const useCompileTasks = (sdkPath)=>{
24
22
  runningDescription: 'Compiling lua code...',
25
23
  finishedDescription: ()=>'Lua code compiled',
26
24
  runner: async ()=>{
27
- return promisifiedExec(`${sdkPath} Source`);
25
+ return new Promise((resolve, reject)=>{
26
+ const pdc = spawn(pdcPath, [
27
+ 'Source',
28
+ 'Game.pdx'
29
+ ]);
30
+ // Collect any standard output or errors
31
+ let stdout = '';
32
+ let stderr = '';
33
+ // Handle stdout (standard output)
34
+ pdc.stdout.on('data', (data)=>{
35
+ stdout += data.toString();
36
+ });
37
+ // Handle stderr (standard error)
38
+ pdc.stderr.on('data', (data)=>{
39
+ stderr += data.toString();
40
+ });
41
+ // Handle the process closing
42
+ pdc.on('close', (code)=>{
43
+ if (code === 0) {
44
+ resolve(stdout); // Resolve the promise with the output
45
+ } else {
46
+ reject(new Error(`pdc exited with code ${code}: ${stderr}`));
47
+ }
48
+ });
49
+ // Handle any errors that occur while starting the process
50
+ pdc.on('error', (err)=>{
51
+ reject(new Error(`Failed to start pdc process: ${err.message}`));
52
+ });
53
+ });
28
54
  },
29
55
  ready: true
30
56
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { promisify } from 'node:util';\nimport { useMemo } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nconst promisifiedExec = promisify(exec);\n\nexport const useCompileTasks = (sdkPath: 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(sdkPath)) {\n throw new Error('Could not find pdc binary');\n }\n\n return sdkPath;\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 return promisifiedExec(`${sdkPath} Source`);\n },\n ready: true,\n },\n ],\n []\n ) as CheckListItem<unknown>[];\n};\n"],"names":["exec","existsSync","promisify","useMemo","promisifiedExec","useCompileTasks","sdkPath","waitingDescription","errorDescription","runningDescription","finishedDescription","result","runner","Error","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,OAAO,QAAQ,QAAQ;AAGhC,MAAMC,kBAAkBF,UAAUF;AAElC,OAAO,MAAMK,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,CAACX,WAAWK,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,OAAOR,gBAAgB,CAAC,EAAEE,QAAQ,OAAO,CAAC;gBAC9C;gBACAQ,OAAO;YACX;SACH,EACD,EAAE;AAEV,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { useMemo } from 'react';\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 return new Promise((resolve, reject) => {\n const pdc = spawn(pdcPath, ['Source', 'Game.pdx']);\n\n // Collect any standard output or errors\n let stdout = '';\n let stderr = '';\n\n // Handle stdout (standard output)\n pdc.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n // Handle stderr (standard error)\n pdc.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n // Handle the process closing\n pdc.on('close', (code) => {\n if (code === 0) {\n resolve(stdout); // Resolve the promise with the output\n } else {\n reject(\n new Error(\n `pdc exited with code ${code}: ${stderr}`\n )\n );\n }\n });\n\n // Handle any errors that occur while starting the process\n pdc.on('error', (err) => {\n reject(\n new Error(\n `Failed to start pdc process: ${err.message}`\n )\n );\n });\n });\n },\n ready: true,\n },\n ],\n []\n ) as CheckListItem<unknown>[];\n};\n"],"names":["spawn","existsSync","useMemo","useCompileTasks","pdcPath","waitingDescription","errorDescription","runningDescription","finishedDescription","result","runner","Error","ready","Promise","resolve","reject","pdc","stdout","stderr","on","data","toString","code","err","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,OAAO,QAAQ,QAAQ;AAGhC,OAAO,MAAMC,kBAAkB,CAACC;IAC5B,OAAOF,QACH,IAAM;YACF;gBACIG,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,CAACC,SAClB,CAAC,qBAAqB,EAAEA,OAAO,CAAC,CAAC;gBACrCC,QAAQ;oBACJ,IAAI,CAACT,WAAWG,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,OAAO,IAAIG,QAAQ,CAACC,SAASC;wBACzB,MAAMC,MAAMhB,MAAMI,SAAS;4BAAC;4BAAU;yBAAW;wBAEjD,wCAAwC;wBACxC,IAAIa,SAAS;wBACb,IAAIC,SAAS;wBAEb,kCAAkC;wBAClCF,IAAIC,MAAM,CAACE,EAAE,CAAC,QAAQ,CAACC;4BACnBH,UAAUG,KAAKC,QAAQ;wBAC3B;wBAEA,iCAAiC;wBACjCL,IAAIE,MAAM,CAACC,EAAE,CAAC,QAAQ,CAACC;4BACnBF,UAAUE,KAAKC,QAAQ;wBAC3B;wBAEA,6BAA6B;wBAC7BL,IAAIG,EAAE,CAAC,SAAS,CAACG;4BACb,IAAIA,SAAS,GAAG;gCACZR,QAAQG,SAAS,sCAAsC;4BAC3D,OAAO;gCACHF,OACI,IAAIJ,MACA,CAAC,qBAAqB,EAAEW,KAAK,EAAE,EAAEJ,OAAO,CAAC;4BAGrD;wBACJ;wBAEA,0DAA0D;wBAC1DF,IAAIG,EAAE,CAAC,SAAS,CAACI;4BACbR,OACI,IAAIJ,MACA,CAAC,6BAA6B,EAAEY,IAAIC,OAAO,CAAC,CAAC;wBAGzD;oBACJ;gBACJ;gBACAZ,OAAO;YACX;SACH,EACD,EAAE;AAEV,EAAE"}
@@ -17,7 +17,37 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
17
17
  getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
18
18
  getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
19
19
  getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").FunctionDeclarationStructure["parameters"];
20
- getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
20
+ getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure> | Partial<import("ts-morph").MethodDeclarationStructure> | {
21
+ overloads: ({
22
+ docs: string[];
23
+ leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
24
+ trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
25
+ hasQuestionToken?: boolean | undefined;
26
+ scope?: import("ts-morph").Scope | undefined;
27
+ hasOverrideKeyword?: boolean | undefined;
28
+ parameters?: import("ts-morph").OptionalKind<import("ts-morph").ParameterDeclarationStructure>[] | undefined;
29
+ typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
30
+ isAbstract?: boolean | undefined;
31
+ returnType?: (string | import("ts-morph").WriterFunction) | undefined;
32
+ isAsync?: boolean | undefined;
33
+ isGenerator?: boolean | undefined;
34
+ isStatic?: boolean | undefined;
35
+ kind?: import("ts-morph").StructureKind.MethodOverload | undefined;
36
+ } | {
37
+ docs: string[];
38
+ leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
39
+ trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
40
+ parameters?: import("ts-morph").OptionalKind<import("ts-morph").ParameterDeclarationStructure>[] | undefined;
41
+ typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
42
+ hasDeclareKeyword?: boolean | undefined;
43
+ isExported?: boolean | undefined;
44
+ isDefaultExport?: boolean | undefined;
45
+ returnType?: (string | import("ts-morph").WriterFunction) | undefined;
46
+ isAsync?: boolean | undefined;
47
+ isGenerator?: boolean | undefined;
48
+ kind?: import("ts-morph").StructureKind.FunctionOverload | undefined;
49
+ })[];
50
+ };
21
51
  save: () => void;
22
52
  } | null;
23
53
  };
@@ -1,4 +1,4 @@
1
- import { FunctionDeclarationStructure } from 'ts-morph';
1
+ import { FunctionDeclarationStructure, ParameterDeclarationStructure, StructureKind } from 'ts-morph';
2
2
  import { FunctionDescription, ParameterDetails, PropertyDescription, PropertyDetails } from '../../../types.js';
3
3
  export declare const createTypeProvider: (version: string) => {
4
4
  getGlobalStatements: () => string[];
@@ -8,6 +8,36 @@ export declare const createTypeProvider: (version: string) => {
8
8
  getFunctionReturnType: (func: FunctionDescription) => string;
9
9
  getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
10
10
  getParameters: (func: FunctionDescription) => FunctionDeclarationStructure["parameters"];
11
- getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
11
+ getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure> | Partial<import("ts-morph").MethodDeclarationStructure> | {
12
+ overloads: ({
13
+ docs: string[];
14
+ leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
15
+ trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
16
+ hasQuestionToken?: boolean | undefined;
17
+ scope?: import("ts-morph").Scope | undefined;
18
+ hasOverrideKeyword?: boolean | undefined;
19
+ parameters?: import("ts-morph").OptionalKind<ParameterDeclarationStructure>[] | undefined;
20
+ typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
21
+ isAbstract?: boolean | undefined;
22
+ returnType?: (string | import("ts-morph").WriterFunction) | undefined;
23
+ isAsync?: boolean | undefined;
24
+ isGenerator?: boolean | undefined;
25
+ isStatic?: boolean | undefined;
26
+ kind?: StructureKind.MethodOverload | undefined;
27
+ } | {
28
+ docs: string[];
29
+ leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
30
+ trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
31
+ parameters?: import("ts-morph").OptionalKind<ParameterDeclarationStructure>[] | undefined;
32
+ typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
33
+ hasDeclareKeyword?: boolean | undefined;
34
+ isExported?: boolean | undefined;
35
+ isDefaultExport?: boolean | undefined;
36
+ returnType?: (string | import("ts-morph").WriterFunction) | undefined;
37
+ isAsync?: boolean | undefined;
38
+ isGenerator?: boolean | undefined;
39
+ kind?: StructureKind.FunctionOverload | undefined;
40
+ })[];
41
+ };
12
42
  save: () => void;
13
43
  };
@@ -124,7 +124,17 @@ export const createTypeProvider = (version)=>{
124
124
  };
125
125
  const getFunctionOverrideOptions = (func)=>{
126
126
  var _getFunctionDetails_overrideOptions;
127
- return (_getFunctionDetails_overrideOptions = getFunctionDetails(func).overrideOptions) != null ? _getFunctionDetails_overrideOptions : {};
127
+ const options = (_getFunctionDetails_overrideOptions = getFunctionDetails(func).overrideOptions) != null ? _getFunctionDetails_overrideOptions : {};
128
+ if ('overloads' in options && Array.isArray(options.overloads)) {
129
+ return {
130
+ overloads: options.overloads.map((overload)=>_extends({}, overload, {
131
+ docs: [
132
+ func.docs
133
+ ]
134
+ }))
135
+ };
136
+ }
137
+ return options;
128
138
  };
129
139
  const save = ()=>{
130
140
  const contents = JSON.stringify(provider, null, 4) + '\n';
@@ -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} 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 statements: [],\n classes: {},\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\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 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 return getFunctionDetails(func).overrideOptions ?? {};\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 getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","classes","properties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","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,QACV,WAAW;AAClB,SAASC,UAAU,QAAQ,qBAAqB;AAUhD,SAASC,iBAAiBC,GAAW;IACjC,OAAOA,IAAIC,OAAO,CAAC,aAAa,CAACC,GAAGC,SAAWA,OAAOC,WAAW;AACrE;AAEA,OAAO,MAAMC,qBAAqB,CAACC;IAC/B,MAAMC,OAAOX,KAAKE,YAAY,CAAC,EAAEQ,QAAQ,KAAK,CAAC;IAC/C,MAAME,mBAAmBd,WAAWa,QAC7BE,KAAKC,KAAK,CAACjB,aAAac,MAAM,YAC9B;QACGI,kBAAkB,EAAE;QACpBC,YAAY,EAAE;QACdC,SAAS,CAAC;QACVC,YAAY,CAAC;QACbC,WAAW,CAAC;IAChB;IACN,MAAMC,WAAW;QACbL,kBAAkBH,iBAAiBG,gBAAgB;QACnDC,YAAYJ,iBAAiBI,UAAU;QACvCC,SAASL,iBAAiBK,OAAO;QACjCC,YAAY,CAAC;QACbC,WAAW,CAAC;IAChB;IACA,MAAME,oBAAoB,IAAIC;IAC9B,MAAMC,mBAAmB,IAAID;IAE7B,MAAME,kBAAkB,CAACC;YACdL;QAAP,OAAOA,CA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CAACtB;YACzBD;QAAP,OAAOA,CAAAA,sCAAAA,mBAAmBC,MAAMmB,eAAe,YAAxCpB,sCAA4C,CAAC;IACxD;IAEA,MAAMwB,OAAO;QACT,MAAMC,WAAWhD,KAAKiD,SAAS,CAAC1C,UAAU,MAAM,KAAK;QAErDrB,cAAcY,MAAMkD,UAAU;IAClC;IAEA,OAAO;QACHjB;QACAC;QACArB;QACAE;QACAoB;QACAC;QACAI;QACAQ;QACAC;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 FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\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 statements: [],\n classes: {},\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\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 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 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 getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","classes","properties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","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","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,QACV,WAAW;AACl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import { exec } from 'node:child_process';
2
1
  import { watch as watchDir } from 'node:fs';
3
2
  import { join } from 'node:path';
4
3
  import { StatusMessage } from '@inkjs/ui';
4
+ import open from 'open';
5
5
  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';
@@ -23,21 +23,24 @@ export const Simulator = ({ environment, path, watch = false, background = false
23
23
  setHasChanged
24
24
  ]);
25
25
  const handleFinish = useCallback(()=>{
26
- exec(`open ${background ? '--background' : ''} Source.pdx`);
27
- if (!watch) {
28
- process.exit();
29
- }
30
- setHasChangedMessage(false);
31
- if (watcher.current) {
32
- watcher.current.close();
33
- }
34
- setIsWatching(true);
35
- watcher.current = watchDir(join(path, 'src'), {
36
- recursive: true
37
- }, ()=>{
38
- setHasChanged(true);
39
- setHasChangedMessage(true);
40
- setIsWatching(false);
26
+ open('Game.pdx', {
27
+ background
28
+ }).then(()=>{
29
+ if (!watch) {
30
+ process.exit();
31
+ }
32
+ setHasChangedMessage(false);
33
+ if (watcher.current) {
34
+ watcher.current.close();
35
+ }
36
+ setIsWatching(true);
37
+ watcher.current = watchDir(join(path, 'src'), {
38
+ recursive: true
39
+ }, ()=>{
40
+ setHasChanged(true);
41
+ setHasChangedMessage(true);
42
+ setIsWatching(false);
43
+ });
41
44
  });
42
45
  }, [
43
46
  watch,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { FSWatcher, watch as watchDir } from 'node:fs';\nimport { join } from 'node:path';\nimport { StatusMessage } from '@inkjs/ui';\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 { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n background?: boolean;\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = 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\n useEffect(() => {\n if (hasChanged) {\n setHasChanged(false);\n }\n }, [hasChanged, setHasChanged]);\n\n const handleFinish = useCallback(() => {\n exec(`open ${background ? '--background' : ''} Source.pdx`);\n\n if (!watch) {\n process.exit();\n }\n\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 }, [watch, setHasChanged, setIsWatching]);\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 <StatusMessage variant=\"info\">\n Watching for changes...\n </StatusMessage>\n )}\n {hasChangedMessage && (\n <StatusMessage variant=\"info\">Change detected</StatusMessage>\n )}\n </>\n );\n};\n"],"names":["exec","watch","watchDir","join","StatusMessage","React","useCallback","useEffect","useMemo","useRef","useState","getPdcPathFromEnvironment","useCompileTasks","useTranspileTasks","CheckList","Simulator","environment","path","background","watcher","isWatching","setIsWatching","hasChanged","setHasChanged","hasChangedMessage","setHasChangedMessage","transpileTasks","compileTasks","handleFinish","process","exit","current","close","recursive","tasks","items","onFinish","variant"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,qBAAqB;AAC1C,SAAoBC,SAASC,QAAQ,QAAQ,UAAU;AACvD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,aAAa,QAAQ,YAAY;AAC1C,OAAOC,SACHC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,QAAQ;AACf,SAASC,yBAAyB,QAAQ,gEAAgE;AAC1G,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,iBAAiB,QAAQ,6DAA6D;AAC/F,SAASC,SAAS,QAAQ,sCAAsC;AAUhE,OAAO,MAAMC,YAAY,CAAC,EACtBC,WAAW,EACXC,IAAI,EACJhB,QAAQ,KAAK,EACbiB,aAAa,KAAK,EACd;IACJ,MAAMC,UAAUV,OAAyB;IACzC,MAAM,CAACW,YAAYC,cAAc,GAAGX,SAAS;IAC7C,MAAM,CAACY,YAAYC,cAAc,GAAGb,SAAS;IAC7C,MAAM,CAACc,mBAAmBC,qBAAqB,GAAGf,SAAS;IAC3D,MAAMgB,iBAAiBb,kBAAkBI;IACzC,MAAMU,eAAef,gBACjBD,0BAA0BK;IAG9BT,UAAU;QACN,IAAIe,YAAY;YACZC,cAAc;QAClB;IACJ,GAAG;QAACD;QAAYC;KAAc;IAE9B,MAAMK,eAAetB,YAAY;QAC7BN,KAAK,CAAC,KAAK,EAAEkB,aAAa,iBAAiB,GAAG,WAAW,CAAC;QAE1D,IAAI,CAACjB,OAAO;YACR4B,QAAQC,IAAI;QAChB;QAEAL,qBAAqB;QAErB,IAAIN,QAAQY,OAAO,EAAE;YACjBZ,QAAQY,OAAO,CAACC,KAAK;QACzB;QAEAX,cAAc;QAEdF,QAAQY,OAAO,GAAG7B,SACdC,KAAKc,MAAM,QACX;YAAEgB,WAAW;QAAK,GAClB;YACIV,cAAc;YACdE,qBAAqB;YACrBJ,cAAc;QAClB;IAER,GAAG;QAACpB;QAAOsB;QAAeF;KAAc;IAExC,MAAMa,QAAQ1B,QAAQ;QAClB,OAAO;eAAIkB;eAAmBC;SAAa;IAC/C,GAAG;QAACD;QAAgBC;KAAa;IAEjC,qBACI,0CACK,CAACL,4BAAc,oBAACR;QAAUqB,OAAOD;QAAOE,UAAUR;QAClDR,cAAc,CAACI,mCACZ,oBAACpB;QAAciC,SAAQ;OAAO,4BAIjCb,mCACG,oBAACpB;QAAciC,SAAQ;OAAO;AAI9C,EAAE"}
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 { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n background?: boolean;\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = 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\n useEffect(() => {\n if (hasChanged) {\n setHasChanged(false);\n }\n }, [hasChanged, setHasChanged]);\n\n const handleFinish = useCallback(() => {\n open('Game.pdx', {\n background,\n }).then(() => {\n if (!watch) {\n process.exit();\n }\n\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 }, [watch, setHasChanged, setIsWatching]);\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 <StatusMessage variant=\"info\">\n Watching for changes...\n </StatusMessage>\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","useTranspileTasks","CheckList","Simulator","environment","path","background","watcher","isWatching","setIsWatching","hasChanged","setHasChanged","hasChangedMessage","setHasChangedMessage","transpileTasks","compileTasks","handleFinish","then","process","exit","current","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,QAAQ;AACf,SAASC,yBAAyB,QAAQ,gEAAgE;AAC1G,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,iBAAiB,QAAQ,6DAA6D;AAC/F,SAASC,SAAS,QAA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