baremetal.js 1.0.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.0] - 2026-06-18
9
+
10
+ ### Added
11
+ - Auto-Request Cancellation (AbortController) to prevent bandwidth waste on rapid navigation.
12
+ - Component Lazy Loading via IntersectionObserver (`lazy` property in loader).
13
+ - State Hydration (`persistState`) to automatically recover from browser hard reloads.
14
+ - DOM Virtualization Helper (`Virtualizer`) to render massive lists with zero jank.
15
+
16
+
8
17
  ## [1.0.0] - 2026-06-17
9
18
 
10
19
  ### Added
package/README.md CHANGED
@@ -10,8 +10,23 @@ BareMetal.js is designed to bring Single Page Application (SPA) functionality to
10
10
 
11
11
  ## Key Features
12
12
 
13
- - **Hover Pre-fetching (0ms Latency):** BareMetal anticipates user actions by fetching HTML in the background when a user hovers over an internal link, resulting in instant transitions upon click.
14
- - **Smart Module Keep-Alive:** Share state and complex UI modules across page transitions without destroying them. Native `<video>` and `<audio>` tags can be preserved and re-injected into the new DOM seamlessly.
13
+ ### Hover Pre-fetching (0ms Latency)
14
+ BareMetal anticipates user actions. When a user hovers over an internal link, the engine instantly fetches the HTML in the background. By the time they click, the page is already cached, resulting in instantaneous, zero-latency transitions.
15
+
16
+ ### Auto-Request Cancellation
17
+ If a user is frantically clicking links, BareMetal won't clog up their network. The Router automatically utilizes the `AbortController` API to cancel any pending `fetch` requests as soon as a new navigation is triggered, saving bandwidth and preventing race conditions.
18
+
19
+ ### Smart Module Keep-Alive
20
+ Share state and complex UI modules (like persistent sidebars or floating media players) across page transitions without destroying them. Native `<video>` and `<audio>` tags are preserved and re-injected into the new DOM layout without interrupting playback!
21
+
22
+ ### Component Lazy Loading
23
+ Load heavy widgets only when they scroll into view! The Loader supports an `IntersectionObserver` API out of the box. Just pass a `lazy` CSS selector to the `loader({ widget: { path: './widget.js', lazy: '#widget' } })` and it defers downloading and execution until the user actually sees it.
24
+
25
+ ### State Hydration (F5 Resilience)
26
+ Never lose state on a hard reload again. If enabled, BareMetal automatically serializes the `stateManager` to `sessionStorage` in real-time. If the user hits F5, the engine instantly hydrates the state and bounces right back to where they were!
27
+
28
+ ### DOM Virtualization Helper
29
+ Rendering 10,000 table rows? BareMetal exposes a `Virtualizer` class that recycles DOM nodes to render massive lists with zero jank. When enabled globally, the engine automatically injects the `virtualize` helper directly into your module's `mount` context!.
15
30
  - **Scroll Memory & Programmatic Back:** Maintains a persistent history stack, restoring your exact scroll depth instantly when navigating backward.
16
31
  - **Reactive State Management:** Includes a built-in publish/subscribe Signals pattern, preventing race conditions and keeping your UI synced.
17
32
  - **Custom Page Transitions:** Build and integrate your own loading animations and transition effects hooking into the routing lifecycle.
@@ -22,7 +37,23 @@ BareMetal.js is designed to bring Single Page Application (SPA) functionality to
22
37
 
23
38
  ### Installation
24
39
 
25
- No installation required! Just clone the repository or copy the `src` folder into your project.
40
+ **Option 1: Using npm**
41
+ If you are using a bundler (like Vite, Webpack) or modern Node.js environments:
42
+ ```bash
43
+ npm install baremetal.js
44
+ ```
45
+ ```javascript
46
+ import { BareMetal, loader } from 'baremetal.js';
47
+ ```
48
+
49
+ **Option 2: Using jsDelivr CDN**
50
+ To use the latest version directly in the browser without any build tools, import it via CDN:
51
+ ```javascript
52
+ import { BareMetal, loader } from 'https://cdn.jsdelivr.net/npm/baremetal.js@latest/dist/baremetal.min.js';
53
+ ```
54
+
55
+ **Option 3: Manual Download**
56
+ Just clone the repository or copy the `src` folder directly into your project.
26
57
 
27
58
  ### Running the Demo
28
59
 
@@ -36,25 +67,6 @@ npx serve .
36
67
 
37
68
  Then visit: `http://localhost:3000/demo/page1.html`
38
69
 
39
- ## Project Structure
40
-
41
- ```
42
- ├── src/ # The BareMetal Engine Source Code
43
- │ ├── index.js
44
- │ ├── router.js
45
- │ ├── loader.js
46
- │ ├── state.js
47
- │ └── transition.js
48
- ├── demo/ # Demo Application
49
- │ ├── page1.html
50
- │ ├── page2.html
51
- │ ├── page3_normal.html
52
- │ ├── main.js
53
- │ └── assets/ # Page-specific widgets and media
54
- ├── docs/
55
- │ └── api.md # Comprehensive API Reference
56
- ```
57
-
58
70
  ## Usage
59
71
 
60
72
  ### 1. Engine Initialization
@@ -69,6 +81,9 @@ BareMetal.init({
69
81
  keepAliveSameModules: true,
70
82
  autoWrap: false,
71
83
  hoverPrefetch: true, // 0ms Latency Pre-fetching
84
+ persistState: true, // F5 Resilience
85
+ virtualizeDom: true, // Inject virtualizer
86
+ showErrorNotification: true, // Error Boundaries
72
87
  transition: {
73
88
  enabled: true,
74
89
  simulatedDelay: 0
@@ -109,23 +124,21 @@ On your HTML pages, instruct BareMetal on which modules are required for that sp
109
124
  </script>
110
125
  ```
111
126
 
112
- ## Configuration Reference
113
-
114
- The `BareMetal.init(config)` method accepts the following configuration object:
127
+ ### Lazy Loading a Component
115
128
 
116
- | Option | Type | Default | Description |
117
- |--------|------|---------|-------------|
118
- | `debug` | boolean | `false` | Enable verbose console logs. |
119
- | `keepAliveSameModules` | boolean | `true` | Prevent destruction of modules shared between routes. |
120
- | `autoWrap` | boolean | `true` | Automatically wrap modules that do not export a `mount` function. |
121
- | `hoverPrefetch` | boolean | `false` | Enable 0ms latency pre-fetching on link hover. |
122
- | `transition.enabled` | boolean | `false` | Enable the protected transition module. |
123
- | `transition.module` | string | `null` | Path to a custom transition module. |
124
- | `transition.simulatedDelay` | number | `0` | Artificial delay (ms) for testing transitions. |
129
+ ```html
130
+ <script type="module">
131
+ import { loader } from './src/index.js';
132
+ loader({
133
+ sharedSidebar: "./js/sidebar.js",
134
+ heavyChart: { path: "./js/chart.js", lazy: "#chart-container" } // Only loads when visible!
135
+ });
136
+ </script>
137
+ ```
125
138
 
126
139
  ## API Reference
127
140
 
128
- For detailed documentation on the Router, State Manager, and Events, please see the [API Documentation](docs/api.md).
141
+ For detailed documentation on the Configuration, Router, State Manager, and Events, please see the [API Documentation](docs/api.md).
129
142
 
130
143
  ## Custom Transitions
131
144
 
package/SECURITY.md CHANGED
@@ -6,8 +6,8 @@ Currently, only the latest version of BareMetal.js is supported with security up
6
6
 
7
7
  | Version | Supported |
8
8
  | ------- | ------------------ |
9
- | 1.0.x | :white_check_mark: |
10
- | < 1.0 | :x: |
9
+ | 1.2.x | :white_check_mark: |
10
+ | < 1.2 | :x: |
11
11
 
12
12
  ## Reporting a Vulnerability
13
13