@nextcloud/typings
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -5,2 +5,12 @@ # Changelog | ||
## 1.7.0 - 2023-06-13 | ||
### Added | ||
- Added typings for `OC.Util` (all versions) | ||
- Added typings for `OCP.Accessibility` (Nextcloud 25+) | ||
- Added namespace for Nextcloud 26 | ||
- Added namespace for Nextcloud 27 | ||
- Including typings for new `OCP.Files.Router` API | ||
### Changed | ||
- Dependency updates | ||
## 1.6.0 - 2023-01-06 | ||
@@ -7,0 +17,0 @@ ### Added |
@@ -139,2 +139,107 @@ /// <reference types="jquery" /> | ||
interface UtilHistory { | ||
/** | ||
* Push the current URL parameters to the history stack | ||
* and change the visible URL. | ||
* | ||
* @param params to append to the URL | ||
* @param url URL to be used, otherwise the current URL will be used, using the params as query string | ||
*/ | ||
pushState(params: Record<string, string> | string, url?: string): void; | ||
/** | ||
* Replace the current URL parameters on the history stack | ||
* and change the visible URL. | ||
* | ||
* @param {object | string} params to append to the URL | ||
* @param url URL to be used | ||
*/ | ||
replaceState(params: Record<string, string> | string, url: string): void; | ||
/** | ||
* Add a popstate handler | ||
* | ||
* @param handler The handler | ||
*/ | ||
addOnPopStateHandler(handler: Function): void; | ||
/** | ||
* Parse the query/search part of the URL. | ||
* | ||
* @return map of parameters | ||
*/ | ||
parseUrlQuery(): Record<string, string>; | ||
} | ||
interface Util { | ||
History: UtilHistory, | ||
/** | ||
* Make a human file size (2048 to 2 kB) | ||
* @param size File size in bytes | ||
* @return A human readable file size | ||
*/ | ||
humanFileSize(size: number, skipSmallSizes: boolean): string, | ||
/** | ||
* Returns a file size in bytes from a humanly readable string | ||
* Like 2kB to 2048. | ||
* | ||
* @param string file size in human readable format | ||
* @return Number of bytes or Null if string could not be parsed | ||
*/ | ||
computerFileSize(string: string): null|number; | ||
formatDate(timestamp: string, format: string): string; | ||
/** | ||
* Human readable difference from now | ||
*/ | ||
relativeModifiedDate(timestamp: string): string; | ||
/** | ||
* Returns whether this is IE | ||
*/ | ||
isIE(): boolean; | ||
/** | ||
* Returns the width of a generic browser scrollbar | ||
* | ||
* @return width of scrollbar | ||
*/ | ||
getScrollBarWidth(): number; | ||
/** | ||
* Remove the time component from a given date | ||
* | ||
* @param date Given date | ||
* @return {Date} Date with stripped time | ||
*/ | ||
stripTime(date: Date): Date; | ||
/** | ||
* Compare two strings to provide a natural sort | ||
* @param a first string to compare | ||
* @param b second string to compare | ||
* @return negative if b comes before a, positive if a comes before b | ||
* or 0 if the strings are identical | ||
*/ | ||
naturalSortCompare(a: string, b: string): number; | ||
/** | ||
* Calls the callback in a given interval until it returns true | ||
* @param callback The callback function | ||
* @param interval in milliseconds | ||
*/ | ||
waitFor(callback: Function, interval: number): void; | ||
/** | ||
* Checks if a cookie with the given name is present and is set to the provided value. | ||
* @param name name of the cookie | ||
* @param value value of the cookie | ||
* @return true if the cookie with the given name has the given value | ||
*/ | ||
isCookieSetToValue(name: string, value: string): boolean; | ||
} | ||
interface OC { | ||
@@ -171,2 +276,3 @@ appswebroots: any | ||
Plugins: Plugins; | ||
Util: Util; | ||
@@ -184,5 +290,4 @@ webroot: string | ||
interface humanFileSize { | ||
(size: number, skipSmallSizes: boolean): string; | ||
} | ||
// global scope until v18 | ||
type humanFileSize = Util["humanFileSize"]; | ||
@@ -189,0 +294,0 @@ interface DayMonthConstants { |
@@ -11,1 +11,3 @@ /// <reference path="v16/OC.d.ts" /> | ||
/// <reference path="v25/OC.d.ts" /> | ||
/// <reference path="v26/OC.d.ts" /> | ||
/// <reference path="v27/OC.d.ts" /> |
@@ -9,3 +9,3 @@ declare namespace Nextcloud.v24 { | ||
type OC = Nextcloud.v23.OC & { | ||
type OC = Omit<Nextcloud.v23.OC, 'Util'> & { | ||
dialogs: { | ||
@@ -23,2 +23,5 @@ filepicker( | ||
} | ||
// OC.Util.isIE was dropped | ||
Util: Omit<Nextcloud.v23.OC["Util"], 'isIE'>; | ||
} | ||
@@ -25,0 +28,0 @@ |
declare namespace Nextcloud.v25 { | ||
type FilePickerFilter = Nextcloud.v24.FilePickerFilter | ||
interface FilePickerOptions extends Nextcloud.v24.FilePickerOptions { | ||
interface Accessibility { | ||
/** Whether the user opted-out of shortcuts so that they should not be registered */ | ||
disableKeyboardShortcuts(): boolean | ||
} | ||
@@ -14,3 +13,3 @@ | ||
interface OCP extends Nextcloud.v24.OCP { | ||
Accessibility: Accessibility | ||
} | ||
@@ -17,0 +16,0 @@ |
{ | ||
"name": "@nextcloud/typings", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Nextcloud TypeScript typings", | ||
@@ -33,8 +33,10 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/jquery": "2.0.60" | ||
"@types/jquery": "3.5.16", | ||
"vue": "^2.7.14", | ||
"vue-router": "<4" | ||
}, | ||
"devDependencies": { | ||
"babel-jest": "^27.0.5", | ||
"jest": "^28.1.0", | ||
"typescript": "^4.0.2" | ||
"babel-jest": "^29.5.0", | ||
"jest": "^29.5.0", | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -41,0 +43,0 @@ "engines": { |
# @nextcloud/typings | ||
[![NPM package](https://img.shields.io/npm/v/@nextcloud/typings?style=for-the-badge)](https://www.npmjs.com/package/@nextcloud/typings) | ||
[![License](https://img.shields.io/npm/l/@nextcloud/typings?color=green&style=for-the-badge)](https://github.com/nextcloud/nextcloud-typings/blob/master/LICENSE) | ||
[![Open issues](https://img.shields.io/github/issues-raw/nextcloud/nextcloud-typings?style=for-the-badge)](https://github.com/nextcloud/nextcloud-typings/issues) | ||
[![Build Status](https://travis-ci.com/nextcloud/nextcloud-typings.svg?branch=master)](https://travis-ci.com/nextcloud/nextcloud-typings) | ||
Versioned typings for the (internal) JavaScript APIs of Nextcloud used in higher level packages. | ||
## Installation | ||
```sh | ||
npm i -S @nextcloud/typings | ||
``` | ||
The typings have to be in the ``dependencies`` section, not ``devDependencies``. See https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#dependencies for details. | ||
## Usage | ||
@@ -14,3 +23,3 @@ | ||
declare var OC: Nextcloud.v22.OC | Nextcloud.v23.OC | Nextcloud.v24.OC; | ||
declare var OC: Nextcloud.v25.OC | Nextcloud.v26.OC | Nextcloud.v27.OC; | ||
@@ -17,0 +26,0 @@ OC.L10N.translate("app", "text") |
@@ -13,6 +13,10 @@ { | ||
}, | ||
"include": [ | ||
"lib" | ||
], | ||
"exclude": [ | ||
"dist", | ||
"node_modules", | ||
"dist" | ||
"test" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
61425
28
502
29
3
+ Addedvue@^2.7.14
+ Addedvue-router@<4
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Added@types/jquery@3.5.16(transitive)
+ Added@types/sizzle@2.3.9(transitive)
+ Added@vue/compiler-sfc@2.7.16(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addednanoid@3.3.8(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.4.49(transitive)
+ Addedprettier@2.8.8(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-js@1.2.1(transitive)
+ Addedvue@2.7.16(transitive)
+ Addedvue-router@3.6.5(transitive)
- Removed@types/jquery@2.0.60(transitive)
Updated@types/jquery@3.5.16