@aarongustafson/pull-to-refresh 0.0.5 → 1.0.0

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/README.md CHANGED
@@ -29,21 +29,31 @@ npm install @aarongustafson/pull-to-refresh
29
29
 
30
30
  ### Usage
31
31
 
32
- **Option 1: Auto-define (easiest)**
32
+ **Option 1: Manual registration**
33
33
  ```javascript
34
- import '@aarongustafson/pull-to-refresh';
34
+ import { PullToRefreshElement } from '@aarongustafson/pull-to-refresh';
35
+
36
+ customElements.define('pull-to-refresh', PullToRefreshElement);
35
37
  ```
36
38
 
37
- **Option 2: Manual registration**
39
+ **Option 2: Auto-define (browser environments only)**
38
40
  ```javascript
39
- import { PullToRefreshElement } from '@aarongustafson/pull-to-refresh/pull-to-refresh.js';
40
- customElements.define('pull-to-refresh', PullToRefreshElement);
41
+ import '@aarongustafson/pull-to-refresh/define.js';
42
+ // Registers <pull-to-refresh> when customElements is available
41
43
  ```
42
44
 
43
- **Option 3: Both (class + auto-define)**
45
+ Prefer to control when registration happens? Call the helper directly:
46
+
44
47
  ```javascript
45
- import { PullToRefreshElement } from '@aarongustafson/pull-to-refresh';
46
- // Element is registered AND class is available
48
+ import { definePullToRefresh } from '@aarongustafson/pull-to-refresh/define.js';
49
+
50
+ definePullToRefresh();
51
+ ```
52
+
53
+ You can also include the guarded script from HTML:
54
+
55
+ ```html
56
+ <script src="./node_modules/@aarongustafson/pull-to-refresh/define.js" type="module"></script>
47
57
  ```
48
58
 
49
59
  ### Basic Example
package/define.js CHANGED
@@ -1,3 +1,18 @@
1
1
  import { PullToRefreshElement } from './pull-to-refresh.js';
2
2
 
3
- customElements.define('pull-to-refresh', PullToRefreshElement);
3
+ export function definePullToRefresh(tagName = 'pull-to-refresh') {
4
+ const hasWindow = typeof window !== 'undefined';
5
+ const registry = hasWindow ? window.customElements : undefined;
6
+
7
+ if (!registry || typeof registry.define !== 'function') {
8
+ return false;
9
+ }
10
+
11
+ if (!registry.get(tagName)) {
12
+ registry.define(tagName, PullToRefreshElement);
13
+ }
14
+
15
+ return true;
16
+ }
17
+
18
+ definePullToRefresh();
package/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { PullToRefreshElement } from './pull-to-refresh.js';
2
- import './define.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarongustafson/pull-to-refresh",
3
- "version": "0.0.5",
3
+ "version": "1.0.0",
4
4
  "description": "Web component that enables pull-to-refresh functionality.",
5
5
  "keywords": [
6
6
  "html",