crankscript 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crankscript",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "scripts": {
5
5
  "dev": "tsx src/index.ts",
6
6
  "post-build": "tsc-alias --project tsconfig.json"
@@ -1,4 +1,4 @@
1
- import { InterfaceDeclaration, ModuleDeclaration, SourceFile } from 'ts-morph';
1
+ import { ClassDeclaration, ModuleDeclaration, SourceFile } from 'ts-morph';
2
2
  import { createTypeProvider } from '../../../commands/GenerateTypes/utils/createTypeProvider.js';
3
3
  import { PlaydateNamespace, PlaydateType } from '../../../types.js';
4
- export declare const generateNamespace: (namespaceDescription: PlaydateNamespace, namespaces: string[], subjects: Map<string, SourceFile | ModuleDeclaration>, typeSubjects: Map<string, InterfaceDeclaration>, typeProvider: ReturnType<typeof createTypeProvider>, types: Record<string, PlaydateType>) => void;
4
+ export declare const generateNamespace: (namespaceDescription: PlaydateNamespace, namespaces: string[], subjects: Map<string, SourceFile | ModuleDeclaration>, typeSubjects: Map<string, ClassDeclaration>, typeProvider: ReturnType<typeof createTypeProvider>, types: Record<string, PlaydateType>) => void;
@@ -5,22 +5,22 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
5
5
  const subjectName = namespaces.slice(0, -1).join('.');
6
6
  const namespaceName = namespaces[namespaces.length - 1];
7
7
  const isRoot = namespaces.length === 1 && namespaces[0] === 'playdate';
8
- const subject = namespaces.length === 1 ? subjects.get('root') : subjects.get(subjectName);
8
+ const subject = namespaces.length <= 1 ? subjects.get('root') : subjects.get(subjectName);
9
9
  if (!subject) {
10
10
  return;
11
11
  }
12
- const module = subject.addModule({
12
+ const module = namespaces.length > 0 ? subject.addModule({
13
13
  name: namespaceName
14
- });
14
+ }) : subject;
15
15
  const addMethods = (typeName, subj, methods)=>{
16
16
  const interfaceName = typeName.split('.').map((name)=>name[0].toUpperCase() + name.slice(1)).join('');
17
- const typeInterface = subj.addInterface({
17
+ const typeClass = subj.addClass({
18
18
  name: interfaceName
19
19
  });
20
- typeSubjects.set(typeName, typeInterface);
20
+ typeSubjects.set(typeName, typeClass);
21
21
  for (const func of methods){
22
22
  const parameters = typeProvider.getParameters(func);
23
- typeInterface.addMethod(_extends({
23
+ typeClass.addMethod(_extends({
24
24
  name: func.name,
25
25
  docs: [
26
26
  func.docs
@@ -30,7 +30,7 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
30
30
  }, typeProvider.getFunctionOverrideOptions(func)));
31
31
  }
32
32
  };
33
- if (isRoot) {
33
+ if (isRoot && 'addJsDoc' in module) {
34
34
  module.addJsDoc({
35
35
  description: 'Playdate SDK'
36
36
  });
@@ -39,7 +39,9 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
39
39
  addMethods(eachType, module, types[eachType].methods);
40
40
  });
41
41
  }
42
- subjects.set(namespaces.join('.'), module);
42
+ if (namespaces.length > 0) {
43
+ subjects.set(namespaces.join('.'), module);
44
+ }
43
45
  if (namespaceDescription.methods.length > 0) {
44
46
  addMethods(namespaces.join('.'), subjects.get('playdate'), namespaceDescription.methods);
45
47
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateNamespace.ts"],"sourcesContent":["import {\n InterfaceDeclaration,\n MethodSignatureStructure,\n ModuleDeclaration,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph';\nimport { generateFunction } from '@/cli/commands/GenerateTypes/fn/generateFunction.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport {\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n} from '@/cli/types.js';\n\nexport const generateNamespace = (\n namespaceDescription: PlaydateNamespace,\n namespaces: string[],\n subjects: Map<string, SourceFile | ModuleDeclaration>,\n typeSubjects: Map<string, InterfaceDeclaration>,\n typeProvider: ReturnType<typeof createTypeProvider>,\n types: Record<string, PlaydateType>\n) => {\n const subjectName = namespaces.slice(0, -1).join('.');\n const namespaceName = namespaces[namespaces.length - 1];\n const isRoot = namespaces.length === 1 && namespaces[0] === 'playdate';\n const subject =\n namespaces.length === 1\n ? subjects.get('root')\n : subjects.get(subjectName);\n\n if (!subject) {\n return;\n }\n\n const module = subject.addModule({\n name: namespaceName,\n });\n\n const addMethods = (\n typeName: string,\n subj: ModuleDeclaration,\n methods: FunctionDescription[]\n ) => {\n const interfaceName = typeName\n .split('.')\n .map((name) => name[0].toUpperCase() + name.slice(1))\n .join('');\n const typeInterface = subj.addInterface({\n name: interfaceName,\n });\n typeSubjects.set(typeName, typeInterface);\n\n for (const func of methods) {\n const parameters = typeProvider.getParameters(func);\n\n typeInterface.addMethod({\n name: func.name,\n docs: [func.docs],\n returnType: typeProvider.getFunctionReturnType(func),\n parameters,\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as Partial<MethodSignatureStructure>),\n });\n }\n };\n\n if (isRoot) {\n module.addJsDoc({\n description: 'Playdate SDK',\n });\n module.addStatements(typeProvider.getStatements());\n\n Object.keys(types).forEach((eachType) => {\n addMethods(eachType, module, types[eachType].methods);\n });\n }\n\n subjects.set(namespaces.join('.'), module);\n\n if (namespaceDescription.methods.length > 0) {\n addMethods(\n namespaces.join('.'),\n subjects.get('playdate') as ModuleDeclaration,\n namespaceDescription.methods\n );\n }\n\n for (const property of namespaceDescription.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n if (!propertyDetails.isStatic) {\n const typeName = namespaces.join('.');\n\n if (typeSubjects.has(typeName)) {\n const typeInterface = typeSubjects.get(\n typeName\n ) as InterfaceDeclaration;\n\n typeInterface.addProperty({\n name: property.name,\n type: propertyDetails.type,\n docs: [property.docs],\n isReadonly: propertyDetails.isReadOnly,\n });\n }\n\n continue;\n }\n\n const propertyType = propertyDetails.type;\n\n module.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: property.name,\n type: propertyType,\n },\n ],\n });\n }\n\n for (const func of namespaceDescription.functions) {\n generateFunction(func, module, typeProvider);\n }\n};\n"],"names":["VariableDeclarationKind","generateFunction","generateNamespace","namespaceDescription","namespaces","subjects","typeSubjects","typeProvider","types","subjectName","slice","join","namespaceName","length","isRoot","subject","get","module","addModule","name","addMethods","typeName","subj","methods","interfaceName","split","map","toUpperCase","typeInterface","addInterface","set","func","parameters","getParameters","addMethod","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addJsDoc","description","addStatements","getStatements","Object","keys","forEach","eachType","property","properties","propertyDetails","getPropertyDetails","isStatic","has","addProperty","type","isReadonly","isReadOnly","propertyType","addVariableStatement","isExported","declarationKind","Const","declarations","functions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAKIA,uBAAuB,QACpB,WAAW;AAClB,SAASC,gBAAgB,QAAQ,sDAAsD;AAQvF,OAAO,MAAMC,oBAAoB,CAC7BC,sBACAC,YACAC,UACAC,cACAC,cACAC;IAEA,MAAMC,cAAcL,WAAWM,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;IACjD,MAAMC,gBAAgBR,UAAU,CAACA,WAAWS,MAAM,GAAG,EAAE;IACvD,MAAMC,SAASV,WAAWS,MAAM,KAAK,KAAKT,UAAU,CAAC,EAAE,KAAK;IAC5D,MAAMW,UACFX,WAAWS,MAAM,KAAK,IAChBR,SAASW,GAAG,CAAC,UACbX,SAASW,GAAG,CAACP;IAEvB,IAAI,CAACM,SAAS;QACV;IACJ;IAEA,MAAME,SAASF,QAAQG,SAAS,CAAC;QAC7BC,MAAMP;IACV;IAEA,MAAMQ,aAAa,CACfC,UACAC,MACAC;QAEA,MAAMC,gBAAgBH,SACjBI,KAAK,CAAC,KACNC,GAAG,CAAC,CAACP,OAAS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AML,gBAAgBK,IAAI;oBAC1BnB,MAAM;wBAACY,SAASZ,IAAI;qBAAC;oBACrBoB,YAAYN,gBAAgBO,UAAU;gBAC1C;YACJ;YAEA;QACJ;QAEA,MAAMC,eAAeR,gBAAgBK,IAAI;QAEzCrC,OAAOyC,oBAAoB,CAAC;YACxBC,YAAY;YACZC,iBAAiB5D,wBAAwB6D,KAAK;YAC9CC,cAAc;gBACV;oBACI3C,MAAM4B,SAAS5B,IAAI;oBACnBmC,MAAMG;gBACV;aACH;QACL;IACJ;IAEA,KAAK,MAAM1B,QAAQ5B,qBAAqB4D,SAAS,CAAE;QAC/C9D,iBAAiB8B,MAAMd,QAAQV;IACnC;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateNamespace.ts"],"sourcesContent":["import {\n ClassDeclaration,\n MethodDeclarationStructure,\n ModuleDeclaration,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph';\nimport { generateFunction } from '@/cli/commands/GenerateTypes/fn/generateFunction.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport {\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n} from '@/cli/types.js';\n\nexport const generateNamespace = (\n namespaceDescription: PlaydateNamespace,\n namespaces: string[],\n subjects: Map<string, SourceFile | ModuleDeclaration>,\n typeSubjects: Map<string, ClassDeclaration>,\n typeProvider: ReturnType<typeof createTypeProvider>,\n types: Record<string, PlaydateType>\n) => {\n const subjectName = namespaces.slice(0, -1).join('.');\n const namespaceName = namespaces[namespaces.length - 1];\n const isRoot = namespaces.length === 1 && namespaces[0] === 'playdate';\n const subject =\n namespaces.length <= 1\n ? subjects.get('root')\n : subjects.get(subjectName);\n\n if (!subject) {\n return;\n }\n\n const module =\n namespaces.length > 0\n ? subject.addModule({\n name: namespaceName,\n })\n : subject;\n\n const addMethods = (\n typeName: string,\n subj: ModuleDeclaration,\n methods: FunctionDescription[]\n ) => {\n const interfaceName = typeName\n .split('.')\n .map((name) => name[0].toUpperCase() + name.slice(1))\n .join('');\n const typeClass = subj.addClass({\n name: interfaceName,\n });\n typeSubjects.set(typeName, typeClass);\n\n for (const func of methods) {\n const parameters = typeProvider.getParameters(func);\n\n typeClass.addMethod({\n name: func.name,\n docs: [func.docs],\n returnType: typeProvider.getFunctionReturnType(func),\n parameters,\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n };\n\n if (isRoot && 'addJsDoc' in module) {\n module.addJsDoc({\n description: 'Playdate SDK',\n });\n module.addStatements(typeProvider.getStatements());\n\n Object.keys(types).forEach((eachType) => {\n addMethods(eachType, module, types[eachType].methods);\n });\n }\n\n if (namespaces.length > 0) {\n subjects.set(namespaces.join('.'), module);\n }\n\n if (namespaceDescription.methods.length > 0) {\n addMethods(\n namespaces.join('.'),\n subjects.get('playdate') as ModuleDeclaration,\n namespaceDescription.methods\n );\n }\n\n for (const property of namespaceDescription.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n if (!propertyDetails.isStatic) {\n const typeName = namespaces.join('.');\n\n if (typeSubjects.has(typeName)) {\n const typeInterface = typeSubjects.get(\n typeName\n ) as ClassDeclaration;\n\n typeInterface.addProperty({\n name: property.name,\n type: propertyDetails.type,\n docs: [property.docs],\n isReadonly: propertyDetails.isReadOnly,\n });\n }\n\n continue;\n }\n\n const propertyType = propertyDetails.type;\n\n module.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: property.name,\n type: propertyType,\n },\n ],\n });\n }\n\n for (const func of namespaceDescription.functions) {\n generateFunction(func, module, typeProvider);\n }\n};\n"],"names":["VariableDeclarationKind","generateFunction","generateNamespace","namespaceDescription","namespaces","subjects","typeSubjects","typeProvider","types","subjectName","slice","join","namespaceName","length","isRoot","subject","get","module","addModule","name","addMethods","typeName","subj","methods","interfaceName","split","map","toUpperCase","typeClass","addClass","set","func","parameters","getParameters","addMethod","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addJsDoc","description","addStatements","getStatements","Object","keys","forEach","eachType","property","properties","propertyDetails","getPropertyDetails","isStatic","has","typeInterface","addProperty","type","isReadonly","isReadOnly","propertyType","addVariableStatement","isExported","declarationKind","Const","declarations","functions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAKIA,uBAAuB,QACpB,WAAW;AAClB,SAASC,gBAAgB,QAAQ,sDAAsD;AAQvF,OAAO,MAAMC,oBAAoB,CAC7BC,sBACAC,YACAC,UACAC,cACAC,cACAC;IAEA,MAAMC,cAAcL,WAAWM,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;IACjD,MAAMC,gBAAgBR,UAAU,CAACA,WAAWS,MAAM,GAAG,EAAE;IACvD,MAAMC,SAASV,WAAWS,MAAM,KAAK,KAAKT,UAAU,CAAC,EAAE,KAAK;IAC5D,MAAMW,UACFX,WAAWS,MAAM,IAAI,IACfR,SAASW,GAAG,CAAC,UACbX,SAASW,GAAG,CAACP;IAEvB,IAAI,CAACM,SAAS;QACV;IACJ;IAEA,MAAME,SACFb,WAAWS,MAAM,GAAG,IACdE,QAAQG,SAAS,CAAC;QACdC,MAAMP;IACV,KACAG;IAEV,MAAMK,aAAa,CACfC,UACAC,MACAC;QAEA,MAAMC,gBAAgBH,SACjBI,KAAK,CAAC,KACNC,GAAG,CAAC,CAACP,OAASA,IAAI,CAAC,EAAE,CAACQ,WAAW,KAAKR,KAAKT,KAAK,CAAC,IACjDC,IAAI,CAAC;QACV,MAAMiB,YAAYN,KAAKO,QAAQ,CAAC;YAC5BV,MAAMK;QACV;QACAlB,aAAawB,GAAG,CAACT,UAAUO;QAE3B,KAAK,MAAMG,QAAQR,QAAS;YACxB,MAAMS,aAAazB,aAAa0B,aAAa,CAACF;YAE9CH,UAAUM,SAAS,CAA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AiB7D,wBAAwB8D,KAAK;YAC9CC,cAAc;gBACV;oBACI5C,MAAM4B,SAAS5B,IAAI;oBACnBoC,MAAMG;gBACV;aACH;QACL;IACJ;IAEA,KAAK,MAAM3B,QAAQ5B,qBAAqB6D,SAAS,CAAE;QAC/C/D,iBAAiB8B,MAAMd,QAAQV;IACnC;AACJ,EAAE"}
@@ -1,5 +1,6 @@
1
1
  import { FunctionDescription, PlaydateNamespace, PlaydateType, PropertyDescription } from '../../../types.js';
2
2
  export declare const getApiDefinitions: (functions: FunctionDescription[], properties: PropertyDescription[]) => {
3
+ rootNamespace: PlaydateNamespace;
3
4
  namespaces: Record<string, PlaydateNamespace>;
4
5
  types: Record<string, PlaydateType>;
5
6
  };
@@ -1,4 +1,9 @@
1
1
  export const getApiDefinitions = (functions, properties)=>{
2
+ const rootNamespace = {
3
+ functions: [],
4
+ methods: [],
5
+ properties: []
6
+ };
2
7
  const namespaces = {};
3
8
  const types = {};
4
9
  const realNamespaces = new Set();
@@ -58,15 +63,24 @@ export const getApiDefinitions = (functions, properties)=>{
58
63
  };
59
64
  }
60
65
  types[fullNamespacePath].methods.push(func);
66
+ } else if (fullNamespacePath === '') {
67
+ if (func.hasSelf) {
68
+ rootNamespace.methods.push(func);
69
+ } else {
70
+ rootNamespace.functions.push(func);
71
+ }
61
72
  }
62
73
  });
63
74
  properties.forEach((prop)=>{
64
75
  const fullNamespacePath = prop.namespaces.join('.');
65
76
  if (realNamespaces.has(fullNamespacePath)) {
66
77
  namespaces[fullNamespacePath].properties.push(prop);
78
+ } else if (fullNamespacePath === '') {
79
+ rootNamespace.properties.push(prop);
67
80
  }
68
81
  });
69
82
  return {
83
+ rootNamespace,
70
84
  namespaces,
71
85
  types
72
86
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[]\n) => {\n const namespaces: Record<string, PlaydateNamespace> = {};\n const types: Record<string, PlaydateType> = {};\n const realNamespaces = new Set<string>();\n const potentialNamespaces = new Set<string>();\n\n functions.forEach((func) => {\n if (!func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n }\n });\n\n properties.forEach((prop) => {\n let currentNamespace = '';\n prop.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n });\n\n functions.forEach((func) => {\n if (func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n if (!potentialNamespaces.has(currentNamespace)) {\n potentialNamespaces.add(currentNamespace);\n }\n });\n }\n });\n\n realNamespaces.forEach((ns) => {\n namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n };\n });\n\n functions.forEach((func) => {\n const fullNamespacePath = func.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n if (func.hasSelf) {\n namespaces[fullNamespacePath].methods.push(func);\n } else {\n namespaces[fullNamespacePath].functions.push(func);\n }\n } else if (potentialNamespaces.has(fullNamespacePath)) {\n if (!types[fullNamespacePath]) {\n types[fullNamespacePath] = { methods: [] };\n }\n types[fullNamespacePath].methods.push(func);\n }\n });\n\n properties.forEach((prop) => {\n const fullNamespacePath = prop.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n namespaces[fullNamespacePath].properties.push(prop);\n }\n });\n\n return {\n namespaces,\n types,\n } satisfies ApiDefinitions;\n};\n"],"names":["getApiDefinitions","functions","properties","namespaces","types","realNamespaces","Set","potentialNamespaces","forEach","func","hasSelf","currentNamespace","ns","realNamespaceName","trim","has","add","prop","methods","fullNamespacePath","join","push"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAQA,OAAO,MAAMA,oBAAoB,CAC7BC,WACAC;IAEA,MAAMC,aAAgD,CAAC;IACvD,MAAMC,QAAsC,CAAC;IAC7C,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,sBAAsB,IAAID;IAEhCL,UAAUO,OAAO,CAAC,CAACC;QACf,IAAI,CAACA,KAAKC,OAAO,EAAE;YACf,IAAIC,mBAAmB;YACvBF,KAAKN,UAAU,CAACK,OAAO,CAAC,CAACI;gBACrBD,mBAAmBA,mBACb,CAAC,EAAEA,iBAAiB,CAAC,EAAEC,GAAG,CAAC,GAC3BA;gBAEN,MAAMC,oBAAoBF,iBAAiBG,IAAI;gBAE/C,IAAI,CAACT,eAAeU,GAAG,CAACF,oBAAoB;oBACxCR,eAAeW,GAAG,CAACH;gBACvB;YACJ;QACJ;IACJ;IAEAX,WAAWM,OAAO,CAAC,CAACS;QAChB,IAAIN,mBAAmB;QACvBM,KAAKd,UAAU,CAACK,OAAO,CAAC,CAACI;YACrBD,mBAAmBA,mBACb,CAAC,EAAEA,iBAAiB,CAAC,EAAEC,GAAG,CAAC,GAC3BA;YAEN,MAAMC,oBAAoBF,iBAAiBG,IAAI;YAE/C,IAAI,CAACT,eAAeU,GAAG,CAACF,oBAAoB;gBACxCR,eAAeW,GAAG,CAACH;YACvB;QACJ;IACJ;IAEAZ,UAAUO,OAAO,CAAC,CAACC;QACf,IAAIA,KAAKC,OAAO,EAAE;YACd,IAAIC,mBAAmB;YACvBF,KAAKN,UAAU,CAACK,OAAO,CAAC,CAACI;gBACrBD,mBAAmBA,mBACb,CAAC,EAAEA,iBAAiB,CAAC,EAAEC,GAAG,CAAC,GAC3BA;gBAEN,IAAI,CAACL,oBAAoBQ,GAAG,CAACJ,mBAAmB;oBAC5CJ,oBAAoBS,GAAG,CAACL;gBAC5B;YACJ;QACJ;IACJ;IAEAN,eAAeG,OAAO,CAAC,CAACI;QACpBT,UAAU,CAACS,GAAG,GAAG;YACbX,WAAW,EAAE;YACbiB,SAAS,EAAE;YACXhB,YAAY,EAAE;QAClB;IACJ;IAEAD,UAAUO,OAAO,CAAC,CAACC;QACf,MAAMU,oBAAoBV,KAAKN,UAAU,CAACiB,IAAI,CAAC;QAE/C,IAAIf,eAAeU,GAAG,CAACI,oBAAoB;YACvC,IAAIV,KAAKC,OAAO,EAAE;gBACdP,UAAU,CAACgB,kBAAkB,CAACD,OAAO,CAACG,IAAI,CAACZ;YAC/C,OAAO;gBACHN,UAAU,CAACgB,kBAAkB,CAAClB,SAAS,CAACoB,IAAI,CAACZ;YACjD;QACJ,OAAO,IAAIF,oBAAoBQ,GAAG,CAACI,oBAAoB;YACnD,IAAI,CAACf,KAAK,CAACe,kBAAkB,EAAE;gBAC3Bf,KAAK,CAACe,kBAAkB,GAAG;oBAAED,SAAS,EAAE;gBAAC;YAC7C;YACAd,KAAK,CAACe,kBAAkB,CAACD,OAAO,CAACG,IAAI,CAACZ;QAC1C;IACJ;IAEAP,WAAWM,OAAO,CAAC,CAACS;QAChB,MAAME,oBAAoBF,KAAKd,UAAU,CAACiB,IAAI,CAAC;QAE/C,IAAIf,eAAeU,GAAG,CAACI,oBAAoB;YACvChB,UAAU,CAACgB,kBAAkB,CAACjB,UAAU,CAACmB,IAAI,CAACJ;QAClD;IACJ;IAEA,OAAO;QACHd;QACAC;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[]\n) => {\n const rootNamespace: PlaydateNamespace = {\n functions: [],\n methods: [],\n properties: [],\n };\n const namespaces: Record<string, PlaydateNamespace> = {};\n const types: Record<string, PlaydateType> = {};\n const realNamespaces = new Set<string>();\n const potentialNamespaces = new Set<string>();\n\n functions.forEach((func) => {\n if (!func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n }\n });\n\n properties.forEach((prop) => {\n let currentNamespace = '';\n prop.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n });\n\n functions.forEach((func) => {\n if (func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n if (!potentialNamespaces.has(currentNamespace)) {\n potentialNamespaces.add(currentNamespace);\n }\n });\n }\n });\n\n realNamespaces.forEach((ns) => {\n namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n };\n });\n\n functions.forEach((func) => {\n const fullNamespacePath = func.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n if (func.hasSelf) {\n namespaces[fullNamespacePath].methods.push(func);\n } else {\n namespaces[fullNamespacePath].functions.push(func);\n }\n } else if (potentialNamespaces.has(fullNamespacePath)) {\n if (!types[fullNamespacePath]) {\n types[fullNamespacePath] = { methods: [] };\n }\n types[fullNamespacePath].methods.push(func);\n } else if (fullNamespacePath === '') {\n if (func.hasSelf) {\n rootNamespace.methods.push(func);\n } else {\n rootNamespace.functions.push(func);\n }\n }\n });\n\n properties.forEach((prop) => {\n const fullNamespacePath = prop.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n namespaces[fullNamespacePath].properties.push(prop);\n } else if (fullNamespacePath === '') {\n rootNamespace.properties.push(prop);\n }\n });\n\n return {\n rootNamespace,\n namespaces,\n types,\n } satisfies ApiDefinitions;\n};\n"],"names":["getApiDefinitions","functions","properties","rootNamespace","methods","namespaces","types","realNamespaces","Set","potentialNamespaces","forEach","func","hasSelf","currentNamespace","ns","realNamespaceName","trim","has","add","prop","fullNamespacePath","join","push"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAQA,OAAO,MAAMA,oBAAoB,CAC7BC,WACAC;IAEA,MAAMC,gBAAmC;QACrCF,WAAW,EAAE;QACbG,SAAS,EAAE;QACXF,YAAY,EAAE;IAClB;IACA,MAAMG,aAAgD,CAAC;IACvD,MAAMC,QAAsC,CAAC;IAC7C,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,sBAAsB,IAAID;IAEhCP,UAAUS,OAAO,CAAC,CAACC;QACf,IAAI,CAACA,KAAKC,OAAO,EAAE;YACf,IAAIC,mBAAmB;YACvBF,KAAKN,UAAU,CAACK,OAAO,CAAC,CAACI;gBACrBD,mBAAmBA,mBACb,CAAC,EAAEA,iBAAiB,CAAC,EAAEC,GAAG,CAAC,GAC3BA;gBAEN,MAAMC,oBAAoBF,iBAAiBG,IAAI;gBAE/C,IAAI,CAACT,eAAeU,GAAG,CAACF,oBAAoB;oBACxCR,eAAeW,GAAG,CAACH;gBACvB;YACJ;QACJ;IACJ;IAEAb,WAAWQ,OAAO,CAAC,CAACS;QAChB,IAAIN,mBAAmB;QACvBM,KAAKd,UAAU,CAACK,OAAO,CAAC,CAACI;YACrBD,mBAAmBA,mBACb,CAAC,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AAcC,OAAO,CAACkB,IAAI,CAACX;YAC/B,OAAO;gBACHR,cAAcF,SAAS,CAACqB,IAAI,CAACX;YACjC;QACJ;IACJ;IAEAT,WAAWQ,OAAO,CAAC,CAACS;QAChB,MAAMC,oBAAoBD,KAAKd,UAAU,CAACgB,IAAI,CAAC;QAE/C,IAAId,eAAeU,GAAG,CAACG,oBAAoB;YACvCf,UAAU,CAACe,kBAAkB,CAAClB,UAAU,CAACoB,IAAI,CAACH;QAClD,OAAO,IAAIC,sBAAsB,IAAI;YACjCjB,cAAcD,UAAU,CAACoB,IAAI,CAACH;QAClC;IACJ;IAEA,OAAO;QACHhB;QACAE;QACAC;IACJ;AACJ,EAAE"}
@@ -25,8 +25,8 @@ export const getDescriptionsFromHtml = (html, version)=>{
25
25
  var _$_attr;
26
26
  const id = (_$_attr = $(element).attr('id')) != null ? _$_attr : '';
27
27
  const isProperty = id.startsWith('v-');
28
- const titleText = $(element).find('.title').text();
29
- if (titleText.indexOf('#') !== -1 || /[a-zA-Z]\[/.test(titleText)) {
28
+ const titleText = $(element).find('> .title').text();
29
+ if (titleText.indexOf('#') !== -1 || /[a-zA-Z]\[/.test(titleText) || /^-[a-zA-Z]/.test(titleText) || /[+*/]/.test(titleText) || titleText.indexOf(' - ') !== -1 || titleText.indexOf(' .. ') !== -1) {
30
30
  continue;
31
31
  }
32
32
  const titles = isProperty ? titleText.split(' ') : extractFunctionCalls(titleText);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { parseFunctionSignature } from '@/cli/commands/GenerateTypes/fn/parseFunctionSignature.js';\nimport { FunctionDescription, PropertyDescription } from '@/cli/types.js';\n\nconst extractFunctionCalls = (input: string) => {\n const functionCallRegex =\n /([a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*(?::[a-zA-Z_]\\w*)?)\\s*(\\([^)]*\\))?/g;\n const matches: string[] = [];\n let match;\n\n while ((match = functionCallRegex.exec(input)) !== null) {\n matches.push(match[0].trim());\n }\n\n return matches;\n};\n\nconst normalizeSignature = (signature: string) => {\n const closingParenIndex = signature.indexOf(')');\n return closingParenIndex !== -1\n ? signature.slice(0, closingParenIndex + 1)\n : signature;\n};\n\nexport const getDescriptionsFromHtml = (html: string, version: string) => {\n const $ = load(html);\n\n const functionSignatures = $(\n '[id^=\"m-\"], [id^=\"f-\"], [id^=\"c-\"], [id^=\"v-\"]'\n ).toArray();\n const functions: FunctionDescription[] = [];\n const properties: PropertyDescription[] = [];\n const visitedSignatures: string[] = [];\n\n for (const element of functionSignatures) {\n const id = $(element).attr('id') ?? '';\n const isProperty = id.startsWith('v-');\n const titleText = $(element).find('.title').text();\n\n if (titleText.indexOf('#') !== -1 || /[a-zA-Z]\\[/.test(titleText)) {\n continue;\n }\n\n const titles = isProperty\n ? titleText.split(' ')\n : extractFunctionCalls(titleText);\n\n let docsString = ($(element).find('.content').html() ?? '').trim();\n\n if (docsString.startsWith('<div class=\"paragraph\">')) {\n docsString = docsString.slice('<div class=\"paragraph\">'.length);\n }\n\n if (docsString.endsWith('</div>')) {\n docsString = docsString.slice(\n 0,\n docsString.length - '</div>'.length\n );\n }\n\n docsString = docsString.replace(\n /<a href=\"#/g,\n '<a href=\"' + PlaydateSdkUrl + version + '#'\n );\n\n const baseDocs = id\n ? `${docsString}\\n[Read more](${PlaydateSdkUrl}${version}#${id})`\n : docsString;\n\n for (const title of titles) {\n const signature = normalizeSignature(title);\n\n if (visitedSignatures.includes(signature)) {\n continue;\n }\n\n visitedSignatures.push(signature);\n\n if (isProperty) {\n properties.push({\n name: title.split('.').slice(-1)[0],\n namespaces: signature.split('.').slice(0, -1),\n signature,\n docs: baseDocs,\n });\n } else {\n try {\n const description = parseFunctionSignature(signature);\n\n const docs = description.hasSelf\n ? baseDocs\n : `${baseDocs}\\n\\n@noSelf`;\n\n functions.push({\n ...description,\n docs,\n });\n } catch (e) {\n // Ignore\n }\n }\n }\n }\n\n return { functions, properties };\n};\n"],"names":["load","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","element","id","attr","isProperty","startsWith","titleText","find","text","test","titles","split","docsString","length","endsWith","replace","baseDocs","title","includes","name","namespaces","docs","description","hasSelf","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAASC,sBAAsB,QAAQ,4DAA4D;AAGnG,MAAMC,uBAAuB,CAACC;IAC1B,MAAMC,oBACF;IACJ,MAAMC,UAAoB,EAAE;IAC5B,IAAIC;IAEJ,MAAO,AAACA,CAAAA,QAAQF,kBAAkBG,IAAI,CAACJ,MAAK,MAAO,KAAM;QACrDE,QAAQG,IAAI,CAACF,KAAK,CAAC,EAAE,CAACG,IAAI;IAC9B;IAEA,OAAOJ;AACX;AAEA,MAAMK,qBAAqB,CAACC;IACxB,MAAMC,oBAAoBD,UAAUE,OAAO,CAAC;IAC5C,OAAOD,sBAAsB,CAAC,IACxBD,UAAUG,KAAK,CAAC,GAAGF,oBAAoB,KACvCD;AACV;AAEA,OAAO,MAAMI,0BAA0B,CAACC,MAAcC;IAClD,MAAMC,IAAInB,KAAKiB;IAEf,MAAMG,qBAAqBD,EACvB,kDACFE,OAAO;IACT,MAAMC,YAAmC,EAAE;IAC3C,MAAMC,aAAoC,EAAE;IAC5C,MAAMC,oBAA8B,EAAE;IAEtC,KAAK,MAAMC,WAAWL,mBAAoB;YAC3BD;QAAX,MAAMO,KAAKP,CAAAA,UAAAA,EAAEM,SAASE,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,MAAMM,cAAc5C,uBAAuBU;oBAE3C,MAAMiC,OAAOC,YAAYC,OAAO,GAC1BP,WACA,CAAC,EAAEA,SAAS,WAAW,CAAC;oBAE9BlB,UAAUb,IAAI,CAAC,aACRqC;wBACHD;;gBAER,EAAE,OAAOG,GAAG;gBACR,SAAS;gBACb;YACJ;QACJ;IACJ;IAEA,OAAO;QAAE1B;QAAWC;IAAW;AACnC,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { parseFunctionSignature } from '@/cli/commands/GenerateTypes/fn/parseFunctionSignature.js';\nimport { FunctionDescription, PropertyDescription } from '@/cli/types.js';\n\nconst extractFunctionCalls = (input: string) => {\n const functionCallRegex =\n /([a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*(?::[a-zA-Z_]\\w*)?)\\s*(\\([^)]*\\))?/g;\n const matches: string[] = [];\n let match;\n\n while ((match = functionCallRegex.exec(input)) !== null) {\n matches.push(match[0].trim());\n }\n\n return matches;\n};\n\nconst normalizeSignature = (signature: string) => {\n const closingParenIndex = signature.indexOf(')');\n return closingParenIndex !== -1\n ? signature.slice(0, closingParenIndex + 1)\n : signature;\n};\n\nexport const getDescriptionsFromHtml = (html: string, version: string) => {\n const $ = load(html);\n\n const functionSignatures = $(\n '[id^=\"m-\"], [id^=\"f-\"], [id^=\"c-\"], [id^=\"v-\"]'\n ).toArray();\n const functions: FunctionDescription[] = [];\n const properties: PropertyDescription[] = [];\n const visitedSignatures: string[] = [];\n\n for (const element of functionSignatures) {\n const id = $(element).attr('id') ?? '';\n const isProperty = id.startsWith('v-');\n const titleText = $(element).find('> .title').text();\n\n if (\n titleText.indexOf('#') !== -1 ||\n /[a-zA-Z]\\[/.test(titleText) ||\n /^-[a-zA-Z]/.test(titleText) ||\n /[+*/]/.test(titleText) ||\n titleText.indexOf(' - ') !== -1 ||\n titleText.indexOf(' .. ') !== -1\n ) {\n continue;\n }\n\n const titles = isProperty\n ? titleText.split(' ')\n : extractFunctionCalls(titleText);\n\n let docsString = ($(element).find('.content').html() ?? '').trim();\n\n if (docsString.startsWith('<div class=\"paragraph\">')) {\n docsString = docsString.slice('<div class=\"paragraph\">'.length);\n }\n\n if (docsString.endsWith('</div>')) {\n docsString = docsString.slice(\n 0,\n docsString.length - '</div>'.length\n );\n }\n\n docsString = docsString.replace(\n /<a href=\"#/g,\n '<a href=\"' + PlaydateSdkUrl + version + '#'\n );\n\n const baseDocs = id\n ? `${docsString}\\n[Read more](${PlaydateSdkUrl}${version}#${id})`\n : docsString;\n\n for (const title of titles) {\n const signature = normalizeSignature(title);\n\n if (visitedSignatures.includes(signature)) {\n continue;\n }\n\n visitedSignatures.push(signature);\n\n if (isProperty) {\n properties.push({\n name: title.split('.').slice(-1)[0],\n namespaces: signature.split('.').slice(0, -1),\n signature,\n docs: baseDocs,\n });\n } else {\n try {\n const description = parseFunctionSignature(signature);\n\n const docs = description.hasSelf\n ? baseDocs\n : `${baseDocs}\\n\\n@noSelf`;\n\n functions.push({\n ...description,\n docs,\n });\n } catch (e) {\n // Ignore\n }\n }\n }\n }\n\n return { functions, properties };\n};\n"],"names":["load","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","element","id","attr","isProperty","startsWith","titleText","find","text","test","titles","split","docsString","length","endsWith","replace","baseDocs","title","includes","name","namespaces","docs","description","hasSelf","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAAS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sC,EAAC,EAAGT,IAAI;QAEhE,IAAI0B,WAAWP,UAAU,CAAC,4BAA4B;YAClDO,aAAaA,WAAWrB,KAAK,CAAC,0BAA0BsB,MAAM;QAClE;QAEA,IAAID,WAAWE,QAAQ,CAAC,WAAW;YAC/BF,aAAaA,WAAWrB,KAAK,CACzB,GACAqB,WAAWC,MAAM,GAAG,SAASA,MAAM;QAE3C;QAEAD,aAAaA,WAAWG,OAAO,CAC3B,eACA,cAActC,iBAAiBiB,UAAU;QAG7C,MAAMsB,WAAWd,KACX,CAAC,EAAEU,WAAW,cAAc,EAAEnC,eAAe,EAAEiB,QAAQ,CAAC,EAAEQ,GAAG,CAAC,CAAC,GAC/DU;QAEN,KAAK,MAAMK,SAASP,OAAQ;YACxB,MAAMtB,YAAYD,mBAAmB8B;YAErC,IAAIjB,kBAAkBkB,QAAQ,CAAC9B,YAAY;gBACvC;YACJ;YAEAY,kBAAkBf,IAAI,CAACG;YAEvB,IAAIgB,YAAY;gBACZL,WAAWd,IAAI,CAAC;oBACZkC,MAAMF,MAAMN,KAAK,CAAC,KAAKpB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE;oBACnC6B,YAAYhC,UAAUuB,KAAK,CAAC,KAAKpB,KAAK,CAAC,GAAG,CAAC;oBAC3CH;oBACAiC,MAAML;gBACV;YACJ,OAAO;gBACH,IAAI;oBACA,MAAMM,cAAc5C,uBAAuBU;oBAE3C,MAAMiC,OAAOC,YAAYC,OAAO,GAC1BP,WACA,CAAC,EAAEA,SAAS,WAAW,CAAC;oBAE9BlB,UAAUb,IAAI,CAAC,aACRqC;wBACHD;;gBAER,EAAE,OAAOG,GAAG;gBACR,SAAS;gBACb;YACJ;QACJ;IACJ;IAEA,OAAO;QAAE1B;QAAWC;IAAW;AACnC,EAAE"}
@@ -24,12 +24,13 @@ export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
24
24
  const subjects = new Map();
25
25
  const typeSubjects = new Map();
26
26
  subjects.set('root', typeFile);
27
+ generateNamespace(definitions.rootNamespace, [], subjects, typeSubjects, typeProvider, definitions.types);
27
28
  Object.keys(definitions.namespaces).forEach((namespace)=>{
28
29
  const namespaceDescription = definitions.namespaces[namespace];
29
30
  const namespaces = namespace.split('.');
30
31
  generateNamespace(namespaceDescription, namespaces, subjects, typeSubjects, typeProvider, definitions.types);
31
32
  });
32
- writeFileSync(path, typeFile.getFullText().replace('/** Playdate SDK */', '\n/** Playdate SDK */'));
33
+ writeFileSync(path, typeFile.getFullText().replace('/**', '\n/**'));
33
34
  },
34
35
  ready: definitions !== null && typeProvider !== null
35
36
  };
@@ -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 InterfaceDeclaration,\n ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { generateNamespace } from '@/cli/commands/GenerateTypes/fn/generateNamespace.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { ApiDefinitions, CheckListItem } 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 typeFile.addStatements(typeProvider.getGlobalStatements());\n\n const subjects = new Map<\n string,\n SourceFile | ModuleDeclaration\n >();\n const typeSubjects = new Map<string, InterfaceDeclaration>();\n subjects.set('root', typeFile);\n\n Object.keys(definitions.namespaces).forEach((namespace) => {\n const namespaceDescription =\n definitions.namespaces[namespace];\n const namespaces = namespace.split('.');\n generateNamespace(\n namespaceDescription,\n namespaces,\n subjects,\n typeSubjects,\n typeProvider,\n definitions.types\n );\n });\n\n writeFileSync(\n path,\n typeFile\n .getFullText()\n .replace('/** Playdate SDK */', '\\n/** Playdate SDK */')\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n"],"names":["writeFileSync","useMemo","Project","generateNamespace","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","getGlobalStatements","subjects","Map","typeSubjects","set","Object","keys","namespaces","forEach","namespace","namespaceDescription","split","types","getFullText","replace","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAGIC,OAAO,QAEJ,WAAW;AAClB,SAASC,iBAAiB,QAAQ,uDAAuD;AAIzF,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBP,QAAQ;QAC7B,OAAO;YACHQ,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,IAAIb;gBACpB,MAAMc,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBACAF,SAASG,aAAa,CAACZ,aAAaa,mBAAmB;gBAEvD,MAAMC,WAAW,IAAIC;gBAIrB,MAAMC,eAAe,IAAID;gBACzBD,SAASG,GAAG,CAAC,QAAQR;gBAErBS,OAAOC,IAAI,CAACpB,YAAYqB,UAAU,EAAEC,OAAO,CAAC,CAACC;oBACzC,MAAMC,uBACFxB,YAAYqB,UAAU,CAACE,UAAU;oBACrC,MAAMF,aAAaE,UAAUE,KAAK,CAAC;oBACnC5B,kBACI2B,sBACAH,YACAN,UACAE,cACAhB,cACAD,YAAY0B,KAAK;gBAEzB;gBAEAhC,cACIK,MACAW,SACKiB,WAAW,GACXC,OAAO,CAAC,uBAAuB;YAE5C;YACAC,OAAO7B,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ;AACJ,EAAE"}
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 ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { generateNamespace } from '@/cli/commands/GenerateTypes/fn/generateNamespace.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { ApiDefinitions, CheckListItem } 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 typeFile.addStatements(typeProvider.getGlobalStatements());\n\n const subjects = new Map<\n string,\n SourceFile | ModuleDeclaration\n >();\n const typeSubjects = new Map<string, ClassDeclaration>();\n subjects.set('root', typeFile);\n\n generateNamespace(\n definitions.rootNamespace,\n [],\n subjects,\n typeSubjects,\n typeProvider,\n definitions.types\n );\n\n Object.keys(definitions.namespaces).forEach((namespace) => {\n const namespaceDescription =\n definitions.namespaces[namespace];\n const namespaces = namespace.split('.');\n generateNamespace(\n namespaceDescription,\n namespaces,\n subjects,\n typeSubjects,\n typeProvider,\n definitions.types\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"],"names":["writeFileSync","useMemo","Project","generateNamespace","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","getGlobalStatements","subjects","Map","typeSubjects","set","rootNamespace","types","Object","keys","namespaces","forEach","namespace","namespaceDescription","split","getFullText","replace","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAGIC,OAAO,QAEJ,WAAW;AAClB,SAASC,iBAAiB,QAAQ,uDAAuD;AAIzF,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBP,QAAQ;QAC7B,OAAO;YACHQ,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,IAAIb;gBACpB,MAAMc,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBACAF,SAASG,aAAa,CAACZ,aAAaa,mBAAmB;gBAEvD,MAAMC,WAAW,IAAIC;gBAIrB,MAAMC,eAAe,IAAID;gBACzBD,SAASG,GAAG,CAAC,QAAQR;gBAErBb,kBACIG,YAAYmB,aAAa,EACzB,EAAE,EACFJ,UACAE,cACAhB,cACAD,YAAYoB,KAAK;gBAGrBC,OAAOC,IAAI,CAACtB,YAAYuB,UAAU,EAAEC,OAAO,CAAC,CAACC;oBACzC,MAAMC,uBACF1B,YAAYuB,UAAU,CAACE,UAAU;oBACrC,MAAMF,aAAaE,UAAUE,KAAK,CAAC;oBACnC9B,kBACI6B,sBACAH,YACAR,UACAE,cACAhB,cACAD,YAAYoB,KAAK;gBAEzB;gBAEA1B,cACIK,MACAW,SAASkB,WAAW,GAAGC,OAAO,CAAC,OAAO;YAE9C;YACAC,OAAO9B,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ;AACJ,EAAE"}
@@ -16,7 +16,7 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
16
16
  getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
17
17
  getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
18
18
  getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").FunctionDeclarationStructure["parameters"];
19
- getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodSignatureStructure>;
19
+ getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
20
20
  save: () => void;
21
21
  } | null;
22
22
  };
@@ -7,6 +7,7 @@ export declare const useParseDocumentation: (html: string | null, version: strin
7
7
  finishedDescription: () => string;
8
8
  runningDescription: string;
9
9
  runner: () => Promise<{
10
+ rootNamespace: import("../../../types.js").PlaydateNamespace;
10
11
  namespaces: Record<string, import("../../../types.js").PlaydateNamespace>;
11
12
  types: Record<string, import("../../../types.js").PlaydateType>;
12
13
  }>;
@@ -7,6 +7,6 @@ export declare const createTypeProvider: (version: string) => {
7
7
  getFunctionReturnType: (func: FunctionDescription) => string;
8
8
  getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
9
9
  getParameters: (func: FunctionDescription) => FunctionDeclarationStructure["parameters"];
10
- getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").MethodSignatureStructure>;
10
+ getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
11
11
  save: () => void;
12
12
  };
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FunctionDeclarationStructure, MethodSignatureStructure, ParameterDeclarationStructure } from 'ts-morph';
1
+ import { FunctionDeclarationStructure, MethodDeclarationStructure, ParameterDeclarationStructure } from 'ts-morph';
2
2
  import { Environment } from './environment/dto/Environment.js';
3
3
  import { PlaydateSdkPath } from './environment/path/dto/PlaydateSdkPath.js';
4
4
  export declare enum PlaydateSdkVersionIdentifier {
@@ -72,6 +72,7 @@ export interface PlaydateType {
72
72
  methods: FunctionDescription[];
73
73
  }
74
74
  export interface ApiDefinitions {
75
+ rootNamespace: PlaydateNamespace;
75
76
  namespaces: Record<string, PlaydateNamespace>;
76
77
  types: Record<string, PlaydateType>;
77
78
  }
@@ -91,7 +92,7 @@ export interface FunctionDetails {
91
92
  parameters: ParameterDetails[];
92
93
  returnType: string;
93
94
  overrideParameters?: boolean;
94
- overrideOptions?: Partial<FunctionDeclarationStructure | MethodSignatureStructure>;
95
+ overrideOptions?: Partial<FunctionDeclarationStructure | MethodDeclarationStructure>;
95
96
  }
96
97
  export type TypeProviderData = {
97
98
  globalStatements: string[];
package/src/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n MethodSignatureStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\n\nexport interface ConstantDescription {\n name: string;\n docs: string;\n values: {\n name: string;\n value: number;\n docs: string;\n }[];\n}\n\nexport interface PlaydateNamespace {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n}\n\nexport interface PlaydateType {\n methods: FunctionDescription[];\n}\n\nexport interface ApiDefinitions {\n namespaces: Record<string, PlaydateNamespace>;\n types: Record<string, PlaydateType>;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodSignatureStructure\n >;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType"],"rangeMappings":";;;;;;;;;","mappings":";UAQYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA"}
1
+ {"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\n\nexport interface ConstantDescription {\n name: string;\n docs: string;\n values: {\n name: string;\n value: number;\n docs: string;\n }[];\n}\n\nexport interface PlaydateNamespace {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n}\n\nexport interface PlaydateType {\n methods: FunctionDescription[];\n}\n\nexport interface ApiDefinitions {\n rootNamespace: PlaydateNamespace;\n namespaces: Record<string, PlaydateNamespace>;\n types: Record<string, PlaydateType>;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n >;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType"],"rangeMappings":";;;;;;;;;","mappings":";UAQYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA"}