clarioncom-webview2-create
Creates WebView2-based COM controls for Clarion using HTML/CSS/JavaScript with browser rendering
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Creates WebView2-based COM controls for Clarion using HTML/CSS/JavaScript with browser rendering
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Analyze Clarion code generation traces to find recurring failure patterns. Uses evidence-gating (2+ occurrences) to identify real issues. Suggests improvements for the /clarion skill. Triggers on '/clarion-analyze', 'analyze clarion traces', 'what mistakes am I making'.
Benchmark Clarion code generation quality by running test prompts and scoring the output. Measures improvement over time. Triggers on '/clarion-benchmark', 'benchmark clarion', 'test clarion code quality'.
Convert a Clarion dictionary from one file driver to another (e.g., TopSpeed to SQLite). Exports the dictionary to .dctx, transforms driver settings, regenerates GUIDs, creates a new .dct from blank template, and prepares for import. User must perform the final import manually in the IDE.
Create Clarion IDE addins with proper project structure, templates, and SharpDevelop integration. Use when creating new IDE tools, pads, embeditor toolbar buttons, or menu commands for the Clarion IDE.
Clarion language programming reference with syntax rules, data types, control structures, Windows API integration patterns, and template-authoring gotchas (#AT,
Compile C# COM projects for Clarion using MSBuild with correct paths, error handling, and build verification. Supports public releases with changelog management. Auto-applies for building .NET Framework COM components. Verification steps use parallel execution.
| name | clarioncom-webview2-create |
| description | Creates WebView2-based COM controls for Clarion using HTML/CSS/JavaScript with browser rendering |
| version | 1.0.0 |
Use the helper script to avoid shell escaping issues:
powershell -ExecutionPolicy Bypass -Command "& ([Environment]::GetFolderPath('ApplicationData') + '\ClarionCOM\scripts\clarioncom-env.ps1') home"
If NOT_INSTALLED: Stop and tell user:
ClarionCOM is not installed. Please run Install-ClarionCOM.ps1 from the ClarionCOM distribution folder.
Use the helper script to get the templates path:
powershell -ExecutionPolicy Bypass -Command "& ([Environment]::GetFolderPath('ApplicationData') + '\ClarionCOM\scripts\clarioncom-env.ps1') templates"
Template paths:
$TEMPLATES_PATH/WebView2/$CLARIONCOM_HOME\scripts\This skill creates WebView2-based COM components that use HTML/CSS/JavaScript for rendering, while maintaining full COM compatibility with Clarion.
<clrClass> element (NOT <comClass>)runtimeVersion="v4.0.30319" attributeprocessorArchitecture="x86"When asking for the control name, always suggest the current working directory name as the default.
The wwwroot/controls/{controlname}/ folder MUST use the exact same name as the project/assembly (lowercase):
wwwroot/controls/webcalendarcom/wwwroot/controls/mygridcontrolcom/Use this skill when user wants:
After gathering basic control information, ask:
Question: "Which JavaScript library will you use?" Options:
Question: "Will this control need database access?" Options:
Question: "Which database will you use?" Options:
All WebView2 template files are in Template/WebView2/:
Template/WebView2/
WebView2Template.csproj
WebView2Control.cs
IWebView2Control.cs
IWebView2ControlEvents.cs
WebView2Control.manifest
Properties/
AssemblyInfo.cs
wwwroot/
css/styles.css
js/dx-config.js
controls/{controlname}/
index.html
app.js
Data/
SqlServerDataProvider.cs
PostgresDataProvider.cs
MySqlDataProvider.cs
SqliteDataProvider.cs
QueryBuilder.cs
Generate 4 unique GUIDs for every WebView2 COM component:
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2849.39" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
| Database | NuGet Package |
|---|---|
| SQL Server | System.Data.SqlClient |
| PostgreSQL | Npgsql |
| MySQL | MySql.Data |
| SQLite | System.Data.SQLite.Core |
WebView2 controls use a wwwroot folder for web content:
wwwroot/
css/
styles.css # Shared styles
dx.light.css # DevExtreme theme (copied during build)
js/
dx-config.js # DevExtreme configuration
jquery.min.js # jQuery (copied during build)
dx.all.js # DevExtreme library (copied during build)
controls/
{controlname}/ # MUST match lowercase DLL name without extension (e.g., DLL "WebCalendarCOM.dll" → folder "webcalendarcom")
index.html # Main HTML file
app.js # Control JavaScript
DevExtreme Files: If using DevExtreme, you must manually place dx.all.js, jquery.min.js, and dx.light.css in the wwwroot/js and wwwroot/css folders. DevExtreme requires a license (trial mode shows a watermark).
WebView2 maps local files via virtual host:
_webView.CoreWebView2.SetVirtualHostNameToFolderMapping(
"localapp.clarioncontrols",
wwwrootPath,
CoreWebView2HostResourceAccessKind.Allow);
Navigate to: https://localapp.clarioncontrols/controls/{name}/index.html
For C# to JavaScript communication:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class WebViewHostObject
{
private readonly Action<string> _onMessage;
public WebViewHostObject(Action<string> onMessage)
{
_onMessage = onMessage;
}
public void SendMessage(string jsonMessage)
{
_onMessage?.Invoke(jsonMessage);
}
}
// Register in WebView2 initialization:
_hostObject = new WebViewHostObject(HandleHostObjectMessage);
_webView.CoreWebView2.AddHostObjectToScript("controlHost", _hostObject);
JavaScript calls C#:
var host = window.chrome.webview.hostObjects.sync.controlHost;
host.SendMessage(JSON.stringify({ type: 'action', data: value }));
Generate 4 unique GUIDs
Create project folder with control name
Copy and customize template files:
{NAMESPACE} with project namespace{CONTROL_NAME} with control class name{GUID_INTERFACE}, {GUID_EVENTS}, {GUID_CLASS}, {GUID_TYPELIB}{controlname} with lowercase assembly/project name (for wwwroot folder)
CRITICAL: File Naming Convention
For a project named "WebCalendarCOM" (folder name), with {CONTROL_NAME} = "WebCalendarCOM":
| Template File | Output File | Notes |
|---|---|---|
WebView2Template.csproj | WebCalendarCOM.csproj | Project name = folder name |
WebView2Control.cs | WebCalendarCOMControl.cs | Class = {CONTROL_NAME}Control |
IWebView2Control.cs | IWebCalendarCOMControl.cs | Interface = I{CONTROL_NAME}Control |
IWebView2ControlEvents.cs | IWebCalendarCOMControlEvents.cs | Events = I{CONTROL_NAME}ControlEvents |
WebView2Control.manifest | WebCalendarCOM.manifest | Manifest = project name |
Properties/AssemblyInfo.cs | Properties/AssemblyInfo.cs | Same path |
Key Points:
Include data provider if selected:
Create manifest file with correct GUIDs
Build project with MSBuild
Verify deployment:
Before building, verify all source files exist in PROJECT ROOT:
{CONTROL_NAME}Control.cs exists (e.g., WebCalendarCOMControl.cs)I{CONTROL_NAME}Control.cs exists (e.g., IWebCalendarCOMControl.cs)I{CONTROL_NAME}ControlEvents.cs exists (e.g., IWebCalendarCOMControlEvents.cs){PROJECT_NAME}.manifest exists (e.g., WebCalendarCOM.manifest){PROJECT_NAME}.csproj exists (e.g., WebCalendarCOM.csproj)Properties/AssemblyInfo.cs existswwwroot/controls/{controlname}/index.html existswwwroot/controls/{controlname}/app.js existsCRITICAL: The interface files (I{CONTROL_NAME}Control.cs and I{CONTROL_NAME}ControlEvents.cs) MUST exist with correct naming for the metadata generator to create the .methods file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="ControlName"
version="1.0.0.0"
processorArchitecture="x86"
type="win32"/>
<clrClass
clsid="{CLASS-GUID}"
progid="Namespace.ControlName"
threadingModel="Apartment"
name="Namespace.ControlName"
runtimeVersion="v4.0.30319">
</clrClass>
<file name="ControlName.dll">
<typelib
tlbid="{TYPELIB-GUID}"
version="1.0"
helpdir=""
resourceid="0"
flags="HASDISKIMAGE"/>
</file>
</assembly>
CRITICAL: Always specify a persistent user data folder when creating the WebView2 environment. Without this, WebView2 creates a temporary browser profile on every launch, causing slow startup.
// WRONG - creates temp profile every time, slow cold start
var env = await CoreWebView2Environment.CreateAsync(null, null, null);
// CORRECT - reuses cached browser profile, much faster after first launch
var userDataFolder = System.IO.Path.Combine(
System.IO.Path.GetTempPath(), "ClarionCOM", "{ControlName}");
var env = await CoreWebView2Environment.CreateAsync(null, userDataFolder, null);
Pattern: Use %TEMP%\ClarionCOM\{ControlName}\ so each control has its own cache but all are under one parent folder. The folder is created automatically on first use.
Why it matters: The persistent folder caches the browser profile, compiled JavaScript, and runtime resources. First launch is normal speed; subsequent launches are significantly faster because WebView2 skips cold initialization.
Template integration: When generating InitializeWebView2Async() in the control's .cs file, always include the persistent user data folder. Replace {ControlName} with the actual project/assembly name (e.g., "WebCalendarCOM").
IMPORTANT: WebView2 controls require the WebView2 Runtime to be installed on the target machine.
Use Visual Studio MSBuild (NOT dotnet CLI):
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" ProjectName.csproj -p:Configuration=Release
After build, the Clarion folder should contain:
Deployment to Clarion: When using copy-to-clarion.ps1:
accessory\bin\accessory\resources\accessory\resources\wwwroot\