Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
daun committed Jul 14, 2024
0 parents commit 0211cbb
Show file tree
Hide file tree
Showing 13 changed files with 11,742 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: E2E tests

on:
push:
branches: [main, master, next]
pull_request:
workflow_dispatch:

jobs:
run-tests:
name: E2E tests
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm ci

- name: Bundle library
run: npm run build

- name: Install browsers
run: npx playwright install --with-deps

- name: Run tests
run: npx playwright test --config ./tests/config/playwright.config.ts

- name: Create report comment
uses: daun/playwright-report-summary@v2
if: always()
with:
report-file: playwright-results.json
21 changes: 21 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow publishes a package to NPM

name: Publish package

on:
release:
types: [published]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
9 changes: 9 additions & 0 deletions .github/workflows/redeploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Redeploy Docs
on:
push:
branches: [master]

jobs:
redeploy-docs:
uses: swup/.github/.github/workflows/redeploy-docs.yml@master
secrets: inherit
28 changes: 28 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Unit tests

on:
push:
branches: [main, master, next]
pull_request:
workflow_dispatch:

jobs:
run-tests:
name: Run unit tests
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18

- run: npm ci
- run: npm run build

- name: Run tests
run: npm run test:unit
35 changes: 35 additions & 0 deletions .github/workflows/version-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow bumps the package.json version and creates a PR

name: Update package version

on:
workflow_dispatch:
inputs:
segment:
description: 'Semver segment to update'
required: true
default: 'patch'
type: choice
options:
- minor
- patch

jobs:
update-version:
name: Update package version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: echo "Updating ${{ inputs.segment }} version"
- name: Update version
run: npm --no-git-tag-version version ${{ inputs.segment }}
- uses: peter-evans/create-pull-request@v4
with:
base: 'master'
branch: 'version/automated'
title: 'Update package version (automated)'
commit-message: 'Update package version'
body: 'Automated update to ${{ inputs.segment }} version'
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DS_Store
*.DS_Store
!.gitignore
!.htaccess
!web.config
node_modules
bower_components
Thumbs.db
wiki-common
wiki-images files
wiki-wishlist
*.sublime-project
*.sublime-workspace
.editorconfig
.idea
/dist
/tests/fixtures/dist
/tests/reports
/tests/results
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Georgy Marchuk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Swup Offline Plugin

A [swup](https://swup.js.org) plugin for making content available offline.

- Preload pages for offline access
- Prevent new network requests while offline
- Display a notification when network status changes

## Installation

Install the plugin from npm and import it into your bundle.

```bash
npm install @swup/offline-plugin
```

```js
import SwupOfflinePlugin from '@swup/offline-plugin';
```

Or include the minified production file from a CDN:

```html
<script src="https://unpkg.com/@swup/offline-plugin@1"></script>
```

## Usage

To run this plugin, include an instance in the swup options.

```javascript
const swup = new Swup({
plugins: [new SwupOfflinePlugin()]
});
```

## Offline Content

Lorem ipsum dolor sit amet.

## Options

Lorem ipsum dolor sit amet.

## Hooks

The plugin creates two new hooks.

> **Note** The visit object might be `undefined` or already settled for these hooks
### network:offline

Fires when the user's device goes offline.

```js
swup.hooks.on('network:offline', () => showOfflineBanner());
```

### network:online

Fires when the user's device goes online again.

```js
swup.hooks.on('network:online', () => hideOfflineBanner());
```
Loading

0 comments on commit 0211cbb

Please sign in to comment.