-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lib/anyware): data type oriented builders (#1274)
- Loading branch information
1 parent
5abf7a8
commit a78ebbe
Showing
67 changed files
with
1,335 additions
and
1,162 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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,31 +1,40 @@ | ||
import type { ConfigManager } from '../../config-manager/__.js' | ||
import type { Overload } from '../Overload/__.js' | ||
import type { Pipeline } from '../Pipeline/__.js' | ||
import { Overload } from '../Overload/__.js' | ||
import type { PipelineDef } from '../PipelineDef/__.js' | ||
import type { Extension } from './__.js' | ||
|
||
type Create = <$Pipeline extends PipelineDef>() => Builder<$Pipeline, Extension.States.Empty> | ||
|
||
export interface Builder< | ||
$PipelineContext extends Pipeline.Context = Pipeline.Context, | ||
$Context extends Context = Context, | ||
$Pipeline extends PipelineDef = PipelineDef, | ||
$Extension extends Extension = Extension, | ||
> { | ||
context: $Context | ||
type: $Extension | ||
/** | ||
* TODO | ||
*/ | ||
overload: <$OverloadBuilder extends Overload.Builder<$PipelineContext>>( | ||
overloadBuilder: Overload.BuilderCallback<$PipelineContext, $OverloadBuilder>, | ||
overload: <$OverloadBuilder extends Overload.Builder<$Pipeline>>( | ||
overloadBuilderCallback: Overload.BuilderCallback<$Pipeline, $OverloadBuilder>, | ||
) => Builder< | ||
$PipelineContext, | ||
ConfigManager.AppendAtKey< | ||
$Context, | ||
'overloads', | ||
$OverloadBuilder['context'] | ||
> | ||
$Pipeline, | ||
Extension.Updaters.AddOverload<$Extension, $OverloadBuilder['type']> | ||
> | ||
} | ||
|
||
export interface Context { | ||
overloads: Overload.BuilderContext[] | ||
} | ||
export namespace Builder { | ||
export const create: Create = () => { | ||
const extension: Extension = { | ||
overloads: [], | ||
} | ||
|
||
const builder: Builder = { | ||
type: extension, | ||
overload: (builderCallback) => { | ||
const overload = builderCallback({ create: Overload.create }) | ||
extension.overloads.push(overload.type) | ||
return builder as any | ||
}, | ||
} | ||
|
||
export interface ContextEmpty extends Context { | ||
overloads: [] | ||
return builder as any | ||
} | ||
} |
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 |
---|---|---|
@@ -1,25 +0,0 @@ | ||
import { __ } from '../../prelude.js' | ||
import { Overload } from '../Overload/__.js' | ||
import type { Pipeline } from '../Pipeline/__.js' | ||
import type { Builder, Context, ContextEmpty } from './Builder.js' | ||
|
||
export * from './Builder.js' | ||
|
||
export const create: Create = () => { | ||
const context: Context = { | ||
overloads: [], | ||
} | ||
|
||
const builder: Builder = { | ||
context, | ||
overload: (builderCallback) => { | ||
const overload = builderCallback({ create: Overload.create }) | ||
context.overloads.push(overload.context) | ||
return builder as any | ||
}, | ||
} | ||
|
||
return builder as any | ||
} | ||
|
||
type Create = <$PipelineContext extends Pipeline.Context>() => Builder<$PipelineContext, ContextEmpty> | ||
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 @@ | ||
import type { Extension } from './__.js' | ||
|
||
export namespace States { | ||
export interface Empty extends Extension { | ||
overloads: [] | ||
} | ||
} |
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,14 @@ | ||
import type { ConfigManager } from '../../config-manager/__.js' | ||
import type { Overload } from '../Overload/__.js' | ||
import type { Extension } from './__.js' | ||
|
||
export namespace Updaters { | ||
export type AddOverload< | ||
$Extension extends Extension, | ||
$Overload extends Overload, | ||
> = ConfigManager.UpdateKeyWithAppend< | ||
$Extension, | ||
'overloads', | ||
$Overload | ||
> | ||
} |
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,3 @@ | ||
export * from './Builder.js' | ||
export * from './States.js' | ||
export * from './Updaters.js' |
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
export * as Extension from './Extension.js' | ||
import type { Overload } from '../Overload/__.js' | ||
|
||
export * as Extension from './_.js' | ||
|
||
export interface Extension { | ||
overloads: Overload[] | ||
} |
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
Oops, something went wrong.