From c5bbd90cabb7d6668f297acd508a141aa7391321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Wed, 14 Jun 2023 10:58:09 +0200 Subject: [PATCH] fix: Do not export the declaration of window.OC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- __tests__/fileAction.spec.ts | 7 -- __tests__/humanFileSize.spec.ts | 6 - __tests__/index.spec.ts | 7 -- __tests__/newFileMenu.spec.ts | 7 -- jest.config.js | 12 +- lib/index.ts | 8 -- package-lock.json | 200 +++++++++++++++++++++++++++++--- package.json | 2 +- tsconfig.json | 2 +- window.d.ts | 14 +++ 10 files changed, 205 insertions(+), 60 deletions(-) create mode 100644 window.d.ts diff --git a/__tests__/fileAction.spec.ts b/__tests__/fileAction.spec.ts index 6aa925d4..87d85765 100644 --- a/__tests__/fileAction.spec.ts +++ b/__tests__/fileAction.spec.ts @@ -1,13 +1,6 @@ import { getFileActions, registerFileAction, FileAction } from '../lib/fileAction' import logger from '../lib/utils/logger'; -declare global { - interface Window { - OC: any; - _nc_fileactions: FileAction[] | undefined; - } -} - describe('FileActions init', () => { beforeEach(() => { diff --git a/__tests__/humanFileSize.spec.ts b/__tests__/humanFileSize.spec.ts index f9e6aaaa..05adadeb 100644 --- a/__tests__/humanFileSize.spec.ts +++ b/__tests__/humanFileSize.spec.ts @@ -1,11 +1,5 @@ import { formatFileSize } from '../lib/humanfilesize' -declare global { - interface Window { - OC: any; - } -} - describe('humanFileSize', () => { describe('formatFileSize', () => { it('renders file sizes with the correct unit', function() { diff --git a/__tests__/index.spec.ts b/__tests__/index.spec.ts index dd6f3765..0e91d876 100644 --- a/__tests__/index.spec.ts +++ b/__tests__/index.spec.ts @@ -18,13 +18,6 @@ import { FileType as FileTypeSource } from '../lib/files/fileType' import { Entry, NewFileMenu } from '../lib/newFileMenu'; import { FileAction, registerFileAction, getFileActions } from '../lib/fileAction' -declare global { - interface Window { - OC: any; - _nc_newfilemenu: NewFileMenu | undefined; - } -} - describe('Exports checks', () => { test('formatFileSize', () => { expect(formatFileSize).toBeTruthy() diff --git a/__tests__/newFileMenu.spec.ts b/__tests__/newFileMenu.spec.ts index 32246ecd..0fc3fd85 100644 --- a/__tests__/newFileMenu.spec.ts +++ b/__tests__/newFileMenu.spec.ts @@ -1,13 +1,6 @@ import { NewFileMenu, getNewFileMenu, type Entry } from '../lib/newFileMenu' import logger from '../lib/utils/logger'; -declare global { - interface Window { - OC: any; - _nc_newfilemenu: NewFileMenu | undefined; - } -} - describe('NewFileMenu init', () => { test('Initializing NewFileMenu', () => { logger.debug = jest.fn() diff --git a/jest.config.js b/jest.config.js index a42d0835..21d941bc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,12 +4,12 @@ module.exports = { coveragePathIgnorePatterns: ['lib/utils/logger.ts'], testEnvironment: 'jsdom', preset: 'ts-jest/presets/js-with-ts', - globals: { - 'ts-jest': { - tsconfig: '__tests__/tsconfig.json', - }, - }, transformIgnorePatterns: [ - 'node_modules/(?!(abcde|fghij)/)', + 'node_modules', ], + transform: { + '^.+\\.tsx?$': ['ts-jest', { + tsconfig: '__tests__/tsconfig.json', + }] + }, } diff --git a/lib/index.ts b/lib/index.ts index 0b1e2cc0..5c835975 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -33,14 +33,6 @@ export { Node } from './files/node' export { Permission, parseWebdavPermissions } from './permissions' export { FileAction, registerFileAction, getFileActions } from './fileAction' -declare global { - interface Window { - OC: any; - _nc_newfilemenu: NewFileMenu | undefined; - _nc_fileactions: FileAction[] | undefined; - } -} - /** * Add a new menu entry to the upload manager menu */ diff --git a/package-lock.json b/package-lock.json index 9362f94f..52000a7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@babel/core": "^7.18.5", "@babel/preset-env": "^7.18.2", "@babel/preset-typescript": "^7.17.12", - "@nextcloud/typings": "^1.6.0", + "@nextcloud/typings": "^1.7.0", "@rollup-extras/plugin-clean": "^1.2.3", "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-node-resolve": "^15.0.1", @@ -2401,12 +2401,14 @@ } }, "node_modules/@nextcloud/typings": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.6.0.tgz", - "integrity": "sha512-5uIsteFy9Z9/ZaNGE8w8SDgJp+FK8/LeRLgfnakC2pU8eNKTPlQfkiYR163oEI5Xu5YzwdIzf6/roIXdNinhrw==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.7.0.tgz", + "integrity": "sha512-fK1i09FYTfSUBdXswyiCr8ng5MwdWjEWOF7hRvNvq5i+XFUSmGjSsRmpQZFM2AONroHqGGQBkvQqpONUshFBJQ==", "dev": true, "dependencies": { - "@types/jquery": "2.0.60" + "@types/jquery": "3.5.16", + "vue": "^2.7.14", + "vue-router": "<4" }, "engines": { "node": "^16.0.0", @@ -2744,10 +2746,13 @@ } }, "node_modules/@types/jquery": { - "version": "2.0.60", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.60.tgz", - "integrity": "sha512-izi6OBEVrAwaHiqWITjOPBbVtcKZKAXTocJqPZsAKA2lvmbpFEyPSAxgcqmisbiMYj9EvrooUEPLHQeQqVMWAg==", - "dev": true + "version": "3.5.16", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.16.tgz", + "integrity": "sha512-bsI7y4ZgeMkmpG9OM710RRzDFp+w4P1RGiIt30C1mSBT+ExCleeh4HObwgArnDFELmRrOpXgSYN9VF1hj+f1lw==", + "dev": true, + "dependencies": { + "@types/sizzle": "*" + } }, "node_modules/@types/jsdom": { "version": "20.0.0", @@ -2778,6 +2783,12 @@ "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", "dev": true }, + "node_modules/@types/sizzle": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz", + "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==", + "dev": true + }, "node_modules/@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -2805,6 +2816,17 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "node_modules/@vue/compiler-sfc": { + "version": "2.7.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.14.tgz", + "integrity": "sha512-aNmNHyLPsw+sVvlQFQ2/8sjNuLtK54TC6cuKnVzAY93ks4ZBrvwQSnkkIh7bsbNhum5hJBS00wSDipQ937f5DA==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.18.4", + "postcss": "^8.4.14", + "source-map": "^0.6.1" + } + }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -3447,6 +3469,12 @@ "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", "dev": true }, + "node_modules/csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "dev": true + }, "node_modules/data-urls": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", @@ -5127,6 +5155,24 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -5383,6 +5429,34 @@ "node": ">=8" } }, + "node_modules/postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -5732,6 +5806,15 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-support": { "version": "0.5.13", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", @@ -6197,6 +6280,22 @@ "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", "dev": true }, + "node_modules/vue": { + "version": "2.7.14", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.14.tgz", + "integrity": "sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==", + "dev": true, + "dependencies": { + "@vue/compiler-sfc": "2.7.14", + "csstype": "^3.1.0" + } + }, + "node_modules/vue-router": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.6.5.tgz", + "integrity": "sha512-VYXZQLtjuvKxxcshuRAwjHnciqZVoXAjTjcqBTz4rKc8qih9g9pI3hbDjmqXaHdgL3v8pV6P8Z335XvHzESxLQ==", + "dev": true + }, "node_modules/w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", @@ -8112,12 +8211,14 @@ } }, "@nextcloud/typings": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.6.0.tgz", - "integrity": "sha512-5uIsteFy9Z9/ZaNGE8w8SDgJp+FK8/LeRLgfnakC2pU8eNKTPlQfkiYR163oEI5Xu5YzwdIzf6/roIXdNinhrw==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.7.0.tgz", + "integrity": "sha512-fK1i09FYTfSUBdXswyiCr8ng5MwdWjEWOF7hRvNvq5i+XFUSmGjSsRmpQZFM2AONroHqGGQBkvQqpONUshFBJQ==", "dev": true, "requires": { - "@types/jquery": "2.0.60" + "@types/jquery": "3.5.16", + "vue": "^2.7.14", + "vue-router": "<4" } }, "@niceties/logger": { @@ -8366,10 +8467,13 @@ } }, "@types/jquery": { - "version": "2.0.60", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.60.tgz", - "integrity": "sha512-izi6OBEVrAwaHiqWITjOPBbVtcKZKAXTocJqPZsAKA2lvmbpFEyPSAxgcqmisbiMYj9EvrooUEPLHQeQqVMWAg==", - "dev": true + "version": "3.5.16", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.16.tgz", + "integrity": "sha512-bsI7y4ZgeMkmpG9OM710RRzDFp+w4P1RGiIt30C1mSBT+ExCleeh4HObwgArnDFELmRrOpXgSYN9VF1hj+f1lw==", + "dev": true, + "requires": { + "@types/sizzle": "*" + } }, "@types/jsdom": { "version": "20.0.0", @@ -8400,6 +8504,12 @@ "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", "dev": true }, + "@types/sizzle": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz", + "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==", + "dev": true + }, "@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -8427,6 +8537,17 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "@vue/compiler-sfc": { + "version": "2.7.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.14.tgz", + "integrity": "sha512-aNmNHyLPsw+sVvlQFQ2/8sjNuLtK54TC6cuKnVzAY93ks4ZBrvwQSnkkIh7bsbNhum5hJBS00wSDipQ937f5DA==", + "dev": true, + "requires": { + "@babel/parser": "^7.18.4", + "postcss": "^8.4.14", + "source-map": "^0.6.1" + } + }, "abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -8898,6 +9019,12 @@ } } }, + "csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "dev": true + }, "data-urls": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", @@ -10164,6 +10291,12 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "dev": true + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -10356,6 +10489,17 @@ "find-up": "^4.0.0" } }, + "postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "dev": true, + "requires": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + } + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -10623,6 +10767,12 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true + }, "source-map-support": { "version": "0.5.13", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", @@ -10939,6 +11089,22 @@ "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", "dev": true }, + "vue": { + "version": "2.7.14", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.14.tgz", + "integrity": "sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==", + "dev": true, + "requires": { + "@vue/compiler-sfc": "2.7.14", + "csstype": "^3.1.0" + } + }, + "vue-router": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.6.5.tgz", + "integrity": "sha512-VYXZQLtjuvKxxcshuRAwjHnciqZVoXAjTjcqBTz4rKc8qih9g9pI3hbDjmqXaHdgL3v8pV6P8Z335XvHzESxLQ==", + "dev": true + }, "w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", diff --git a/package.json b/package.json index 260b7ac8..874d19a9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@babel/core": "^7.18.5", "@babel/preset-env": "^7.18.2", "@babel/preset-typescript": "^7.17.12", - "@nextcloud/typings": "^1.6.0", + "@nextcloud/typings": "^1.7.0", "@rollup-extras/plugin-clean": "^1.2.3", "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-node-resolve": "^15.0.1", diff --git a/tsconfig.json b/tsconfig.json index 0807b60a..701c7d16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["./lib/**/*.ts", "./lib/**/*.ts"], + "include": ["./lib/**/*.ts", "./*.d.ts"], "compilerOptions": { "allowSyntheticDefaultImports": true, "moduleResolution": "node", diff --git a/window.d.ts b/window.d.ts new file mode 100644 index 00000000..78d17cc6 --- /dev/null +++ b/window.d.ts @@ -0,0 +1,14 @@ +/// + +import { FileAction } from "./lib/fileAction"; +import { NewFileMenu } from "./lib/newFileMenu"; + +export {}; + +declare global { + interface Window { + OC: Nextcloud.v25.OC | Nextcloud.v26.OC | Nextcloud.v27.OC; + _nc_newfilemenu: NewFileMenu | undefined; + _nc_fileactions: FileAction[] | undefined; + } +}