crankscript 0.5.0 → 0.6.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 (62) hide show
  1. package/package.json +25 -25
  2. package/src/commands/DoctorCommand.js +1 -1
  3. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +2 -2
  4. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +3 -3
  5. package/src/commands/EnvironmentAwareCommand/components/HealthReport.d.ts +1 -1
  6. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js +1 -1
  7. package/src/commands/GenerateTypes/GenerateTypesCommand.d.ts +2 -1
  8. package/src/commands/GenerateTypes/GenerateTypesCommand.js +7 -3
  9. package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -1
  10. package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +3 -2
  11. package/src/commands/GenerateTypes/components/GenerateTypes.js +17 -11
  12. package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
  13. package/src/commands/GenerateTypes/fn/generateFunction.d.ts +4 -0
  14. package/src/commands/GenerateTypes/fn/generateFunction.js +28 -0
  15. package/src/commands/GenerateTypes/fn/generateFunction.js.map +1 -0
  16. package/src/commands/GenerateTypes/fn/generateNamespace.d.ts +4 -3
  17. package/src/commands/GenerateTypes/fn/generateNamespace.js +68 -21
  18. package/src/commands/GenerateTypes/fn/generateNamespace.js.map +1 -1
  19. package/src/commands/GenerateTypes/fn/getApiDefinitions.d.ts +2 -11
  20. package/src/commands/GenerateTypes/fn/getApiDefinitions.js +26 -9
  21. package/src/commands/GenerateTypes/fn/getApiDefinitions.js.map +1 -1
  22. package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.d.ts +5 -0
  23. package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js +75 -0
  24. package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js.map +1 -0
  25. package/src/commands/GenerateTypes/fn/parseFunctionSignature.d.ts +1 -1
  26. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +4 -6
  27. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
  28. package/src/commands/GenerateTypes/hooks/useFetchHtml.js +1 -1
  29. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.d.ts +3 -2
  30. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +15 -24
  31. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
  32. package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +11 -1
  33. package/src/commands/GenerateTypes/hooks/useGetVersion.js +7 -3
  34. package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -1
  35. package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +3 -12
  36. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +4 -4
  37. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -1
  38. package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +12 -0
  39. package/src/commands/GenerateTypes/utils/createTypeProvider.js +141 -0
  40. package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -0
  41. package/src/components/CheckList/CheckList.d.ts +1 -1
  42. package/src/components/CheckList/CheckList.js +1 -2
  43. package/src/components/CheckList/CheckList.js.map +1 -1
  44. package/src/components/CheckList/Item.d.ts +1 -1
  45. package/src/components/CheckList/Item.js +1 -0
  46. package/src/components/CheckList/Item.js.map +1 -1
  47. package/src/constants.d.ts +2 -0
  48. package/src/constants.js +4 -0
  49. package/src/constants.js.map +1 -1
  50. package/src/index.js +3 -3
  51. package/src/index.js.map +1 -1
  52. package/src/types.d.ts +36 -5
  53. package/src/types.js.map +1 -1
  54. package/src/utils/dirname.d.ts +1 -1
  55. package/src/utils/dirname.js +2 -3
  56. package/src/utils/dirname.js.map +1 -1
  57. package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.d.ts +0 -2
  58. package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js +0 -37
  59. package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js.map +0 -1
  60. package/src/commands/GenerateTypes/utils/playdateConstants.d.ts +0 -9
  61. package/src/commands/GenerateTypes/utils/playdateConstants.js +0 -134
  62. package/src/commands/GenerateTypes/utils/playdateConstants.js.map +0 -1
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
- "name": "crankscript",
3
- "version": "0.5.0",
4
- "scripts": {
5
- "dev": "tsx src/index.ts",
6
- "post-build": "tsc-alias --project tsconfig.json"
7
- },
8
- "bin": {
9
- "crankscript": "./src/index.js"
10
- },
11
- "license": "MIT",
12
- "dependencies": {
13
- "@inkjs/ui": "^2.0.0",
14
- "@swc/helpers": "~0.5.11",
15
- "cheerio": "^1.0.0",
16
- "clipanion": "^4.0.0-rc.4",
17
- "ink": "^5.0.1",
18
- "react": "^18.3.1",
19
- "ts-morph": "^23.0.0",
20
- "typanion": "^3.14.0"
21
- },
22
- "type": "module",
23
- "main": "./src/index.js",
24
- "typings": "./src/index.d.ts",
25
- "module": "./src/index.js",
26
- "types": "./src/index.d.ts"
2
+ "name": "crankscript",
3
+ "version": "0.6.0",
4
+ "scripts": {
5
+ "dev": "tsx src/index.ts",
6
+ "post-build": "tsc-alias --project tsconfig.json"
7
+ },
8
+ "bin": {
9
+ "crankscript": "./src/index.js"
10
+ },
11
+ "license": "MIT",
12
+ "dependencies": {
13
+ "@inkjs/ui": "^2.0.0",
14
+ "@swc/helpers": "~0.5.11",
15
+ "cheerio": "^1.0.0",
16
+ "clipanion": "^4.0.0-rc.4",
17
+ "ink": "^5.0.1",
18
+ "react": "^18.3.1",
19
+ "ts-morph": "^23.0.0",
20
+ "typanion": "^3.14.0"
21
+ },
22
+ "type": "module",
23
+ "main": "./src/index.js",
24
+ "typings": "./src/index.d.ts",
25
+ "module": "./src/index.js",
26
+ "types": "./src/index.d.ts"
27
27
  }
@@ -1,7 +1,7 @@
1
1
  import { Command } from 'clipanion';
2
2
  import { Text } from 'ink';
3
3
  import React from 'react';
4
- import { createEnvironment } from '@/cli/environment/createEnvironment.js';
4
+ import { createEnvironment } from '../environment/createEnvironment.js';
5
5
  import { HealthReport } from './EnvironmentAwareCommand/components/HealthReport.js';
6
6
  import { RenderableCommand } from './RenderableCommand.js';
7
7
  export class DoctorCommand extends RenderableCommand {
@@ -1,6 +1,6 @@
1
1
  import { JSX } from 'react';
2
- import { RenderableCommand } from '@/cli/commands/RenderableCommand.js';
3
- import { Environment } from '@/cli/environment/dto/Environment.js';
2
+ import { RenderableCommand } from '../../commands/RenderableCommand.js';
3
+ import { Environment } from '../../environment/dto/Environment.js';
4
4
  export declare abstract class EnvironmentAwareCommand extends RenderableCommand {
5
5
  private environment;
6
6
  protected abstract renderWithEnvironment(environment: Environment): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { HealthReport } from '@/cli/commands/EnvironmentAwareCommand/components/HealthReport.js';
3
- import { RenderableCommand } from '@/cli/commands/RenderableCommand.js';
4
- import { createEnvironment } from '@/cli/environment/createEnvironment.js';
2
+ import { HealthReport } from '../../commands/EnvironmentAwareCommand/components/HealthReport.js';
3
+ import { RenderableCommand } from '../../commands/RenderableCommand.js';
4
+ import { createEnvironment } from '../../environment/createEnvironment.js';
5
5
  export class EnvironmentAwareCommand extends RenderableCommand {
6
6
  render() {
7
7
  if (!this.environment) {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { EnvironmentHealthResult } from '@/cli/types.js';
2
+ import { EnvironmentHealthResult } from '../../../types.js';
3
3
  interface Props {
4
4
  environment: EnvironmentHealthResult;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import { StatusMessage } from '@inkjs/ui';
2
2
  import { Text } from 'ink';
3
3
  import React from 'react';
4
- import { HealthCheckStatusType } from '@/cli/types.js';
4
+ import { HealthCheckStatusType } from '../../../types.js';
5
5
  const SuccessMessages = {
6
6
  sdkPathKnown: {
7
7
  [HealthCheckStatusType.Unknown]: 'SDK path status unknown',
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
- import { RenderableCommand } from '@/cli/commands/RenderableCommand.js';
2
+ import { RenderableCommand } from '../../commands/RenderableCommand.js';
3
3
  export declare class GenerateTypesCommand extends RenderableCommand {
4
4
  static paths: string[][];
5
5
  static usage: import("clipanion").Usage;
6
6
  output: string;
7
+ overwriteJson: boolean;
7
8
  version: any;
8
9
  render(): React.JSX.Element;
9
10
  }
@@ -3,15 +3,16 @@ import * as process from 'node:process';
3
3
  import { Command, Option } from 'clipanion';
4
4
  import React from 'react';
5
5
  import * as t from 'typanion';
6
- import { RenderableCommand } from '@/cli/commands/RenderableCommand.js';
7
- import { PlaydateSdkVersionIdentifier } from '@/cli/types.js';
6
+ import { RenderableCommand } from '../../commands/RenderableCommand.js';
7
+ import { PlaydateSdkVersionIdentifier } from '../../types.js';
8
8
  import { GenerateTypes } from './components/GenerateTypes.js';
9
9
  export class GenerateTypesCommand extends RenderableCommand {
10
10
  render() {
11
11
  const output = this.output.endsWith('.d.ts') ? this.output : join(this.output, 'playdate.d.ts');
12
12
  return /*#__PURE__*/ React.createElement(GenerateTypes, {
13
13
  output: output,
14
- version: this.version
14
+ version: this.version,
15
+ overwriteJson: this.overwriteJson
15
16
  });
16
17
  }
17
18
  constructor(...args){
@@ -20,6 +21,9 @@ export class GenerateTypesCommand extends RenderableCommand {
20
21
  description: `Where to generate the playdate.d.ts file. Defaults to the current working directory ("${process.cwd()}")`,
21
22
  validator: t.isString()
22
23
  });
24
+ this.overwriteJson = Option.Boolean('-j,--overwrite-json', false, {
25
+ description: 'Overwrite the JSON data file with the new data'
26
+ });
23
27
  this.version = Option.String({
24
28
  name: 'version',
25
29
  validator: t.isOneOf([
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/GenerateTypesCommand.tsx"],"sourcesContent":["import { join } from 'node:path';\nimport * as process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { AnyStrictValidator } from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { PlaydateSdkVersionIdentifier } from '@/cli/types.js';\nimport { GenerateTypes } from './components/GenerateTypes.js';\n\nexport class GenerateTypesCommand extends RenderableCommand {\n static override paths = [['generate-types']];\n static override usage = Command.Usage({\n description: 'Generate types from the Playdate SDK documentation',\n });\n\n output = Option.String('-o,--output', process.cwd(), {\n description: `Where to generate the playdate.d.ts file. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n });\n\n version = Option.String({\n name: 'version',\n validator: t.isOneOf([\n t.isLiteral(PlaydateSdkVersionIdentifier.Latest),\n t.matchesRegExp(/^[0-9]+\\.[0-9]+\\.[0-9]+$/) as AnyStrictValidator,\n ]),\n });\n\n override render() {\n const output = this.output.endsWith('.d.ts')\n ? this.output\n : join(this.output, 'playdate.d.ts');\n\n return <GenerateTypes output={output} version={this.version} />;\n }\n}\n"],"names":["join","process","Command","Option","React","t","RenderableCommand","PlaydateSdkVersionIdentifier","GenerateTypes","GenerateTypesCommand","render","output","endsWith","version","String","cwd","description","validator","isString","name","isOneOf","isLiteral","Latest","matchesRegExp","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,YAAYC,aAAa,eAAe;AACxC,SAASC,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAE9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,4BAA4B,QAAQ,iBAAiB;AAC9D,SAASC,aAAa,QAAQ,gCAAgC;AAE9D,OAAO,MAAMC,6BAA6BH;IAmB7BI,SAAS;QACd,MAAMC,SAAS,IAAI,CAACA,MAAM,CAACC,QAAQ,CAAC,WAC9B,IAAI,CAACD,MAAM,GACXX,KAAK,IAAI,CAACW,MAAM,EAAE;QAExB,qBAAO,oBAACH;YAAcG,QAAQA;YAAQE,SAAS,IAAI,CAACA,OAAO;;IAC/D;;;aAnBAF,SAASR,OAAOW,MAAM,CAAC,eAAeb,QAAQc,GAAG,IAAI;YACjDC,aAAa,CAAC,sFAAsF,EAAEf,QAAQc,GAAG,GAAG,EAAE,CAAC;YACvHE,WAAWZ,EAAEa,QAAQ;QACzB;aAEAL,UAAUV,OAAOW,MAAM,CAAC;YACpBK,MAAM;YACNF,WAAWZ,EAAEe,OAAO,CAAC;gBACjBf,EAAEgB,SAAS,CAACd,6BAA6Be,MAAM;gBAC/CjB,EAAEkB,aAAa,CAAC;aACnB;QACL;;AASJ;AA1Bad,qBACOe,QAAQ;IAAC;QAAC;KAAiB;CAAC;AADnCf,qBAEOgB,QAAQvB,QAAQwB,KAAK,CAAC;IAClCV,aAAa;AACjB"}
1
+ {"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/GenerateTypesCommand.tsx"],"sourcesContent":["import { join } from 'node:path';\nimport * as process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { AnyStrictValidator } from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { PlaydateSdkVersionIdentifier } from '@/cli/types.js';\nimport { GenerateTypes } from './components/GenerateTypes.js';\n\nexport class GenerateTypesCommand extends RenderableCommand {\n static override paths = [['generate-types']];\n static override usage = Command.Usage({\n description: 'Generate types from the Playdate SDK documentation',\n });\n\n output = Option.String('-o,--output', process.cwd(), {\n description: `Where to generate the playdate.d.ts file. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n });\n\n overwriteJson = Option.Boolean('-j,--overwrite-json', false, {\n description: 'Overwrite the JSON data file with the new data',\n });\n\n version = Option.String({\n name: 'version',\n validator: t.isOneOf([\n t.isLiteral(PlaydateSdkVersionIdentifier.Latest),\n t.matchesRegExp(/^[0-9]+\\.[0-9]+\\.[0-9]+$/) as AnyStrictValidator,\n ]),\n });\n\n override render() {\n const output = this.output.endsWith('.d.ts')\n ? this.output\n : join(this.output, 'playdate.d.ts');\n\n return (\n <GenerateTypes\n output={output}\n version={this.version}\n overwriteJson={this.overwriteJson}\n />\n );\n }\n}\n"],"names":["join","process","Command","Option","React","t","RenderableCommand","PlaydateSdkVersionIdentifier","GenerateTypes","GenerateTypesCommand","render","output","endsWith","version","overwriteJson","String","cwd","description","validator","isString","Boolean","name","isOneOf","isLiteral","Latest","matchesRegExp","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,YAAYC,aAAa,eAAe;AACxC,SAASC,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAE9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,4BAA4B,QAAQ,iBAAiB;AAC9D,SAASC,aAAa,QAAQ,gCAAgC;AAE9D,OAAO,MAAMC,6BAA6BH;IAuB7BI,SAAS;QACd,MAAMC,SAAS,IAAI,CAACA,MAAM,CAACC,QAAQ,CAAC,WAC9B,IAAI,CAACD,MAAM,GACXX,KAAK,IAAI,CAACW,MAAM,EAAE;QAExB,qBACI,oBAACH;YACGG,QAAQA;YACRE,SAAS,IAAI,CAACA,OAAO;YACrBC,eAAe,IAAI,CAACA,aAAa;;IAG7C;;;aA7BAH,SAASR,OAAOY,MAAM,CAAC,eAAed,QAAQe,GAAG,IAAI;YACjDC,aAAa,CAAC,sFAAsF,EAAEhB,QAAQe,GAAG,GAAG,EAAE,CAAC;YACvHE,WAAWb,EAAEc,QAAQ;QACzB;aAEAL,gBAAgBX,OAAOiB,OAAO,CAAC,uBAAuB,OAAO;YACzDH,aAAa;QACjB;aAEAJ,UAAUV,OAAOY,MAAM,CAAC;YACpBM,MAAM;YACNH,WAAWb,EAAEiB,OAAO,CAAC;gBACjBjB,EAAEkB,SAAS,CAAChB,6BAA6BiB,MAAM;gBAC/CnB,EAAEoB,aAAa,CAAC;aACnB;QACL;;AAeJ;AApCahB,qBACOiB,QAAQ;IAAC;QAAC;KAAiB;CAAC;AADnCjB,qBAEOkB,QAAQzB,QAAQ0B,KAAK,CAAC;IAClCX,aAAa;AACjB"}
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import { PlaydateSdkVersion } from '@/cli/types.js';
2
+ import { PlaydateSdkVersion } from '../../../types.js';
3
3
  interface Props {
4
4
  output: string;
5
5
  version: PlaydateSdkVersion;
6
+ overwriteJson: boolean;
6
7
  }
7
- export declare const GenerateTypes: ({ output, version }: Props) => React.JSX.Element;
8
+ export declare const GenerateTypes: ({ output, version, overwriteJson }: Props) => React.JSX.Element;
8
9
  export {};
@@ -1,16 +1,16 @@
1
1
  import React, { useMemo } from 'react';
2
- import { useFetchHtml } from '@/cli/commands/GenerateTypes/hooks/useFetchHtml.js';
3
- import { useGenerateTypeFile } from '@/cli/commands/GenerateTypes/hooks/useGenerateTypeFile.js';
4
- import { useGetVersion } from '@/cli/commands/GenerateTypes/hooks/useGetVersion.js';
5
- import { useParseDocumentation } from '@/cli/commands/GenerateTypes/hooks/useParseDocumentation.js';
6
- import { CheckList } from '@/cli/components/CheckList/index.js';
7
- import { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.js';
8
- export const GenerateTypes = ({ output, version })=>{
2
+ import { useFetchHtml } from '../../../commands/GenerateTypes/hooks/useFetchHtml.js';
3
+ import { useGenerateTypeFile } from '../../../commands/GenerateTypes/hooks/useGenerateTypeFile.js';
4
+ import { useGetVersion } from '../../../commands/GenerateTypes/hooks/useGetVersion.js';
5
+ import { useParseDocumentation } from '../../../commands/GenerateTypes/hooks/useParseDocumentation.js';
6
+ import { CheckList } from '../../../components/CheckList/index.js';
7
+ import { useQuitOnCtrlC } from '../../../hooks/useQuitOnCtrlC.js';
8
+ export const GenerateTypes = ({ output, version, overwriteJson })=>{
9
9
  useQuitOnCtrlC();
10
- const { fetchedVersion, getVersion } = useGetVersion(version);
10
+ const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);
11
11
  const { html, fetchHtml } = useFetchHtml(fetchedVersion);
12
12
  const { definitions, parseDocumentation } = useParseDocumentation(html, version);
13
- const { generateTypeFile } = useGenerateTypeFile(output, definitions);
13
+ const { generateTypeFile } = useGenerateTypeFile(output, definitions, typeProvider);
14
14
  const items = useMemo(()=>{
15
15
  return [
16
16
  getVersion,
@@ -21,11 +21,17 @@ export const GenerateTypes = ({ output, version })=>{
21
21
  }, [
22
22
  fetchedVersion,
23
23
  html,
24
- definitions
24
+ definitions,
25
+ typeProvider
25
26
  ]);
26
27
  return /*#__PURE__*/ React.createElement(CheckList, {
27
28
  items: items,
28
- onFinish: process.exit
29
+ onFinish: ()=>{
30
+ if (overwriteJson) {
31
+ typeProvider == null ? void 0 : typeProvider.save();
32
+ }
33
+ process.exit();
34
+ }
29
35
  });
30
36
  };
31
37
 
@@ -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 { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.js';\nimport { CheckListItem, PlaydateSdkVersion } from '@/cli/types.js';\n\ninterface Props {\n output: string;\n version: PlaydateSdkVersion;\n}\n\nexport const GenerateTypes = ({ output, version }: Props) => {\n useQuitOnCtrlC();\n\n const { fetchedVersion, getVersion } = useGetVersion(version);\n const { html, fetchHtml } = useFetchHtml(fetchedVersion);\n const { definitions, parseDocumentation } = useParseDocumentation(\n html,\n version\n );\n const { generateTypeFile } = useGenerateTypeFile(output, definitions);\n\n const items = useMemo(() => {\n return [\n getVersion,\n fetchHtml,\n parseDocumentation,\n generateTypeFile,\n ] as CheckListItem<unknown>[];\n }, [fetchedVersion, html, definitions]);\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["React","useMemo","useFetchHtml","useGenerateTypeFile","useGetVersion","useParseDocumentation","CheckList","useQuitOnCtrlC","GenerateTypes","output","version","fetchedVersion","getVersion","html","fetchHtml","definitions","parseDocumentation","generateTypeFile","items","onFinish","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;AAChE,SAASC,cAAc,QAAQ,gCAAgC;AAQ/D,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,OAAO,EAAS;IACpDH;IAEA,MAAM,EAAEI,cAAc,EAAEC,UAAU,EAAE,GAAGR,cAAcM;IACrD,MAAM,EAAEG,IAAI,EAAEC,SAAS,EAAE,GAAGZ,aAAaS;IACzC,MAAM,EAAEI,WAAW,EAAEC,kBAAkB,EAAE,GAAGX,sBACxCQ,MACAH;IAEJ,MAAM,EAAEO,gBAAgB,EAAE,GAAGd,oBAAoBM,QAAQM;IAEzD,MAAMG,QAAQjB,QAAQ;QAClB,OAAO;YACHW;YACAE;YACAE;YACAC;SACH;IACL,GAAG;QAACN;QAAgBE;QAAME;KAAY;IAEtC,qBAAO,oBAACT;QAAUY,OAAOA;QAAOC,UAAUC,QAAQC,IAAI;;AAC1D,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 { 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 { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.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 useQuitOnCtrlC();\n\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","useQuitOnCtrlC","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;AAChE,SAASC,cAAc,QAAQ,gCAAgC;AAS/D,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAS;IACnEJ;IAEA,MAAM,EAAEK,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGV,cAAcM;IACnE,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAE,GAAGd,aAAaW;IACzC,MAAM,EAAEI,WAAW,EAAEC,kBAAkB,EAAE,GAAGb,sBACxCU,MACAL;IAEJ,MAAM,EAAES,gBAAgB,EAAE,GAAGhB,oBACzBM,QACAQ,aACAL;IAGJ,MAAMQ,QAAQnB,QAAQ;QAClB,OAAO;YACHa;YACAE;YACAE;YACAC;SACH;IACL,GAAG;QAACN;QAAgBE;QAAME;QAAaL;KAAa;IAEpD,qBACI,oBAACN;QACGc,OAAOA;QACPC,UAAU;YACN,IAAIV,eAAe;gBACfC,gCAAAA,aAAcU,IAAI;YACtB;YAEAC,QAAQC,IAAI;QAChB;;AAGZ,EAAE"}
@@ -0,0 +1,4 @@
1
+ import { ModuleDeclaration, SourceFile } from 'ts-morph';
2
+ import { createTypeProvider } from '../../../commands/GenerateTypes/utils/createTypeProvider.js';
3
+ import { FunctionDescription } from '../../../types.js';
4
+ export declare const generateFunction: (func: FunctionDescription, subject: SourceFile | ModuleDeclaration, typeProvider: ReturnType<typeof createTypeProvider>) => void;
@@ -0,0 +1,28 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { TypescriptReservedNamed } from '../../../constants.js';
3
+ export const generateFunction = (func, subject, typeProvider)=>{
4
+ const isReserved = TypescriptReservedNamed.includes(func.name);
5
+ const name = isReserved ? `_${func.name}` : func.name;
6
+ var _typeProvider_getFunctionOverrideOptions;
7
+ subject.addFunction(_extends({
8
+ name,
9
+ docs: [
10
+ func.docs
11
+ ],
12
+ isExported: !isReserved,
13
+ returnType: typeProvider.getFunctionReturnType(func),
14
+ parameters: typeProvider.getParameters(func)
15
+ }, (_typeProvider_getFunctionOverrideOptions = typeProvider.getFunctionOverrideOptions(func)) != null ? _typeProvider_getFunctionOverrideOptions : {}));
16
+ if (isReserved) {
17
+ subject.addExportDeclaration({
18
+ namedExports: [
19
+ {
20
+ name,
21
+ alias: func.name
22
+ }
23
+ ]
24
+ });
25
+ }
26
+ };
27
+
28
+ //# sourceMappingURL=generateFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateFunction.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n ModuleDeclaration,\n SourceFile,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { FunctionDescription } from '@/cli/types.js';\n\nexport const generateFunction = (\n func: FunctionDescription,\n subject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>\n) => {\n const isReserved = TypescriptReservedNamed.includes(func.name);\n\n const name = isReserved ? `_${func.name}` : func.name;\n\n subject.addFunction({\n name,\n docs: [func.docs],\n isExported: !isReserved,\n returnType: typeProvider.getFunctionReturnType(func),\n parameters: typeProvider.getParameters(func),\n ...((typeProvider.getFunctionOverrideOptions(\n func\n ) as Partial<FunctionDeclarationStructure>) ?? {}),\n });\n\n if (isReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name,\n alias: func.name,\n },\n ],\n });\n }\n};\n"],"names":["TypescriptReservedNamed","generateFunction","func","subject","typeProvider","isReserved","includes","name","addFunction","docs","isExported","returnType","getFunctionReturnType","parameters","getParameters","getFunctionOverrideOptions","addExportDeclaration","namedExports","alias"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAMA,SAASA,uBAAuB,QAAQ,qBAAqB;AAG7D,OAAO,MAAMC,mBAAmB,CAC5BC,MACAC,SACAC;IAEA,MAAMC,aAAaL,wBAAwBM,QAAQ,CAACJ,KAAKK,IAAI;IAE7D,MAAMA,OAAOF,aAAa,CAAC,CAAC,EAAEH,KAAKK,IAAI,CAAC,CAAC,GAAGL,KAAKK,IAAI;QAQ5CH;IANTD,QAAQK,WAAW,CAAC;QAChBD;QACAE,MAAM;YAACP,KAAKO,IAAI;SAAC;QACjBC,YAAY,CAACL;QACbM,YAAYP,aAAaQ,qBAAqB,CAACV;QAC/CW,YAAYT,aAAaU,aAAa,CAACZ;OACnC,CAACE,2CAAAA,aAAaW,0BAA0B,CACxCb,iBADCE,2CAE0C,CAAC;IAGpD,IAAIC,YAAY;QACZF,QAAQa,oBAAoB,CAAC;YACzBC,cAAc;gBACV;oBACIV;oBACAW,OAAOhB,KAAKK,IAAI;gBACpB;aACH;QACL;IACJ;AACJ,EAAE"}
@@ -1,3 +1,4 @@
1
- import { ModuleDeclaration, SourceFile } from 'ts-morph';
2
- import { PlaydateNamespace } from '@/cli/types.js';
3
- export declare const generateNamespace: (subject: SourceFile | ModuleDeclaration, namespace: string, namespaceDescription: PlaydateNamespace, nextNamespaces: string[]) => void;
1
+ import { InterfaceDeclaration, ModuleDeclaration, SourceFile } from 'ts-morph';
2
+ import { createTypeProvider } from '../../../commands/GenerateTypes/utils/createTypeProvider.js';
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;
@@ -1,32 +1,79 @@
1
- import { TypescriptReservedNamed } from '@/cli/constants.js';
2
- export const generateNamespace = (subject, namespace, namespaceDescription, nextNamespaces)=>{
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { VariableDeclarationKind } from 'ts-morph';
3
+ import { generateFunction } from '../../../commands/GenerateTypes/fn/generateFunction.js';
4
+ export const generateNamespace = (namespaceDescription, namespaces, subjects, typeSubjects, typeProvider, types)=>{
5
+ const subjectName = namespaces.slice(0, -1).join('.');
6
+ const namespaceName = namespaces[namespaces.length - 1];
7
+ const isRoot = namespaces.length === 1 && namespaces[0] === 'playdate';
8
+ const subject = namespaces.length === 1 ? subjects.get('root') : subjects.get(subjectName);
9
+ if (!subject) {
10
+ return;
11
+ }
3
12
  const module = subject.addModule({
4
- name: namespace.trim()
13
+ name: namespaceName
5
14
  });
6
- if (nextNamespaces.length) {
7
- generateNamespace(module, nextNamespaces[0], namespaceDescription, nextNamespaces.slice(1));
8
- } else {
9
- for (const func of namespaceDescription.functions){
10
- const isReserved = TypescriptReservedNamed.includes(func.name);
11
- const name = isReserved ? `_${func.name}` : func.name;
12
- module.addFunction({
13
- name,
15
+ const addMethods = (typeName, subj, methods)=>{
16
+ const interfaceName = typeName.split('.').map((name)=>name[0].toUpperCase() + name.slice(1)).join('');
17
+ const typeInterface = subj.addInterface({
18
+ name: interfaceName
19
+ });
20
+ typeSubjects.set(typeName, typeInterface);
21
+ for (const func of methods){
22
+ const parameters = typeProvider.getParameters(func);
23
+ typeInterface.addMethod(_extends({
24
+ name: func.name,
14
25
  docs: [
15
26
  func.docs
16
27
  ],
17
- isExported: !isReserved
18
- });
19
- if (isReserved) {
20
- module.addExportDeclaration({
21
- namedExports: [
22
- {
23
- name,
24
- alias: func.name
25
- }
26
- ]
28
+ returnType: typeProvider.getFunctionReturnType(func),
29
+ parameters
30
+ }, typeProvider.getFunctionOverrideOptions(func)));
31
+ }
32
+ };
33
+ if (isRoot) {
34
+ module.addJsDoc({
35
+ description: 'Playdate SDK'
36
+ });
37
+ module.addStatements(typeProvider.getStatements());
38
+ Object.keys(types).forEach((eachType)=>{
39
+ addMethods(eachType, module, types[eachType].methods);
40
+ });
41
+ }
42
+ subjects.set(namespaces.join('.'), module);
43
+ if (namespaceDescription.methods.length > 0) {
44
+ addMethods(namespaces.join('.'), subjects.get('playdate'), namespaceDescription.methods);
45
+ }
46
+ for (const property of namespaceDescription.properties){
47
+ const propertyDetails = typeProvider.getPropertyDetails(property);
48
+ if (!propertyDetails.isStatic) {
49
+ const typeName = namespaces.join('.');
50
+ if (typeSubjects.has(typeName)) {
51
+ const typeInterface = typeSubjects.get(typeName);
52
+ typeInterface.addProperty({
53
+ name: property.name,
54
+ type: propertyDetails.type,
55
+ docs: [
56
+ property.docs
57
+ ],
58
+ isReadonly: propertyDetails.isReadOnly
27
59
  });
28
60
  }
61
+ continue;
29
62
  }
63
+ const propertyType = propertyDetails.type;
64
+ module.addVariableStatement({
65
+ isExported: true,
66
+ declarationKind: VariableDeclarationKind.Const,
67
+ declarations: [
68
+ {
69
+ name: property.name,
70
+ type: propertyType
71
+ }
72
+ ]
73
+ });
74
+ }
75
+ for (const func of namespaceDescription.functions){
76
+ generateFunction(func, module, typeProvider);
30
77
  }
31
78
  };
32
79
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateNamespace.ts"],"sourcesContent":["import { ModuleDeclaration, SourceFile } from 'ts-morph';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { PlaydateNamespace } from '@/cli/types.js';\n\nexport const generateNamespace = (\n subject: SourceFile | ModuleDeclaration,\n namespace: string,\n namespaceDescription: PlaydateNamespace,\n nextNamespaces: string[]\n) => {\n const module = subject.addModule({\n name: namespace.trim(),\n });\n\n if (nextNamespaces.length) {\n generateNamespace(\n module,\n nextNamespaces[0],\n namespaceDescription,\n nextNamespaces.slice(1)\n );\n } else {\n for (const func of namespaceDescription.functions) {\n const isReserved = TypescriptReservedNamed.includes(func.name);\n\n const name = isReserved ? `_${func.name}` : func.name;\n\n module.addFunction({\n name,\n docs: [func.docs],\n isExported: !isReserved,\n });\n\n if (isReserved) {\n module.addExportDeclaration({\n namedExports: [\n {\n name,\n alias: func.name,\n },\n ],\n });\n }\n }\n }\n};\n"],"names":["TypescriptReservedNamed","generateNamespace","subject","namespace","namespaceDescription","nextNamespaces","module","addModule","name","trim","length","slice","func","functions","isReserved","includes","addFunction","docs","isExported","addExportDeclaration","namedExports","alias"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,uBAAuB,QAAQ,qBAAqB;AAG7D,OAAO,MAAMC,oBAAoB,CAC7BC,SACAC,WACAC,sBACAC;IAEA,MAAMC,SAASJ,QAAQK,SAAS,CAAC;QAC7BC,MAAML,UAAUM,IAAI;IACxB;IAEA,IAAIJ,eAAeK,MAAM,EAAE;QACvBT,kBACIK,QACAD,cAAc,CAAC,EAAE,EACjBD,sBACAC,eAAeM,KAAK,CAAC;IAE7B,OAAO;QACH,KAAK,MAAMC,QAAQR,qBAAqBS,SAAS,CAAE;YAC/C,MAAMC,aAAad,wBAAwBe,QAAQ,CAACH,KAAKJ,IAAI;YAE7D,MAAMA,OAAOM,aAAa,CAAC,CAAC,EAAEF,KAAKJ,IAAI,CAAC,CAAC,GAAGI,KAAKJ,IAAI;YAErDF,OAAOU,WAAW,CAAC;gBACfR;gBACAS,MAAM;oBAACL,KAAKK,IAAI;iBAAC;gBACjBC,YAAY,CAACJ;YACjB;YAEA,IAAIA,YAAY;gBACZR,OAAOa,oBAAoB,CAAC;oBACxBC,cAAc;wBACV;4BACIZ;4BACAa,OAAOT,KAAKJ,IAAI;wBACpB;qBACH;gBACL;YACJ;QACJ;IACJ;AACJ,EAAE"}
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,OAASA,IAAI,CAAC,EAAE,CAACQ,WAAW,KAAKR,KAAKT,KAAK,CAAC,IACjDC,IAAI,CAAC;QACV,MAAMiB,gBAAgBN,KAAKO,YAAY,CAAC;YACpCV,MAAMK;QACV;QACAlB,aAAawB,GAAG,CAACT,UAAUO;QAE3B,KAAK,MAAMG,QAAQR,QAAS;YACxB,MAAMS,aAAazB,aAAa0B,aAAa,CAACF;YAE9CH,cAAcM,SAAS,CAAC;gBACpBf,MAAMY,KAAKZ,IAAI;gBACfgB,MAAM;oBAACJ,KAAKI,IAAI;iBAAC;gBACjBC,YAAY7B,aAAa8B,qBAAqB,CAACN;gBAC/CC;eACIzB,aAAa+B,0BAA0B,CACvCP;QAGZ;IACJ;IAEA,IAAIjB,QAAQ;QACRG,OAAOsB,QAAQ,CAAC;YACZC,aAAa;QACjB;QACAvB,OAAOwB,aAAa,CAAClC,aAAamC,aAAa;QAE/CC,OAAOC,IAAI,CAACpC,OAAOqC,OAAO,CAAC,CAACC;YACxB1B,WAAW0B,UAAU7B,QAAQT,KAAK,CAACsC,SAAS,CAACvB,OAAO;QACxD;IACJ;IAEAlB,SAASyB,GAAG,CAAC1B,WAAWO,IAAI,CAAC,MAAMM;IAEnC,IAAId,qBAAqBoB,OAAO,CAACV,MAAM,GAAG,GAAG;QACzCO,WACIhB,WAAWO,IAAI,CAAC,MAChBN,SAASW,GAAG,CAAC,aACbb,qBAAqBoB,OAAO;IAEpC;IAEA,KAAK,MAAMwB,YAAY5C,qBAAqB6C,UAAU,CAAE;QACpD,MAAMC,kBAAkB1C,aAAa2C,kBAAkB,CAACH;QACxD,IAAI,CAACE,gBAAgBE,QAAQ,EAAE;YAC3B,MAAM9B,WAAWjB,WAAWO,IAAI,CAAC;YAEjC,IAAIL,aAAa8C,GAAG,CAAC/B,WAAW;gBAC5B,MAAMO,gBAAgBtB,aAAaU,GAAG,CAClCK;gBAGJO,cAAcyB,WAAW,CAAC;oBACtBlC,MAAM4B,SAAS5B,IAAI;oBACnBmC,MAAML,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,14 +1,5 @@
1
- import { FunctionDescription, PlaydateNamespace, PlaydateType } from '@/cli/types.js';
2
- export declare const getApiDefinitions: (functions: FunctionDescription[]) => {
1
+ import { FunctionDescription, PlaydateNamespace, PlaydateType, PropertyDescription } from '../../../types.js';
2
+ export declare const getApiDefinitions: (functions: FunctionDescription[], properties: PropertyDescription[]) => {
3
3
  namespaces: Record<string, PlaydateNamespace>;
4
4
  types: Record<string, PlaydateType>;
5
- constants: {
6
- name: string;
7
- values: {
8
- name: string;
9
- value: number;
10
- docs: string;
11
- }[];
12
- docs: string;
13
- }[];
14
5
  };
@@ -1,5 +1,4 @@
1
- import { playdateConstants } from '@/cli/commands/GenerateTypes/utils/playdateConstants.js';
2
- export const getApiDefinitions = (functions)=>{
1
+ export const getApiDefinitions = (functions, properties)=>{
3
2
  const namespaces = {};
4
3
  const types = {};
5
4
  const realNamespaces = new Set();
@@ -9,17 +8,29 @@ export const getApiDefinitions = (functions)=>{
9
8
  let currentNamespace = '';
10
9
  func.namespaces.forEach((ns)=>{
11
10
  currentNamespace = currentNamespace ? `${currentNamespace}.${ns}` : ns;
12
- // Add to realNamespaces because there's a non-method function here
13
- realNamespaces.add(currentNamespace);
11
+ const realNamespaceName = currentNamespace.trim();
12
+ if (!realNamespaces.has(realNamespaceName)) {
13
+ realNamespaces.add(realNamespaceName);
14
+ }
14
15
  });
15
16
  }
16
17
  });
18
+ properties.forEach((prop)=>{
19
+ let currentNamespace = '';
20
+ prop.namespaces.forEach((ns)=>{
21
+ currentNamespace = currentNamespace ? `${currentNamespace}.${ns}` : ns;
22
+ const realNamespaceName = currentNamespace.trim();
23
+ if (!realNamespaces.has(realNamespaceName)) {
24
+ realNamespaces.add(realNamespaceName);
25
+ }
26
+ });
27
+ });
17
28
  functions.forEach((func)=>{
18
29
  if (func.hasSelf) {
19
30
  let currentNamespace = '';
20
31
  func.namespaces.forEach((ns)=>{
21
32
  currentNamespace = currentNamespace ? `${currentNamespace}.${ns}` : ns;
22
- if (!realNamespaces.has(currentNamespace)) {
33
+ if (!potentialNamespaces.has(currentNamespace)) {
23
34
  potentialNamespaces.add(currentNamespace);
24
35
  }
25
36
  });
@@ -28,14 +39,15 @@ export const getApiDefinitions = (functions)=>{
28
39
  realNamespaces.forEach((ns)=>{
29
40
  namespaces[ns] = {
30
41
  functions: [],
31
- callbacks: []
42
+ methods: [],
43
+ properties: []
32
44
  };
33
45
  });
34
46
  functions.forEach((func)=>{
35
47
  const fullNamespacePath = func.namespaces.join('.');
36
48
  if (realNamespaces.has(fullNamespacePath)) {
37
49
  if (func.hasSelf) {
38
- namespaces[fullNamespacePath].callbacks.push(func);
50
+ namespaces[fullNamespacePath].methods.push(func);
39
51
  } else {
40
52
  namespaces[fullNamespacePath].functions.push(func);
41
53
  }
@@ -48,10 +60,15 @@ export const getApiDefinitions = (functions)=>{
48
60
  types[fullNamespacePath].methods.push(func);
49
61
  }
50
62
  });
63
+ properties.forEach((prop)=>{
64
+ const fullNamespacePath = prop.namespaces.join('.');
65
+ if (realNamespaces.has(fullNamespacePath)) {
66
+ namespaces[fullNamespacePath].properties.push(prop);
67
+ }
68
+ });
51
69
  return {
52
70
  namespaces,
53
- types,
54
- constants: playdateConstants
71
+ types
55
72
  };
56
73
  };
57
74
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import { playdateConstants } from '@/cli/commands/GenerateTypes/utils/playdateConstants.js';\nimport {\n ApiDefinitions,\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (functions: FunctionDescription[]) => {\n const namespaces: Record<string, PlaydateNamespace> = {};\n const types: Record<string, PlaydateType> = {};\n const realNamespaces = new Set<string>();\n const potentialNamespaces: Set<string> = new Set();\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 // Add to realNamespaces because there's a non-method function here\n realNamespaces.add(currentNamespace);\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 (!realNamespaces.has(currentNamespace)) {\n potentialNamespaces.add(currentNamespace);\n }\n });\n }\n });\n\n realNamespaces.forEach((ns) => {\n namespaces[ns] = {\n functions: [],\n callbacks: [],\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].callbacks.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 return {\n namespaces,\n types,\n constants: playdateConstants,\n } satisfies ApiDefinitions;\n};\n"],"names":["playdateConstants","getApiDefinitions","functions","namespaces","types","realNamespaces","Set","potentialNamespaces","forEach","func","hasSelf","currentNamespace","ns","add","has","callbacks","fullNamespacePath","join","push","methods","constants"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,iBAAiB,QAAQ,0DAA0D;AAQ5F,OAAO,MAAMC,oBAAoB,CAACC;IAC9B,MAAMC,aAAgD,CAAC;IACvD,MAAMC,QAAsC,CAAC;IAC7C,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,sBAAmC,IAAID;IAE7CJ,UAAUM,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,mEAAmE;gBACnEP,eAAeQ,GAAG,CAACF;YACvB;QACJ;IACJ;IAEAT,UAAUM,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,CAACP,eAAeS,GAAG,CAACH,mBAAmB;oBACvCJ,oBAAoBM,GAAG,CAACF;gBAC5B;YACJ;QACJ;IACJ;IAEAN,eAAeG,OAAO,CAAC,CAACI;QACpBT,UAAU,CAACS,GAAG,GAAG;YACbV,WAAW,EAAE;YACba,WAAW,EAAE;QACjB;IACJ;IAEAb,UAAUM,OAAO,CAAC,CAACC;QACf,MAAMO,oBAAoBP,KAAKN,UAAU,CAACc,IAAI,CAAC;QAE/C,IAAIZ,eAAeS,GAAG,CAACE,oBAAoB;YACvC,IAAIP,KAAKC,OAAO,EAAE;gBACdP,UAAU,CAACa,kBAAkB,CAACD,SAAS,CAACG,IAAI,CAACT;YACjD,OAAO;gBACHN,UAAU,CAACa,kBAAkB,CAACd,SAAS,CAACgB,IAAI,CAACT;YACjD;QACJ,OAAO,IAAIF,oBAAoBO,GAAG,CAACE,oBAAoB;YACnD,IAAI,CAACZ,KAAK,CAACY,kBAAkB,EAAE;gBAC3BZ,KAAK,CAACY,kBAAkB,GAAG;oBAAEG,SAAS,EAAE;gBAAC;YAC7C;YACAf,KAAK,CAACY,kBAAkB,CAACG,OAAO,CAACD,IAAI,CAACT;QAC1C;IACJ;IAEA,OAAO;QACHN;QACAC;QACAgB,WAAWpB;IACf;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 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"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDescription, PropertyDescription } from '../../../types.js';
2
+ export declare const getDescriptionsFromHtml: (html: string, version: string) => {
3
+ functions: FunctionDescription[];
4
+ properties: PropertyDescription[];
5
+ };