Skip to content

Commit

Permalink
Merge pull request #265 from remix-pwa/dev
Browse files Browse the repository at this point in the history
Moving multiple PRs & fixes to release
  • Loading branch information
ShafSpecs authored Sep 24, 2024
2 parents dda9d68 + cfefe4f commit 8c8c07f
Show file tree
Hide file tree
Showing 17 changed files with 505 additions and 306 deletions.
7 changes: 7 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## @remix-pwa/client 3.0.7-dev.1 (2024-08-23)


### Bug Fixes

* stop useNetworkConnectivity from causing hydration errors. 9cf2978

## @remix-pwa/client 3.0.6 (2024-07-21)


Expand Down
45 changes: 23 additions & 22 deletions packages/client/hooks/useNetworkConnectivity.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
/* eslint-disable n/no-callback-literal */
import { useEffect, useState } from 'react';
import { useEffect, useSyncExternalStore } from 'react';

import { isWindowAvailable } from '../lib/user-agent.js';
const subscribeToNetworkConnectivity = (callback: () => void) => {
window.addEventListener('online', callback);
window.addEventListener('offline', callback);
return () => {
window.removeEventListener('online', callback);
window.removeEventListener('offline', callback);
};
};

const getNetworkConnectivitySnapshot = () => window.navigator.onLine;

const getNetworkConnectivityServerSnapshot = () => false;

export const useNetworkConnectivity = (
options: {
onOnline?: (isOnline: boolean) => void;
onOffline?: (isOnline: boolean) => void;
} = {}
) => {
const [isOnline, setIsOnline] = useState(isWindowAvailable() ? navigator.onLine : false);

const handleOnline = () => {
setIsOnline(true);
options.onOnline && options.onOnline(true);
};

const handleOffline = () => {
setIsOnline(false);
options.onOffline && options.onOffline(false);
};
const isOnline = useSyncExternalStore(
subscribeToNetworkConnectivity,
getNetworkConnectivitySnapshot,
getNetworkConnectivityServerSnapshot
);

useEffect(() => {
if (isWindowAvailable()) {
window.addEventListener('online', handleOnline);
window.addEventListener('offline', handleOffline);

return () => {
window.removeEventListener('online', handleOnline);
window.removeEventListener('offline', handleOffline);
};
if (isOnline) {
options.onOnline && options.onOnline(true);
} else if (options.onOnline) {
options.onOffline && options.onOffline(false);
}
}, []);
}, [isOnline, options]);

return isOnline;
};
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remix-pwa/client",
"version": "3.0.6",
"version": "3.0.7-dev.1",
"description": "A set of utilities for client-side development to enhance the native feel of your Remix App",
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions packages/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface WebAppManifest {
type?: string;
platform?: string;
label?: string;
form_factor?: 'narrow' | 'wide';
}>;
shortcuts?: Array<{
name?: string;
Expand Down
7 changes: 7 additions & 0 deletions packages/sw/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## @remix-pwa/sw 3.0.10-dev.1 (2024-09-24)


### Bug Fixes

* **sw:** changed manifest link `rel` from `manifest` to `webmanifest` 942f76a

## @remix-pwa/sw 3.0.9 (2024-08-11)


Expand Down
2 changes: 1 addition & 1 deletion packages/sw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remix-pwa/sw",
"version": "3.0.9",
"version": "3.0.10-dev.1",
"description": "Service Worker APIs and utilities for Remix PWA",
"repository": {
"type": "git",
Expand Down
11 changes: 9 additions & 2 deletions packages/sw/src/components/ManifestLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import type { LinkHTMLAttributes } from 'react';
import React from 'react';

export const ManifestLink = ({ manifestUrl = '/manifest.webmanifest' }: { manifestUrl?: string }) => {
return <link rel="manifest" href={manifestUrl} />;
export const ManifestLink = ({
crossOrigin,
manifestUrl = '/manifest.webmanifest',
}: {
manifestUrl?: string;
crossOrigin?: LinkHTMLAttributes<HTMLLinkElement>['crossOrigin'];
}) => {
return <link rel="webmanifest" href={manifestUrl} crossOrigin={crossOrigin} />;
};
10 changes: 10 additions & 0 deletions packages/sync/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## @remix-pwa/sync 3.0.5-dev.1 (2024-09-24)





### Dependencies

* **@remix-pwa/sw:** upgraded to 3.0.10-dev.1

## @remix-pwa/sync 3.0.4 (2024-08-11)


Expand Down
4 changes: 2 additions & 2 deletions packages/sync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remix-pwa/sync",
"version": "3.0.4",
"version": "3.0.5-dev.1",
"description": "A Background Sync addon for Remix PWA",
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,7 +34,7 @@
"rimraf": "^6.0.1"
},
"dependencies": {
"@remix-pwa/sw": "^3.0.9",
"@remix-pwa/sw": "^3.0.10-dev.1",
"idb": "^8.0.0"
}
}
Loading

0 comments on commit 8c8c07f

Please sign in to comment.