baremetal.js 1.0.1 → 1.2.2
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 +9 -0
- package/README.md +32 -37
- package/SECURITY.md +2 -2
- package/dist/baremetal.js +599 -0
- package/dist/baremetal.min.js +1 -0
- package/docs/api.md +17 -35
- package/package.json +22 -5
- package/src/index.js +13 -2
- package/src/loader.js +89 -71
- package/src/router.js +39 -45
- package/src/state.js +20 -20
- package/src/transition.js +7 -12
- package/src/virtualize.js +58 -0
- package/.gitattributes +0 -2
- package/.github/workflows/npm-publish.yml +0 -34
- package/CODE_OF_CONDUCT.md +0 -122
- package/CONTRIBUTING.md +0 -53
- package/demo/assets/audio/darren_hirst-20-474737.mp3 +0 -0
- package/demo/assets/js/media_player.js +0 -9
- package/demo/assets/js/page1_specific.js +0 -23
- package/demo/assets/js/page2_specific.js +0 -15
- package/demo/assets/js/shared.js +0 -56
- package/demo/assets/js/sidebar.js +0 -49
- package/demo/main.js +0 -18
- package/demo/page1.html +0 -139
- package/demo/page2.html +0 -132
- package/demo/page3_normal.html +0 -26
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
|
-
|
|
14
|
-
|
|
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.
|
|
@@ -34,7 +49,7 @@ import { BareMetal, loader } from 'baremetal.js';
|
|
|
34
49
|
**Option 2: Using jsDelivr CDN**
|
|
35
50
|
To use the latest version directly in the browser without any build tools, import it via CDN:
|
|
36
51
|
```javascript
|
|
37
|
-
import { BareMetal, loader } from 'https://cdn.jsdelivr.net/npm/baremetal.js@latest/
|
|
52
|
+
import { BareMetal, loader } from 'https://cdn.jsdelivr.net/npm/baremetal.js@latest/dist/baremetal.min.js';
|
|
38
53
|
```
|
|
39
54
|
|
|
40
55
|
**Option 3: Manual Download**
|
|
@@ -52,25 +67,6 @@ npx serve .
|
|
|
52
67
|
|
|
53
68
|
Then visit: `http://localhost:3000/demo/page1.html`
|
|
54
69
|
|
|
55
|
-
## Project Structure
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
├── src/ # The BareMetal Engine Source Code
|
|
59
|
-
│ ├── index.js
|
|
60
|
-
│ ├── router.js
|
|
61
|
-
│ ├── loader.js
|
|
62
|
-
│ ├── state.js
|
|
63
|
-
│ └── transition.js
|
|
64
|
-
├── demo/ # Demo Application
|
|
65
|
-
│ ├── page1.html
|
|
66
|
-
│ ├── page2.html
|
|
67
|
-
│ ├── page3_normal.html
|
|
68
|
-
│ ├── main.js
|
|
69
|
-
│ └── assets/ # Page-specific widgets and media
|
|
70
|
-
├── docs/
|
|
71
|
-
│ └── api.md # Comprehensive API Reference
|
|
72
|
-
```
|
|
73
|
-
|
|
74
70
|
## Usage
|
|
75
71
|
|
|
76
72
|
### 1. Engine Initialization
|
|
@@ -85,6 +81,9 @@ BareMetal.init({
|
|
|
85
81
|
keepAliveSameModules: true,
|
|
86
82
|
autoWrap: false,
|
|
87
83
|
hoverPrefetch: true, // 0ms Latency Pre-fetching
|
|
84
|
+
persistState: true, // F5 Resilience
|
|
85
|
+
virtualizeDom: true, // Inject virtualizer
|
|
86
|
+
showErrorNotification: true, // Error Boundaries
|
|
88
87
|
transition: {
|
|
89
88
|
enabled: true,
|
|
90
89
|
simulatedDelay: 0
|
|
@@ -125,25 +124,21 @@ On your HTML pages, instruct BareMetal on which modules are required for that sp
|
|
|
125
124
|
</script>
|
|
126
125
|
```
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
The `BareMetal.init(config)` method accepts the following configuration object:
|
|
127
|
+
### Lazy Loading a Component
|
|
131
128
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
| `offline` | object | `{}` | Configure offline service worker support. See API docs for details. |
|
|
142
|
-
| `transition.useViewTransitions` | boolean | `false` | Enables the native View Transitions API for smooth cross-fades during navigation. |
|
|
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
|
+
```
|
|
143
138
|
|
|
144
139
|
## API Reference
|
|
145
140
|
|
|
146
|
-
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).
|
|
147
142
|
|
|
148
143
|
## Custom Transitions
|
|
149
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.
|
|
10
|
-
| < 1.
|
|
9
|
+
| 1.2.x | :white_check_mark: |
|
|
10
|
+
| < 1.2 | :x: |
|
|
11
11
|
|
|
12
12
|
## Reporting a Vulnerability
|
|
13
13
|
|