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.
Files changed (57) hide show
  1. package/package.json +3 -3
  2. package/src/commands/CompileCommand/components/Compile.js +1 -1
  3. package/src/commands/CompileCommand/components/Compile.js.map +1 -1
  4. package/src/commands/GenerateTypes/components/GenerateTypes.js +6 -2
  5. package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
  6. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +5 -2
  7. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
  8. package/src/commands/GenerateTypes/hooks/useFetchHtml.d.ts +1 -1
  9. package/src/commands/GenerateTypes/hooks/useFetchHtml.js +1 -1
  10. package/src/commands/GenerateTypes/hooks/useFetchHtml.js.map +1 -1
  11. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.d.ts +11 -0
  12. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js +70 -0
  13. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js.map +1 -0
  14. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +11 -4
  15. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
  16. package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +7 -37
  17. package/src/commands/GenerateTypes/hooks/useGetVersion.js +1 -1
  18. package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -1
  19. package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +1 -1
  20. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +1 -1
  21. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -1
  22. package/src/commands/GenerateTypes/types.d.ts +12 -0
  23. package/src/commands/GenerateTypes/types.js +3 -0
  24. package/src/commands/GenerateTypes/types.js.map +1 -0
  25. package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +7 -37
  26. package/src/commands/GenerateTypes/utils/createTypeProvider.js +51 -27
  27. package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
  28. package/src/commands/NewCommand/components/New.js +1 -1
  29. package/src/commands/NewCommand/components/New.js.map +1 -1
  30. package/src/commands/SimulatorCommand/components/Simulator.js +14 -4
  31. package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -1
  32. package/src/commands/TranspileCommand/TranspileCommand.d.ts +1 -0
  33. package/src/commands/TranspileCommand/TranspileCommand.js +10 -1
  34. package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
  35. package/src/commands/TranspileCommand/components/Transpile.d.ts +3 -2
  36. package/src/commands/TranspileCommand/components/Transpile.js +5 -3
  37. package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
  38. package/src/commands/TranspileCommand/fn/transpile.d.ts +5 -1
  39. package/src/commands/TranspileCommand/fn/transpile.js +5 -4
  40. package/src/commands/TranspileCommand/fn/transpile.js.map +1 -1
  41. package/src/commands/TranspileCommand/fn/validateEntryPoint.d.ts +5 -0
  42. package/src/commands/TranspileCommand/fn/validateEntryPoint.js +22 -0
  43. package/src/commands/TranspileCommand/fn/validateEntryPoint.js.map +1 -0
  44. package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +4 -1
  45. package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +6 -3
  46. package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -1
  47. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.d.ts +11 -0
  48. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js +3 -0
  49. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js.map +1 -0
  50. package/src/components/CheckList/CheckList.d.ts +4 -5
  51. package/src/components/CheckList/CheckList.js +6 -1
  52. package/src/components/CheckList/CheckList.js.map +1 -1
  53. package/src/components/CheckList/Item.d.ts +1 -1
  54. package/src/components/CheckList/Item.js +24 -6
  55. package/src/components/CheckList/Item.js.map +1 -1
  56. package/src/types.d.ts +20 -18
  57. package/src/types.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crankscript",
3
- "version": "0.11.13",
3
+ "version": "0.12.0",
4
4
  "scripts": {
5
5
  "dev": "tsx src/index.ts",
6
6
  "post-build": "tsc-alias --project tsconfig.json"
@@ -21,8 +21,8 @@
21
21
  "ts-morph": "^23.0.0",
22
22
  "turndown": "^7.2.0",
23
23
  "typanion": "^3.14.0",
24
- "typescript-to-lua": "^1.27.0",
25
- "typescript": "5.7.3"
24
+ "typescript": "5.7.3",
25
+ "typescript-to-lua": "^1.27.0"
26
26
  },
27
27
  "type": "module",
28
28
  "main": "./src/index.js",
@@ -7,7 +7,7 @@ export const Compile = ({ environment })=>{
7
7
  const items = useCompileTasks(getPdcPathFromEnvironment(environment));
8
8
  return /*#__PURE__*/ React.createElement(CheckList, {
9
9
  items: items,
10
- onFinish: process.exit
10
+ onFinish: ()=>process.exit
11
11
  });
12
12
  };
13
13
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import process from 'node:process';\nimport React from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n}\n\nexport const Compile = ({ environment }: Props) => {\n const items = useCompileTasks(getPdcPathFromEnvironment(environment));\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["process","React","getPdcPathFromEnvironment","useCompileTasks","CheckList","Compile","environment","items","onFinish","exit"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,yBAAyB,QAAQ,gEAAgE;AAC1G,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,SAAS,QAAQ,sCAAsC;AAOhE,OAAO,MAAMC,UAAU,CAAC,EAAEC,WAAW,EAAS;IAC1C,MAAMC,QAAQJ,gBAAgBD,0BAA0BI;IAExD,qBAAO,oBAACF;QAAUG,OAAOA;QAAOC,UAAUR,QAAQS,IAAI;;AAC1D,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import process from 'node:process';\nimport React from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n}\n\nexport const Compile = ({ environment }: Props) => {\n const items = useCompileTasks(getPdcPathFromEnvironment(environment));\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["process","React","getPdcPathFromEnvironment","useCompileTasks","CheckList","Compile","environment","items","onFinish","exit"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,yBAAyB,QAAQ,gEAAgE;AAC1G,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,SAAS,QAAQ,sCAAsC;AAOhE,OAAO,MAAMC,UAAU,CAAC,EAAEC,WAAW,EAAS;IAC1C,MAAMC,QAAQJ,gBAAgBD,0BAA0BI;IAExD,qBAAO,oBAACF;QAAUG,OAAOA;QAAOC,UAAU,IAAMR,QAAQS,IAAI;;AAChE,EAAE"}
@@ -1,5 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { useFetchHtml } from '../../../commands/GenerateTypes/hooks/useFetchHtml.js';
3
+ import { useFormatTypeFile } from '../../../commands/GenerateTypes/hooks/useFormatTypeFile.js';
3
4
  import { useGenerateTypeFile } from '../../../commands/GenerateTypes/hooks/useGenerateTypeFile.js';
4
5
  import { useGetVersion } from '../../../commands/GenerateTypes/hooks/useGetVersion.js';
5
6
  import { useParseDocumentation } from '../../../commands/GenerateTypes/hooks/useParseDocumentation.js';
@@ -9,18 +10,21 @@ export const GenerateTypes = ({ output, version, overwriteJson })=>{
9
10
  const { html, fetchHtml } = useFetchHtml(fetchedVersion);
10
11
  const { definitions, parseDocumentation } = useParseDocumentation(html, version);
11
12
  const { generateTypeFile } = useGenerateTypeFile(output, definitions, typeProvider);
13
+ const { formatTypeFile } = useFormatTypeFile(output);
12
14
  const items = useMemo(()=>{
13
15
  return [
14
16
  getVersion,
15
17
  fetchHtml,
16
18
  parseDocumentation,
17
- generateTypeFile
19
+ generateTypeFile,
20
+ formatTypeFile
18
21
  ];
19
22
  }, [
20
23
  fetchedVersion,
21
24
  html,
22
25
  definitions,
23
- typeProvider
26
+ typeProvider,
27
+ formatTypeFile
24
28
  ]);
25
29
  return /*#__PURE__*/ React.createElement(CheckList, {
26
30
  items: items,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useFetchHtml } from '@/cli/commands/GenerateTypes/hooks/useFetchHtml.js';\nimport { useGenerateTypeFile } from '@/cli/commands/GenerateTypes/hooks/useGenerateTypeFile.js';\nimport { useGetVersion } from '@/cli/commands/GenerateTypes/hooks/useGetVersion.js';\nimport { useParseDocumentation } from '@/cli/commands/GenerateTypes/hooks/useParseDocumentation.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, PlaydateSdkVersion } from '@/cli/types.js';\n\ninterface Props {\n output: string;\n version: PlaydateSdkVersion;\n overwriteJson: boolean;\n}\n\nexport const GenerateTypes = ({ output, version, overwriteJson }: Props) => {\n const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);\n const { html, fetchHtml } = useFetchHtml(fetchedVersion);\n const { definitions, parseDocumentation } = useParseDocumentation(\n html,\n version,\n );\n const { generateTypeFile } = useGenerateTypeFile(\n output,\n definitions,\n typeProvider,\n );\n\n const items = useMemo(() => {\n return [\n getVersion,\n fetchHtml,\n parseDocumentation,\n generateTypeFile,\n ] as CheckListItem<unknown>[];\n }, [fetchedVersion, html, definitions, typeProvider]);\n\n return (\n <CheckList\n items={items}\n onFinish={() => {\n if (overwriteJson) {\n typeProvider?.save();\n }\n\n process.exit();\n }}\n />\n );\n};\n"],"names":["React","useMemo","useFetchHtml","useGenerateTypeFile","useGetVersion","useParseDocumentation","CheckList","GenerateTypes","output","version","overwriteJson","typeProvider","fetchedVersion","getVersion","html","fetchHtml","definitions","parseDocumentation","generateTypeFile","items","onFinish","save","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,YAAY,QAAQ,qDAAqD;AAClF,SAASC,mBAAmB,QAAQ,4DAA4D;AAChG,SAASC,aAAa,QAAQ,sDAAsD;AACpF,SAASC,qBAAqB,QAAQ,8DAA8D;AACpG,SAASC,SAAS,QAAQ,sCAAsC;AAShE,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAS;IACnE,MAAM,EAAEC,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGT,cAAcK;IACnE,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAE,GAAGb,aAAaU;IACzC,MAAM,EAAEI,WAAW,EAAEC,kBAAkB,EAAE,GAAGZ,sBACxCS,MACAL;IAEJ,MAAM,EAAES,gBAAgB,EAAE,GAAGf,oBACzBK,QACAQ,aACAL;IAGJ,MAAMQ,QAAQlB,QAAQ;QAClB,OAAO;YACHY;YACAE;YACAE;YACAC;SACH;IACL,GAAG;QAACN;QAAgBE;QAAME;QAAaL;KAAa;IAEpD,qBACI,oBAACL;QACGa,OAAOA;QACPC,UAAU;YACN,IAAIV,eAAe;gBACfC,gCAAAA,aAAcU,IAAI;YACtB;YAEAC,QAAQC,IAAI;QAChB;;AAGZ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useFetchHtml } from '@/cli/commands/GenerateTypes/hooks/useFetchHtml.js';\nimport { useFormatTypeFile } from '@/cli/commands/GenerateTypes/hooks/useFormatTypeFile.js';\nimport { useGenerateTypeFile } from '@/cli/commands/GenerateTypes/hooks/useGenerateTypeFile.js';\nimport { useGetVersion } from '@/cli/commands/GenerateTypes/hooks/useGetVersion.js';\nimport { useParseDocumentation } from '@/cli/commands/GenerateTypes/hooks/useParseDocumentation.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, PlaydateSdkVersion } from '@/cli/types.js';\n\ninterface Props {\n output: string;\n version: PlaydateSdkVersion;\n overwriteJson: boolean;\n}\n\nexport const GenerateTypes = ({ output, version, overwriteJson }: Props) => {\n const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);\n const { html, fetchHtml } = useFetchHtml(fetchedVersion);\n const { definitions, parseDocumentation } = useParseDocumentation(\n html,\n version,\n );\n const { generateTypeFile } = useGenerateTypeFile(\n output,\n definitions,\n typeProvider,\n );\n const { formatTypeFile } = useFormatTypeFile(output);\n\n const items = useMemo(() => {\n return [\n getVersion,\n fetchHtml,\n parseDocumentation,\n generateTypeFile,\n formatTypeFile,\n ] as CheckListItem<unknown>[];\n }, [fetchedVersion, html, definitions, typeProvider, formatTypeFile]);\n\n return (\n <CheckList\n items={items}\n onFinish={() => {\n if (overwriteJson) {\n typeProvider?.save();\n }\n\n process.exit();\n }}\n />\n );\n};\n"],"names":["React","useMemo","useFetchHtml","useFormatTypeFile","useGenerateTypeFile","useGetVersion","useParseDocumentation","CheckList","GenerateTypes","output","version","overwriteJson","typeProvider","fetchedVersion","getVersion","html","fetchHtml","definitions","parseDocumentation","generateTypeFile","formatTypeFile","items","onFinish","save","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,YAAY,QAAQ,qDAAqD;AAClF,SAASC,iBAAiB,QAAQ,0DAA0D;AAC5F,SAASC,mBAAmB,QAAQ,4DAA4D;AAChG,SAASC,aAAa,QAAQ,sDAAsD;AACpF,SAASC,qBAAqB,QAAQ,8DAA8D;AACpG,SAASC,SAAS,QAAQ,sCAAsC;AAShE,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAS;IACnE,MAAM,EAAEC,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGT,cAAcK;IACnE,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAE,GAAGd,aAAaW;IACzC,MAAM,EAAEI,WAAW,EAAEC,kBAAkB,EAAE,GAAGZ,sBACxCS,MACAL;IAEJ,MAAM,EAAES,gBAAgB,EAAE,GAAGf,oBACzBK,QACAQ,aACAL;IAEJ,MAAM,EAAEQ,cAAc,EAAE,GAAGjB,kBAAkBM;IAE7C,MAAMY,QAAQpB,QAAQ;QAClB,OAAO;YACHa;YACAE;YACAE;YACAC;YACAC;SACH;IACL,GAAG;QAACP;QAAgBE;QAAME;QAAaL;QAAcQ;KAAe;IAEpE,qBACI,oBAACb;QACGc,OAAOA;QACPC,UAAU;YACN,IAAIX,eAAe;gBACfC,gCAAAA,aAAcW,IAAI;YACtB;YAEAC,QAAQC,IAAI;QAChB;;AAGZ,EAAE"}
@@ -7,13 +7,16 @@ export const parseFunctionSignature = (signature)=>{
7
7
  const functionName = segments[segments.length - 1];
8
8
  const namespaces = segments.slice(0, -1);
9
9
  const params = paramString.split(')')[0].split(',').filter(Boolean);
10
+ // Find if there's any optional parameter
11
+ const firstOptionalIndex = params.findIndex((param)=>param.includes('[') || param.includes(']'));
10
12
  return {
11
13
  signature,
12
14
  name: functionName,
13
15
  namespaces,
14
- parameters: params.map((eachParam)=>({
16
+ parameters: params.map((eachParam, index)=>({
15
17
  name: eachParam.replace(/\[/g, '').replace(/]/g, '').trim(),
16
- required: !eachParam.includes('[') && !eachParam.includes(']')
18
+ // Parameter is not required if it has brackets or comes after an optional parameter
19
+ required: firstOptionalIndex === -1 ? !eachParam.includes('[') && !eachParam.includes(']') : index < firstOptionalIndex
17
20
  })),
18
21
  hasSelf
19
22
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/parseFunctionSignature.ts"],"sourcesContent":["import { FunctionDescription } from '@/cli/types.js';\n\nexport const parseFunctionSignature = (signature: string) => {\n const normalizedSignature = signature.includes('(')\n ? signature\n : signature + '()';\n\n const [fullyQualifiedName, paramString] = normalizedSignature.split('(');\n const hasSelf = fullyQualifiedName.includes(':');\n const normalizedFullyQualifiedName = fullyQualifiedName.replace(':', '.');\n const segments = normalizedFullyQualifiedName.split('.');\n const functionName = segments[segments.length - 1];\n const namespaces = segments.slice(0, -1);\n const params = paramString.split(')')[0].split(',').filter(Boolean);\n\n return {\n signature,\n name: functionName,\n namespaces,\n parameters: params.map(eachParam => ({\n name: eachParam.replace(/\\[/g, '').replace(/]/g, '').trim(),\n required: !eachParam.includes('[') && !eachParam.includes(']'),\n })),\n hasSelf,\n } satisfies Omit<FunctionDescription, 'docs'>;\n};\n"],"names":["parseFunctionSignature","signature","normalizedSignature","includes","fullyQualifiedName","paramString","split","hasSelf","normalizedFullyQualifiedName","replace","segments","functionName","length","namespaces","slice","params","filter","Boolean","name","parameters","map","eachParam","trim","required"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,sBAAsBD,UAAUE,QAAQ,CAAC,OACzCF,YACAA,YAAY;IAElB,MAAM,CAACG,oBAAoBC,YAAY,GAAGH,oBAAoBI,KAAK,CAAC;IACpE,MAAMC,UAAUH,mBAAmBD,QAAQ,CAAC;IAC5C,MAAMK,+BAA+BJ,mBAAmBK,OAAO,CAAC,KAAK;IACrE,MAAMC,WAAWF,6BAA6BF,KAAK,CAAC;IACpD,MAAMK,eAAeD,QAAQ,CAACA,SAASE,MAAM,GAAG,EAAE;IAClD,MAAMC,aAAaH,SAASI,KAAK,CAAC,GAAG,CAAC;IACtC,MAAMC,SAASV,YAAYC,KAAK,CAAC,IAAI,CAAC,EAAE,CAACA,KAAK,CAAC,KAAKU,MAAM,CAACC;IAE3D,OAAO;QACHhB;QACAiB,MAAMP;QACNE;QACAM,YAAYJ,OAAOK,GAAG,CAACC,CAAAA,YAAc,CAAA;gBACjCH,MAAMG,UAAUZ,OAAO,CAAC,OAAO,IAAIA,OAAO,CAAC,MAAM,IAAIa,IAAI;gBACzDC,UAAU,CAACF,UAAUlB,QAAQ,CAAC,QAAQ,CAACkB,UAAUlB,QAAQ,CAAC;YAC9D,CAAA;QACAI;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/parseFunctionSignature.ts"],"sourcesContent":["import { FunctionDescription } from '@/cli/types.js';\n\nexport const parseFunctionSignature = (signature: string) => {\n const normalizedSignature = signature.includes('(')\n ? signature\n : signature + '()';\n\n const [fullyQualifiedName, paramString] = normalizedSignature.split('(');\n const hasSelf = fullyQualifiedName.includes(':');\n const normalizedFullyQualifiedName = fullyQualifiedName.replace(':', '.');\n const segments = normalizedFullyQualifiedName.split('.');\n const functionName = segments[segments.length - 1];\n const namespaces = segments.slice(0, -1);\n const params = paramString.split(')')[0].split(',').filter(Boolean);\n\n // Find if there's any optional parameter\n const firstOptionalIndex = params.findIndex(\n param => param.includes('[') || param.includes(']'),\n );\n\n return {\n signature,\n name: functionName,\n namespaces,\n parameters: params.map((eachParam, index) => ({\n name: eachParam.replace(/\\[/g, '').replace(/]/g, '').trim(),\n // Parameter is not required if it has brackets or comes after an optional parameter\n required:\n firstOptionalIndex === -1\n ? !eachParam.includes('[') && !eachParam.includes(']')\n : index < firstOptionalIndex,\n })),\n hasSelf,\n } satisfies Omit<FunctionDescription, 'docs'>;\n};\n"],"names":["parseFunctionSignature","signature","normalizedSignature","includes","fullyQualifiedName","paramString","split","hasSelf","normalizedFullyQualifiedName","replace","segments","functionName","length","namespaces","slice","params","filter","Boolean","firstOptionalIndex","findIndex","param","name","parameters","map","eachParam","index","trim","required"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,sBAAsBD,UAAUE,QAAQ,CAAC,OACzCF,YACAA,YAAY;IAElB,MAAM,CAACG,oBAAoBC,YAAY,GAAGH,oBAAoBI,KAAK,CAAC;IACpE,MAAMC,UAAUH,mBAAmBD,QAAQ,CAAC;IAC5C,MAAMK,+BAA+BJ,mBAAmBK,OAAO,CAAC,KAAK;IACrE,MAAMC,WAAWF,6BAA6BF,KAAK,CAAC;IACpD,MAAMK,eAAeD,QAAQ,CAACA,SAASE,MAAM,GAAG,EAAE;IAClD,MAAMC,aAAaH,SAASI,KAAK,CAAC,GAAG,CAAC;IACtC,MAAMC,SAASV,YAAYC,KAAK,CAAC,IAAI,CAAC,EAAE,CAACA,KAAK,CAAC,KAAKU,MAAM,CAACC;IAE3D,yCAAyC;IACzC,MAAMC,qBAAqBH,OAAOI,SAAS,CACvCC,CAAAA,QAASA,MAAMjB,QAAQ,CAAC,QAAQiB,MAAMjB,QAAQ,CAAC;IAGnD,OAAO;QACHF;QACAoB,MAAMV;QACNE;QACAS,YAAYP,OAAOQ,GAAG,CAAC,CAACC,WAAWC,QAAW,CAAA;gBAC1CJ,MAAMG,UAAUf,OAAO,CAAC,OAAO,IAAIA,OAAO,CAAC,MAAM,IAAIiB,IAAI;gBACzD,oFAAoF;gBACpFC,UACIT,uBAAuB,CAAC,IAClB,CAACM,UAAUrB,QAAQ,CAAC,QAAQ,CAACqB,UAAUrB,QAAQ,CAAC,OAChDsB,QAAQP;YACtB,CAAA;QACAX;IACJ;AACJ,EAAE"}
@@ -6,7 +6,7 @@ export declare const useFetchHtml: (version: string | null) => {
6
6
  finishedDescription: () => string;
7
7
  runningDescription: string;
8
8
  runner: () => Promise<string>;
9
- onFinish: (result: string) => void;
9
+ onFinish: (result: string | false) => void;
10
10
  ready: boolean;
11
11
  };
12
12
  };
@@ -15,7 +15,7 @@ export const useFetchHtml = (version)=>{
15
15
  return getHtmlForVersion(version);
16
16
  },
17
17
  onFinish: (result)=>{
18
- setHtml(result);
18
+ setHtml(result === false ? null : result);
19
19
  },
20
20
  ready: version !== null
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useFetchHtml.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getHtmlForVersion } from '@/cli/commands/GenerateTypes/fn/getHtmlForVersion.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useFetchHtml = (version: string | null) => {\n const [html, setHtml] = useState<string | null>(null);\n\n const fetchHtml = useMemo(() => {\n return {\n waitingDescription: 'Waiting to fetch HTML contents',\n errorDescription: 'Failed to fetch HTML contents',\n finishedDescription: () => 'HTML contents fetched',\n runningDescription: 'Fetching HTML contents...',\n runner: async () => {\n if (!version) {\n throw new Error('Version is not set');\n }\n\n return getHtmlForVersion(version);\n },\n onFinish: result => {\n setHtml(result);\n },\n ready: version !== null,\n } satisfies CheckListItem<string>;\n }, [version]);\n\n return {\n html,\n fetchHtml,\n };\n};\n"],"names":["useMemo","useState","getHtmlForVersion","useFetchHtml","version","html","setHtml","fetchHtml","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","onFinish","result","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AAGzF,OAAO,MAAMC,eAAe,CAACC;IACzB,MAAM,CAACC,MAAMC,QAAQ,GAAGL,SAAwB;IAEhD,MAAMM,YAAYP,QAAQ;QACtB,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACR,SAAS;oBACV,MAAM,IAAIS,MAAM;gBACpB;gBAEA,OAAOX,kBAAkBE;YAC7B;YACAU,UAAUC,CAAAA;gBACNT,QAAQS;YACZ;YACAC,OAAOZ,YAAY;QACvB;IACJ,GAAG;QAACA;KAAQ;IAEZ,OAAO;QACHC;QACAE;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useFetchHtml.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getHtmlForVersion } from '@/cli/commands/GenerateTypes/fn/getHtmlForVersion.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useFetchHtml = (version: string | null) => {\n const [html, setHtml] = useState<string | null>(null);\n\n const fetchHtml = useMemo(() => {\n return {\n waitingDescription: 'Waiting to fetch HTML contents',\n errorDescription: 'Failed to fetch HTML contents',\n finishedDescription: () => 'HTML contents fetched',\n runningDescription: 'Fetching HTML contents...',\n runner: async () => {\n if (!version) {\n throw new Error('Version is not set');\n }\n\n return getHtmlForVersion(version);\n },\n onFinish: result => {\n setHtml(result === false ? null : result);\n },\n ready: version !== null,\n } satisfies CheckListItem<string>;\n }, [version]);\n\n return {\n html,\n fetchHtml,\n };\n};\n"],"names":["useMemo","useState","getHtmlForVersion","useFetchHtml","version","html","setHtml","fetchHtml","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","onFinish","result","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AAGzF,OAAO,MAAMC,eAAe,CAACC;IACzB,MAAM,CAACC,MAAMC,QAAQ,GAAGL,SAAwB;IAEhD,MAAMM,YAAYP,QAAQ;QACtB,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACR,SAAS;oBACV,MAAM,IAAIS,MAAM;gBACpB;gBAEA,OAAOX,kBAAkBE;YAC7B;YACAU,UAAUC,CAAAA;gBACNT,QAAQS,WAAW,QAAQ,OAAOA;YACtC;YACAC,OAAOZ,YAAY;QACvB;IACJ,GAAG;QAACA;KAAQ;IAEZ,OAAO;QACHC;QACAE;IACJ;AACJ,EAAE"}
@@ -0,0 +1,11 @@
1
+ export declare const useFormatTypeFile: (path: string) => {
2
+ formatTypeFile: {
3
+ waitingDescription: string;
4
+ errorDescription: string;
5
+ finishedDescription: () => string;
6
+ runningDescription: string;
7
+ runner: () => Promise<boolean>;
8
+ ready: true;
9
+ skip: boolean;
10
+ };
11
+ };
@@ -0,0 +1,70 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { useMemo } from 'react';
3
+ export const useFormatTypeFile = (path)=>{
4
+ const formatTypeFile = useMemo(()=>{
5
+ // Check if prettier and eslint are available
6
+ const checkToolsAvailability = ()=>{
7
+ let hasPrettier = false;
8
+ let hasEslint = false;
9
+ try {
10
+ // Check if prettier is available
11
+ execSync('npx prettier --version', {
12
+ stdio: 'ignore'
13
+ });
14
+ hasPrettier = true;
15
+ } catch (error) {
16
+ // Prettier not available
17
+ }
18
+ try {
19
+ // Check if eslint is available
20
+ execSync('npx eslint --version', {
21
+ stdio: 'ignore'
22
+ });
23
+ hasEslint = true;
24
+ } catch (error) {
25
+ // ESLint not available
26
+ }
27
+ return {
28
+ hasPrettier,
29
+ hasEslint
30
+ };
31
+ };
32
+ const { hasPrettier, hasEslint } = checkToolsAvailability();
33
+ return {
34
+ waitingDescription: 'Waiting to format the type file...',
35
+ errorDescription: 'Failed to format the type file',
36
+ finishedDescription: ()=>'Type file formatted',
37
+ runningDescription: 'Formatting the type file...',
38
+ runner: async ()=>{
39
+ try {
40
+ // Run prettier on the generated file if available
41
+ if (hasPrettier) {
42
+ execSync(`npx prettier --write "${path}"`, {
43
+ stdio: 'ignore'
44
+ });
45
+ }
46
+ // Run eslint if available
47
+ if (hasEslint) {
48
+ execSync(`npx eslint --fix "${path}"`, {
49
+ stdio: 'ignore'
50
+ });
51
+ }
52
+ return true;
53
+ } catch (error) {
54
+ console.error('Error formatting file:', error);
55
+ return false;
56
+ }
57
+ },
58
+ ready: true,
59
+ // Skip only if both tools are unavailable
60
+ skip: !hasPrettier && !hasEslint
61
+ };
62
+ }, [
63
+ path
64
+ ]);
65
+ return {
66
+ formatTypeFile
67
+ };
68
+ };
69
+
70
+ //# sourceMappingURL=useFormatTypeFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useFormatTypeFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { useMemo } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useFormatTypeFile = (path: string) => {\n const formatTypeFile = useMemo(() => {\n // Check if prettier and eslint are available\n const checkToolsAvailability = () => {\n let hasPrettier = false;\n let hasEslint = false;\n\n try {\n // Check if prettier is available\n execSync('npx prettier --version', { stdio: 'ignore' });\n hasPrettier = true;\n } catch (error) {\n // Prettier not available\n }\n\n try {\n // Check if eslint is available\n execSync('npx eslint --version', { stdio: 'ignore' });\n hasEslint = true;\n } catch (error) {\n // ESLint not available\n }\n\n return { hasPrettier, hasEslint };\n };\n\n const { hasPrettier, hasEslint } = checkToolsAvailability();\n\n return {\n waitingDescription: 'Waiting to format the type file...',\n errorDescription: 'Failed to format the type file',\n finishedDescription: () => 'Type file formatted',\n runningDescription: 'Formatting the type file...',\n runner: async () => {\n try {\n // Run prettier on the generated file if available\n if (hasPrettier) {\n execSync(`npx prettier --write \"${path}\"`, {\n stdio: 'ignore',\n });\n }\n\n // Run eslint if available\n if (hasEslint) {\n execSync(`npx eslint --fix \"${path}\"`, {\n stdio: 'ignore',\n });\n }\n\n return true;\n } catch (error) {\n console.error('Error formatting file:', error);\n return false;\n }\n },\n ready: true,\n // Skip only if both tools are unavailable\n skip: !hasPrettier && !hasEslint,\n } satisfies CheckListItem<boolean>;\n }, [path]);\n\n return {\n formatTypeFile,\n };\n};\n"],"names":["execSync","useMemo","useFormatTypeFile","path","formatTypeFile","checkToolsAvailability","hasPrettier","hasEslint","stdio","error","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","console","ready","skip"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,OAAO,QAAQ,QAAQ;AAGhC,OAAO,MAAMC,oBAAoB,CAACC;IAC9B,MAAMC,iBAAiBH,QAAQ;QAC3B,6CAA6C;QAC7C,MAAMI,yBAAyB;YAC3B,IAAIC,cAAc;YAClB,IAAIC,YAAY;YAEhB,IAAI;gBACA,iCAAiC;gBACjCP,SAAS,0BAA0B;oBAAEQ,OAAO;gBAAS;gBACrDF,cAAc;YAClB,EAAE,OAAOG,OAAO;YACZ,yBAAyB;YAC7B;YAEA,IAAI;gBACA,+BAA+B;gBAC/BT,SAAS,wBAAwB;oBAAEQ,OAAO;gBAAS;gBACnDD,YAAY;YAChB,EAAE,OAAOE,OAAO;YACZ,uBAAuB;YAC3B;YAEA,OAAO;gBAAEH;gBAAaC;YAAU;QACpC;QAEA,MAAM,EAAED,WAAW,EAAEC,SAAS,EAAE,GAAGF;QAEnC,OAAO;YACHK,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI;oBACA,kDAAkD;oBAClD,IAAIR,aAAa;wBACbN,SAAS,CAAC,sBAAsB,EAAEG,KAAK,CAAC,CAAC,EAAE;4BACvCK,OAAO;wBACX;oBACJ;oBAEA,0BAA0B;oBAC1B,IAAID,WAAW;wBACXP,SAAS,CAAC,kBAAkB,EAAEG,KAAK,CAAC,CAAC,EAAE;4BACnCK,OAAO;wBACX;oBACJ;oBAEA,OAAO;gBACX,EAAE,OAAOC,OAAO;oBACZM,QAAQN,KAAK,CAAC,0BAA0BA;oBACxC,OAAO;gBACX;YACJ;YACAO,OAAO;YACP,0CAA0C;YAC1CC,MAAM,CAACX,eAAe,CAACC;QAC3B;IACJ,GAAG;QAACJ;KAAK;IAET,OAAO;QACHC;IACJ;AACJ,EAAE"}
@@ -1,7 +1,7 @@
1
1
  import { _ as _extends } from "@swc/helpers/_/_extends";
2
2
  import { writeFileSync } from 'node:fs';
3
3
  import { useMemo } from 'react';
4
- import { Project, VariableDeclarationKind } from 'ts-morph';
4
+ import { ModuleDeclarationKind, Project, VariableDeclarationKind } from 'ts-morph';
5
5
  import { TypescriptReservedNamed } from '../../../constants.js';
6
6
  export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
7
7
  const generateTypeFile = useMemo(()=>{
@@ -23,7 +23,12 @@ export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
23
23
  });
24
24
  const globalNamespace = definitions.global;
25
25
  typeFile.addStatements(typeProvider.getGlobalStatements());
26
- generateNamespace(globalNamespace, typeFile, typeProvider, '');
26
+ const globalModule = typeFile.addModule({
27
+ name: 'global',
28
+ hasDeclareKeyword: true,
29
+ declarationKind: ModuleDeclarationKind.Global
30
+ });
31
+ generateNamespace(globalNamespace, globalModule, typeProvider, '');
27
32
  writeFileSync(path, typeFile.getFullText().replace('*/', '*/\n'));
28
33
  },
29
34
  ready: definitions !== null && typeProvider !== null
@@ -74,6 +79,7 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, namespace,
74
79
  }, typeProvider.getFunctionOverrideOptions(func)));
75
80
  if (isFunctionNameReserved) {
76
81
  subject.addExportDeclaration({
82
+ leadingTrivia: '/** @ts-ignore */\n',
77
83
  namedExports: [
78
84
  {
79
85
  name: resolvedName,
@@ -86,7 +92,8 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, namespace,
86
92
  let propertiesSubject = null;
87
93
  if (name && apiObject.methods.length > 0) {
88
94
  const typeClass = incomingSubject.addClass(_extends({
89
- name
95
+ name,
96
+ isExported: true
90
97
  }, typeProvider.getClassOptions(fullNamespaceName)));
91
98
  propertiesSubject = typeClass;
92
99
  for (const method of apiObject.methods){
@@ -120,7 +127,7 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, namespace,
120
127
  ],
121
128
  type: propertyDetails.type,
122
129
  isStatic: propertyDetails.isStatic,
123
- isReadonly: propertyDetails.isReadOnly
130
+ isReadonly: propertyDetails.isReadonly
124
131
  });
125
132
  } else {
126
133
  subject.addVariableStatement({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n ClassDeclaration,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ModuleDeclaration,\n Project,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport {\n ApiDefinitions,\n ApiObject,\n CheckListItem,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null,\n typeProvider: ReturnType<typeof createTypeProvider> | null,\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n if (!typeProvider) {\n throw new Error('Type provider is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n\n const globalNamespace = definitions.global;\n\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n generateNamespace(globalNamespace, typeFile, typeProvider, '');\n\n writeFileSync(\n path,\n typeFile.getFullText().replace('*/', '*/\\n'),\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n\nconst generateNamespace = (\n apiObject: ApiObject,\n incomingSubject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>,\n namespace: string,\n name?: string,\n) => {\n let subject = incomingSubject;\n const fullNamespaceName = [namespace, name].filter(Boolean).join('.');\n\n if (name) {\n subject = incomingSubject.addModule({\n name,\n });\n }\n\n if (name === 'playdate') {\n subject.addStatements(typeProvider.getStatements());\n }\n\n for (const constant of typeProvider.getConstants(fullNamespaceName)) {\n subject.addVariableStatement({\n declarations: [constant],\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n });\n }\n\n for (const func of apiObject.functions) {\n const isFunctionNameReserved = TypescriptReservedNamed.includes(\n func.name,\n );\n const resolvedName = `_${func.name}`;\n const parameters = typeProvider.getParameters(func);\n\n subject.addFunction({\n name: isFunctionNameReserved ? resolvedName : func.name,\n docs: [func.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(func),\n isExported: !!name,\n ...(typeProvider.getFunctionOverrideOptions(\n func,\n ) as FunctionDeclarationStructure),\n });\n\n if (isFunctionNameReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name: resolvedName,\n alias: func.name,\n },\n ],\n });\n }\n }\n\n let propertiesSubject: ClassDeclaration | null = null;\n\n if (name && apiObject.methods.length > 0) {\n const typeClass = incomingSubject.addClass({\n name,\n ...typeProvider.getClassOptions(fullNamespaceName),\n });\n propertiesSubject = typeClass;\n\n for (const method of apiObject.methods) {\n const parameters = typeProvider.getParameters(method);\n\n typeClass.addMethod({\n name: method.name,\n docs: [method.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(method),\n ...(typeProvider.getFunctionOverrideOptions(\n method,\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n }\n\n const dynamicProperties = typeProvider\n .getDynamicProperties(`${namespace}.${name}`)\n .map(\n dynamicProperty =>\n ({\n name: dynamicProperty.name,\n docs: dynamicProperty.docs,\n namespaces: namespace.split('.'),\n signature: `${namespace}.${name}.${dynamicProperty.name}`,\n } satisfies PropertyDescription),\n );\n\n for (const property of [...apiObject.properties, ...dynamicProperties]) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n\n if (propertiesSubject) {\n propertiesSubject.addProperty({\n name: property.name,\n docs: [property.docs],\n type: propertyDetails.type,\n isStatic: propertyDetails.isStatic,\n isReadonly: propertyDetails.isReadOnly,\n });\n } else {\n subject.addVariableStatement({\n docs: [property.docs],\n declarations: [\n {\n name: property.name,\n type: propertyDetails.type,\n },\n ],\n });\n }\n }\n\n for (const eachNamespace of Object.entries(apiObject.namespaces)) {\n generateNamespace(\n eachNamespace[1],\n subject,\n typeProvider,\n fullNamespaceName,\n eachNamespace[0],\n );\n }\n};\n"],"names":["writeFileSync","useMemo","Project","VariableDeclarationKind","TypescriptReservedNamed","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","globalNamespace","global","addStatements","getGlobalStatements","generateNamespace","getFullText","replace","ready","apiObject","incomingSubject","namespace","name","subject","fullNamespaceName","filter","Boolean","join","addModule","getStatements","constant","getConstants","addVariableStatement","declarations","isExported","declarationKind","Const","func","functions","isFunctionNameReserved","includes","resolvedName","parameters","getParameters","addFunction","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addExportDeclaration","namedExports","alias","propertiesSubject","methods","length","typeClass","addClass","getClassOptions","method","addMethod","dynamicProperties","getDynamicProperties","map","dynamicProperty","namespaces","split","signature","property","properties","propertyDetails","getPropertyDetails","addProperty","type","isStatic","isReadonly","isReadOnly","eachNamespace","Object","entries"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAKIC,OAAO,EAEPC,uBAAuB,QACpB,WAAW;AAElB,SAASC,uBAAuB,QAAQ,qBAAqB;AAQ7D,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBR,QAAQ;QAC7B,OAAO;YACHS,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACP,aAAa;oBACd,MAAM,IAAIQ,MAAM;gBACpB;gBAEA,IAAI,CAACP,cAAc;oBACf,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAId;gBACpB,MAAMe,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBAEA,MAAMC,kBAAkBb,YAAYc,MAAM;gBAE1CJ,SAASK,aAAa,CAACd,aAAae,mBAAmB;gBAEvDC,kBAAkBJ,iBAAiBH,UAAUT,cAAc;gBAE3DR,cACIM,MACAW,SAASQ,WAAW,GAAGC,OAAO,CAAC,MAAM;YAE7C;YACAC,OAAOpB,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ;AACJ,EAAE;AAEF,MAAMe,oBAAoB,CACtBI,WACAC,iBACArB,cACAsB,WACAC;IAEA,IAAIC,UAAUH;IACd,MAAMI,oBAAoB;QAACH;QAAWC;KAAK,CAACG,MAAM,CA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B;AACJ"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n ClassDeclaration,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ModuleDeclaration,\n ModuleDeclarationKind,\n Project,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport {\n ApiDefinitions,\n ApiObject,\n CheckListItem,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null,\n typeProvider: ReturnType<typeof createTypeProvider> | null,\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n if (!typeProvider) {\n throw new Error('Type provider is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n\n const globalNamespace = definitions.global;\n\n typeFile.addStatements(typeProvider.getGlobalStatements());\n const globalModule = typeFile.addModule({\n name: 'global',\n hasDeclareKeyword: true,\n declarationKind: ModuleDeclarationKind.Global,\n });\n\n generateNamespace(\n globalNamespace,\n globalModule,\n typeProvider,\n '',\n );\n\n writeFileSync(\n path,\n typeFile.getFullText().replace('*/', '*/\\n'),\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n\nconst generateNamespace = (\n apiObject: ApiObject,\n incomingSubject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>,\n namespace: string,\n name?: string,\n) => {\n let subject = incomingSubject;\n const fullNamespaceName = [namespace, name].filter(Boolean).join('.');\n\n if (name) {\n subject = incomingSubject.addModule({\n name,\n });\n }\n\n if (name === 'playdate') {\n subject.addStatements(typeProvider.getStatements());\n }\n\n for (const constant of typeProvider.getConstants(fullNamespaceName)) {\n subject.addVariableStatement({\n declarations: [constant],\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n });\n }\n\n for (const func of apiObject.functions) {\n const isFunctionNameReserved = TypescriptReservedNamed.includes(\n func.name,\n );\n const resolvedName = `_${func.name}`;\n const parameters = typeProvider.getParameters(func);\n\n subject.addFunction({\n name: isFunctionNameReserved ? resolvedName : func.name,\n docs: [func.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(func),\n isExported: !!name,\n ...(typeProvider.getFunctionOverrideOptions(\n func,\n ) as FunctionDeclarationStructure),\n });\n\n if (isFunctionNameReserved) {\n subject.addExportDeclaration({\n leadingTrivia: '/** @ts-ignore */\\n',\n namedExports: [\n {\n name: resolvedName,\n alias: func.name,\n },\n ],\n });\n }\n }\n\n let propertiesSubject: ClassDeclaration | null = null;\n\n if (name && apiObject.methods.length > 0) {\n const typeClass = incomingSubject.addClass({\n name,\n isExported: true,\n ...typeProvider.getClassOptions(fullNamespaceName),\n });\n propertiesSubject = typeClass;\n\n for (const method of apiObject.methods) {\n const parameters = typeProvider.getParameters(method);\n\n typeClass.addMethod({\n name: method.name,\n docs: [method.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(method),\n ...(typeProvider.getFunctionOverrideOptions(\n method,\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n }\n\n const dynamicProperties = typeProvider\n .getDynamicProperties(`${namespace}.${name}`)\n .map(\n dynamicProperty =>\n ({\n name: dynamicProperty.name,\n docs: dynamicProperty.docs,\n namespaces: namespace.split('.'),\n signature: `${namespace}.${name}.${dynamicProperty.name}`,\n } satisfies PropertyDescription),\n );\n\n for (const property of [...apiObject.properties, ...dynamicProperties]) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n\n if (propertiesSubject) {\n propertiesSubject.addProperty({\n name: property.name,\n docs: [property.docs],\n type: propertyDetails.type,\n isStatic: propertyDetails.isStatic,\n isReadonly: propertyDetails.isReadonly,\n });\n } else {\n subject.addVariableStatement({\n docs: [property.docs],\n declarations: [\n {\n name: property.name,\n type: propertyDetails.type,\n },\n ],\n });\n }\n }\n\n for (const eachNamespace of Object.entries(apiObject.namespaces)) {\n generateNamespace(\n eachNamespace[1],\n subject,\n typeProvider,\n fullNamespaceName,\n eachNamespace[0],\n );\n }\n};\n"],"names":["writeFileSync","useMemo","ModuleDeclarationKind","Project","VariableDeclarationKind","TypescriptReservedNamed","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","globalNamespace","global","addStatements","getGlobalStatements","globalModule","addModule","name","hasDeclareKeyword","declarationKind","Global","generateNamespace","getFullText","replace","ready","apiObject","incomingSubject","namespace","subject","fullNamespaceName","filter","Boolean","join","getStatements","constant","getConstants","addVariableStatement","declarations","isExported","Const","func","functions","isFunctionNameReserved","includes","resolvedName","parameters","getParameters","addFunction","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addExportDeclaration","leadingTrivia","namedExports","alias","propertiesSubject","methods","length","typeClass","addClass","getClassOptions","method","addMethod","dynamicProperties","getDynamicProperties","map","dynamicProperty","namespaces","split","signature","property","properties","propertyDetails","getPropertyDetails","addProperty","type","isStatic","isReadonly","eachNamespace","Object","entries"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAKIC,qBAAqB,E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BAAoBjE,aACrBkE,oBAAoB,CAAC,CAAC,EAAEtC,UAAU,CAAC,EAAEV,KAAK,CAAC,EAC3CiD,GAAG,CACAC,CAAAA,kBACK,CAAA;YACGlD,MAAMkD,gBAAgBlD,IAAI;YAC1B+B,MAAMmB,gBAAgBnB,IAAI;YAC1BoB,YAAYzC,UAAU0C,KAAK,CAAC;YAC5BC,WAAW,CAAC,EAAE3C,UAAU,CAAC,EAAEV,KAAK,CAAC,EAAEkD,gBAAgBlD,IAAI,CAAC,CAAC;QAC7D,CAAA;IAGZ,KAAK,MAAMsD,YAAY;WAAI9C,UAAU+C,UAAU;WAAKR;KAAkB,CAAE;QACpE,MAAMS,kBAAkB1E,aAAa2E,kBAAkB,CAACH;QAExD,IAAIf,mBAAmB;YACnBA,kBAAkBmB,WAAW,CAAC;gBAC1B1D,MAAMsD,SAAStD,IAAI;gBACnB+B,MAAM;oBAACuB,SAASvB,IAAI;iBAAC;gBACrB4B,MAAMH,gBAAgBG,IAAI;gBAC1BC,UAAUJ,gBAAgBI,QAAQ;gBAClCC,YAAYL,gBAAgBK,UAAU;YAC1C;QACJ,OAAO;YACHlD,QAAQQ,oBAAoB,CAAC;gBACzBY,MAAM;oBAACuB,SAASvB,IAAI;iBAAC;gBACrBX,cAAc;oBACV;wBACIpB,MAAMsD,SAAStD,IAAI;wBACnB2D,MAAMH,gBAAgBG,IAAI;oBAC9B;iBACH;YACL;QACJ;IACJ;IAEA,KAAK,MAAMG,iBAAiBC,OAAOC,OAAO,CAACxD,UAAU2C,UAAU,EAAG;QAC9D/C,kBACI0D,aAAa,CAAC,EAAE,EAChBnD,SACA7B,cACA8B,mBACAkD,aAAa,CAAC,EAAE;IAExB;AACJ"}
@@ -5,9 +5,9 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
5
5
  waitingDescription: string;
6
6
  runningDescription: string;
7
7
  errorDescription: string;
8
- finishedDescription: (result: string) => string;
8
+ finishedDescription: (result: string | false) => string;
9
9
  runner: () => Promise<string>;
10
- onFinish: (result: string) => void;
10
+ onFinish: (result: string | false) => void;
11
11
  };
12
12
  typeProvider: {
13
13
  getGlobalStatements: () => string[];
@@ -15,44 +15,14 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
15
15
  getClassOptions: (className: string) => Partial<import("ts-morph").ClassDeclarationStructure>;
16
16
  getPropertyDetails: (property: import("../../../types.js").PropertyDescription) => import("../../../types.js").PropertyDetails;
17
17
  getDynamicProperties: (namespace: string) => Pick<import("../../../types.js").PropertyDescription, "name" | "docs">[];
18
- getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
19
- getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
20
- getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").FunctionDeclarationStructure["parameters"];
21
- getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure> | Partial<import("ts-morph").MethodDeclarationStructure> | {
22
- overloads: ({
23
- docs: string[];
24
- leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
25
- trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
26
- hasQuestionToken?: boolean | undefined;
27
- scope?: import("ts-morph").Scope | undefined;
28
- hasOverrideKeyword?: boolean | undefined;
29
- parameters?: import("ts-morph").OptionalKind<import("ts-morph").ParameterDeclarationStructure>[] | undefined;
30
- typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
31
- isAbstract?: boolean | undefined;
32
- returnType?: (string | import("ts-morph").WriterFunction) | undefined;
33
- isAsync?: boolean | undefined;
34
- isGenerator?: boolean | undefined;
35
- isStatic?: boolean | undefined;
36
- kind?: import("ts-morph").StructureKind.MethodOverload | undefined;
37
- } | {
38
- docs: string[];
39
- leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
40
- trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
41
- parameters?: import("ts-morph").OptionalKind<import("ts-morph").ParameterDeclarationStructure>[] | undefined;
42
- typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
43
- hasDeclareKeyword?: boolean | undefined;
44
- isExported?: boolean | undefined;
45
- isDefaultExport?: boolean | undefined;
46
- returnType?: (string | import("ts-morph").WriterFunction) | undefined;
47
- isAsync?: boolean | undefined;
48
- isGenerator?: boolean | undefined;
49
- kind?: import("ts-morph").StructureKind.FunctionOverload | undefined;
50
- })[];
51
- };
18
+ getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string | import("ts-morph").WriterFunction | undefined;
19
+ getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("ts-morph").ParameterDeclarationStructure;
20
+ getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").ParameterDeclarationStructure[];
21
+ getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
52
22
  getConstants: (fullNamespace: string) => {
53
23
  kind: import("ts-morph").StructureKind.VariableDeclaration;
54
24
  name: string;
55
- type: string;
25
+ type: string | import("ts-morph").WriterFunction | undefined;
56
26
  }[];
57
27
  save: () => void;
58
28
  } | null;
@@ -38,7 +38,7 @@ export const useGetVersion = (version)=>{
38
38
  return versionLiteral;
39
39
  },
40
40
  onFinish: (result)=>{
41
- setResult(result);
41
+ setResult(result === false ? null : result);
42
42
  }
43
43
  };
44
44
  }, []);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport {\n CheckListItem,\n PlaydateSdkVersion,\n PlaydateSdkVersionIdentifier,\n} from '@/cli/types.js';\n\nexport const useGetVersion = (version: PlaydateSdkVersion) => {\n const [typeProvider, setTypeProvider] = useState<ReturnType<\n typeof createTypeProvider\n > | null>(null);\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: result => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n setTypeProvider(createTypeProvider(versionLiteral));\n\n return versionLiteral;\n },\n onFinish: result => {\n setResult(result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n typeProvider,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","createTypeProvider","PlaydateSdkVersionIdentifier","useGetVersion","version","typeProvider","setTypeProvider","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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C,UAAUD;YACd;QACJ;IACJ,GAAG,EAAE;IAEL,OAAO;QACHqB,gBAAgBrB;QAChBY;QACAd;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport {\n CheckListItem,\n PlaydateSdkVersion,\n PlaydateSdkVersionIdentifier,\n} from '@/cli/types.js';\n\nexport const useGetVersion = (version: PlaydateSdkVersion) => {\n const [typeProvider, setTypeProvider] = useState<ReturnType<\n typeof createTypeProvider\n > | null>(null);\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: result => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n setTypeProvider(createTypeProvider(versionLiteral));\n\n return versionLiteral;\n },\n onFinish: result => {\n setResult(result === false ? null : result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n typeProvider,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","createTypeProvider","PlaydateSdkVersionIdentifier","useGetVersion","version","typeProvider","setTypeProvider","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACvD,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAASC,kBAAkB,QAAQ,2DAA2D;AAC9F,SAGIC,4BAA4B,QACzB,iBAAiB;AAExB,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,MAAM,CAACC,cAAcC,gBAAgB,GAAGP,SAE9B;IACV,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAwB;IACpD,MAAMU,mBAAmBZ,YAAY;QACjC,MAAMa,WAAW,MAAMC,MAAMX;QAC7B,MAAMY,MAAMF,SAASE,GAAG;QAExB,MAAMC,QAAQ;QACd,MAAMC,QAAQF,IAAIE,KAAK,CAACD;QAExB,IAAI,CAACC,SAASA,MAAMC,MAAM,GAAG,GAAG;YAC5B,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOF,KAAK,CAAC,EAAE;IACnB,GAAG,EAAE;IACL,MAAMG,kBAAkBpB,YAAY,OAAOO;QACvC,MAAMM,WAAW,MAAMC,MAAM,CAAC,sBAAsB,EAAEP,QAAQ,CAAC,CAAC;QAEhE,IAAI,CAACM,SAASQ,EAAE,EAAE;YACd,MAAM,IAAIF,MAAM,CAAC,wBAAwB,EAAEZ,QAAQ,CAAC;QACxD;QAEA,OAAO;IACX,GAAG,EAAE;IAEL,MAAMe,aAAarB,QAAQ;QACvB,OAAO;YACHsB,oBAAoB,CAAC,wBAAwB,CAAC;YAC9CC,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqBhB,CAAAA,SAAU,CAAC,gBAAgB,EAAEA,OAAO,CAAC;YAC1DiB,QAAQ;gBACJ,IAAIC,iBAAiBrB;gBAErB,IAAIA,YAAYF,6BAA6BwB,MAAM,EAAE;oBACjDD,iBAAiB,MAAMhB;gBAC3B;gBAEA,MAAMQ,gBAAgBQ;gBAEtBnB,gBAAgBL,mBAAmBwB;gBAEnC,OAAOA;YACX;YACAE,UAAUpB,CAAAA;gBACNC,UAAUD,WAAW,QAAQ,OAAOA;YACxC;QACJ;IACJ,GAAG,EAAE;IAEL,OAAO;QACHqB,gBAAgBrB;QAChBY;QACAd;IACJ;AACJ,EAAE"}
@@ -7,7 +7,7 @@ export declare const useParseDocumentation: (html: string | null, version: strin
7
7
  finishedDescription: () => string;
8
8
  runningDescription: string;
9
9
  runner: () => Promise<ApiDefinitions>;
10
- onFinish: (result: ApiDefinitions) => void;
10
+ onFinish: (result: false | ApiDefinitions) => void;
11
11
  ready: boolean;
12
12
  };
13
13
  };
@@ -18,7 +18,7 @@ export const useParseDocumentation = (html, version)=>{
18
18
  return getApiDefinitions(functions, properties, getFunctionTypeOverride(version));
19
19
  },
20
20
  onFinish: (result)=>{
21
- setResult(result);
21
+ setResult(result === false ? null : result);
22
22
  },
23
23
  ready: html !== null
24
24
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport { getDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getDescriptionsFromHtml.js';\nimport { getFunctionTypeOverride } from '@/cli/commands/GenerateTypes/fn/getFunctionTypeOverride.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useParseDocumentation = (html: string | null, version: string) => {\n const [result, setResult] = useState<ApiDefinitions | null>(null);\n\n const parseDocumentation = useMemo(() => {\n return {\n waitingDescription: 'Waiting to parse the documentation...',\n errorDescription: 'Failed to parse the documentation',\n finishedDescription: () => 'Documentation parsed',\n runningDescription: 'Parsing the documentation...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const { functions, properties } = getDescriptionsFromHtml(\n html,\n version,\n );\n\n return getApiDefinitions(\n functions,\n properties,\n getFunctionTypeOverride(version),\n );\n },\n onFinish: result => {\n setResult(result);\n },\n ready: html !== null,\n } satisfies CheckListItem<ApiDefinitions>;\n }, [html]);\n\n return {\n definitions: result,\n parseDocumentation,\n };\n};\n"],"names":["useMemo","useState","getApiDefinitions","getDescriptionsFromHtml","getFunctionTypeOverride","useParseDocumentation","html","version","result","setResult","parseDocumentation","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","functions","properties","onFinish","ready","definitions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAASC,uBAAuB,QAAQ,6DAA6D;AACrG,SAASC,uBAAuB,QAAQ,6DAA6D;AAGrG,OAAO,MAAMC,wBAAwB,CAACC,MAAqBC;IACvD,MAAM,CAACC,QAAQC,UAAU,GAAGR,SAAgC;IAE5D,MAAMS,qBAAqBV,QAAQ;QAC/B,OAAO;YACHW,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACT,MAAM;oBACP,MAAM,IAAIU,MAAM;gBACpB;gBAEA,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGf,wBAC9BG,MACAC;gBAGJ,OAAOL,kBACHe,WACAC,YACAd,wBAAwBG;YAEhC;YACAY,UAAUX,CAAAA;gBACNC,UAAUD;YACd;YACAY,OAAOd,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHe,aAAab;QACbE;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport { getDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getDescriptionsFromHtml.js';\nimport { getFunctionTypeOverride } from '@/cli/commands/GenerateTypes/fn/getFunctionTypeOverride.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useParseDocumentation = (html: string | null, version: string) => {\n const [result, setResult] = useState<ApiDefinitions | null>(null);\n\n const parseDocumentation = useMemo(() => {\n return {\n waitingDescription: 'Waiting to parse the documentation...',\n errorDescription: 'Failed to parse the documentation',\n finishedDescription: () => 'Documentation parsed',\n runningDescription: 'Parsing the documentation...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const { functions, properties } = getDescriptionsFromHtml(\n html,\n version,\n );\n\n return getApiDefinitions(\n functions,\n properties,\n getFunctionTypeOverride(version),\n );\n },\n onFinish: result => {\n setResult(result === false ? null : result);\n },\n ready: html !== null,\n } satisfies CheckListItem<ApiDefinitions>;\n }, [html]);\n\n return {\n definitions: result,\n parseDocumentation,\n };\n};\n"],"names":["useMemo","useState","getApiDefinitions","getDescriptionsFromHtml","getFunctionTypeOverride","useParseDocumentation","html","version","result","setResult","parseDocumentation","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","functions","properties","onFinish","ready","definitions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAASC,uBAAuB,QAAQ,6DAA6D;AACrG,SAASC,uBAAuB,QAAQ,6DAA6D;AAGrG,OAAO,MAAMC,wBAAwB,CAACC,MAAqBC;IACvD,MAAM,CAACC,QAAQC,UAAU,GAAGR,SAAgC;IAE5D,MAAMS,qBAAqBV,QAAQ;QAC/B,OAAO;YACHW,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACT,MAAM;oBACP,MAAM,IAAIU,MAAM;gBACpB;gBAEA,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGf,wBAC9BG,MACAC;gBAGJ,OAAOL,kBACHe,WACAC,YACAd,wBAAwBG;YAEhC;YACAY,UAAUX,CAAAA;gBACNC,UAAUD,WAAW,QAAQ,OAAOA;YACxC;YACAY,OAAOd,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHe,aAAab;QACbE;IACJ;AACJ,EAAE"}
@@ -0,0 +1,12 @@
1
+ import { ClassDeclarationStructure, PropertyDeclarationStructure } from 'ts-morph';
2
+ export type ClassDefinition = Partial<ClassDeclarationStructure>;
3
+ export type PropertyDefinition = {
4
+ signature: string;
5
+ definition: Partial<PropertyDeclarationStructure>;
6
+ };
7
+ export type VersionDefinition = {
8
+ globalStatements: string[];
9
+ constants: Record<string, string[]>;
10
+ statements: string[];
11
+ classes: Record<string, ClassDefinition>;
12
+ };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/types.ts"],"sourcesContent":["import {\n ClassDeclarationStructure,\n PropertyDeclarationStructure,\n} from 'ts-morph';\n\nexport type ClassDefinition = Partial<ClassDeclarationStructure>;\n\nexport type PropertyDefinition = {\n signature: string;\n definition: Partial<PropertyDeclarationStructure>;\n};\n\nexport type VersionDefinition = {\n globalStatements: string[];\n constants: Record<string, string[]>;\n statements: string[];\n classes: Record<string, ClassDefinition>;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAYA,WAKE"}
@@ -1,49 +1,19 @@
1
- import { FunctionDeclarationStructure, ParameterDeclarationStructure, StructureKind } from 'ts-morph';
2
- import { FunctionDescription, ParameterDetails, PropertyDescription, PropertyDetails } from '../../../types.js';
1
+ import { ParameterDeclarationStructure, StructureKind, FunctionDeclarationStructure, MethodDeclarationStructure } from 'ts-morph';
2
+ import { FunctionDescription, PropertyDescription, PropertyDetails } from '../../../types.js';
3
3
  export declare const createTypeProvider: (version: string) => {
4
4
  getGlobalStatements: () => string[];
5
5
  getStatements: () => string[];
6
6
  getClassOptions: (className: string) => Partial<import("ts-morph").ClassDeclarationStructure>;
7
7
  getPropertyDetails: (property: PropertyDescription) => PropertyDetails;
8
8
  getDynamicProperties: (namespace: string) => Pick<PropertyDescription, "name" | "docs">[];
9
- getFunctionReturnType: (func: FunctionDescription) => string;
10
- getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
11
- getParameters: (func: FunctionDescription) => FunctionDeclarationStructure["parameters"];
12
- getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure> | Partial<import("ts-morph").MethodDeclarationStructure> | {
13
- overloads: ({
14
- docs: string[];
15
- leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
16
- trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
17
- hasQuestionToken?: boolean | undefined;
18
- scope?: import("ts-morph").Scope | undefined;
19
- hasOverrideKeyword?: boolean | undefined;
20
- parameters?: import("ts-morph").OptionalKind<ParameterDeclarationStructure>[] | undefined;
21
- typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
22
- isAbstract?: boolean | undefined;
23
- returnType?: (string | import("ts-morph").WriterFunction) | undefined;
24
- isAsync?: boolean | undefined;
25
- isGenerator?: boolean | undefined;
26
- isStatic?: boolean | undefined;
27
- kind?: StructureKind.MethodOverload | undefined;
28
- } | {
29
- docs: string[];
30
- leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
31
- trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
32
- parameters?: import("ts-morph").OptionalKind<ParameterDeclarationStructure>[] | undefined;
33
- typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
34
- hasDeclareKeyword?: boolean | undefined;
35
- isExported?: boolean | undefined;
36
- isDefaultExport?: boolean | undefined;
37
- returnType?: (string | import("ts-morph").WriterFunction) | undefined;
38
- isAsync?: boolean | undefined;
39
- isGenerator?: boolean | undefined;
40
- kind?: StructureKind.FunctionOverload | undefined;
41
- })[];
42
- };
9
+ getFunctionReturnType: (func: FunctionDescription) => string | import("ts-morph").WriterFunction | undefined;
10
+ getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDeclarationStructure;
11
+ getParameters: (func: FunctionDescription) => ParameterDeclarationStructure[];
12
+ getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | MethodDeclarationStructure>;
43
13
  getConstants: (fullNamespace: string) => {
44
14
  kind: StructureKind.VariableDeclaration;
45
15
  name: string;
46
- type: string;
16
+ type: string | import("ts-morph").WriterFunction | undefined;
47
17
  }[];
48
18
  save: () => void;
49
19
  };