Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarlow committed Apr 22, 2022
0 parents commit 85afaf9
Show file tree
Hide file tree
Showing 5 changed files with 399 additions and 0 deletions.
183 changes: 183 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@

# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,linux,visualstudiocode,jetbrains+all
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,linux,visualstudiocode,jetbrains+all

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### JetBrains+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,visualstudiocode,jetbrains+all
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) 2022 Luke Warlow

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.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Navigation API Types

[![npm](https://img.shields.io/npm/v/navigation-api-types.svg?style=flat-square)](https://www.npmjs.com/package/navigation-api-types)

Type definition for [`Navigation API`](https://github.com/WICG/navigation-api)

### Install

```shell
$ npm i -D navigation-api-types
```

### tsconfig.json

`navigation-api-types` needs to be added to `types` because it uses _ambient_ types that modify the global types.

```json
{
"compilerOptions": {
"types": [
"./node_modules/navigation-api-types"
]
}
}
```

## License

This project is licensed under the [MIT License](https://github.com/lukewarlow/navigation-api-types/blob/master/LICENSE).
149 changes: 149 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// WICG Spec: https://github.com/WICG/navigation-api

// https://wicg.github.io/navigation-api/#navigation
interface Navigation {
entries(): NavigationHistoryEntry[];
readonly currentEntry?: NavigationHistoryEntry;
updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void;
readonly transition?: NavigationTransition;

readonly canGoBack: boolean;
readonly canGoForward: boolean;

navigate(url: string, options?: NavigationNavigateOptions): NavigationResult;
reload(options?: NavigationReloadOptions): NavigationResult;

traverseTo(key: string, options?: NavigationOptions): NavigationResult;
back(options?: NavigationOptions): NavigationResult;
forward(options?: NavigationOptions): NavigationResult;

onnavigate: ((this: Navigation, ev: Event) => any) | null;
onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null;
onnavigateerror: ((this: Navigation, ev: Event) => any) | null;
oncurrententrychange: ((this: Navigation, ev: Event) => any) | null;
}

// https://wicg.github.io/navigation-api/#global
declare const navigation: Navigation | undefined;

declare interface Window extends WindowNavigation {}

// https://wicg.github.io/navigation-api/#global
declare interface WindowNavigation {
readonly navigation?: Navigation;
}

// https://wicg.github.io/navigation-api/#navigateevent
interface NavigationEvent extends Event {
readonly navigationType: NavigationApiNavigationType;
readonly destination: NavigationDestination;
readonly canTransition: boolean;
readonly userInitiated: boolean;
readonly hashChange: boolean;
readonly signal: AbortSignal;
readonly formData?: FormData;
readonly downloadRequest?: string;
readonly info: any;

transitionWhile(newNavigationAction: Promise<void>, options?: NavigationTransitionWhileOptions): void;
restoreScroll(): void;
}

declare var NavigationEvent: {
prototype: NavigationEvent;
new(type: string, eventInit: NavigateEventInit): Event;
readonly AT_TARGET: number;
readonly BUBBLING_PHASE: number;
readonly CAPTURING_PHASE: number;
readonly NONE: number;
};

// https://wicg.github.io/navigation-api/#dictdef-navigateeventinit
interface NavigateEventInit extends EventInit {
navigationType?: NavigationType;
destination: NavigationDestination;
canTransition?: boolean;
userInitiated?: boolean;
hashChange?: boolean;
signal: AbortSignal;
formData?: FormData | null;
downloadRequest?: string | null;
info?: any;
}

// https://wicg.github.io/navigation-api/#navigationhistoryentry
interface NavigationHistoryEntry extends EventTarget {
readonly url?: string;
readonly key: string;
readonly id: string;
readonly index: number;
readonly sameDocument: boolean;

getState(): any;

ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
}

// https://wicg.github.io/navigation-api/#navigationdestination
interface NavigationDestination {
readonly url: string;
readonly key?: string;
readonly id?: string;
readonly index: number;
readonly sameDocument: boolean;

getState(): any;
}

// https://wicg.github.io/navigation-api/#dictdef-navigationupdatecurrententryoptions
interface NavigationUpdateCurrentEntryOptions {
state: any;
}

// https://wicg.github.io/navigation-api/#dictdef-navigationoptions
interface NavigationOptions {
info: any;
}

// https://wicg.github.io/navigation-api/#dictdef-navigationnavigateoptions
interface NavigationNavigateOptions extends NavigationOptions {
state: any;
// Always "auto"
history: NavigationHistoryBehavior;
}

// https://wicg.github.io/navigation-api/#dictdef-navigationreloadoptions
interface NavigationReloadOptions extends NavigationOptions {
state: any;
}

// https://wicg.github.io/navigation-api/#navigationtransition
interface NavigationTransition {
readonly navigationType: NavigationApiNavigationType;
readonly from: NavigationHistoryEntry;
readonly finished: Promise<void>;
}

// https://wicg.github.io/navigation-api/#dictdef-navigationresult
interface NavigationResult {
committed: Promise<NavigationHistoryEntry>;
finished: Promise<NavigationHistoryEntry>;
}

// https://wicg.github.io/navigation-api/#dictdef-navigationtransitionwhileoptions
interface NavigationTransitionWhileOptions {
focusReset: NavigationFocusReset;
scrollRestoration: NavigationScrollRestoration;
}

// https://wicg.github.io/navigation-api/#enumdef-navigationtype
type NavigationApiNavigationType = "reload" | "push" | "replace" | "traverse";

// https://wicg.github.io/navigation-api/#enumdef-navigationhistorybehavior
type NavigationHistoryBehavior = "auto" | "push" | "replace";

// https://wicg.github.io/navigation-api/#enumdef-navigationfocusreset
type NavigationFocusReset = "after-transition" | "manual";

// https://wicg.github.io/navigation-api/#enumdef-navigationscrollrestoration
type NavigationScrollRestoration = "after-transition" | "manual";
Loading

0 comments on commit 85afaf9

Please sign in to comment.