nanosplash 2.5.0 → 2.5.3

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.
@@ -1,25 +1,42 @@
1
- import {addClass, get, mk} from "../utilities/dom";
1
+ import Exception from "../Exceptions/Exception";
2
+ import {addClass, get, mk} from "../Utilities/dom";
2
3
  import {SplashInstance} from "../Core/SplashInstance";
3
4
  import {ContextualAPIObject, Destination} from "../types";
5
+ import DestinationException from "../Exceptions/DestinationException";
6
+ import IllegalArgumentException from "../Exceptions/IllegalArgumentException";
4
7
 
5
8
  export class NanosplashRepository {
6
9
  /**
7
10
  * # Destination To Node
8
11
  * Converts a Destination type into an HTMLElement.
9
12
  * @param {Destination} destination Either a node or a CSS selector.
13
+ * @throws DestinationException
14
+ * @throws IllegalArgumentException
10
15
  */
11
16
  public static destinationToNode(destination: Destination): HTMLElement
12
17
  {
13
18
  if (typeof destination === 'string') {
14
- const element = get<HTMLElement>(destination)
15
- if (!element) {
16
- throw new Error(`No match with ${destination}`)
19
+ try {
20
+ const element = get<HTMLElement>(destination)
21
+ if (!element) {
22
+ throw new Exception(`No DOM match with ${destination}`)
23
+ }
24
+ return element
25
+ } catch (e) {
26
+ throw new DestinationException(
27
+ `Destination (${destination}) is either invalid or non-existing in DOM`,
28
+ destination,
29
+ e as Exception
30
+ )
17
31
  }
18
- return element
19
32
  } else if (destination instanceof Node) {
20
33
  return destination as HTMLElement
21
34
  }
22
- throw new Error('Destination argument must string or Node')
35
+
36
+ throw new IllegalArgumentException(
37
+ `Destination (${destination}) must be either a Node or a CSS selector`,
38
+ destination
39
+ )
23
40
  }
24
41
 
25
42
  /**
@@ -1,4 +1,5 @@
1
- import {addClass, get, mk, move, setAttr} from "./dom";
1
+ import {test} from "vitest"
2
+ import {addClass, get, mk, move, setAttr} from "../Utilities/dom"
2
3
 
3
4
  const resetDOM = () => document.body.innerHTML = ''
4
5
 
File without changes
package/src/types.d.ts CHANGED
@@ -25,8 +25,8 @@ export type ElementTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMa
25
25
  */
26
26
  type CSSProperty = keyof CSSStyleDeclaration
27
27
 
28
- export type ShowFunction = (text: string) => ContextualAPIInterface
29
- export type ProgressFunction = (...[]: SplashJob[]) => ContextualAPIInterface
28
+ export type ShowFunction = (text: string) => ContextualAPIObject
29
+ export type ProgressFunction = (...[]: SplashJob[]) => ContextualAPIObject
30
30
  export type WhileFunction = (asyncTask: Promise<any>) => ShowInterface
31
31
  export type StrategyObject = {
32
32
  show: ShowFunction,
@@ -35,6 +35,7 @@ export type StrategyObject = {
35
35
  }
36
36
 
37
37
  export type InsideFunction = (selector: string) => ContextualAPIInterface
38
+
38
39
  export type ContextualAPIObject = {
39
40
  getId: () => string,
40
41
  inside?: InsideFunction,
@@ -51,7 +52,8 @@ export type InstanceIterationCallback = (id: string, splashInstance: SplashInsta
51
52
  export type NanosplashOptions = {
52
53
  imgSrc?: string,
53
54
  spinner?: boolean,
54
- fontSize?: string
55
+ fontSize?: string,
56
+ debug?: boolean
55
57
  }
56
58
 
57
59
  export default Nanosplash
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "es6",
4
+ "types": ["vitest/globals"],
4
5
  "module": "ESNext",
5
6
  "lib": ["ESNext", "DOM"],
6
7
  "moduleResolution": "Node",
package/update-all.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env bash
2
- yarn remove @types/jest @types/jsdom autoprefixer cssnano jest jsdom jest-environment-jsdom postcss sass ts-jest ts-node typedoc typescript vite
3
- yarn add -D @types/jest @types/jsdom autoprefixer cssnano jest jsdom jest-environment-jsdom postcss sass ts-jest ts-node typedoc typescript vite
2
+ yarn remove @types/jsdom autoprefixer cssnano jsdom postcss sass ts-jest ts-node typedoc typescript vite vitest
3
+ yarn add -D @types/jsdom autoprefixer cssnano jsdom postcss sass ts-jest ts-node typedoc typescript vite vitest
package/vite.config.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'jsdom',
7
+ coverage: {
8
+ reporter: ['text', 'html'],
9
+ exclude: [
10
+ 'node_modules/',
11
+ 'dist/',
12
+ 'docs/',
13
+ ],
14
+ },
15
+ }
16
+ })
@@ -14,12 +14,12 @@ export default defineConfig({
14
14
  minify: 'terser',
15
15
  terserOptions: {
16
16
  parse: {
17
- bare_returns: true,
17
+ bare_returns: false,
18
18
  },
19
19
  compress: {
20
20
  keep_fargs: false,
21
21
  keep_fnames: false,
22
- keep_classnames: false,
22
+ keep_classnames: true,
23
23
  module: true,
24
24
  passes: 3,
25
25
  toplevel: true,
@@ -28,10 +28,7 @@ export default defineConfig({
28
28
  mangle: {
29
29
  toplevel: true,
30
30
  // Reserved class names
31
- reserved: [
32
- 'Nanosplash',
33
- 'SplashInstance'
34
- ],
31
+ reserved: [],
35
32
  properties: {
36
33
  reserved: [
37
34
  'ns',
@@ -59,14 +56,8 @@ export default defineConfig({
59
56
  ],
60
57
  }
61
58
  },
62
- format: {
63
- // wrap_iife: true
64
- },
65
- sourceMap: {
66
- // source map options
67
- },
68
59
  ecma: 2015, // specify one of: 5, 2015, 2016, etc.
69
- keep_classnames: false,
60
+ keep_classnames: true,
70
61
  keep_fnames: false,
71
62
  ie8: false,
72
63
  module: true,
package/jest.config.ts DELETED
@@ -1,194 +0,0 @@
1
- /*
2
- * For a detailed explanation regarding each configuration property and type check, visit:
3
- * https://jestjs.io/docs/configuration
4
- */
5
-
6
- export default {
7
- // All imported modules in your tests should be mocked automatically
8
- // automock: false,
9
-
10
- // Stop running tests after `n` failures
11
- // bail: 0,
12
-
13
- // The directory where Jest should store its cached dependency information
14
- // cacheDirectory: "/private/var/folders/zc/vybtlxpn4dn4wr85nb3sh7lh0000gn/T/jest_dx",
15
-
16
- // Automatically clear mock calls and instances between every test
17
- clearMocks: true,
18
-
19
- // Indicates whether the coverage information should be collected while executing the test
20
- collectCoverage: true,
21
-
22
- // An array of glob patterns indicating a set of files for which coverage information should be collected
23
- // collectCoverageFrom: undefined,
24
-
25
- // The directory where Jest should output its coverage files
26
- coverageDirectory: 'coverage',
27
-
28
- // An array of regexp pattern strings used to skip coverage collection
29
- // coveragePathIgnorePatterns: [
30
- // "/node_modules/"
31
- // ],
32
-
33
- // Indicates which provider should be used to instrument code for coverage
34
- coverageProvider: 'v8',
35
-
36
- // A list of reporter names that Jest uses when writing coverage reports
37
- // coverageReporters: [
38
- // "json",
39
- // "text",
40
- // "lcov",
41
- // "clover"
42
- // ],
43
-
44
- // An object that configures minimum threshold enforcement for coverage results
45
- // coverageThreshold: undefined,
46
-
47
- // A path to a custom dependency extractor
48
- // dependencyExtractor: undefined,
49
-
50
- // Make calling deprecated APIs throw helpful error messages
51
- // errorOnDeprecated: false,
52
-
53
- // Force coverage collection from ignored files using an array of glob patterns
54
- // forceCoverageMatch: [],
55
-
56
- // A path to a module which exports an async function that is triggered once before all test suites
57
- // globalSetup: undefined,
58
-
59
- // A path to a module which exports an async function that is triggered once after all test suites
60
- // globalTeardown: undefined,
61
-
62
- // A set of global variables that need to be available in all test environments
63
- // globals: {},
64
-
65
- // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
66
- // maxWorkers: "50%",
67
-
68
- // An array of directory names to be searched recursively up from the requiring module's location
69
- // moduleDirectories: [
70
- // "node_modules"
71
- // ],
72
-
73
- // An array of file extensions your modules use
74
- // moduleFileExtensions: [
75
- // "js",
76
- // "jsx",
77
- // "ts",
78
- // "tsx",
79
- // "json",
80
- // "node"
81
- // ],
82
-
83
- // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
84
- // moduleNameMapper: {},
85
-
86
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
87
- // modulePathIgnorePatterns: [],
88
-
89
- // Activates notifications for test results
90
- // notify: false,
91
-
92
- // An enum that specifies notification mode. Requires { notify: true }
93
- // notifyMode: "failure-change",
94
-
95
- // A preset that is used as a base for Jest's configuration
96
- preset: 'ts-jest',
97
-
98
- // Run tests from one or more projects
99
- // projects: undefined,
100
-
101
- // Use this configuration option to add custom reporters to Jest
102
- // reporters: undefined,
103
-
104
- // Automatically reset mock state between every test
105
- // resetMocks: false,
106
-
107
- // Reset the module registry before running each individual test
108
- // resetModules: false,
109
-
110
- // A path to a custom resolver
111
- // resolver: undefined,
112
-
113
- // Automatically restore mock state between every test
114
- // restoreMocks: false,
115
-
116
- // The root directory that Jest should scan for tests and modules within
117
- // rootDir: undefined,
118
-
119
- // A list of paths to directories that Jest should use to search for files in
120
- // roots: [
121
- // "<rootDir>"
122
- // ],
123
-
124
- // Allows you to use a custom runner instead of Jest's default test runner
125
- // runner: "jest-runner",
126
-
127
- // The paths to modules that run some code to configure or set up the testing environment before each test
128
- // setupFiles: [],
129
-
130
- // A list of paths to modules that run some code to configure or set up the testing framework before each test
131
- // setupFilesAfterEnv: [],
132
-
133
- // The number of seconds after which a test is considered as slow and reported as such in the results.
134
- // slowTestThreshold: 5,
135
-
136
- // A list of paths to snapshot serializer modules Jest should use for snapshot testing
137
- // snapshotSerializers: [],
138
-
139
- // The test environment that will be used for testing
140
- testEnvironment: 'jsdom',
141
-
142
- // Options that will be passed to the testEnvironment
143
- // testEnvironmentOptions: {},
144
-
145
- // Adds a location field to test results
146
- // testLocationInResults: false,
147
-
148
- // The glob patterns Jest uses to detect test files
149
- // testMatch: [
150
- // "**/__tests__/**/*.[jt]s?(x)",
151
- // "**/?(*.)+(spec|test).[tj]s?(x)"
152
- // ],
153
-
154
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
155
- // testPathIgnorePatterns: [
156
- // "/node_modules/"
157
- // ],
158
-
159
- // The regexp pattern or array of patterns that Jest uses to detect test files
160
- // testRegex: [],
161
-
162
- // This option allows the use of a custom results processor
163
- // testResultsProcessor: undefined,
164
-
165
- // This option allows use of a custom test runner
166
- // testRunner: "jest-circus/runner",
167
-
168
- // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
169
- // testURL: "http://localhost",
170
-
171
- // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
172
- // timers: "real",
173
-
174
- // A map from regular expressions to paths to transformers
175
- // transform: undefined,
176
-
177
- // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
178
- // transformIgnorePatterns: [
179
- // "/node_modules/",
180
- // "\\.pnp\\.[^\\/]+$"
181
- // ],
182
-
183
- // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
184
- // unmockedModulePathPatterns: undefined,
185
-
186
- // Indicates whether each individual test should be reported during the run
187
- // verbose: undefined,
188
-
189
- // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
190
- // watchPathIgnorePatterns: [],
191
-
192
- // Whether to use watchman for file crawling
193
- // watchman: true,
194
- }