Drn buildwww libraries

From duranserkan/DRN-Project · View interactive version

Drn buildwww libraries is an AI agent skill from the GitHub repository duranserkan/DRN-Project. DRN browser behaviors. Keywords: drn, buildwww, rsjs, onmount, htmx, csp

How to use this skill

Skill file

DRN buildwww Libraries

Keep AGENTS.md, DiSCOS, and the profile active. The application guide and browser contracts own public APIs and limits. Follow type ownership and test conventions.

Contents

RSJS Architecture & DrnOnmount

Use the RSJS pattern: declarative HTML hooks and separately bundled behaviors. Prefer data-js-* selectors and queries scoped to the mounted element. Keep one behavior per module. The shared API is window.DRN. Preserve the real DRN, Drn*, and DRN.Framework.* names.

Onmount Wrapper

DRN.Onmount.register(selector, callback, idempotencyKey) uses default cleanup. registerFull(selector, callback, unregisterCallback, idempotencyKey) accepts custom cleanup. Both deduplicate by selector and optional key. Inspect a snapshot with DRN.Onmount.listRegistrationKeys().

Usage Patterns

Global and Page-Specific Components

Group modules under buildwww/app/ts/behaviors/{layout,home,test}/. Entries import their modules without runtime implementations. The Vite skill owns entry names, loading, and outputs.

Put component logic in modules and encoded data in Razor. Keep inline nonce-test fixtures as explicit test exceptions and early configuration before its consumers.

// behaviors/layout/tooltip.ts
DRN.Onmount.register('[data-bs-toggle="tooltip"]', function (options) {
    options.disposable = new bootstrap.Tooltip(this, {animation: false});
});

See React integration for encoded JSON attributes. Read the mounted element's dataset. Never bypass encoding with raw HTML. Layouts forward/render Scripts for full and htmx responses, preserving nonce, SRI, and PathBase.

Application JavaScript Utilities

Use DRN.App.url(applicationRoute) for requests. Only ~/ receives the deployment prefix. External, fragment, relative, and resolved URLs stay unchanged. Render <meta name="drn-app-base" content="@Url.Content("~/")"/> before preload and preserve controller segments. Rebuild affected bundles only with execution permission.

Problem Details Consumer

Use DRN.Problem.fromResponse(response) and DRN.Problem.show(problem, context) for Fetch failures. Context accepts element, target, operation, persist, and focus. Match validation keys to full posted names, including case, prefixes, and collection indexes. Empty keys are form-level. Preserve input and clear only matching operation errors.

Use DRN.ErrorHandler.reportActionError(error, {operation, message, persist}) only for caught failures affecting user actions. Its clientErrorId is shared by notification/backend report. Backend Problem Details use requestId. Preserve copy/search support and never reinterpret either as a trace ID. See hosting errors.

Diagnostics and Privacy

The profile-declared browser guide owns capture limits, display formatting, and saved-detail compatibility. Check it when changing diagnostics.

Notification History

Use DRN.Toast.show for toast/history, record: false for routine acknowledgments, DRN.Notifications.publish for history alone, and persist: false for page-local history. Server feedback uses SendToast. Forms may set data-notification-operation and data-notification-persist. Avoid duplicate inline/toast feedback and routine validation history. The application guide owns limits, panel behavior, and formatting.

Cookie Manager

The footer uses DRN.Cookie.get/set with base64 encoding and its element's server-provided cookie name. Keep configuration local. Resolve the API from buildwww/types/drnCookieManager.types.ts.

Script Loading Order

The full shell loads preload, early DRN.App configuration, htmx, Bootstrap, postload, React, then layout behaviors. Preload provides DRN.React.mount, which returns null until React loads. Postload installs application-wide listeners and deferred DOM work. Page Scripts sections load home/test behaviors after content. React stays global across pages.

htmx Integration

Security with CSP Nonces

Preserve htmx-config nonces, Vite asset references, and CSRF tokens. The profile’s Sample guide owns the HTMX navigation rules.

Client Validation

The htmx bundle installs DRN.Validation (ValidationService from aspnet-client-validation). Register providers after installation and before bootstrap. Use watch: true for swapped data-val-* content and release detached input/form indexes during cleanup.

Bootstrap Customization

buildwww/lib/bootstrap/bootstrap.scss owns variable overrides, imports, and Bootstrap Icons. bootstrapBundle.ts exposes selected plugins under window.bootstrap. Follow package imports for new imports. Do not migrate relative Sass imports without verifying resolution and an authorized build.

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.