forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Efv2 Integration This PR introduces the work on **Emitter Framework v2** from the feature branch into main. The existing emitter framework functionality remains unchanged for now, the new framework is added as a new package @typespec/emitter-framework ### **Core Changes** - **Compiler Alloy Support** - The compiler now detects if `$onEmit` returns an **Alloy component**. If so, it loads Alloy and calls `render`. - This enables emitters to use Alloy components. - **New Package: `@typespec/emitter-framework`** - Wraps raw Alloy components to accept **TypeSpec types as props** and automatically generate language elements. - Currently includes a **subexport for TypeScript (`/typescript`)**, with plans to extend support to other languages. - Example: `ts.Interface` can take a `Model` or `Interface` and directly render a TypeScript interface with model properties or operation signatures. - **New Package: `@typespec/http-client`** - Provides **TypeKits** for querying the **type graph** in the context of an **HTTP client**. - The goal is to eventually **power TCGC** and host decorators that make sense in this context. - Remains **decoupled from Azure**, but we may later introduce an extension package (`@azure-tools/http-client-azure`) for Azure-specific logic and decorators. ### **Follow Up Work** - Deprecate EFv1 - A follow up API review and clean-up will be needed, specifically around TypeKits
- Loading branch information
Showing
119 changed files
with
9,814 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@typespec/html-program-viewer" | ||
- "@typespec/http-client-csharp" | ||
- "@typespec/http-client-java" | ||
- "@typespec/http-server-javascript" | ||
- "@typespec/http" | ||
--- | ||
|
||
Emitter Framework V2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@typespec/emitter-framework" | ||
- "@typespec/http-client" | ||
--- | ||
|
||
Adding Emitter Framework and Http Client packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@typespec/compiler" | ||
--- | ||
|
||
Add Typekits to support EFV2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ words: | |
- imple | ||
- Infima | ||
- initcs | ||
- Initializable | ||
- inlines | ||
- inmemory | ||
- instanceid | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { isArrayModelType } from "../../../core/type-utils.js"; | ||
import { Model, Type } from "../../../core/types.js"; | ||
import { defineKit } from "../define-kit.js"; | ||
|
||
/** | ||
* @experimental | ||
*/ | ||
export interface ArrayKit { | ||
/** | ||
* Check if a type is an array. | ||
*/ | ||
is(type: Type): boolean; | ||
/** | ||
* Get the element type of an array. | ||
*/ | ||
getElementType(type: Model): Type; | ||
/** | ||
* Create an array type. | ||
*/ | ||
create(elementType: Type): Model; | ||
} | ||
|
||
interface TypekitExtension { | ||
/** @experimental */ | ||
array: ArrayKit; | ||
} | ||
|
||
declare module "../define-kit.js" { | ||
interface Typekit extends TypekitExtension {} | ||
} | ||
|
||
defineKit<TypekitExtension>({ | ||
array: { | ||
is(type) { | ||
return ( | ||
type.kind === "Model" && isArrayModelType(this.program, type) && type.properties.size === 0 | ||
); | ||
}, | ||
getElementType(type) { | ||
if (!this.array.is(type)) { | ||
throw new Error("Type is not an array."); | ||
} | ||
return type.indexer!.value; | ||
}, | ||
create(elementType) { | ||
return this.model.create({ | ||
name: "Array", | ||
properties: {}, | ||
indexer: { | ||
key: this.builtin.integer, | ||
value: elementType, | ||
}, | ||
}); | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.