@thednp/shorty 2.0.0-alpha6 → 2.0.0-alpha7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@thednp/shorty",
3
- "version": "2.0.0alpha6",
3
+ "version": "2.0.0alpha7",
4
+ "type": "module",
4
5
  "description": "TypeScript shorties for the web",
5
6
  "source": "./src/index.ts",
6
7
  "main": "./dist/shorty.js",
7
8
  "types": "./dist/shorty.d.ts",
8
9
  "module": "./dist/shorty.mjs",
9
- "*exports": {
10
+ "exports": {
10
11
  ".": {
11
12
  "import": "./dist/shorty.mjs",
12
13
  "require": "./dist/shorty.cjs",
@@ -20,14 +21,14 @@
20
21
  "scripts": {
21
22
  "pre-test": "npm run clean-coverage",
22
23
  "test": "npm run pre-test && npx cypress run",
23
- "clean": "rimraf dist",
24
24
  "clean-coverage": "rimraf coverage .nyc_output",
25
25
  "cypress": "npm run pre-test && npx cypress open",
26
26
  "coverage:report": "nyc report --reporter=lcov --reporter=json --reporter=text --reporter=json-summary",
27
27
  "format": "prettier --write \"src/**/*.ts\"",
28
- "lint:ts": "eslint -c .eslintrc.js --ext .ts src",
29
- "fix:ts": "eslint -c .eslintrc.js --ext .ts src --fix",
30
- "build": "npm run clean && tsc && vite build && dts-bundle-generator --config ./dts.config.ts"
28
+ "lint:ts": "eslint -c .eslintrc.cjs --ext .ts src",
29
+ "fix:ts": "eslint -c .eslintrc.cjs --ext .ts src --fix",
30
+ "build": "npm run lint:ts && vite build && npm run dts",
31
+ "dts": "dts-bundle-generator --config ./dts.config.ts"
31
32
  },
32
33
  "publishConfig": {
33
34
  "access": "public",
@@ -51,12 +52,12 @@
51
52
  "devDependencies": {
52
53
  "@bahmutov/cypress-esbuild-preprocessor": "^2.1.3",
53
54
  "@cypress/code-coverage": "^3.10.0",
54
- "@testing-library/cypress": "^8.0.3",
55
+ "@rollup/plugin-json": "^5.0.2",
55
56
  "@types/istanbul-lib-instrument": "^1.7.4",
56
57
  "@typescript-eslint/eslint-plugin": "^5.35.1",
57
58
  "@typescript-eslint/parser": "^5.35.1",
58
- "cypress": "^11.2.0",
59
- "dts-bundle-generator": "^6.12.0",
59
+ "cypress": "^12.0.2",
60
+ "dts-bundle-generator": "^7.1.0",
60
61
  "esbuild": "^0.14.30",
61
62
  "eslint": "^8.23.0",
62
63
  "eslint-plugin-jsdoc": "^39.3.6",
@@ -69,7 +70,7 @@
69
70
  "nyc": "^15.1.0",
70
71
  "prettier": "^2.7.1",
71
72
  "rimraf": "^3.0.2",
72
- "typescript": "^4.7.4",
73
+ "typescript": "^4.9.4",
73
74
  "vite": "^3.0.9"
74
75
  }
75
76
  }
@@ -1,4 +1,4 @@
1
- import { NavigatorUABrand } from '../interface/navigatorUA';
1
+ import type { NavigatorUABrand } from '../interface/navigatorUA';
2
2
  import userAgentData from '../strings/userAgentData';
3
3
  import userAgent from '../strings/userAgent';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import isHTMLElement from '../is/isHTMLElement';
2
- import { BoundingClientRect } from '../interface/boundingClientRect';
2
+ import type { BoundingClientRect } from '../interface/boundingClientRect';
3
3
 
4
4
  /**
5
5
  * Returns the bounding client rect of a target `HTMLElement`.
@@ -1,4 +1,4 @@
1
- import { OffsetRect } from '../interface/offsetRect';
1
+ import type { OffsetRect } from '../interface/offsetRect';
2
2
  import isScaledElement from '../is/isScaledElement';
3
3
  import isHTMLElement from '../is/isHTMLElement';
4
4
  import getBoundingClientRect from './getBoundingClientRect';
package/src/index.ts CHANGED
@@ -160,7 +160,8 @@ import documentHead from './blocks/documentHead';
160
160
 
161
161
  // misc
162
162
  import ArrayFrom from './misc/ArrayFrom';
163
- import Data, { getInstance } from './misc/data';
163
+ import Data from './misc/data';
164
+ import getInstance from './misc/getInstance';
164
165
  import createElement from './misc/createElement';
165
166
  import createElementNS from './misc/createElementNS';
166
167
  import dispatchEvent from './misc/dispatchEvent';
@@ -171,11 +172,11 @@ import Float32ArrayFrom from './misc/Float32ArrayFrom';
171
172
  import Float64ArrayFrom from './misc/Float64ArrayFrom';
172
173
  import focus from './misc/focus';
173
174
  import noop from './misc/noop';
174
- import hasOwn from './misc/hasOwn';
175
175
  import normalizeOptions from './misc/normalizeOptions';
176
176
  import normalizeValue from './misc/normalizeValue';
177
177
  import ObjectAssign from './misc/ObjectAssign';
178
178
  import ObjectEntries from './misc/ObjectEntries';
179
+ import ObjectHasOwn from './misc/ObjectHasOwn';
179
180
  import ObjectKeys from './misc/ObjectKeys';
180
181
  import ObjectValues from './misc/ObjectValues';
181
182
  import createCustomEvent from './misc/createCustomEvent';
@@ -242,7 +243,7 @@ import getElementsByTagName from './selectors/getElementsByTagName';
242
243
  import getElementsByClassName from './selectors/getElementsByClassName';
243
244
  import matches from './selectors/matches';
244
245
 
245
- const SHORTY = {
246
+ export {
246
247
  ariaChecked,
247
248
  ariaDescription,
248
249
  ariaDescribedBy,
@@ -426,7 +427,6 @@ const SHORTY = {
426
427
  getElementsByClassName,
427
428
  getElementsByTagName,
428
429
  matches,
429
- hasOwn,
430
430
  normalizeValue,
431
431
  normalizeOptions,
432
432
  reflow,
@@ -436,6 +436,7 @@ const SHORTY = {
436
436
  ArrayFrom,
437
437
  Float32ArrayFrom,
438
438
  Float64ArrayFrom,
439
+ ObjectHasOwn,
439
440
  ObjectAssign,
440
441
  ObjectEntries,
441
442
  ObjectKeys,
@@ -456,5 +457,3 @@ const SHORTY = {
456
457
  removeAttribute,
457
458
  removeAttributeNS,
458
459
  };
459
-
460
- export default SHORTY;
@@ -1,4 +1,4 @@
1
- export interface BoundingClientRect {
1
+ export declare interface BoundingClientRect {
2
2
  width: number;
3
3
  height: number;
4
4
  top: number;
@@ -0,0 +1,4 @@
1
+ export declare interface CSS4Declaration
2
+ extends Exclude<() => string | symbol, CSSStyleDeclaration> {
3
+ [key: string]: string;
4
+ }
@@ -1,4 +1,4 @@
1
- export interface CustomElement extends HTMLElement {
1
+ export declare interface CustomElement extends HTMLElement {
2
2
  shadowRoot: ShadowRoot;
3
3
  connectedCallback?: () => void;
4
4
  disconnectedCallback?: () => void;
@@ -1,15 +1,15 @@
1
1
  // https://github.com/lukewarlow/user-agent-data-types/blob/master/index.d.ts
2
- export interface NavigatorUABrand {
2
+ export declare interface NavigatorUABrand {
3
3
  readonly brand: string;
4
4
  readonly version: string;
5
5
  }
6
6
 
7
- export interface NavigatorUAData {
7
+ export declare interface NavigatorUAData {
8
8
  readonly brands: NavigatorUABrand[];
9
9
  readonly mobile: boolean;
10
10
  readonly platform: string;
11
11
  }
12
12
 
13
- export interface NavigatorUA extends Navigator {
13
+ export declare interface NavigatorUA extends Navigator {
14
14
  readonly userAgentData: NavigatorUAData;
15
15
  }
@@ -1,4 +1,4 @@
1
- export interface OffsetRect {
1
+ export declare interface OffsetRect {
2
2
  width: number;
3
3
  height: number;
4
4
  x: number;
@@ -0,0 +1,4 @@
1
+ export declare interface OriginalEvent extends CustomEvent<any> {
2
+ readonly type: string;
3
+ relatedTarget?: EventTarget;
4
+ }
@@ -1,5 +1,5 @@
1
1
  import isHTMLElement from './isHTMLElement';
2
- import { CustomElement } from '../interface/customElement';
2
+ import type { CustomElement } from '../interface/customElement';
3
3
 
4
4
  /**
5
5
  * Checks if an object is a `CustomElement`.
@@ -9,9 +9,9 @@ import isObject from '../is/isObject';
9
9
  * @param prop the property to check
10
10
  * @returns the query result
11
11
  */
12
- const hasOwn = <T extends object, K extends PropertyKey>(
12
+ const ObjectHasOwn = <T extends object, K extends PropertyKey>(
13
13
  obj: T,
14
14
  prop: K,
15
15
  ): obj is T & Record<K, unknown> => isObject(obj) && (Object.hasOwn(obj, prop) || prop in obj);
16
16
 
17
- export default hasOwn;
17
+ export default ObjectHasOwn;
@@ -1,4 +1,4 @@
1
- import { OriginalEvent } from '../interface/originalEvent';
1
+ import type { OriginalEvent } from '../interface/originalEvent';
2
2
  import isObject from '../is/isObject';
3
3
  import ObjectAssign from './ObjectAssign';
4
4
 
package/src/misc/data.ts CHANGED
@@ -79,10 +79,4 @@ const Data = {
79
79
  },
80
80
  };
81
81
 
82
- /**
83
- * An alias for `Data.get()`.
84
- */
85
- export const getInstance = <T>(target: HTMLElement, component: string): T | null =>
86
- Data.get(target, component);
87
-
88
82
  export default Data;
@@ -0,0 +1,9 @@
1
+ import Data from './data';
2
+
3
+ /**
4
+ * An alias for `Data.get()`.
5
+ */
6
+ const getInstance = <T>(target: HTMLElement, component: string): T | null =>
7
+ Data.get(target, component);
8
+
9
+ export default getInstance;
@@ -1,7 +1,7 @@
1
1
  import ObjectAssign from './ObjectAssign';
2
2
  import ObjectEntries from './ObjectEntries';
3
- import { CSS4Declaration } from '../interface/css4Declaration';
4
3
  import isString from '../is/isString';
4
+ import type { CSS4Declaration } from '../interface/css4Declaration';
5
5
 
6
6
  /**
7
7
  * Shortcut for multiple uses of `HTMLElement.style.propertyName` method.
@@ -1,6 +1,6 @@
1
- import { CustomElement } from '../interface/customElement';
2
1
  import isCustomElement from '../is/isCustomElement';
3
2
  import getElementsByTagName from './getElementsByTagName';
3
+ import type { CustomElement } from '../interface/customElement';
4
4
 
5
5
  /**
6
6
  * Returns an `Array` of `Node` elements that are registered as
@@ -1,4 +1,4 @@
1
- import { NavigatorUA } from '../interface/navigatorUA';
1
+ import type { NavigatorUA } from '../interface/navigatorUA';
2
2
 
3
3
  const uaDATA = (navigator as NavigatorUA).userAgentData;
4
4
 
@@ -1,3 +0,0 @@
1
- export interface CSS4Declaration extends Exclude<() => string | symbol, CSSStyleDeclaration> {
2
- [key: string]: string;
3
- }
@@ -1,4 +0,0 @@
1
- export interface OriginalEvent extends CustomEvent<any> {
2
- readonly type: string;
3
- relatedTarget?: EventTarget;
4
- }