Skip to content

Commit

Permalink
feat: update to pion
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Upgrade to @pionjs/pion
  • Loading branch information
megheaiulian committed Jan 11, 2024
1 parent 6f56e7b commit a9b4e40
Show file tree
Hide file tree
Showing 15 changed files with 2,092 additions and 1,968 deletions.
4,015 changes: 2,070 additions & 1,945 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@
"./use-hash-param": "./dist/use-hash-param.js"
},
"dependencies": {
"haunted": "^5.0.0",
"lit-html": "^2.0.0"
"@pionjs/pion": "^2.0.0"
},
"devDependencies": {
"@commitlint/cli": "^18.0.0",
"@commitlint/config-conventional": "^18.0.0",
"@neovici/cfg": "^1.15.0",
"@open-wc/testing": "^3.1.0",
"@open-wc/testing": "^4.0.0",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/git": "^10.0.0",
"@types/mocha": "^10.0.3",
"@web/dev-server": "^0.4.0",
"@web/dev-server-storybook": "^1.0.0",
"@web/dev-server-storybook": "^2.0.0",
"@web/test-runner": "^0.18.0",
"husky": "^8.0.0",
"semantic-release": "^22.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/load.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html as htm } from 'haunted';
import { html as htm } from '@pionjs/pion';
import { RuleRet, BaseRoute } from './match';

const html: typeof htm = (arr, ...thru) =>
Expand Down
2 changes: 1 addition & 1 deletion src/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { nothing } from 'lit-html';

Check warning on line 1 in src/router.ts

View workflow job for this annotation

GitHub Actions / build / build

'lit-html' should be listed in the project's dependencies. Run 'npm i -S lit-html' to add it
import { guard } from 'lit-html/directives/guard.js';

Check warning on line 2 in src/router.ts

View workflow job for this annotation

GitHub Actions / build / build

'lit-html' should be listed in the project's dependencies. Run 'npm i -S lit-html' to add it
import { until } from 'lit-html/directives/until.js';

Check warning on line 3 in src/router.ts

View workflow job for this annotation

GitHub Actions / build / build

'lit-html' should be listed in the project's dependencies. Run 'npm i -S lit-html' to add it
import { component } from 'haunted';
import { component } from '@pionjs/pion';

import { useRouter, Route } from './use-router';
import { useRouteEvents } from './use-route-events';
Expand Down
2 changes: 1 addition & 1 deletion src/use-hash-param.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useMemo, useRef } from 'haunted';
import { useState, useEffect, useMemo, useRef } from '@pionjs/pion';

const hashUrl = () =>
new URL(
Expand Down
2 changes: 1 addition & 1 deletion src/use-route-events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'haunted';
import { useEffect } from '@pionjs/pion';
import type { BaseRoute } from './match';

const dispatch = (el: HTMLElement, type: string, opts?: object) =>
Expand Down
2 changes: 1 addition & 1 deletion src/use-router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'haunted';
import { useMemo } from '@pionjs/pion';

import { useRoutes } from './use-routes';
import type { BaseRoute } from './match';
Expand Down
2 changes: 1 addition & 1 deletion src/use-routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useMemo } from 'haunted';
import { useState, useEffect, useMemo } from '@pionjs/pion';
import { match, BaseRoute } from './match';

export const documentUrl = () =>
Expand Down
2 changes: 1 addition & 1 deletion stories/cosmoz-router.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, component } from 'haunted';
import { html, component } from '@pionjs/pion';
import { hashbang, createElement } from '../src/index.ts';

export default {
Expand Down
2 changes: 1 addition & 1 deletion stories/views/home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, component } from 'haunted';
import { html, component } from '@pionjs/pion';

customElements.define(
'demo-home',
Expand Down
2 changes: 1 addition & 1 deletion stories/views/param-reading-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, component } from 'haunted';
import { html, component } from '@pionjs/pion';

customElements.define(
'param-reading-view',
Expand Down
2 changes: 1 addition & 1 deletion stories/views/view-1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, component, useState, useEffect } from 'haunted';
import { html, component, useState, useEffect } from '@pionjs/pion';

customElements.define(
'view-1',
Expand Down
2 changes: 1 addition & 1 deletion stories/views/view-2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, component, useState, useEffect } from 'haunted';
import { html, component, useState, useEffect } from '@pionjs/pion';

customElements.define(
'view-2',
Expand Down
2 changes: 1 addition & 1 deletion stories/views/view-3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, component, useState, useEffect } from 'haunted';
import { html, component, useState, useEffect } from '@pionjs/pion';

customElements.define(
'view-3',
Expand Down
14 changes: 7 additions & 7 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,51 +53,51 @@ suite('cosmoz-router', () => {
test('renders home', async () => {
navigate('/');
const router = fixtureSync(html`<cosmoz-router .routes=${routes} />`);
await oneEvent(router, 'route-loaded');
await oneEvent(router, 'route-loaded', false);
await nextFrame();
assert.shadowDom.equal(router, '<demo-home></demo-home>');
});

test('renders view-1', async () => {
navigate('#!/view-1');
const router = fixtureSync(html`<cosmoz-router .routes=${routes} />`);
await oneEvent(router, 'route-loaded');
await oneEvent(router, 'route-loaded', false);
await nextFrame();
assert.shadowDom.equal(router, '<view-1></view-1>');
});

test('renders not-found', async () => {
navigate('#/not-found');
const router = fixtureSync(html`<cosmoz-router .routes=${routes} />`);
await oneEvent(router, 'route-not-found');
await oneEvent(router, 'route-not-found', false);
await nextFrame();
assert.shadowDom.equal(router, '');
});

test('renders home, then view-1', async () => {
navigate('/');
const router = fixtureSync(html`<cosmoz-router .routes=${routes} />`);
await oneEvent(router, 'route-loaded');
await oneEvent(router, 'route-loaded', false);
await nextFrame();
assert.shadowDom.equal(router, '<demo-home></demo-home>');

navigate('#!/view-1');
await oneEvent(router, 'route-loaded');
await oneEvent(router, 'route-loaded', false);
await nextFrame();
assert.shadowDom.equal(router, '<view-1></view-1>');
});

test('error', async () => {
navigate('#!/error');
const router = fixtureSync(html`<cosmoz-router .routes=${routes} />`),
{ detail } = await oneEvent(router, 'route-error');
{ detail } = await oneEvent(router, 'route-error', false);
assert.equal(detail.error.message, 'testing');
});

test('params', async () => {
navigate('#!/param-reading-view?p1=1&p2=2');
const router = fixtureSync(html`<cosmoz-router .routes=${routes} />`);
await oneEvent(router, 'route-loaded');
await oneEvent(router, 'route-loaded', false);
await nextFrame();
assert.shadowDom.equal(
router.shadowRoot?.querySelector('param-reading-view'),
Expand Down

0 comments on commit a9b4e40

Please sign in to comment.