crankscript 0.9.11 → 0.10.1
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/assets/plugin.js +11 -0
- package/assets/plugin.ts +23 -0
- package/package.json +3 -1
- package/src/commands/CompileCommand/CompileCommand.d.ts +0 -1
- package/src/commands/CompileCommand/CompileCommand.js +2 -9
- package/src/commands/CompileCommand/CompileCommand.js.map +1 -1
- package/src/commands/CompileCommand/components/Compile.d.ts +1 -2
- package/src/commands/CompileCommand/components/Compile.js +5 -35
- package/src/commands/CompileCommand/components/Compile.js.map +1 -1
- package/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.d.ts +2 -0
- package/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.js +6 -0
- package/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.js.map +1 -0
- package/src/commands/CompileCommand/hooks/useCompileTasks.d.ts +2 -0
- package/src/commands/CompileCommand/hooks/useCompileTasks.js +34 -0
- package/src/commands/CompileCommand/hooks/useCompileTasks.js.map +1 -0
- package/src/commands/GenerateTypes/components/GenerateTypes.js +0 -2
- package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getApiDefinitions.d.ts +2 -2
- package/src/commands/GenerateTypes/fn/getApiDefinitions.js +3 -2
- package/src/commands/GenerateTypes/fn/getApiDefinitions.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js +4 -1
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getFunctionTypeOverride.d.ts +1 -0
- package/src/commands/GenerateTypes/fn/getFunctionTypeOverride.js +7 -0
- package/src/commands/GenerateTypes/fn/getFunctionTypeOverride.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +2 -1
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -1
- package/src/commands/GenerateTypes/utils/functionTypeOverrides.d.ts +2 -0
- package/src/commands/GenerateTypes/utils/functionTypeOverrides.js +18 -0
- package/src/commands/GenerateTypes/utils/functionTypeOverrides.js.map +1 -0
- package/src/commands/NewCommand/NewCommand.d.ts +10 -0
- package/src/commands/NewCommand/NewCommand.js +35 -0
- package/src/commands/NewCommand/NewCommand.js.map +1 -0
- package/src/commands/NewCommand/components/New.d.ts +8 -0
- package/src/commands/NewCommand/components/New.js +26 -0
- package/src/commands/NewCommand/components/New.js.map +1 -0
- package/src/commands/SimulatorCommand/SimulatorCommand.d.ts +11 -0
- package/src/commands/SimulatorCommand/SimulatorCommand.js +35 -0
- package/src/commands/SimulatorCommand/SimulatorCommand.js.map +1 -0
- package/src/commands/SimulatorCommand/components/Simulator.d.ts +10 -0
- package/src/commands/SimulatorCommand/components/Simulator.js +66 -0
- package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -0
- package/src/commands/SimulatorCommand/index.d.ts +1 -0
- package/src/commands/SimulatorCommand/index.js +3 -0
- package/src/commands/SimulatorCommand/index.js.map +1 -0
- package/src/commands/TranspileCommand/TranspileCommand.d.ts +2 -0
- package/src/commands/TranspileCommand/TranspileCommand.js +9 -5
- package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
- package/src/commands/TranspileCommand/components/Transpile.d.ts +4 -2
- package/src/commands/TranspileCommand/components/Transpile.js +2 -30
- package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/transpile.d.ts +1 -0
- package/src/commands/TranspileCommand/fn/transpile.js +19 -0
- package/src/commands/TranspileCommand/fn/transpile.js.map +1 -0
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +2 -0
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +18 -0
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -0
- package/src/components/CheckList/Item.js +5 -21
- package/src/components/CheckList/Item.js.map +1 -1
- package/src/components/Spinner.d.ts +3 -0
- package/src/components/Spinner.js +26 -0
- package/src/components/Spinner.js.map +1 -0
- package/src/index.js +10 -1
- package/src/index.js.map +1 -1
- package/src/types.d.ts +6 -0
- package/src/types.js +4 -0
- package/src/types.js.map +1 -1
- package/src/hooks/useQuitOnCtrlC.d.ts +0 -1
- package/src/hooks/useQuitOnCtrlC.js +0 -10
- package/src/hooks/useQuitOnCtrlC.js.map +0 -1
package/assets/plugin.js
CHANGED
@@ -162,6 +162,17 @@ var transformClassDeclaration = function (declaration, context) {
|
|
162
162
|
.map(function (method) { return transformMethodDeclaration(context, method, className); })
|
163
163
|
.filter(function (method) { return method !== undefined; });
|
164
164
|
statements.push.apply(statements, methods);
|
165
|
+
// export the class if needed
|
166
|
+
// todo: check if there is a cleaner way to do this
|
167
|
+
if ('localSymbol' in declaration &&
|
168
|
+
typeof declaration.localSymbol === 'object' &&
|
169
|
+
'exportSymbol' in declaration.localSymbol &&
|
170
|
+
typeof declaration.localSymbol.exportSymbol === 'object' &&
|
171
|
+
'escapedName' in declaration.localSymbol.exportSymbol &&
|
172
|
+
typeof declaration.localSymbol.exportSymbol.escapedName === 'string') {
|
173
|
+
var escapedName = declaration.localSymbol.exportSymbol.escapedName;
|
174
|
+
statements.push(tstl.createAssignmentStatement(tstl.createTableIndexExpression(tstl.createIdentifier('____exports'), tstl.createStringLiteral(escapedName)), className));
|
175
|
+
}
|
165
176
|
return statements;
|
166
177
|
};
|
167
178
|
exports.transformClassDeclaration = transformClassDeclaration;
|
package/assets/plugin.ts
CHANGED
@@ -233,6 +233,29 @@ export const transformClassDeclaration: FunctionVisitor<
|
|
233
233
|
.filter((method): method is tstl.Statement => method !== undefined);
|
234
234
|
statements.push(...methods);
|
235
235
|
|
236
|
+
// export the class if needed
|
237
|
+
// todo: check if there is a cleaner way to do this
|
238
|
+
if (
|
239
|
+
'localSymbol' in declaration &&
|
240
|
+
typeof declaration.localSymbol === 'object' &&
|
241
|
+
'exportSymbol' in declaration.localSymbol &&
|
242
|
+
typeof declaration.localSymbol.exportSymbol === 'object' &&
|
243
|
+
'escapedName' in declaration.localSymbol.exportSymbol &&
|
244
|
+
typeof declaration.localSymbol.exportSymbol.escapedName === 'string'
|
245
|
+
) {
|
246
|
+
const escapedName = declaration.localSymbol.exportSymbol.escapedName;
|
247
|
+
|
248
|
+
statements.push(
|
249
|
+
tstl.createAssignmentStatement(
|
250
|
+
tstl.createTableIndexExpression(
|
251
|
+
tstl.createIdentifier('____exports'),
|
252
|
+
tstl.createStringLiteral(escapedName)
|
253
|
+
),
|
254
|
+
className
|
255
|
+
)
|
256
|
+
);
|
257
|
+
}
|
258
|
+
|
236
259
|
return statements;
|
237
260
|
};
|
238
261
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "crankscript",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.1",
|
4
4
|
"scripts": {
|
5
5
|
"dev": "tsx src/index.ts",
|
6
6
|
"post-build": "tsc-alias --project tsconfig.json",
|
@@ -17,7 +17,9 @@
|
|
17
17
|
"clipanion": "^4.0.0-rc.4",
|
18
18
|
"ink": "^5.0.1",
|
19
19
|
"react": "^18.3.1",
|
20
|
+
"tiged": "^3.0.0-rc.0",
|
20
21
|
"ts-morph": "^23.0.0",
|
22
|
+
"turndown": "^7.2.0",
|
21
23
|
"typanion": "^3.14.0",
|
22
24
|
"typescript-to-lua": "^1.27.0"
|
23
25
|
},
|
@@ -4,6 +4,5 @@ import { Environment } from '../../environment/dto/Environment.js';
|
|
4
4
|
export declare class CompileCommand extends EnvironmentAwareCommand {
|
5
5
|
static paths: string[][];
|
6
6
|
static usage: import("clipanion").Usage;
|
7
|
-
watch: boolean;
|
8
7
|
renderWithEnvironment(environment: Environment): React.JSX.Element;
|
9
8
|
}
|
@@ -1,18 +1,11 @@
|
|
1
|
-
import { Command
|
1
|
+
import { Command } from 'clipanion';
|
2
2
|
import React from 'react';
|
3
3
|
import { Compile } from '../../commands/CompileCommand/components/Compile.js';
|
4
4
|
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
5
5
|
export class CompileCommand extends EnvironmentAwareCommand {
|
6
6
|
renderWithEnvironment(environment) {
|
7
7
|
return /*#__PURE__*/ React.createElement(Compile, {
|
8
|
-
environment: environment
|
9
|
-
watch: this.watch
|
10
|
-
});
|
11
|
-
}
|
12
|
-
constructor(...args){
|
13
|
-
super(...args);
|
14
|
-
this.watch = Option.Boolean('-w,--watch', false, {
|
15
|
-
description: 'Watch for changes'
|
8
|
+
environment: environment
|
16
9
|
});
|
17
10
|
}
|
18
11
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/CompileCommand/CompileCommand.tsx"],"sourcesContent":["import { Command
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/CompileCommand/CompileCommand.tsx"],"sourcesContent":["import { Command } from 'clipanion';\nimport React from 'react';\nimport { Compile } from '@/cli/commands/CompileCommand/components/Compile.js';\nimport { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport class CompileCommand extends EnvironmentAwareCommand {\n static override paths = [['compile']];\n\n static override usage = Command.Usage({\n description: 'Compiles the code and runs the simulator',\n });\n\n override renderWithEnvironment(environment: Environment) {\n return <Compile environment={environment} />;\n }\n}\n"],"names":["Command","React","Compile","EnvironmentAwareCommand","CompileCommand","renderWithEnvironment","environment","paths","usage","Usage","description"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,sDAAsD;AAC9E,SAASC,uBAAuB,QAAQ,kDAAkD;AAG1F,OAAO,MAAMC,uBAAuBD;IAOvBE,sBAAsBC,WAAwB,EAAE;QACrD,qBAAO,oBAACJ;YAAQI,aAAaA;;IACjC;AACJ;AAVaF,eACOG,QAAQ;IAAC;QAAC;KAAU;CAAC;AAD5BH,eAGOI,QAAQR,QAAQS,KAAK,CAAC;IAClCC,aAAa;AACjB"}
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
2
2
|
import { Environment } from '../../../environment/dto/Environment.js';
|
3
3
|
interface Props {
|
4
4
|
environment: Environment;
|
5
|
-
watch?: boolean;
|
6
5
|
}
|
7
|
-
export declare const Compile: ({ environment
|
6
|
+
export declare const Compile: ({ environment }: Props) => React.JSX.Element;
|
8
7
|
export {};
|
@@ -1,40 +1,10 @@
|
|
1
|
-
import { exec } from 'node:child_process';
|
2
|
-
import { existsSync } from 'node:fs';
|
3
|
-
import { join } from 'node:path';
|
4
1
|
import process from 'node:process';
|
5
|
-
import
|
6
|
-
import
|
2
|
+
import React from 'react';
|
3
|
+
import { getPdcPathFromEnvironment } from '../../../commands/CompileCommand/fn/getPdcPathFromEnvironment.js';
|
4
|
+
import { useCompileTasks } from '../../../commands/CompileCommand/hooks/useCompileTasks.js';
|
7
5
|
import { CheckList } from '../../../components/CheckList/index.js';
|
8
|
-
|
9
|
-
const
|
10
|
-
export const Compile = ({ environment, watch = false })=>{
|
11
|
-
useQuitOnCtrlC();
|
12
|
-
const path = join(environment.sdkPath.path, 'bin', 'pdc');
|
13
|
-
const items = useMemo(()=>[
|
14
|
-
{
|
15
|
-
waitingDescription: 'Waiting to check for pdc binary...',
|
16
|
-
errorDescription: 'Could not find pdc binary',
|
17
|
-
runningDescription: 'Checking for pdc binary...',
|
18
|
-
finishedDescription: (result)=>`Found pdc binary at "${result}"`,
|
19
|
-
runner: async ()=>{
|
20
|
-
if (!existsSync(path)) {
|
21
|
-
throw new Error('Could not find pdc binary');
|
22
|
-
}
|
23
|
-
return path;
|
24
|
-
},
|
25
|
-
ready: true
|
26
|
-
},
|
27
|
-
{
|
28
|
-
waitingDescription: 'Waiting for pdc binary path...',
|
29
|
-
errorDescription: 'Could not compile lua code',
|
30
|
-
runningDescription: 'Compiling lua code...',
|
31
|
-
finishedDescription: ()=>'Lua code compiled',
|
32
|
-
runner: async ()=>{
|
33
|
-
return promisifiedExec(`${path} Source`);
|
34
|
-
},
|
35
|
-
ready: true
|
36
|
-
}
|
37
|
-
], []);
|
6
|
+
export const Compile = ({ environment })=>{
|
7
|
+
const items = useCompileTasks(getPdcPathFromEnvironment(environment));
|
38
8
|
return /*#__PURE__*/ React.createElement(CheckList, {
|
39
9
|
items: items,
|
40
10
|
onFinish: process.exit
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import process from 'node:process';\nimport React from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n}\n\nexport const Compile = ({ environment }: Props) => {\n const items = useCompileTasks(getPdcPathFromEnvironment(environment));\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["process","React","getPdcPathFromEnvironment","useCompileTasks","CheckList","Compile","environment","items","onFinish","exit"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,yBAAyB,QAAQ,gEAAgE;AAC1G,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,SAAS,QAAQ,sCAAsC;AAOhE,OAAO,MAAMC,UAAU,CAAC,EAAEC,WAAW,EAAS;IAC1C,MAAMC,QAAQJ,gBAAgBD,0BAA0BI;IAExD,qBAAO,oBAACF;QAAUG,OAAOA;QAAOC,UAAUR,QAAQS,IAAI;;AAC1D,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/fn/getPdcPathFromEnvironment.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport const getPdcPathFromEnvironment = (environment: Environment) => {\n return join(environment.sdkPath.path, 'bin', 'pdc');\n};\n"],"names":["join","getPdcPathFromEnvironment","environment","sdkPath","path"],"rangeMappings":";;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AAGjC,OAAO,MAAMC,4BAA4B,CAACC;IACtC,OAAOF,KAAKE,YAAYC,OAAO,CAACC,IAAI,EAAE,OAAO;AACjD,EAAE"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { exec } from 'node:child_process';
|
2
|
+
import { existsSync } from 'node:fs';
|
3
|
+
import { promisify } from 'node:util';
|
4
|
+
import { useMemo } from 'react';
|
5
|
+
const promisifiedExec = promisify(exec);
|
6
|
+
export const useCompileTasks = (sdkPath)=>{
|
7
|
+
return useMemo(()=>[
|
8
|
+
{
|
9
|
+
waitingDescription: 'Waiting to check for pdc binary...',
|
10
|
+
errorDescription: 'Could not find pdc binary',
|
11
|
+
runningDescription: 'Checking for pdc binary...',
|
12
|
+
finishedDescription: (result)=>`Found pdc binary at "${result}"`,
|
13
|
+
runner: async ()=>{
|
14
|
+
if (!existsSync(sdkPath)) {
|
15
|
+
throw new Error('Could not find pdc binary');
|
16
|
+
}
|
17
|
+
return sdkPath;
|
18
|
+
},
|
19
|
+
ready: true
|
20
|
+
},
|
21
|
+
{
|
22
|
+
waitingDescription: 'Waiting for pdc binary path...',
|
23
|
+
errorDescription: 'Could not compile lua code',
|
24
|
+
runningDescription: 'Compiling lua code...',
|
25
|
+
finishedDescription: ()=>'Lua code compiled',
|
26
|
+
runner: async ()=>{
|
27
|
+
return promisifiedExec(`${sdkPath} Source`);
|
28
|
+
},
|
29
|
+
ready: true
|
30
|
+
}
|
31
|
+
], []);
|
32
|
+
};
|
33
|
+
|
34
|
+
//# sourceMappingURL=useCompileTasks.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { promisify } from 'node:util';\nimport { useMemo } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nconst promisifiedExec = promisify(exec);\n\nexport const useCompileTasks = (sdkPath: string) => {\n return useMemo(\n () => [\n {\n waitingDescription: 'Waiting to check for pdc binary...',\n errorDescription: 'Could not find pdc binary',\n runningDescription: 'Checking for pdc binary...',\n finishedDescription: (result) =>\n `Found pdc binary at \"${result}\"`,\n runner: async () => {\n if (!existsSync(sdkPath)) {\n throw new Error('Could not find pdc binary');\n }\n\n return sdkPath;\n },\n ready: true,\n } satisfies CheckListItem<string>,\n {\n waitingDescription: 'Waiting for pdc binary path...',\n errorDescription: 'Could not compile lua code',\n runningDescription: 'Compiling lua code...',\n finishedDescription: () => 'Lua code compiled',\n runner: async () => {\n return promisifiedExec(`${sdkPath} Source`);\n },\n ready: true,\n },\n ],\n []\n ) as CheckListItem<unknown>[];\n};\n"],"names":["exec","existsSync","promisify","useMemo","promisifiedExec","useCompileTasks","sdkPath","waitingDescription","errorDescription","runningDescription","finishedDescription","result","runner","Error","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,OAAO,QAAQ,QAAQ;AAGhC,MAAMC,kBAAkBF,UAAUF;AAElC,OAAO,MAAMK,kBAAkB,CAACC;IAC5B,OAAOH,QACH,IAAM;YACF;gBACII,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,CAACC,SAClB,CAAC,qBAAqB,EAAEA,OAAO,CAAC,CAAC;gBACrCC,QAAQ;oBACJ,IAAI,CAACX,WAAWK,UAAU;wBACtB,MAAM,IAAIO,MAAM;oBACpB;oBAEA,OAAOP;gBACX;gBACAQ,OAAO;YACX;YACA;gBACIP,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BE,QAAQ;oBACJ,OAAOR,gBAAgB,CAAC,EAAEE,QAAQ,OAAO,CAAC;gBAC9C;gBACAQ,OAAO;YACX;SACH,EACD,EAAE;AAEV,EAAE"}
|
@@ -4,9 +4,7 @@ import { useGenerateTypeFile } from '../../../commands/GenerateTypes/hooks/useGe
|
|
4
4
|
import { useGetVersion } from '../../../commands/GenerateTypes/hooks/useGetVersion.js';
|
5
5
|
import { useParseDocumentation } from '../../../commands/GenerateTypes/hooks/useParseDocumentation.js';
|
6
6
|
import { CheckList } from '../../../components/CheckList/index.js';
|
7
|
-
import { useQuitOnCtrlC } from '../../../hooks/useQuitOnCtrlC.js';
|
8
7
|
export const GenerateTypes = ({ output, version, overwriteJson })=>{
|
9
|
-
useQuitOnCtrlC();
|
10
8
|
const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);
|
11
9
|
const { html, fetchHtml } = useFetchHtml(fetchedVersion);
|
12
10
|
const { definitions, parseDocumentation } = useParseDocumentation(html, version);
|
@@ -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 {
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useFetchHtml } from '@/cli/commands/GenerateTypes/hooks/useFetchHtml.js';\nimport { useGenerateTypeFile } from '@/cli/commands/GenerateTypes/hooks/useGenerateTypeFile.js';\nimport { useGetVersion } from '@/cli/commands/GenerateTypes/hooks/useGetVersion.js';\nimport { useParseDocumentation } from '@/cli/commands/GenerateTypes/hooks/useParseDocumentation.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, PlaydateSdkVersion } from '@/cli/types.js';\n\ninterface Props {\n output: string;\n version: PlaydateSdkVersion;\n overwriteJson: boolean;\n}\n\nexport const GenerateTypes = ({ output, version, overwriteJson }: Props) => {\n const { typeProvider, fetchedVersion, getVersion } = useGetVersion(version);\n const { html, fetchHtml } = useFetchHtml(fetchedVersion);\n const { definitions, parseDocumentation } = useParseDocumentation(\n html,\n version\n );\n const { generateTypeFile } = useGenerateTypeFile(\n output,\n definitions,\n typeProvider\n );\n\n const items = useMemo(() => {\n return [\n getVersion,\n fetchHtml,\n parseDocumentation,\n generateTypeFile,\n ] as CheckListItem<unknown>[];\n }, [fetchedVersion, html, definitions, typeProvider]);\n\n return (\n <CheckList\n items={items}\n onFinish={() => {\n if (overwriteJson) {\n typeProvider?.save();\n }\n\n process.exit();\n }}\n />\n );\n};\n"],"names":["React","useMemo","useFetchHtml","useGenerateTypeFile","useGetVersion","useParseDocumentation","CheckList","GenerateTypes","output","version","overwriteJson","typeProvider","fetchedVersion","getVersion","html","fetchHtml","definitions","parseDocumentation","generateTypeFile","items","onFinish","save","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,YAAY,QAAQ,qDAAqD;AAClF,SAASC,mBAAmB,QAAQ,4DAA4D;AAChG,SAASC,aAAa,QAAQ,sDAAsD;AACpF,SAASC,qBAAqB,QAAQ,8DAA8D;AACpG,SAASC,SAAS,QAAQ,sCAAsC;AAShE,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAS;IACnE,MAAM,EAAEC,YAAY,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGT,cAAcK;IACnE,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAE,GAAGb,aAAaU;IACzC,MAAM,EAAEI,WAAW,EAAEC,kBAAkB,EAAE,GAAGZ,sBACxCS,MACAL;IAEJ,MAAM,EAAES,gBAAgB,EAAE,GAAGf,oBACzBK,QACAQ,aACAL;IAGJ,MAAMQ,QAAQlB,QAAQ;QAClB,OAAO;YACHY;YACAE;YACAE;YACAC;SACH;IACL,GAAG;QAACN;QAAgBE;QAAME;QAAaL;KAAa;IAEpD,qBACI,oBAACL;QACGa,OAAOA;QACPC,UAAU;YACN,IAAIV,eAAe;gBACfC,gCAAAA,aAAcU,IAAI;YACtB;YAEAC,QAAQC,IAAI;QAChB;;AAGZ,EAAE"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { ApiDefinitions, FunctionDescription, PropertyDescription } from '../../../types.js';
|
2
|
-
export declare const getApiDefinitions: (functions: FunctionDescription[], properties: PropertyDescription[]) => ApiDefinitions;
|
1
|
+
import { ApiDefinitions, FunctionDescription, PropertyDescription, FunctionTypeOverrideMap } from '../../../types.js';
|
2
|
+
export declare const getApiDefinitions: (functions: FunctionDescription[], properties: PropertyDescription[], functionTypeOverride: FunctionTypeOverrideMap) => ApiDefinitions;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export const getApiDefinitions = (functions, properties)=>{
|
1
|
+
export const getApiDefinitions = (functions, properties, functionTypeOverride)=>{
|
2
2
|
const global = {
|
3
3
|
functions: [],
|
4
4
|
methods: [],
|
@@ -19,8 +19,9 @@ export const getApiDefinitions = (functions, properties)=>{
|
|
19
19
|
}, root);
|
20
20
|
};
|
21
21
|
functions.forEach((func)=>{
|
22
|
+
var _functionTypeOverride_func_signature;
|
22
23
|
const targetNamespace = getOrCreateNamespace(func.namespaces, global);
|
23
|
-
if (func.hasSelf) {
|
24
|
+
if (func.hasSelf || ((_functionTypeOverride_func_signature = functionTypeOverride[func.signature]) == null ? void 0 : _functionTypeOverride_func_signature.isMethod)) {
|
24
25
|
targetNamespace.methods.push(func);
|
25
26
|
} else {
|
26
27
|
targetNamespace.functions.push(func);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n ApiObject,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[]\n): ApiDefinitions => {\n const global: ApiObject = {\n functions: [],\n methods: [],\n properties: [],\n namespaces: {},\n };\n\n const getOrCreateNamespace = (\n path: string[],\n root: ApiObject\n ): ApiObject => {\n return path.reduce((currentNamespace, ns) => {\n if (!currentNamespace.namespaces[ns]) {\n currentNamespace.namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n namespaces: {},\n };\n }\n return currentNamespace.namespaces[ns];\n }, root);\n };\n\n functions.forEach((func) => {\n const targetNamespace = getOrCreateNamespace(func.namespaces, global);\n if (func.hasSelf) {\n targetNamespace.methods.push(func);\n } else {\n targetNamespace.functions.push(func);\n }\n });\n\n properties.forEach((prop) => {\n const targetNamespace = getOrCreateNamespace(prop.namespaces, global);\n targetNamespace.properties.push(prop);\n });\n\n return { global };\n};\n"],"names":["getApiDefinitions","functions","properties","global","methods","namespaces","getOrCreateNamespace","path","root","reduce","currentNamespace","ns","forEach","func","targetNamespace","hasSelf","push","prop"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n ApiObject,\n PropertyDescription,\n FunctionTypeOverrideMap,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[],\n functionTypeOverride: FunctionTypeOverrideMap\n): ApiDefinitions => {\n const global: ApiObject = {\n functions: [],\n methods: [],\n properties: [],\n namespaces: {},\n };\n\n const getOrCreateNamespace = (\n path: string[],\n root: ApiObject\n ): ApiObject => {\n return path.reduce((currentNamespace, ns) => {\n if (!currentNamespace.namespaces[ns]) {\n currentNamespace.namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n namespaces: {},\n };\n }\n return currentNamespace.namespaces[ns];\n }, root);\n };\n\n functions.forEach((func) => {\n const targetNamespace = getOrCreateNamespace(func.namespaces, global);\n if (func.hasSelf || functionTypeOverride[func.signature]?.isMethod) {\n targetNamespace.methods.push(func);\n } else {\n targetNamespace.functions.push(func);\n }\n });\n\n properties.forEach((prop) => {\n const targetNamespace = getOrCreateNamespace(prop.namespaces, global);\n targetNamespace.properties.push(prop);\n });\n\n return { global };\n};\n"],"names":["getApiDefinitions","functions","properties","functionTypeOverride","global","methods","namespaces","getOrCreateNamespace","path","root","reduce","currentNamespace","ns","forEach","func","targetNamespace","hasSelf","signature","isMethod","push","prop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAQA,OAAO,MAAMA,oBAAoB,CAC7BC,WACAC,YACAC;IAEA,MAAMC,SAAoB;QACtBH,WAAW,EAAE;QACbI,SAAS,EAAE;QACXH,YAAY,EAAE;QACdI,YAAY,CAAC;IACjB;IAEA,MAAMC,uBAAuB,CACzBC,MACAC;QAEA,OAAOD,KAAKE,MAAM,CAAC,CAACC,kBAAkBC;YAClC,IAAI,CAACD,iBAAiBL,UAAU,CAACM,GAAG,EAAE;gBAClCD,iBAAiBL,UAAU,CAACM,GAAG,GAAG;oBAC9BX,WAAW,EAAE;oBACbI,SAAS,EAAE;oBACXH,YAAY,EAAE;oBACdI,YAAY,CAAC;gBACjB;YACJ;YACA,OAAOK,iBAAiBL,UAAU,CAACM,GAAG;QAC1C,GAAGH;IACP;IAEAR,UAAUY,OAAO,CAAC,CAACC;YAEKX;QADpB,MAAMY,kBAAkBR,qBAAqBO,KAAKR,UAAU,EAAEF;QAC9D,IAAIU,KAAKE,OAAO,MAAIb,uCAAAA,oBAAoB,CAACW,KAAKG,SAAS,CAAC,qBAApCd,qCAAsCe,QAAQ,GAAE;YAChEH,gBAAgBV,OAAO,CAACc,IAAI,CAACL;QACjC,OAAO;YACHC,gBAAgBd,SAAS,CAACkB,IAAI,CAACL;QACnC;IACJ;IAEAZ,WAAWW,OAAO,CAAC,CAACO;QAChB,MAAML,kBAAkBR,qBAAqBa,KAAKd,UAAU,EAAEF;QAC9DW,gBAAgBb,UAAU,CAACiB,IAAI,CAACC;IACpC;IAEA,OAAO;QAAEhB;IAAO;AACpB,EAAE"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
2
2
|
import { load } from 'cheerio';
|
3
|
+
import Turndown from 'turndown';
|
3
4
|
import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
|
4
5
|
import { parseFunctionSignature } from '../../../commands/GenerateTypes/fn/parseFunctionSignature.js';
|
5
6
|
const extractFunctionCalls = (input)=>{
|
@@ -21,6 +22,7 @@ export const getDescriptionsFromHtml = (html, version)=>{
|
|
21
22
|
const functions = [];
|
22
23
|
const properties = [];
|
23
24
|
const visitedSignatures = [];
|
25
|
+
const turndown = new Turndown();
|
24
26
|
for (const element of functionSignatures){
|
25
27
|
var _$_attr;
|
26
28
|
const id = (_$_attr = $(element).attr('id')) != null ? _$_attr : '';
|
@@ -39,7 +41,8 @@ export const getDescriptionsFromHtml = (html, version)=>{
|
|
39
41
|
docsString = docsString.slice(0, docsString.length - '</div>'.length);
|
40
42
|
}
|
41
43
|
docsString = docsString.replace(/<a href="#/g, '<a href="' + PlaydateSdkUrl + version + '#');
|
42
|
-
|
44
|
+
docsString = turndown.turndown(docsString);
|
45
|
+
const baseDocs = id ? `${docsString}\n\n[Read more](${PlaydateSdkUrl}${version}#${id})` : docsString;
|
43
46
|
for (const title of titles){
|
44
47
|
const signature = normalizeSignature(title);
|
45
48
|
if (visitedSignatures.includes(signature)) {
|
@@ -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 (\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":"
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport Turndown from 'turndown';\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 const turndown = new Turndown();\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 docsString = turndown.turndown(docsString);\n\n const baseDocs = id\n ? `${docsString}\\n\\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","Turndown","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","turndown","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":"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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getFunctionTypeOverride: (version: string) => import("../../../types.js").FunctionTypeOverrideMap;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { functionTypeOverrides } from '../../../commands/GenerateTypes/utils/functionTypeOverrides.js';
|
2
|
+
export const getFunctionTypeOverride = (version)=>{
|
3
|
+
var _functionTypeOverrides_version;
|
4
|
+
return (_functionTypeOverrides_version = functionTypeOverrides[version]) != null ? _functionTypeOverrides_version : functionTypeOverrides['defaultVersion'];
|
5
|
+
};
|
6
|
+
|
7
|
+
//# sourceMappingURL=getFunctionTypeOverride.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getFunctionTypeOverride.ts"],"sourcesContent":["import { functionTypeOverrides } from '@/cli/commands/GenerateTypes/utils/functionTypeOverrides.js';\n\nexport const getFunctionTypeOverride = (version: string) => {\n return (\n functionTypeOverrides[version] ??\n functionTypeOverrides['defaultVersion']\n );\n};\n"],"names":["functionTypeOverrides","getFunctionTypeOverride","version"],"rangeMappings":";;;;","mappings":"AAAA,SAASA,qBAAqB,QAAQ,8DAA8D;AAEpG,OAAO,MAAMC,0BAA0B,CAACC;QAEhCF;IADJ,OACIA,CAAAA,iCAAAA,qBAAqB,CAACE,QAAQ,YAA9BF,iCACAA,qBAAqB,CAAC,iBAAiB;AAE/C,EAAE"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { useMemo, useState } from 'react';
|
2
2
|
import { getApiDefinitions } from '../../../commands/GenerateTypes/fn/getApiDefinitions.js';
|
3
3
|
import { getDescriptionsFromHtml } from '../../../commands/GenerateTypes/fn/getDescriptionsFromHtml.js';
|
4
|
+
import { getFunctionTypeOverride } from '../../../commands/GenerateTypes/fn/getFunctionTypeOverride.js';
|
4
5
|
export const useParseDocumentation = (html, version)=>{
|
5
6
|
const [result, setResult] = useState(null);
|
6
7
|
const parseDocumentation = useMemo(()=>{
|
@@ -14,7 +15,7 @@ export const useParseDocumentation = (html, version)=>{
|
|
14
15
|
throw new Error('HTML is not set');
|
15
16
|
}
|
16
17
|
const { functions, properties } = getDescriptionsFromHtml(html, version);
|
17
|
-
return getApiDefinitions(functions, properties);
|
18
|
+
return getApiDefinitions(functions, properties, getFunctionTypeOverride(version));
|
18
19
|
},
|
19
20
|
onFinish: (result)=>{
|
20
21
|
setResult(result);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport { getDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getDescriptionsFromHtml.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useParseDocumentation = (html: string | null, version: string) => {\n const [result, setResult] = useState<ApiDefinitions | null>(null);\n\n const parseDocumentation = useMemo(() => {\n return {\n waitingDescription: 'Waiting to parse the documentation...',\n errorDescription: 'Failed to parse the documentation',\n finishedDescription: () => 'Documentation parsed',\n runningDescription: 'Parsing the documentation...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const { functions, properties } = getDescriptionsFromHtml(\n html,\n version\n );\n\n return getApiDefinitions(functions
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport { getDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getDescriptionsFromHtml.js';\nimport { getFunctionTypeOverride } from '@/cli/commands/GenerateTypes/fn/getFunctionTypeOverride.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useParseDocumentation = (html: string | null, version: string) => {\n const [result, setResult] = useState<ApiDefinitions | null>(null);\n\n const parseDocumentation = useMemo(() => {\n return {\n waitingDescription: 'Waiting to parse the documentation...',\n errorDescription: 'Failed to parse the documentation',\n finishedDescription: () => 'Documentation parsed',\n runningDescription: 'Parsing the documentation...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const { functions, properties } = getDescriptionsFromHtml(\n html,\n version\n );\n\n return getApiDefinitions(\n functions,\n properties,\n getFunctionTypeOverride(version)\n );\n },\n onFinish: (result) => {\n setResult(result);\n },\n ready: html !== null,\n } satisfies CheckListItem<ApiDefinitions>;\n }, [html]);\n\n return {\n definitions: result,\n parseDocumentation,\n };\n};\n"],"names":["useMemo","useState","getApiDefinitions","getDescriptionsFromHtml","getFunctionTypeOverride","useParseDocumentation","html","version","result","setResult","parseDocumentation","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","functions","properties","onFinish","ready","definitions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAASC,uBAAuB,QAAQ,6DAA6D;AACrG,SAASC,uBAAuB,QAAQ,6DAA6D;AAGrG,OAAO,MAAMC,wBAAwB,CAACC,MAAqBC;IACvD,MAAM,CAACC,QAAQC,UAAU,GAAGR,SAAgC;IAE5D,MAAMS,qBAAqBV,QAAQ;QAC/B,OAAO;YACHW,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACT,MAAM;oBACP,MAAM,IAAIU,MAAM;gBACpB;gBAEA,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGf,wBAC9BG,MACAC;gBAGJ,OAAOL,kBACHe,WACAC,YACAd,wBAAwBG;YAEhC;YACAY,UAAU,CAACX;gBACPC,UAAUD;YACd;YACAY,OAAOd,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHe,aAAab;QACbE;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export const functionTypeOverrides = {
|
2
|
+
defaultVersion: {
|
3
|
+
'playdate.timer.timerEndedCallback': {
|
4
|
+
isMethod: true
|
5
|
+
},
|
6
|
+
'playdate.timer.updateCallback': {
|
7
|
+
isMethod: true
|
8
|
+
},
|
9
|
+
'playdate.frameTimer.timerEndedCallback': {
|
10
|
+
isMethod: true
|
11
|
+
},
|
12
|
+
'playdate.frameTimer.updateCallback': {
|
13
|
+
isMethod: true
|
14
|
+
}
|
15
|
+
}
|
16
|
+
};
|
17
|
+
|
18
|
+
//# sourceMappingURL=functionTypeOverrides.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/functionTypeOverrides.ts"],"sourcesContent":["import { FunctionTypeOverrideMap } from '@/cli/types.js';\n\nexport const functionTypeOverrides: Record<string, FunctionTypeOverrideMap> = {\n defaultVersion: {\n 'playdate.timer.timerEndedCallback': {\n isMethod: true,\n },\n 'playdate.timer.updateCallback': {\n isMethod: true,\n },\n 'playdate.frameTimer.timerEndedCallback': {\n isMethod: true,\n },\n 'playdate.frameTimer.updateCallback': {\n isMethod: true,\n },\n },\n};\n"],"names":["functionTypeOverrides","defaultVersion","isMethod"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,wBAAiE;IAC1EC,gBAAgB;QACZ,qCAAqC;YACjCC,UAAU;QACd;QACA,iCAAiC;YAC7BA,UAAU;QACd;QACA,0CAA0C;YACtCA,UAAU;QACd;QACA,sCAAsC;YAClCA,UAAU;QACd;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
3
|
+
import { TemplateName } from '../../types.js';
|
4
|
+
export declare class NewCommand extends RenderableCommand {
|
5
|
+
static paths: string[][];
|
6
|
+
static usage: import("clipanion").Usage;
|
7
|
+
name: string;
|
8
|
+
template: TemplateName;
|
9
|
+
render(): React.JSX.Element;
|
10
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { Command, Option } from 'clipanion';
|
2
|
+
import React from 'react';
|
3
|
+
import * as t from 'typanion';
|
4
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
5
|
+
import { TemplateName } from '../../types.js';
|
6
|
+
import { New } from './components/New.js';
|
7
|
+
const defaultTemplate = TemplateName.Blank;
|
8
|
+
export class NewCommand extends RenderableCommand {
|
9
|
+
render() {
|
10
|
+
return /*#__PURE__*/ React.createElement(New, {
|
11
|
+
name: this.name,
|
12
|
+
template: this.template
|
13
|
+
});
|
14
|
+
}
|
15
|
+
constructor(...args){
|
16
|
+
super(...args);
|
17
|
+
this.name = Option.String({
|
18
|
+
name: 'name'
|
19
|
+
});
|
20
|
+
this.template = Option.String('-t,--template', defaultTemplate, {
|
21
|
+
description: `The template to use, defaults to "${defaultTemplate}"`,
|
22
|
+
validator: t.isEnum(TemplateName)
|
23
|
+
});
|
24
|
+
}
|
25
|
+
}
|
26
|
+
NewCommand.paths = [
|
27
|
+
[
|
28
|
+
'new'
|
29
|
+
]
|
30
|
+
];
|
31
|
+
NewCommand.usage = Command.Usage({
|
32
|
+
description: 'Create a new crankscript project'
|
33
|
+
});
|
34
|
+
|
35
|
+
//# sourceMappingURL=NewCommand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/NewCommand/NewCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { TemplateName } from '@/cli/types.js';\nimport { New } from './components/New.js';\n\nconst defaultTemplate = TemplateName.Blank;\n\nexport class NewCommand extends RenderableCommand {\n static override paths = [['new']];\n\n static override usage = Command.Usage({\n description: 'Create a new crankscript project',\n });\n\n name = Option.String({\n name: 'name',\n });\n\n template = Option.String('-t,--template', defaultTemplate, {\n description: `The template to use, defaults to \"${defaultTemplate}\"`,\n validator: t.isEnum(TemplateName),\n });\n\n override render() {\n return <New name={this.name} template={this.template} />;\n }\n}\n"],"names":["Command","Option","React","t","RenderableCommand","TemplateName","New","defaultTemplate","Blank","NewCommand","render","name","template","String","description","validator","isEnum","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,GAAG,QAAQ,sBAAsB;AAE1C,MAAMC,kBAAkBF,aAAaG,KAAK;AAE1C,OAAO,MAAMC,mBAAmBL;IAgBnBM,SAAS;QACd,qBAAO,oBAACJ;YAAIK,MAAM,IAAI,CAACA,IAAI;YAAEC,UAAU,IAAI,CAACA,QAAQ;;IACxD;;;aAXAD,OAAOV,OAAOY,MAAM,CAAC;YACjBF,MAAM;QACV;aAEAC,WAAWX,OAAOY,MAAM,CAAC,iBAAiBN,iBAAiB;YACvDO,aAAa,CAAC,kCAAkC,EAAEP,gBAAgB,CAAC,CAAC;YACpEQ,WAAWZ,EAAEa,MAAM,CAACX;QACxB;;AAKJ;AAnBaI,WACOQ,QAAQ;IAAC;QAAC;KAAM;CAAC;AADxBR,WAGOS,QAAQlB,QAAQmB,KAAK,CAAC;IAClCL,aAAa;AACjB"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React, { useMemo } from 'react';
|
2
|
+
import tiged from 'tiged';
|
3
|
+
import { CheckList } from '../../../components/CheckList/index.js';
|
4
|
+
export const New = ({ name, template })=>{
|
5
|
+
const items = useMemo(()=>{
|
6
|
+
return [
|
7
|
+
{
|
8
|
+
ready: true,
|
9
|
+
runner: async ()=>{
|
10
|
+
const task = tiged(`crankscript/template-${template}`);
|
11
|
+
await task.clone(name);
|
12
|
+
},
|
13
|
+
waitingDescription: `About to create a new project named "${name}" using the "${template}" template`,
|
14
|
+
runningDescription: `Creating a new project named "${name}" using the "${template}" template`,
|
15
|
+
finishedDescription: ()=>`Created a new project named "${name}" using the "${template}" template`,
|
16
|
+
errorDescription: `Failed to create project named "${name}" using the "${template}" template`
|
17
|
+
}
|
18
|
+
];
|
19
|
+
}, []);
|
20
|
+
return /*#__PURE__*/ React.createElement(CheckList, {
|
21
|
+
items: items,
|
22
|
+
onFinish: process.exit
|
23
|
+
});
|
24
|
+
};
|
25
|
+
|
26
|
+
//# sourceMappingURL=New.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/NewCommand/components/New.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport tiged from 'tiged';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, TemplateName } from '@/cli/types.js';\n\ninterface Props {\n name: string;\n template: TemplateName;\n}\n\nexport const New = ({ name, template }: Props) => {\n const items = useMemo(() => {\n return [\n {\n ready: true,\n runner: async () => {\n const task = tiged(`crankscript/template-${template}`);\n\n await task.clone(name);\n },\n waitingDescription: `About to create a new project named \"${name}\" using the \"${template}\" template`,\n runningDescription: `Creating a new project named \"${name}\" using the \"${template}\" template`,\n finishedDescription: () =>\n `Created a new project named \"${name}\" using the \"${template}\" template`,\n errorDescription: `Failed to create project named \"${name}\" using the \"${template}\" template`,\n },\n ];\n }, []) satisfies CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["React","useMemo","tiged","CheckList","New","name","template","items","ready","runner","task","clone","waitingDescription","runningDescription","finishedDescription","errorDescription","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,SAAS,QAAQ,sCAAsC;AAQhE,OAAO,MAAMC,MAAM,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAS;IACzC,MAAMC,QAAQN,QAAQ;QAClB,OAAO;YACH;gBACIO,OAAO;gBACPC,QAAQ;oBACJ,MAAMC,OAAOR,MAAM,CAAC,qBAAqB,EAAEI,SAAS,CAAC;oBAErD,MAAMI,KAAKC,KAAK,CAACN;gBACrB;gBACAO,oBAAoB,CAAC,qCAAqC,EAAEP,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBACpGO,oBAAoB,CAAC,8BAA8B,EAAER,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC7FQ,qBAAqB,IACjB,CAAC,6BAA6B,EAAET,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC5ES,kBAAkB,CAAC,gCAAgC,EAAEV,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;YACjG;SACH;IACL,GAAG,EAAE;IAEL,qBAAO,oBAACH;QAAUI,OAAOA;QAAOS,UAAUC,QAAQC,IAAI;;AAC1D,EAAE"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
3
|
+
import { Environment } from '../../environment/dto/Environment.js';
|
4
|
+
export declare class SimulatorCommand extends EnvironmentAwareCommand {
|
5
|
+
static paths: string[][];
|
6
|
+
static usage: import("clipanion").Usage;
|
7
|
+
watch: boolean;
|
8
|
+
background: boolean;
|
9
|
+
projectPath: string;
|
10
|
+
renderWithEnvironment(environment: Environment): React.JSX.Element;
|
11
|
+
}
|