Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="2.3.0" />
<PackageVersion Include="ModelContextProtocol.Core" Version="2.3.0" />
<PackageVersion Include="NJsonSchema" Version="11.6.1" />
<PackageVersion Include="Enfilade" Version="0.2.1" />
<PackageVersion Include="Enfilade" Version="0.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="5.6.0" />
<PackageVersion Include="MudBlazor" Version="9.12.0" />
<PackageVersion Include="MessageFormat" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion docs/en/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Keep other files of the extension in `context.DataDirectory`.

## Versions and compatibility

The manifest of a package records the extension API version, currently `2.0`. A
The manifest of a package records the extension API version, currently `3.0`. A
server loads an extension when the major version equals its own and the minor
version is not higher. An incompatible extension is skipped with an error in the
log and the server keeps working.
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ dotnet ef migrations add Initial

## Версии и совместимость

Манифест пакета хранит версию API расширений, сейчас `2.0`. Сервер загружает расширение,
Манифест пакета хранит версию API расширений, сейчас `3.0`. Сервер загружает расширение,
если мажорная версия равна его собственной, а минорная не выше. Несовместимое расширение
пропускается с ошибкой в логе, сервер продолжает работать.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@implements IAsyncDisposable
@inject IJSRuntime Js
@inject NavigationManager Navigation
@inject ServerCatalog Catalog
@inject ILogger<CodeEditor> Logger
@inject ILogger<DraftEditor> Logger

<div class="builder-editor">
<div class="builder-editor-bar">
Expand All @@ -24,7 +22,9 @@
{
<p class="bad-t" role="alert" data-testid="save-error">@_error</p>
}
<div @ref="_host" class="builder-editor-host" data-testid="editor"></div>
<div data-testid="editor">
<CodeEditor @ref="_editor" Value="@Content" Language="python" OnChange="EditorChanged"/>
</div>
</div>

@code {
Expand All @@ -40,9 +40,7 @@
}

private readonly SemaphoreSlim _gate = new(1, 1);
private ElementReference _host;
private IJSObjectReference? _module;
private DotNetObjectReference<CodeEditor>? _self;
private CodeEditor? _editor;
private CancellationTokenSource? _quiet;
private SaveState _state = SaveState.Saved;
private string? _error;
Expand Down Expand Up @@ -72,17 +70,7 @@
_revision = Revision;
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
_module = await Js.InvokeAsync<IJSObjectReference>("import", Navigation.ToAbsoluteUri("_content/CtxUi.Builder/editor.js").AbsoluteUri);
_self = DotNetObjectReference.Create(this);
await _module.InvokeVoidAsync("create", _host, _self, Content);
}

[JSInvokable]
public Task EditorChanged()
private Task EditorChanged()
{
return InvokeAsync(() =>
{
Expand Down Expand Up @@ -126,10 +114,10 @@
await _gate.WaitAsync();
try
{
if (!_dirty || _state == SaveState.Conflict || _module is null || _disposed)
if (!_dirty || _state == SaveState.Conflict || _editor is null || _disposed)
return;

var text = await _module.InvokeAsync<string>("getValue", _host);
var text = await _editor.GetValueAsync();
_dirty = false;
_error = null;
_state = SaveState.Saving;
Expand Down Expand Up @@ -174,7 +162,7 @@
_dirty = false;
_error = null;
_state = SaveState.Saved;
await _module!.InvokeVoidAsync("setValue", _host, file.Content);
await _editor!.SetValueAsync(file.Content);
}

private async Task KeepMineAsync()
Expand All @@ -197,20 +185,15 @@
_quiet = null;
try
{
if (_module is not null)
{
if (_editor is not null)
await SaveAsync();
await _module.InvokeVoidAsync("dispose", _host);
await _module.DisposeAsync();
}
}
catch (Exception failure) when (failure is JSDisconnectedException or ObjectDisposedException or InvalidOperationException)
{
}
finally
{
_disposed = true;
_self?.Dispose();
}
}

Expand Down
4 changes: 2 additions & 2 deletions extensions/builder/CtxUi.Builder/Components/ServerPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ else
}
else if (_selected is not null && _files.FirstOrDefault(file => file.Path == _selected) is { } file)
{
<CodeEditor @ref="_editor" @key="file.Path" ServerId="Id" Path="@file.Path" Content="@file.Content"
<DraftEditor @ref="_editor" @key="file.Path" ServerId="Id" Path="@file.Path" Content="@file.Content"
Revision="file.Revision"/>
}
else
Expand All @@ -123,7 +123,7 @@ else
private ServerSettingsView? _settings;
private InboundSummary? _inbound;
private bool _connectOpen;
private CodeEditor? _editor;
private DraftEditor? _editor;
private string? _selected;
private ServerView _view;
private IReadOnlyList<FormTool> _formTools = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
private async Task ExportAsync()
{
var export = await Catalog.ExportAsync(Settings.ServerId, CancellationToken.None);
await using var module = await Js.InvokeAsync<IJSObjectReference>("import", Navigation.ToAbsoluteUri("_content/CtxUi.Builder/editor.js").AbsoluteUri);
await using var module = await Js.InvokeAsync<IJSObjectReference>("import", Navigation.ToAbsoluteUri("_content/CtxUi.Builder/download.js").AbsoluteUri);
using var stream = new DotNetStreamReference(new MemoryStream(export.Content));
await module.InvokeVoidAsync("download", export.FileName, stream);
}
Expand Down
111 changes: 0 additions & 111 deletions extensions/builder/CtxUi.Builder/editor/editor.ts

This file was deleted.

Loading