@revivejs/resize-observer 4.0.4 → 4.0.5

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.
Files changed (2) hide show
  1. package/README.md +98 -70
  2. package/package.json +11 -3
package/README.md CHANGED
@@ -1,65 +1,71 @@
1
1
  # @revivejs/resize-observer
2
2
 
3
- > A maintained ResizeObserver ponyfill for browser applications, with support for content-box, border-box, and device-pixel-content-box observations.
4
-
5
- [![npm version](https://img.shields.io/npm/v/@revivejs/resize-observer.svg?style=flat-square)](https://www.npmjs.com/package/@revivejs/resize-observer)
6
- [![npm downloads](https://img.shields.io/npm/dt/@revivejs/resize-observer.svg?style=flat-square)](https://www.npmjs.com/package/@revivejs/resize-observer)
7
- [![npm monthly](https://img.shields.io/npm/dm/@revivejs/resize-observer.svg?style=flat-square)](https://www.npmjs.com/package/@revivejs/resize-observer)
8
- [![license](https://img.shields.io/npm/l/@revivejs/resize-observer.svg?style=flat-square)](https://github.com/alexandroit/resize-observer/blob/HEAD/LICENSE)
9
- [![TypeScript 4.7+](https://img.shields.io/badge/TypeScript-4.7%2B-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org)
3
+ > A maintained **ResizeObserver 4.0.x ponyfill** for browser applications, with support for `content-box`, `border-box`, and `device-pixel-content-box` observations, TypeScript declarations, ESM and UMD bundles, and versioned docs for every published ReviveJS release.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40revivejs%2Fresize-observer.svg?style=flat-square)](https://www.npmjs.com/package/@revivejs/resize-observer)
6
+ [![npm downloads](https://img.shields.io/npm/dt/%40revivejs%2Fresize-observer.svg?style=flat-square)](https://www.npmjs.com/package/@revivejs/resize-observer)
7
+ [![npm monthly](https://img.shields.io/npm/dm/%40revivejs%2Fresize-observer.svg?style=flat-square)](https://www.npmjs.com/package/@revivejs/resize-observer)
8
+ [![license](https://img.shields.io/npm/l/%40revivejs%2Fresize-observer.svg?style=flat-square)](https://github.com/alexandroit/resize-observer/blob/HEAD/LICENSE)
9
+ [![JavaScript ES2018+](https://img.shields.io/badge/JavaScript-ES2018%2B-f7df1e?style=flat-square&logo=javascript&logoColor=111)](https://developer.mozilla.org/docs/Web/JavaScript)
10
+ [![TypeScript typings](https://img.shields.io/badge/TypeScript-5.x-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org)
10
11
  [![GitHub stars](https://img.shields.io/github/stars/alexandroit/resize-observer.svg?style=flat-square)](https://github.com/alexandroit/resize-observer/stargazers)
11
12
 
12
- **[Documentation & Demo](https://alexandroit.github.io/resize-observer/)** | **[Repository](https://github.com/alexandroit/resize-observer)** | **[npm](https://www.npmjs.com/package/@revivejs/resize-observer)** | **[Changelog](https://github.com/alexandroit/resize-observer/blob/HEAD/CHANGELOG.md)**
13
+ **[Documentation & Live Demos](https://alexandroit.github.io/resize-observer/)** | **[npm](https://www.npmjs.com/package/@revivejs/resize-observer)** | **[Issues](https://github.com/alexandroit/resize-observer/issues)** | **[Repository](https://github.com/alexandroit/resize-observer)**
14
+
15
+ **Latest version:** `4.0.5`
13
16
 
14
17
  ---
15
18
 
16
19
  > **Credits:** Original project by Juggle.
17
- > Maintained and modernized by Revivejs.
20
+ > Maintained and republished by Alexandroit under the ReviveJS scope.
18
21
 
19
22
  ---
20
23
 
21
- ## Why this package?
22
-
23
- `@revivejs/resize-observer` preserves the proven upstream ResizeObserver polyfill while updating the package metadata, docs, demo pipeline, and repository automation for the current maintainer. It stays framework-agnostic, so Angular, React, Vue, Web Components, and plain browser apps can all use the same entry point.
24
+ ## Why this library?
24
25
 
25
- ---
26
+ `@revivejs/resize-observer` keeps the proven ResizeObserver ponyfill API available under active
27
+ package ownership for teams that still need a browser-safe observer implementation with box-size
28
+ support. The package stays intentionally close to the maintained 4.0.x line while cleaning up
29
+ metadata, documentation, and GitHub Pages delivery.
26
30
 
27
31
  ## Features
28
32
 
29
33
  | Feature | Supported |
30
34
  | :--- | :---: |
31
- | ResizeObserver ponyfill API | Yes |
32
- | `content-box` observations | Yes |
33
- | `border-box` observations | Yes |
34
- | `device-pixel-content-box` observations | Yes |
35
- | Resize loop error delivery | Yes |
36
- | Inline-element handling rules | Yes |
37
- | SVG element observation | Yes |
38
- | Static GitHub Pages demo in `docs/` | Yes |
39
-
40
- ---
35
+ | Maintained ResizeObserver 4.0.x ponyfill line | |
36
+ | `content-box`, `border-box`, and `device-pixel-content-box` | |
37
+ | Classic `contentRect` plus box-size arrays | |
38
+ | HTML, inline, and SVG targets | |
39
+ | Transition, animation, and lifecycle observation demos | |
40
+ | ESM and UMD bundles | |
41
+ | TypeScript declaration files | |
42
+ | Versioned docs per published package release | |
41
43
 
42
44
  ## Table of Contents
43
45
 
44
- 1. [Framework Compatibility](#framework-compatibility)
46
+ 1. [Published Version Compatibility](#published-version-compatibility)
45
47
  2. [Installation](#installation)
46
- 3. [Quick Start](#quick-start)
47
- 4. [API](#api)
48
- 5. [Configuration](#configuration)
49
- 6. [Run Locally](#run-locally)
50
- 7. [Publishing](#publishing)
51
- 8. [License](#license)
52
-
53
- ---
54
-
55
- ## Framework Compatibility
56
-
57
- | Package Version | Angular | React | Vue | TypeScript | Notes |
58
- | :--- | :---: | :---: | :---: | :---: | :--- |
59
- | 4.x | Any browser-based version | Any browser-based version | Any browser-based version | 5.x+ | Maintained `@revivejs` fork |
60
- | 3.x | Any browser-based version | Any browser-based version | Any browser-based version | 4.7 | Original upstream `@juggle` package line |
61
-
62
- This library is not Angular-specific. If your framework runs in a browser and can import npm packages, it can use this ponyfill.
48
+ 3. [Setup](#setup)
49
+ 4. [Basic Usage](#basic-usage)
50
+ 5. [Core APIs](#core-apis)
51
+ 6. [Box Options and Output](#box-options-and-output)
52
+ 7. [Browser Assets](#browser-assets)
53
+ 8. [Run Locally](#run-locally)
54
+ 9. [Publishing](#publishing)
55
+ 10. [License](#license)
56
+
57
+ ## Published Version Compatibility
58
+
59
+ | Package version | Maintained line | Runtime target | TypeScript declarations | Demo link |
60
+ | :---: | :---: | :--- | :--- | :--- |
61
+ | **4.0.5** | **ResizeObserver 4.0.x** | **Modern browsers with ES2018 demo bundle** | **`lib/exports/resize-observer.d.ts`** | [ResizeObserver 4.0.5 docs](https://alexandroit.github.io/resize-observer/v4.0.5/) |
62
+ | **4.0.4** | **ResizeObserver 4.0.x** | **Modern browsers with ES2018 demo bundle** | **`lib/exports/resize-observer.d.ts`** | [ResizeObserver 4.0.4 docs](https://alexandroit.github.io/resize-observer/v4.0.4/) |
63
+ | 4.0.3 | ResizeObserver 4.0.x | Modern browsers with ES2018 demo bundle | `lib/exports/resize-observer.d.ts` | [ResizeObserver 4.0.3 docs](https://alexandroit.github.io/resize-observer/v4.0.3/) |
64
+ | 4.0.2 | ResizeObserver 4.0.x | Modern browsers with ES2018 demo bundle | `lib/exports/resize-observer.d.ts` | [ResizeObserver 4.0.2 docs](https://alexandroit.github.io/resize-observer/v4.0.2/) |
65
+ | 4.0.1 | ResizeObserver 4.0.x | Modern browsers with ES2018 demo bundle | `lib/exports/resize-observer.d.ts` | [ResizeObserver 4.0.1 docs](https://alexandroit.github.io/resize-observer/v4.0.1/) |
66
+ | 4.0.0 | ResizeObserver 4.0.x | Modern browsers with ES2018 demo bundle | `lib/exports/resize-observer.d.ts` | [ResizeObserver 4.0.0 docs](https://alexandroit.github.io/resize-observer/v4.0.0/) |
67
+
68
+ Earlier `3.x` releases were published from the original upstream package line at `@juggle/resize-observer`.
63
69
 
64
70
  ---
65
71
 
@@ -71,58 +77,78 @@ npm install @revivejs/resize-observer
71
77
 
72
78
  ---
73
79
 
74
- ## Quick Start
80
+ ## Setup
75
81
 
76
82
  ```ts
77
83
  import { ResizeObserver } from '@revivejs/resize-observer';
78
84
 
79
- const ro = new ResizeObserver((entries) => {
85
+ const observer = new ResizeObserver((entries) => {
80
86
  for (const entry of entries) {
81
- const { inlineSize, blockSize } = entry.contentBoxSize[0];
82
- entry.target.setAttribute(
83
- 'data-size',
84
- `${Math.round(inlineSize)} x ${Math.round(blockSize)}`
85
- );
87
+ console.log(entry.contentRect.width, entry.contentRect.height);
86
88
  }
87
89
  });
88
-
89
- ro.observe(document.body, { box: 'content-box' });
90
90
  ```
91
91
 
92
92
  ---
93
93
 
94
- ## API
94
+ ## Basic Usage
95
95
 
96
- ### `new ResizeObserver(callback)`
96
+ ```ts
97
+ import { ResizeObserver } from '@revivejs/resize-observer';
97
98
 
98
- Creates an observer that receives `ResizeObserverEntry[]` and the active observer instance.
99
+ const target = document.querySelector('[data-resize-target]');
99
100
 
100
- ### `observe(target, options?)`
101
+ const observer = new ResizeObserver((entries) => {
102
+ for (const entry of entries) {
103
+ const contentSize = entry.contentBoxSize[0];
104
+ console.log({
105
+ width: entry.contentRect.width,
106
+ height: entry.contentRect.height,
107
+ inlineSize: contentSize?.inlineSize,
108
+ blockSize: contentSize?.blockSize
109
+ });
110
+ }
111
+ });
101
112
 
102
- Starts observing an `Element`.
113
+ observer.observe(target, { box: 'content-box' });
114
+ ```
103
115
 
104
- ### `unobserve(target)`
116
+ ---
105
117
 
106
- Stops observing a previously registered `Element`.
118
+ ## Core APIs
107
119
 
108
- ### `disconnect()`
120
+ | API | Description |
121
+ | :--- | :--- |
122
+ | `new ResizeObserver(callback)` | Creates an observer that receives `ResizeObserverEntry[]` and the active observer instance. |
123
+ | `observe(target, options?)` | Starts observing an `Element` with an optional box selection. |
124
+ | `unobserve(target)` | Stops observing one target while leaving the observer active for others. |
125
+ | `disconnect()` | Stops every active observation on the observer. |
109
126
 
110
- Stops all active observations for the observer.
127
+ ---
111
128
 
112
- ### Resize observer entry fields
129
+ ## Box Options and Output
113
130
 
114
- - `contentRect`
115
- - `contentBoxSize`
116
- - `borderBoxSize`
117
- - `devicePixelContentBoxSize`
131
+ | Option / Field | Description |
132
+ | :--- | :--- |
133
+ | `box: 'content-box'` | Measures the content box and maps naturally to text and padding-free layouts. |
134
+ | `box: 'border-box'` | Includes padding and borders for container-style sizing workflows. |
135
+ | `box: 'device-pixel-content-box'` | Exposes device-pixel measurements when the runtime supports them. |
136
+ | `contentRect` | Legacy rectangle snapshot used widely in existing production code. |
137
+ | `contentBoxSize` | Logical inline/block sizes for the content box. |
138
+ | `borderBoxSize` | Logical inline/block sizes for the border box. |
139
+ | `devicePixelContentBoxSize` | Logical inline/block sizes expressed in device pixels. |
118
140
 
119
141
  ---
120
142
 
121
- ## Configuration
143
+ ## Browser Assets
144
+
145
+ The published package keeps the maintained distribution layout:
122
146
 
123
- | Option | Type | Description | Default |
124
- | :--- | :--- | :--- | :--- |
125
- | `box` | `'content-box' \| 'border-box' \| 'device-pixel-content-box'` | Selects which box size to observe for each target. | `'content-box'` |
147
+ | File | Description |
148
+ | :--- | :--- |
149
+ | `lib/exports/resize-observer.js` | ESM bundle |
150
+ | `lib/exports/resize-observer.umd.js` | UMD/browser-compatible bundle |
151
+ | `lib/exports/resize-observer.d.ts` | TypeScript declarations |
126
152
 
127
153
  ---
128
154
 
@@ -132,6 +158,7 @@ Stops all active observations for the observer.
132
158
  npm install
133
159
  npm test
134
160
  npm run build
161
+ npm run build:docs:all
135
162
  npm start
136
163
  ```
137
164
 
@@ -149,11 +176,12 @@ npm publish --access public
149
176
 
150
177
  ## License
151
178
 
152
- Apache-2.0
179
+ Apache-2.0. See [LICENSE](LICENSE).
153
180
 
154
181
  ---
155
182
 
156
183
  ## Credits
157
184
 
158
185
  - Original project: Juggle
159
- - Maintained by: Revivejs
186
+ - Upstream repository: https://github.com/juggle/resize-observer
187
+ - Maintained by: Alexandroit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revivejs/resize-observer",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "Polyfills the ResizeObserver API and supports box size options from the latest spec",
5
5
  "main": "lib/exports/resize-observer.umd.js",
6
6
  "module": "lib/exports/resize-observer.js",
@@ -18,13 +18,21 @@
18
18
  "lib/**/*.{js,ts}"
19
19
  ],
20
20
  "scripts": {
21
- "clean": "rm -rf lib docs/index.html docs/page.js docs/page.css",
21
+ "clean": "rm -rf lib docs/v* docs/index.html docs/page.js docs/page.css docs/.nojekyll",
22
22
  "build": "npm run clean && npm run build:lib && npm run build:docs",
23
23
  "build:lib": "npm run build:esm && npm run build:umd",
24
24
  "build:esm": "tsc",
25
25
  "build:umd": "rollup -c",
26
- "build:docs": "node scripts/build-docs.mjs",
26
+ "build:docs": "node scripts/build-docs.mjs --all",
27
+ "build:docs:all": "node scripts/build-docs.mjs --all",
28
+ "build:docs:v4.0.0": "node scripts/build-docs.mjs v4.0.0",
29
+ "build:docs:v4.0.1": "node scripts/build-docs.mjs v4.0.1",
30
+ "build:docs:v4.0.2": "node scripts/build-docs.mjs v4.0.2",
31
+ "build:docs:v4.0.3": "node scripts/build-docs.mjs v4.0.3",
32
+ "build:docs:v4.0.4": "node scripts/build-docs.mjs v4.0.4",
33
+ "build:docs:v4.0.5": "node scripts/build-docs.mjs v4.0.5",
27
34
  "build:package": "npm run build",
35
+ "docs:build": "npm run build:docs",
28
36
  "pack:check": "npm pack --dry-run",
29
37
  "start": "npm run build:docs && serve docs -l 4173",
30
38
  "ci": "npm test && npm run build && npm run pack:check",