@operato/utils 8.0.0-beta.0 → 8.0.0-beta.2

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +2 -2
  3. package/.editorconfig +0 -29
  4. package/.storybook/main.js +0 -3
  5. package/.storybook/preview.js +0 -52
  6. package/.storybook/server.mjs +0 -8
  7. package/demo/index.html +0 -43
  8. package/src/adjust-list-param.ts +0 -79
  9. package/src/async-lock.ts +0 -27
  10. package/src/clipboard.ts +0 -41
  11. package/src/closest-element.ts +0 -24
  12. package/src/context-path.ts +0 -42
  13. package/src/cookie.ts +0 -44
  14. package/src/decode-html.ts +0 -5
  15. package/src/detect-overflow.ts +0 -18
  16. package/src/encode-form-params.ts +0 -24
  17. package/src/file-drop-helper.ts +0 -62
  18. package/src/format.ts +0 -123
  19. package/src/fullscreen.ts +0 -82
  20. package/src/gesture-helper.ts +0 -147
  21. package/src/has-overflow.ts +0 -22
  22. package/src/index.ts +0 -25
  23. package/src/is-unvalued.ts +0 -10
  24. package/src/logger.ts +0 -32
  25. package/src/longpressable.ts +0 -101
  26. package/src/mixins/gesture-mixin.ts +0 -157
  27. package/src/mixins/index.ts +0 -2
  28. package/src/mixins/infinite-scrollable.ts +0 -67
  29. package/src/number-parser.ts +0 -24
  30. package/src/os.ts +0 -48
  31. package/src/parse-jwt.ts +0 -21
  32. package/src/password-pattern.ts +0 -63
  33. package/src/reactive-controllers/index.ts +0 -1
  34. package/src/reactive-controllers/tooltip-reactive-controller.ts +0 -88
  35. package/src/sleep.ts +0 -10
  36. package/src/stringify-bignum.ts +0 -35
  37. package/src/swipe-listener.ts +0 -290
  38. package/src/timecapsule/index.ts +0 -2
  39. package/src/timecapsule/snapshot-taker.ts +0 -105
  40. package/src/timecapsule/timecapsule.ts +0 -139
  41. package/tsconfig.json +0 -24
  42. package/web-dev-server.config.mjs +0 -27
  43. package/web-test-runner.config.mjs +0 -41
@@ -1,139 +0,0 @@
1
- import { debug, error, warn } from '../logger'
2
-
3
- import { SnapshotTaker } from './snapshot-taker'
4
-
5
- /**
6
- * A utility class for managing and navigating through a history of snapshots.
7
- */
8
- export class TimeCapsule {
9
- private q: Array<any> = []
10
- private maxsize = 10
11
- private pos = -1
12
-
13
- private _snapshot_taker: SnapshotTaker | null = null
14
-
15
- /**
16
- * Creates an instance of TimeCapsule.
17
- * @param {number} maxsize - The maximum number of snapshots to store.
18
- * @param {any} [start_state] - The initial state to be stored as the first snapshot (optional).
19
- */
20
- constructor(maxsize: number, start_state?: any) {
21
- maxsize = Number(maxsize)
22
-
23
- if (!maxsize || maxsize <= 0) {
24
- error('TimeCapsule maxsize should be greater than 0.', maxsize)
25
- } else {
26
- this.maxsize = maxsize
27
- }
28
-
29
- this.reset()
30
- if (start_state) {
31
- this.snapshot(start_state)
32
- }
33
- }
34
-
35
- /**
36
- * Disposes of the TimeCapsule and clears all stored snapshots.
37
- */
38
- dispose() {
39
- this.reset()
40
- }
41
-
42
- /**
43
- * Captures a snapshot of the current state and stores it.
44
- * @param {any} state - The state to be captured as a snapshot.
45
- */
46
- snapshot(state: any) {
47
- this.q.splice(this.pos + 1, this.q.length - (this.pos + 1), state)
48
-
49
- if (this.q.length > this.maxsize) {
50
- this.q.splice(0, this.q.length - this.maxsize)
51
- }
52
-
53
- this.pos = this.q.length - 1
54
- }
55
-
56
- /**
57
- * Moves forward to the next snapshot in the history.
58
- * @returns {any} The next state snapshot if available, or logs a warning if not.
59
- */
60
- forward() {
61
- if (this.snapshot_taker) this.snapshot_taker.take()
62
-
63
- if (this.forwardable) {
64
- return this.q[++this.pos]
65
- }
66
- warn('Not forwardable.')
67
- }
68
-
69
- /**
70
- * Moves backward to the previous snapshot in the history.
71
- * @returns {any} The previous state snapshot if available, or logs a warning if not.
72
- */
73
- backward() {
74
- if (this.snapshot_taker) this.snapshot_taker.take()
75
-
76
- if (this.backwardable) {
77
- return this.q[--this.pos]
78
- }
79
- warn('Not backwardable.')
80
- }
81
-
82
- /**
83
- * Gets the current state snapshot.
84
- * @returns {any} The current state snapshot if available, or logs a warning if not.
85
- */
86
- get current() {
87
- if (this.pos !== -1) return this.q[this.pos]
88
-
89
- warn('Non state has been recorded.')
90
- }
91
-
92
- /**
93
- * Gets the number of snapshots stored in the TimeCapsule.
94
- * @returns {number} The count of stored snapshots.
95
- */
96
- get length() {
97
- return this.q.length
98
- }
99
-
100
- /**
101
- * Checks if there is a snapshot available to move forward.
102
- * @returns {boolean} True if moving forward is possible, otherwise false.
103
- */
104
- get forwardable() {
105
- return this.pos < this.q.length - 1
106
- }
107
-
108
- /**
109
- * Checks if there is a snapshot available to move backward.
110
- * @returns {boolean} True if moving backward is possible, otherwise false.
111
- */
112
- get backwardable() {
113
- return this.pos > 0
114
- }
115
-
116
- /**
117
- * Gets the SnapshotTaker associated with this TimeCapsule.
118
- * @returns {SnapshotTaker | null} The associated SnapshotTaker, or null if not set.
119
- */
120
- get snapshot_taker(): SnapshotTaker | null {
121
- return this._snapshot_taker
122
- }
123
-
124
- /**
125
- * Sets the SnapshotTaker for this TimeCapsule.
126
- * @param {SnapshotTaker | null} snapshot_taker - The SnapshotTaker instance to associate with this TimeCapsule.
127
- */
128
- set snapshot_taker(snapshot_taker: SnapshotTaker | null) {
129
- this._snapshot_taker = snapshot_taker
130
- }
131
-
132
- /**
133
- * Resets the TimeCapsule, clearing all stored snapshots and resetting the position.
134
- */
135
- reset() {
136
- this.q = []
137
- this.pos = -1
138
- }
139
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "useDefineForClassFields": false,
13
- "importHelpers": true,
14
- "outDir": "dist",
15
- "sourceMap": true,
16
- "inlineSources": true,
17
- "rootDir": "./",
18
- "declaration": true,
19
- "incremental": true,
20
- "skipLibCheck": true,
21
- "types": ["node", "mocha"]
22
- },
23
- "include": ["**/*.ts"]
24
- }
@@ -1,27 +0,0 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- open: '/demo/',
8
- /** Use regular watch mode if HMR is not enabled. */
9
- watch: !hmr,
10
- /** Resolve bare module imports */
11
- nodeResolve: {
12
- exportConditions: ['browser', 'development'],
13
- },
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- plugins: [
22
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
- ],
25
-
26
- // See documentation for all available options
27
- });
@@ -1,41 +0,0 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });