Skip to content

Commit d92d7b3

Browse files
LaunchedExecutionEngine -> ExecutionEngineInstance
make @quarto/types pure type package
1 parent 25bfd6e commit d92d7b3

20 files changed

Lines changed: 142 additions & 226 deletions

packages/quarto-types/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
"name": "@quarto/types",
33
"version": "0.1.0",
44
"description": "TypeScript type definitions for Quarto engine development",
5-
"main": "dist/index.js",
6-
"types": "dist/index.d.ts",
5+
"types": "src/index.ts",
76
"files": [
8-
"dist",
7+
"src",
98
"README.md",
109
"LICENSE"
1110
],
1211
"scripts": {
13-
"build": "tsc",
14-
"prepare": "npm run build"
1512
},
1613
"keywords": [
1714
"quarto",

packages/quarto-types/src/constants.d.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/quarto-types/src/constants.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/quarto-types/src/execution-engine.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export interface DependenciesResult {
167167
*/
168168
export interface PostProcessOptions {
169169
/** The execution engine */
170-
engine: LaunchedExecutionEngine;
170+
engine: ExecutionEngineInstance;
171171

172172
/** The execution target */
173173
target: ExecutionTarget;
@@ -311,17 +311,17 @@ export interface ExecutionEngineDiscovery {
311311
* This is called when the engine is needed for execution
312312
*
313313
* @param context The restricted project context
314-
* @returns LaunchedExecutionEngine that can execute documents
314+
* @returns ExecutionEngineInstance that can execute documents
315315
*/
316-
launch: (context: EngineProjectContext) => LaunchedExecutionEngine;
316+
launch: (context: EngineProjectContext) => ExecutionEngineInstance;
317317
}
318318

319319
/**
320320
* Interface for a launched execution engine
321321
* This represents an engine that has been instantiated with a project context
322322
* and is ready to execute documents
323323
*/
324-
export interface LaunchedExecutionEngine {
324+
export interface ExecutionEngineInstance {
325325
/**
326326
* Name of the engine
327327
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* External engine interfaces for Quarto
3+
*/
4+
5+
/**
6+
* Represents an external engine specified in a project
7+
*/
8+
export interface ExternalEngine {
9+
/**
10+
* Path to the engine implementation
11+
*/
12+
path: string;
13+
}

packages/quarto-types/src/index.ts

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,19 @@
44
*/
55

66
// Export text types
7-
export * from './text-types';
8-
9-
// Export constants
10-
export * from './constants';
7+
export type * from "./text-types.d.ts";
118

129
// Export metadata types
13-
export * from './metadata-types';
10+
export type * from "./metadata-types.d.ts";
11+
12+
// Export external engine types
13+
export type * from "./external-engine.d.ts";
1414

1515
// Export project context types
16-
export * from './project-context';
16+
export type * from "./project-context.d.ts";
1717

1818
// Export execution engine types
19-
export * from './execution-engine';
20-
21-
// Export external engine types
22-
export * from './external-engine';
19+
export type * from "./execution-engine.d.ts";
2320

2421
// Export Quarto API types
25-
export * from './quarto-api';
26-
27-
/**
28-
* Utility to check if a project context satisfies EngineProjectContext interface
29-
*/
30-
import { EngineProjectContext } from './project-context';
31-
32-
export function isEngineProjectContext(
33-
ctx: unknown
34-
): ctx is EngineProjectContext {
35-
if (!ctx) return false;
36-
37-
const context = ctx as Partial<EngineProjectContext>;
38-
39-
return (
40-
typeof context.dir === 'string' &&
41-
typeof context.isSingleFile === 'boolean' &&
42-
context.fileInformationCache instanceof Map &&
43-
typeof context.resolveFullMarkdownForFile === 'function' &&
44-
typeof context.getOutputDirectory === 'function' &&
45-
!!context.quarto
46-
);
47-
}
48-
49-
/**
50-
* Utility to get the output directory from a project context
51-
*/
52-
import { kProjectOutputDir } from './constants';
53-
import { resolve, join, isAbsolute } from 'path';
54-
55-
export function projectOutputDir(context: EngineProjectContext): string {
56-
let outputDir = context.config?.project?.[kProjectOutputDir];
57-
58-
if (outputDir) {
59-
if (!isAbsolute(outputDir)) {
60-
outputDir = join(context.dir, outputDir);
61-
}
62-
} else {
63-
outputDir = context.dir;
64-
}
65-
66-
// Normalize the path
67-
return resolve(outputDir);
68-
}
22+
export type * from "./quarto-api.d.ts";

packages/quarto-types/src/project-context.d.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* Project context interfaces for Quarto engines
33
*/
44

5-
import { MappedString } from './text-types';
6-
import { kProjectOutputDir } from './constants';
7-
import { ExecutionEngine } from './execution-engine';
8-
import { ExternalEngine } from './external-engine';
5+
import type { MappedString } from "./text-types";
6+
import type { ExecutionEngineInstance, ExecutionTarget } from "./execution-engine";
7+
import type { ExternalEngine } from "./external-engine";
8+
import type { Metadata } from "./metadata-types";
99

1010
/**
1111
* Information about a file being processed
@@ -27,17 +27,17 @@ export interface FileInformation {
2727
/**
2828
* The launched execution engine for this file
2929
*/
30-
engine?: import('./execution-engine').LaunchedExecutionEngine;
30+
engine?: ExecutionEngineInstance;
3131

3232
/**
3333
* The execution target for this file
3434
*/
35-
target?: import('./execution-engine').ExecutionTarget;
35+
target?: ExecutionTarget;
3636

3737
/**
3838
* Document metadata
3939
*/
40-
metadata?: import('./metadata-types').Metadata;
40+
metadata?: Metadata;
4141
}
4242

4343
/**
@@ -62,7 +62,7 @@ export interface EngineProjectContext {
6262
config?: {
6363
engines?: (string | ExternalEngine)[];
6464
project?: {
65-
[kProjectOutputDir]?: string;
65+
outputDir?: string;
6666
};
6767
};
6868

@@ -89,7 +89,7 @@ export interface EngineProjectContext {
8989
* @returns Promise resolving to mapped markdown string
9090
*/
9191
resolveFullMarkdownForFile: (
92-
engine: ExecutionEngine | undefined,
92+
engine: ExecutionEngineInstance | undefined,
9393
file: string,
9494
markdown?: MappedString,
9595
force?: boolean,
@@ -98,5 +98,5 @@ export interface EngineProjectContext {
9898
/**
9999
* Reference to the global Quarto API
100100
*/
101-
quarto: import('./quarto-api').QuartoAPI;
102-
}
101+
quarto: import("./quarto-api").QuartoAPI;
102+
}

src/command/render/codetools.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ import {
2020
kCodeToolsViewSource,
2121
kKeepSource,
2222
} from "../../config/constants.ts";
23-
import { ExecutionEngine, ExecutionTarget, LaunchedExecutionEngine } from "../../execute/types.ts";
23+
import {
24+
ExecutionEngine,
25+
ExecutionEngineInstance,
26+
ExecutionTarget,
27+
} from "../../execute/types.ts";
2428

2529
import { isHtmlOutput } from "../../config/format.ts";
2630
import { executionEngineCanKeepSource } from "../../execute/engine-info.ts";
@@ -47,7 +51,7 @@ export function formatHasCodeTools(format: Format) {
4751

4852
export function resolveKeepSource(
4953
format: Format,
50-
engine: LaunchedExecutionEngine,
54+
engine: ExecutionEngineInstance,
5155
target: ExecutionTarget,
5256
) {
5357
// keep source if requested (via keep-source or code-tools), we are targeting html,

src/command/render/render-contexts.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ import {
5959
} from "../../core/language.ts";
6060
import { defaultWriterFormat } from "../../format/formats.ts";
6161
import { mergeConfigs } from "../../core/config.ts";
62-
import { ExecutionTarget, LaunchedExecutionEngine } from "../../execute/types.ts";
62+
import {
63+
ExecutionEngineInstance,
64+
ExecutionTarget,
65+
} from "../../execute/types.ts";
6366
import {
6467
deleteProjectMetadata,
6568
directoryMetadataForInputFile,
@@ -394,7 +397,7 @@ function mergeQuartoConfigs(
394397
async function resolveFormats(
395398
file: RenderFile,
396399
target: ExecutionTarget,
397-
engine: LaunchedExecutionEngine,
400+
engine: ExecutionEngineInstance,
398401
options: RenderOptions,
399402
_notebookContext: NotebookContext,
400403
project: ProjectContext,

src/command/render/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {
1414
} from "../../config/types.ts";
1515
import {
1616
ExecuteResult,
17+
ExecutionEngineInstance,
1718
ExecutionTarget,
18-
LaunchedExecutionEngine,
1919
} from "../../execute/types.ts";
2020
import { Metadata } from "../../config/types.ts";
2121
import { ProjectContext } from "../../project/types.ts";
@@ -56,7 +56,7 @@ export interface RenderServiceWithLifetime extends RenderServices {
5656
export interface RenderContext {
5757
target: ExecutionTarget;
5858
options: RenderOptions;
59-
engine: LaunchedExecutionEngine;
59+
engine: ExecutionEngineInstance;
6060
format: Format;
6161
libDir: string;
6262
project: ProjectContext;

0 commit comments

Comments
 (0)