Skip to content

Commit

Permalink
fix: typings should now work properly (#140)
Browse files Browse the repository at this point in the history
* fix: typings now work properly

* fix typings in package.json

* fix typings
  • Loading branch information
KonnorRogers authored Oct 4, 2021
1 parent 301d3b0 commit b428d67
Show file tree
Hide file tree
Showing 31 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"require": "./plugins/dist/mrujs.js"
}
},
"types": "dist/index.d.ts",
"types": "dist/types.d.ts",
"repository": "[email protected]:ParamagicDev/mrujs.git",
"homepage": "https://mrujs.com",
"author": "ParamagicDev <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"module": "./dist/mrujs.module.js",
"umd:main": "./dist/mrujs.umd.js",
"license": "MIT",
"types": "./dist/types.d.ts",
"peerDependencies": {
"mrujs": ">= 0.4.6"
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Adapter, MrujsInterface } from '../../src/types'
import { Adapter, MrujsInterface } from '../../types'

declare global {
interface Window {
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/mrujsTurbo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MrujsPluginInterface } from '../../src/types'
import { MrujsPluginInterface } from '../../types'

export function MrujsTurbo (): MrujsPluginInterface {
return {
Expand Down
8 changes: 4 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { terser } from "rollup-plugin-terser";
import { brotliCompressSync } from 'zlib'
import gzipPlugin from 'rollup-plugin-gzip'

function basePlugins(tsconfig = "tsconfig.json") {
function basePlugins(tsconfig = "./tsconfig.json") {
return [
resolve(),
typescript({ tsconfig }),
]
}

function compressionPlugins(tsconfig = "tsconfig.json") {
function compressionPlugins(tsconfig = "./tsconfig.json") {
return [
...basePlugins(tsconfig),
terser({
Expand Down Expand Up @@ -69,7 +69,7 @@ export default [
sourcemap: true,
}
],
plugins: basePlugins("tsconfig-plugins.json")
plugins: basePlugins("./tsconfig-plugins.json")
},


Expand Down Expand Up @@ -109,6 +109,6 @@ export default [
sourcemap: true,
}
],
plugins: compressionPlugins("tsconfig-plugins.json")
plugins: compressionPlugins("./tsconfig-plugins.json")
},
]
2 changes: 1 addition & 1 deletion src/addedNodesObserver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MrujsPluginInterface } from './types'
import { MrujsPluginInterface } from '../types'

/**
* Mutation observer for added nodes.
Expand Down
2 changes: 1 addition & 1 deletion src/clickHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addListeners, attachObserverCallback, removeListeners } from './utils/dom'
import { preventInsignificantClick } from './utils/misc'
import { EventQueryInterface, MrujsPluginInterface } from './types'
import { EventQueryInterface, MrujsPluginInterface } from '../types'

export function ClickHandler (): MrujsPluginInterface {
const callbacks = [preventInsignificantClick] as EventListener[]
Expand Down
2 changes: 1 addition & 1 deletion src/confirm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dispatch, stopEverything } from './utils/events'
import { addListeners, removeListeners, attachObserverCallback } from './utils/dom'
import { EventQueryInterface, MrujsPluginInterface } from './types'
import { EventQueryInterface, MrujsPluginInterface } from '../types'

export function Confirm (): MrujsPluginInterface {
const callbacks = [handleConfirm] as EventListener[]
Expand Down
2 changes: 1 addition & 1 deletion src/csrf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/rails/rails/blob/main/actionview/app/assets/javascripts/rails-ujs/utils/csrf.coffee
import { getCookieValue, getMetaContent } from './utils/misc'
import { MrujsPluginInterface } from './types'
import { MrujsPluginInterface } from '../types'

export function Csrf (): MrujsPluginInterface {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/disabledElementChecker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MrujsPluginInterface, EventQueryInterface } from './types'
import { MrujsPluginInterface, EventQueryInterface } from '../types'
import { addListeners, removeListeners, attachObserverCallback } from './utils/dom'
import { stopEverything } from './utils/events'

Expand Down
2 changes: 1 addition & 1 deletion src/elementDisabler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MrujsPluginInterface, EventQueryInterface, Submitter } from './types'
import { MrujsPluginInterface, EventQueryInterface, Submitter } from '../types'
import { attachObserverCallback, addListeners, removeListeners, findFormElements, match } from './utils/dom'
import { stopEverything } from './utils/events'

Expand Down
2 changes: 1 addition & 1 deletion src/elementEnabler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { attachObserverCallback, match, addListeners, removeListeners, findFormElements } from './utils/dom'
import { stopEverything, AJAX_EVENTS } from './utils/events'
import { EventQueryInterface, MrujsPluginInterface } from './types'
import { EventQueryInterface, MrujsPluginInterface } from '../types'

export function ElementEnabler (): MrujsPluginInterface {
const callbacks = [enableElement] as EventListener[]
Expand Down
2 changes: 1 addition & 1 deletion src/formSubmission.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildFormElementFormData, formEnctypeFromString, FormEncType, FormEncTypes, urlEncodeFormData } from './utils/form'
import { findResponseTypeHeader } from './utils/headers'
import { FetchRequestInterface, Submitter } from './types'
import { FetchRequestInterface, Submitter } from '../types'
import { FetchRequest } from './http/fetchRequest'
import { isGetRequest, expandUrl } from './utils/url'

Expand Down
2 changes: 1 addition & 1 deletion src/formSubmitDispatcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AJAX_EVENTS, dispatch } from './utils/events'
import { findSubmitter, ExtendedSubmitEvent } from './submitFinder'
import { FetchResponse } from './http/fetchResponse'
import { MrujsPluginInterface, AddOrRemoveListeners, AjaxEventDetail } from './types'
import { MrujsPluginInterface, AddOrRemoveListeners, AjaxEventDetail } from '../types'
import { FormSubmission } from './formSubmission'
import { disableElement } from './elementDisabler'

Expand Down
2 changes: 1 addition & 1 deletion src/http/fetchRequest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AJAX_EVENTS, dispatch, stopEverything } from '../utils/events'
import { isGetRequest, mergeHeaders, expandUrl } from '../utils/url'
import { getToken } from '../csrf'
import { RequestInfo, FetchRequestBody, FetchRequestInterface, Locateable } from '../types'
import { RequestInfo, FetchRequestBody, FetchRequestInterface, Locateable } from '../../types'

/**
* Fetch Request is essentially an "proxy" class meant to wrap a standard Request
Expand Down
2 changes: 1 addition & 1 deletion src/http/fetchResponse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expandUrl } from '../utils/url'
import { FetchResponseInterface } from '../types'
import { FetchResponseInterface } from '../../types'

// Shamelessly stolen from Turbo.
// https://github.com/hotwired/turbo/blob/main/src/http/fetch_response.ts
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './polyfills'
import { Mrujs } from './mrujs'
import { FetchRequest } from './http/fetchRequest'
import { FetchResponse } from './http/fetchResponse'
import { Adapter, MrujsInterface } from './types'
import { Adapter, MrujsInterface } from '../types'

// This is required for typescript checking in tests
declare global {
Expand Down
2 changes: 1 addition & 1 deletion src/linkSubmission.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { urlEncodeFormData } from './utils/form'
import { findResponseTypeHeader } from './utils/headers'
import { FetchRequest } from './http/fetchRequest'
import { FetchRequestInterface } from './types'
import { FetchRequestInterface } from '../types'
import { isGetRequest } from './utils/url'

export interface LinkSubmissionInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/method.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AJAX_EVENTS, dispatch, stopEverything } from './utils/events'
import { MrujsPluginInterface } from './types'
import { MrujsPluginInterface } from '../types'
import { match } from './utils/dom'
import { LinkSubmission } from './linkSubmission'

Expand Down
2 changes: 1 addition & 1 deletion src/mrujs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
Locateable,
ExtendedRequestInit,
MrujsInterface
} from './types'
} from '../types'

export function Mrujs (obj: Partial<MrujsInterface> = {}): MrujsInterface {
obj.connected = false
Expand Down
2 changes: 1 addition & 1 deletion src/navigationAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Adapter, MrujsPluginInterface, SnapshotCacheInterface,
Locateable, FetchRequestInterface, FetchResponseInterface,
VisitAction
} from './types'
} from '../types'

const ALLOWABLE_ACTIONS = [
'advance',
Expand Down
2 changes: 1 addition & 1 deletion src/remoteWatcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MrujsPluginInterface } from './types'
import { MrujsPluginInterface } from '../types'
import { match } from './utils/dom'

export function RemoteWatcher (): MrujsPluginInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/submitFinder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Submitter } from './types'
import { Submitter } from '../types'

export interface ExtendedSubmitEvent extends CustomEvent {
submitter: Submitter
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is copied from:
// https://github.com/rails/rails/blob/main/actionview/app/assets/javascripts/rails-ujs/utils/dom.coffee
import { EventQueryInterface, QuerySelectorInterface, SelectorInterface } from '../types'
import { EventQueryInterface, QuerySelectorInterface, SelectorInterface } from '../../types'

const m =
Element.prototype.matches ??
Expand Down
2 changes: 1 addition & 1 deletion src/utils/form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Submitter } from '../types'
import { Submitter } from '../../types'

export function buildFormElementFormData (element: HTMLFormElement, submitter?: Submitter): FormData {
const formData = new FormData(element)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/headers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MimeTypeInterface } from '../types'
import { MimeTypeInterface } from '../../types'

export const BASE_ACCEPT_HEADERS: MimeTypeInterface = {
'*': '*/*',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Locateable } from '../types'
import { Locateable } from '../../types'

export function expandUrl (locateable: Locateable): URL {
if (urlExpanded(locateable)) {
Expand Down
2 changes: 1 addition & 1 deletion test/js/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This is a base test for the plugin interface.
import { MrujsPluginInterface } from '../../src/types'
import { MrujsPluginInterface } from '../../types'
import { assert } from '@esm-bundle/chai'
import { spy } from 'sinon'

Expand Down
2 changes: 1 addition & 1 deletion tsconfig-plugins.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./tsconfig.json",
"include": ["./plugins", "./src/types.ts"],
"include": ["./plugins", "./types.ts"],
"exclude": ["./plugins/dist"],
"compilerOptions": {
"outDir": "./plugins/dist"
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"include": ["./src"],
"include": ["./types.ts", "./src"],
"exclude": ["./dist"],
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"declarationMap": true,
"declarationDir": ".",
"esModuleInterop": true,
"importHelpers": true,
"experimentalDecorators": true,
Expand Down
File renamed without changes.

0 comments on commit b428d67

Please sign in to comment.