<!-- Public documentation export; not library implementation source. -->
# PineEditorWorkspaceApi

[Integration guide](https://docs.lumencharts.com/charting-library/reference/compatibility) · [Reference index](https://docs.lumencharts.com/charting-library/api/)

Public contract reference. This declaration describes types and callback shapes; availability is constrained by the linked integration guide and the runtime capability. Legacy product-specific fields are not a promise of implementation.

## getSnapshot {#getsnapshot}

```ts
getSnapshot(): PineEditorWorkspaceSnapshot;
```

Use the type signature above and the integration guide for the owning capability.

## subscribe {#subscribe}

```ts
subscribe(listener: (change: PineEditorWorkspaceChange) => void): () => void;
```

Use the type signature above and the integration guide for the owning capability.

| Parameter | Type | Required |
| --- | --- | --- |
| `listener` | `(change: PineEditorWorkspaceChange) => void` | Yes |

## subscribeLayoutRequests {#subscribelayoutrequests}

```ts
subscribeLayoutRequests(
    listener: (request: PineEditorLayoutRequest) => void,
  ): () => void;
```

Use the type signature above and the integration guide for the owning capability.

| Parameter | Type | Required |
| --- | --- | --- |
| `listener` | `(request: PineEditorLayoutRequest) => void` | Yes |

## previewCompile {#previewcompile}

```ts
previewCompile(source: string): Promise<PineScriptCompileResult>;
```

Use the type signature above and the integration guide for the owning capability.

| Parameter | Type | Required |
| --- | --- | --- |
| `source` | `string` | Yes |

## replaceSource {#replacesource}

```ts
replaceSource(
    source: string,
    expected: { generation: number; sourceHash: string },
  ): Promise<PineEditorWorkspaceSnapshot>;
```

Use the type signature above and the integration guide for the owning capability.

| Parameter | Type | Required |
| --- | --- | --- |
| `source` | `string` | Yes |
| `expected` | `{ generation: number; sourceHash: string }` | Yes |

## openEditor {#openeditor}

```ts
openEditor(): Promise<void>;
```

Use the type signature above and the integration guide for the owning capability.

## openStrategyTester {#openstrategytester}

```ts
openStrategyTester(): Promise<void>;
```

Use the type signature above and the integration guide for the owning capability.

## check {#check}

```ts
check(): Promise<PineEditorWorkspaceSnapshot>;
```

Use the type signature above and the integration guide for the owning capability.

## run {#run}

```ts
run(): Promise<PineEditorWorkspaceSnapshot>;
```

Use the type signature above and the integration guide for the owning capability.

## save {#save}

```ts
save(title?: string): Promise<PineEditorWorkspaceSnapshot>;
```

Use the type signature above and the integration guide for the owning capability.

| Parameter | Type | Required |
| --- | --- | --- |
| `title` | `string` | No |

## getStrategyReport {#getstrategyreport}

```ts
getStrategyReport(): PineStrategyReport | null;
```

Use the type signature above and the integration guide for the owning capability.

## Related types

- [PineEditorWorkspaceSnapshot](https://docs.lumencharts.com/charting-library/api/PineEditorWorkspaceSnapshot)
- [PineEditorWorkspaceChange](https://docs.lumencharts.com/charting-library/api/PineEditorWorkspaceChange)
- [PineEditorLayoutRequest](https://docs.lumencharts.com/charting-library/api/PineEditorLayoutRequest)
- [PineScriptCompileResult](https://docs.lumencharts.com/charting-library/api/PineScriptCompileResult)
- [PineStrategyReport](https://docs.lumencharts.com/charting-library/api/PineStrategyReport)

---
Documentation page: https://docs.lumencharts.com/charting-library/api/PineEditorWorkspaceApi
