diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 0000000..dc691c0 --- /dev/null +++ b/.cursorignore @@ -0,0 +1,3 @@ +# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) +node_modules/ +dist/ \ No newline at end of file diff --git a/.cursorrules b/.cursorrules index c9963ce..7a4ea03 100644 --- a/.cursorrules +++ b/.cursorrules @@ -14,8 +14,7 @@ Update .vscode/settings.json when adding new packages or directories that should Maintain the following package structure: - packages/ - examples/ - - async-loader/ - - custom-signals/ + - async-framework/ - dev/ - custom-element-signals/ Add new packages under the 'packages/' directory @@ -27,8 +26,7 @@ When adding new packages, update the "deno.enablePaths" in .vscode/settings.json Example: "deno.enablePaths": [ "./packages/examples", - "./packages/async-loader", - "./packages/custom-signals", + "./packages/async-framework", "./packages/dev", // Add new package paths here ] @@ -77,4 +75,29 @@ Avoid unnecessary re-renders or computations // README formatting When creating or updating README files, do not use backticks (`) around code examples unless it's already there +// Deno Import guidelines +Always use import aliases defined in deno.jsonc +Never use direct HTTP imports +For Hono, always use the npm version via the import alias +Examples of correct imports: + import { Hono } from "hono"; + import { assertEquals } from "@std/assert"; + import { signal } from "custom-element-signals"; +Examples of incorrect imports: + import { Hono } from "https://deno.land/x/hono@v3.x/mod.ts"; + import { assertEquals } from "https://deno.land/std/assert/mod.ts"; + +// Deno Version +Use Deno 2.0 or higher for this project +Key Deno 2.0 features to leverage: + - Native npm module support + - Enhanced TypeScript support + - Built-in test runner + - Improved Node.js compatibility + - Enhanced security with permissions system +For detailed documentation and features, refer to: + - Runtime Manual: https://docs.deno.com/runtime/manual + - API Reference: https://docs.deno.com/runtime/api + - Examples: https://docs.deno.com/runtime/examples + // Remember to update this file as the project evolves and new standards are established diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000..20de3a1 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,40 @@ +name: "Custom CodeQL Config" + +paths: + - 'packages/**' + +paths-ignore: + - '**/test/**' + - '**/tests/**' + - '**/dist/**' + - '**/node_modules/**' + - '**/*.test.ts' + - '**/*.test.js' + +queries: + - uses: security-extended + - uses: security-and-quality + +query-filters: + - exclude: + problem.severity: + - warning + - recommendation + +database: + analyze-builtin-pretrained-model: true + max-disk: 1024 + max-ram: 4096 + +extraction: + javascript: + index-typescript: true + typescript: true + index-javascript: true + debug: true + +output: + sarif: + category: "/language:javascript-typescript" + level: "error" + add-snippets: true diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d6feb0b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,48 @@ +# Dependencies and build outputs +node_modules/ +dist/ +build/ +.cache/ + +# Deno specific +deno.lock + +# Editor directories +.vscode/ +.idea/ +*.swp +*.swo + +# System files +.DS_Store +Thumbs.db + +# Test coverage +coverage/ + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Environment variables +.env +.env.* + +# Generated files +*.generated.* +*.min.* + +# Package specific +packages/**/dist/ +packages/**/*.js.map +packages/**/*.d.ts + +# Keep source files formatted +!*.ts +!*.tsx +!*.js +!*.jsx +!*.json +!*.md \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 7f132a3..db6f062 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,8 +3,8 @@ "deno.lint": true, "deno.enablePaths": [ "./packages/examples", - "./packages/async-loader", - "./packages/custom-signals", + "./packages/example-apps", + "./packages/async-framework", "./packages/dev" ], "editor.formatOnSave": true, @@ -17,6 +17,10 @@ "editor.defaultFormatter": "denoland.vscode-deno" }, "files.exclude": { + ".prettierignore": true, + ".gitignore": true, + "LICENSE": true, + ".github/codeql": true, "**/.git": true, "**/.svn": true, "**/.hg": true, diff --git a/README.md b/README.md index 5189743..6f538c4 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,517 @@ -# async-framework +# Async Framework -async-framework is a lightweight, asynchronous JavaScript framework designed for -building responsive and efficient web applications. It leverages modern -JavaScript features to provide a simple yet powerful way to handle user -interactions and manage application state. +A lightweight, signal-based framework for building reactive web applications with custom elements and async handlers. -## Key Features +[](http://www.youtube.com/watch?v=mShb7a9znUg "Async Framework") -- Asynchronous event handling -- Custom element support -- Signal-based state management -- Modular architecture -- Easy integration with existing projects +## Core Concepts -## Setup and Development +1. **Signals**: Reactive state management +2. **Custom Elements**: Web components with async capabilities +3. **Event Handlers**: Async event handling with dynamic imports +4. **JSX Support**: Optional JSX/TSX support for component creation -To get started with async-framework examples, follow these steps: +## Stability Status -1. Make sure you have Deno 2.x.x installed on your system. +| Component | Status | Description | +| --------------- | ------------ | --------------------------------------------------------- | +| AsyncLoader | Stable-ish | Core async loading functionality for handlers and modules | +| HandlerRegistry | Stable-ish | Event handler registration and management system | +| Framework Core | Unstable | Core framework features and utilities | +| JSX Runtime | Unstable | JSX/TSX support and rendering (under development) | +| Signals | Experimental | Reactive state management (API may change) | +| Signal-List | Experimental | A signal-list primitive to optimize rendering lists | +| Signal-Table | Experimental | A signal-table primitive to optimize rendering tables | +| Custom Elements | Experimental | Web Components integration and lifecycle management | +| Templates | Experimental | HTML template handling and instantiation | +| QwikLoader | Experimental | Replace QwikLoader with AsyncLoader | -2. Install the project dependencies by running: - ``` - deno install - ``` +## Basic Usage -3. To start the development server, run: - ``` - deno task dev - ``` +### 1. Signals - This will start the dev server on port 3000, which serves the examples - located in the `packages/examples` directory. +Signals are reactive state containers that automatically track dependencies and update subscribers: +```tsx + import { signal, computed } from '@async/framework'; -4. Open your browser and navigate to `http://localhost:3000` to view the - examples. + // Create a basic signal + const count = signal(0); -## Project Structure + // Read and write to signal + console.log(count.value); // 0 + count.value = 1; -The main examples can be found in the `packages/examples` directory. Feel free -to explore and modify these examples to understand how async-framework works. + // Create a computed signal + const doubled = computed(() => count.value * 2); +``` -- `packages/examples/hello-world`: Contains a simple "Hello World" example - showcasing basic usage of the framework. -- `packages/custom-elements`: Includes custom element definitions and - implementations. +### 2. Custom Elements -## Core Concepts +Create reactive web components using signals: +```tsx + // counter-element.js + import { signal } from '@async/framework'; + + export class CounterElement extends HTMLElement { + constructor() { + super(); + this.count = signal(0); + } + + connectedCallback() { + this.innerHTML = /*html*/` + + `; + + // Auto-update view when signal changes + const buttonEl = this.querySelector('button'); + this.count.subscribe(newValue => { + buttonEl.textContent = `Count: ${newValue}`; + }); + } + } +// in main + customElements.define('counter-element', CounterElement); +``` + +### 3. Async Event Handlers + +Event handlers can be loaded asynchronously and chained: + +HTML: +```html + + + + +