52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
import type { ReactNode } from "react";
|
|
|
|
import type { ManagementGateway } from "../../src/features/tech-log/application/ports/management-gateway.ts";
|
|
import type { StudioAssetGateway } from "../../src/features/tech-log/application/ports/studio-asset-gateway.ts";
|
|
import type { StudioGateway } from "../../src/features/tech-log/application/ports/studio-gateway.ts";
|
|
import type { ResolvePublishedLabel } from "../../src/features/tech-log/domain/public-render-content.ts";
|
|
import { createTechLogStudioApplication } from "../../src/features/tech-log/application/studio-application.ts";
|
|
import { createTechLogFeatureInstalledInput } from "../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
|
|
import {
|
|
StudioProvider as ProductionStudioProvider,
|
|
} from "../../src/features/tech-log/presentation/studio/studio-provider.tsx";
|
|
import { createManagementGatewayStub } from "./management-gateway-stub.ts";
|
|
import { MOCK_STUDIO_INSTALL_CONTEXT } from "./studio-install-context.ts";
|
|
import { studioAssetGatewayFromApplication } from "./studio-application-gateway-adapter.ts";
|
|
|
|
type Props = Readonly<{
|
|
children: ReactNode;
|
|
createGateway: () => StudioGateway;
|
|
createAssetGateway?: () => StudioAssetGateway;
|
|
createManagementGateway?: () => ManagementGateway;
|
|
resolvePublishedLabel?: ResolvePublishedLabel;
|
|
now?: () => Date;
|
|
navigate?: (href: string) => void;
|
|
}>;
|
|
|
|
export function StudioProvider({
|
|
children,
|
|
createGateway,
|
|
createAssetGateway,
|
|
createManagementGateway = createManagementGatewayStub,
|
|
...props
|
|
}: Props) {
|
|
return (
|
|
<ProductionStudioProvider
|
|
{...props}
|
|
createStudioApplication={() => {
|
|
const defaults = createTechLogFeatureInstalledInput(
|
|
MOCK_STUDIO_INSTALL_CONTEXT,
|
|
).input.createStudioApplication();
|
|
return createTechLogStudioApplication({
|
|
studio: createGateway(),
|
|
assets:
|
|
createAssetGateway?.() ?? studioAssetGatewayFromApplication(defaults),
|
|
management: createManagementGateway(),
|
|
});
|
|
}}
|
|
>
|
|
{children}
|
|
</ProductionStudioProvider>
|
|
);
|
|
}
|