Skip to content

Commit

Permalink
refactor: improve ESM support and add remix example (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov authored Feb 12, 2024
1 parent 7a2d7db commit c55bfe6
Show file tree
Hide file tree
Showing 371 changed files with 19,133 additions and 2,574 deletions.
11 changes: 2 additions & 9 deletions examples/create-react-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@ yarn-error.log*

.next
.cache

# yarn v3
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn

# Swap the comments on the following lines if you wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
# !.yarn/cache
.pnp.*
.pnp.*
11 changes: 2 additions & 9 deletions examples/gatsby/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@ yarn-error.log*

.next
.cache

# yarn v3
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn

# Swap the comments on the following lines if you wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
# !.yarn/cache
.pnp.*
.pnp.*
11 changes: 2 additions & 9 deletions examples/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@ yarn-error.log*

.next
.cache

# yarn v3
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn

# Swap the comments on the following lines if you wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
# !.yarn/cache
.pnp.*
.pnp.*
7 changes: 1 addition & 6 deletions examples/nextjs14/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ yarn-error.log*
next-env.d.ts

# yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn
File renamed without changes.
41 changes: 41 additions & 0 deletions examples/nextjs14/app/components/WidgetEvents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use client';
import type { Route } from '@lifi/sdk';
import type {
RouteExecutionUpdate,
RouteHighValueLossUpdate,
} from '@lifi/widget';
import { WidgetEvent, useWidgetEvents } from '@lifi/widget';
import { useEffect } from 'react';

export const WidgetEvents = () => {
const widgetEvents = useWidgetEvents();

useEffect(() => {
const onRouteExecutionStarted = (route: Route) => {
console.log('onRouteExecutionStarted fired.');
};
const onRouteExecutionUpdated = (update: RouteExecutionUpdate) => {
console.log('onRouteExecutionUpdated fired.');
};
const onRouteExecutionCompleted = (route: Route) => {
console.log('onRouteExecutionCompleted fired.');
};
const onRouteExecutionFailed = (update: RouteExecutionUpdate) => {
console.log('onRouteExecutionFailed fired.');
};
const onRouteHighValueLoss = (update: RouteHighValueLossUpdate) => {
console.log('onRouteHighValueLoss continued.');
};
widgetEvents.on(WidgetEvent.RouteExecutionStarted, onRouteExecutionStarted);
widgetEvents.on(WidgetEvent.RouteExecutionUpdated, onRouteExecutionUpdated);
widgetEvents.on(
WidgetEvent.RouteExecutionCompleted,
onRouteExecutionCompleted,
);
widgetEvents.on(WidgetEvent.RouteHighValueLoss, onRouteHighValueLoss);
widgetEvents.on(WidgetEvent.RouteExecutionFailed, onRouteExecutionFailed);
return () => widgetEvents.all.clear();
}, [widgetEvents]);

return null;
};
4 changes: 3 additions & 1 deletion examples/nextjs14/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Widget } from './widget';
import { Widget } from './components/Widget';
import { WidgetEvents } from './components/WidgetEvents';

export default function Home() {
return (
<main>
<WidgetEvents />
<Widget />
</main>
);
Expand Down
13 changes: 7 additions & 6 deletions examples/nextjs14/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
"lint": "next lint"
},
"dependencies": {
"@lifi/widget": "^3.0.0-alpha.15",
"next": "14.0.4",
"@lifi/sdk": "^3.0.0-alpha.54",
"@lifi/widget": "^3.0.0-alpha.26",
"next": "14.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^20.11.4",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@types/node": "^20.11.17",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"eslint": "^8.56.0",
"eslint-config-next": "14.0.4",
"eslint-config-next": "14.1.0",
"typescript": "^5.3.3"
}
}
Loading

0 comments on commit c55bfe6

Please sign in to comment.