Skip to content

Update dependencies #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .eslintrc.cjs

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
singleQuote: true,
jsxSingleQuote: true,
trailingComma: 'none',
semi: false,
printWidth: 100
}
4 changes: 2 additions & 2 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
extends: ['@codingame/commitlint-config-codingame']
};
extends: ['@codingame/commitlint-config-codingame']
}
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import eslint from '@eslint/js'
import tsEslint from 'typescript-eslint'
import eslintPluginReact from 'eslint-plugin-react'
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import globals from 'globals'

export default tsEslint.config(
eslint.configs.recommended,
tsEslint.configs.recommended,
eslintPluginReact.configs.flat.recommended,
eslintPluginReact.configs.flat?.['jsx-runtime'],
{
rules: { '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }] },
languageOptions: {
globals: {
...globals.browser
}
}
},

// TODO: Simplify when https://github.com/facebook/react/issues/28313 is resolved
{
plugins: {
'react-hooks': eslintPluginReactHooks
},
rules: { ...eslintPluginReactHooks.configs.recommended.rules }
}
)
13,493 changes: 7,089 additions & 6,404 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 13 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build": "npm run lint && npm run compile",
"compile": "tsc -p ./tsconfig.build.json",
"lint": "eslint --ext .ts --ext .tsx src"
"lint": "eslint 'src/**/*.ts' && prettier --check '**/*.{js,ts}'"
},
"repository": {
"type": "git",
Expand All @@ -23,38 +23,26 @@
],
"types": "dist/index.d.ts",
"dependencies": {
"@codingame/monaco-languageclient-wrapper": "^9.0.0",
"@codingame/monaco-languageclient-wrapper": "^10.0.0",
"@rehooks/local-storage": "^2.4.5",
"react": ">=18.3.1",
"uuid": "^10.0.0"
"uuid": "^11.0.5"
},
"devDependencies": {
"@codingame/commitlint-config-codingame": "^1.1.1",
"@codingame/eslint-config": "^1.1.10",
"@codingame/eslint-config-react": "^1.0.2",
"@codingame/semantic-release-config-github": "^1.0.0",
"@codingame/semantic-release-config-github": "^2.0.0",
"@codingame/tsconfig": "^1.1.1",
"@commitlint/cli": "^19.4.0",
"@commitlint/cli": "^19.7.1",
"@types/deep-equal": "^1.0.4",
"@types/react": "18.3.4",
"@types/react": "19.0.8",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"babel-eslint": "10.1.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"eslint": "8.57.0",
"eslint-config-standard": "17.1.0",
"eslint-config-standard-jsx": "11.0.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.2.0",
"eslint-plugin-react": "7.34.3",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-unused-imports": "3.2.0",
"typescript": "5.5.4"
},
"overrides": {
"@typescript-eslint/eslint-plugin": "$@typescript-eslint/eslint-plugin"
"conventional-changelog-conventionalcommits": "^8.0.0",
"eslint": "9.19.0",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.1.0",
"typescript": "5.7.3",
"typescript-eslint": "^8.23.0",
"prettier": "^3.4.2"
},
"volta": {
"node": "20.10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/LanguageClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function LanguageClient ({
const onDidChangeStatus = useLastVersion(_onDidChangeStatus ?? noop)
const onWillShutdown = useLastVersion(_onWillShutdown ?? noop)

const languageClientRef = useRef<LanguageClientManager>()
const languageClientRef = useRef<LanguageClientManager>(undefined)

const [willShutdown, setWillShutdown] = useState(false)
const [counter, setCounter] = useState(1)
Expand Down
39 changes: 22 additions & 17 deletions src/hooks/useIsUserActive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ if (typeof document.hidden !== 'undefined') {
const prefixes = ['webkit', 'moz', 'ms']
for (let i = 0; i < prefixes.length; i++) {
const prefix = prefixes[i]
if (typeof (document as unknown as Record<string, unknown>)[`${prefix}Hidden`] !== 'undefined') {
if (
typeof (document as unknown as Record<string, unknown>)[`${prefix}Hidden`] !== 'undefined'
) {
hidden = `${prefix}Hidden` as 'hidden'
visibilityChangeEvent = `${prefix}visibilitychange` as 'visibilitychange'
break
Expand Down Expand Up @@ -62,7 +64,7 @@ interface ActivityDetectorParams {
initialState?: State
autoInit?: boolean
}
function createActivityDetector ({
function createActivityDetector({
activityEvents = DEFAULT_ACTIVITY_EVENTS,
inactivityEvents = DEFAULT_INACTIVITY_EVENTS,
ignoredEventsWhenIdle = DEFAULT_IGNORED_EVENTS_WHEN_IDLE,
Expand All @@ -81,7 +83,7 @@ function createActivityDetector ({
}
if (state !== newState) {
state = newState
listeners[state].forEach(l => l())
listeners[state].forEach((l) => l())
}
}

Expand All @@ -104,21 +106,22 @@ function createActivityDetector ({
*/
const init = (firstState = DEFAULT_INITIAL_STATE) => {
setState(firstState === State.active ? State.active : State.idle)
activityEvents.forEach(eventName =>
window.addEventListener(eventName, handleUserActivityEvent))
activityEvents.forEach((eventName) =>
window.addEventListener(eventName, handleUserActivityEvent)
)

inactivityEvents.filter(eventName => eventName !== 'visibilitychange')
.forEach(eventName =>
window.addEventListener(eventName, handleUserInactivityEvent))
inactivityEvents
.filter((eventName) => eventName !== 'visibilitychange')
.forEach((eventName) => window.addEventListener(eventName, handleUserInactivityEvent))

if (inactivityEvents.indexOf('visibilitychange') >= 0 && visibilityChangeEvent != null) {
document.addEventListener(visibilityChangeEvent, handleVisibilityChangeEvent)
}
}

/**
* Register an event listener for the required event
*/
* Register an event listener for the required event
*/
const on = (eventName: State, listener: () => void) => {
listeners[eventName].push(listener)
const off = () => {
Expand All @@ -131,19 +134,21 @@ function createActivityDetector ({
}

/**
* Stops the activity detector and clean the listeners
*/
* Stops the activity detector and clean the listeners
*/
const stop = () => {
listeners[State.active] = []
listeners[State.idle] = []

clearTimeout(timer)

activityEvents.forEach(eventName =>
window.removeEventListener(eventName, handleUserActivityEvent))
activityEvents.forEach((eventName) =>
window.removeEventListener(eventName, handleUserActivityEvent)
)

inactivityEvents.forEach(eventName =>
window.removeEventListener(eventName, handleUserInactivityEvent))
inactivityEvents.forEach((eventName) =>
window.removeEventListener(eventName, handleUserInactivityEvent)
)

if (visibilityChangeEvent != null) {
document.removeEventListener(visibilityChangeEvent, handleVisibilityChangeEvent)
Expand All @@ -157,7 +162,7 @@ function createActivityDetector ({
return { on, stop, init }
}

export default function useIsUserActive (timeToIdle: number): boolean {
export default function useIsUserActive(timeToIdle: number): boolean {
const [active, setActive] = useState(true)
useEffect(() => {
const activityDetector = createActivityDetector({
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useLastVersion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef } from 'react'

export function useLastVersion<P extends unknown[], R> (func: (...args: P) => R): (...args: P) => R {
export function useLastVersion<P extends unknown[], R>(func: (...args: P) => R): (...args: P) => R {
const ref = useRef<(...args: P) => R>(func)
useEffect(() => {
ref.current = func
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useShouldShutdownLanguageClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useEffect, useState } from 'react'

export default function useShouldShutdownLanguageClient (userActive: boolean, delay: number): boolean {
export default function useShouldShutdownLanguageClient(
userActive: boolean,
delay: number
): boolean {
const [paused, setPaused] = useState(false)
useEffect(() => {
setPaused(false)
Expand Down
15 changes: 9 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { CodinGameInfrastructure, Infrastructure, LanguageClientId, loadExtensionConfigurations, registerLanguageClient, WorkspaceFolder } from '@codingame/monaco-languageclient-wrapper'
import {
CodinGameInfrastructure,
Infrastructure,
LanguageClientId,
loadExtensionConfigurations,
registerLanguageClient,
WorkspaceFolder
} from '@codingame/monaco-languageclient-wrapper'
import LanguageClient, { LanguageClientProps, StatusChangeEvent } from './LanguageClient.js'

export default LanguageClient
export {
loadExtensionConfigurations,
registerLanguageClient,
CodinGameInfrastructure
}
export { loadExtensionConfigurations, registerLanguageClient, CodinGameInfrastructure }
export type {
LanguageClientProps,
LanguageClientId,
Expand Down
2 changes: 1 addition & 1 deletion src/types/activity-detector.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare module 'activity-detector' {
class ActivityDetector {
public on (event: 'idle' | 'active', cb: () => void)
public on(event: 'idle' | 'active', cb: () => void)
public init(): void
public stop(): void
}
Expand Down
Loading