@operato/utils 8.0.0-alpha.37 → 8.0.0-beta.1
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/CHANGELOG.md +17 -0
- package/dist/src/mixins/gesture-mixin.d.ts +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/src/adjust-list-param.ts +0 -79
- package/src/async-lock.ts +0 -27
- package/src/clipboard.ts +0 -41
- package/src/closest-element.ts +0 -24
- package/src/context-path.ts +0 -42
- package/src/cookie.ts +0 -44
- package/src/decode-html.ts +0 -5
- package/src/detect-overflow.ts +0 -18
- package/src/encode-form-params.ts +0 -24
- package/src/file-drop-helper.ts +0 -62
- package/src/format.ts +0 -123
- package/src/fullscreen.ts +0 -82
- package/src/gesture-helper.ts +0 -147
- package/src/has-overflow.ts +0 -22
- package/src/index.ts +0 -25
- package/src/is-unvalued.ts +0 -10
- package/src/logger.ts +0 -32
- package/src/longpressable.ts +0 -101
- package/src/mixins/gesture-mixin.ts +0 -157
- package/src/mixins/index.ts +0 -2
- package/src/mixins/infinite-scrollable.ts +0 -67
- package/src/number-parser.ts +0 -24
- package/src/os.ts +0 -48
- package/src/parse-jwt.ts +0 -21
- package/src/password-pattern.ts +0 -63
- package/src/reactive-controllers/index.ts +0 -1
- package/src/reactive-controllers/tooltip-reactive-controller.ts +0 -88
- package/src/sleep.ts +0 -10
- package/src/stringify-bignum.ts +0 -35
- package/src/swipe-listener.ts +0 -290
- package/src/timecapsule/index.ts +0 -2
- package/src/timecapsule/snapshot-taker.ts +0 -105
- package/src/timecapsule/timecapsule.ts +0 -139
- package/tsconfig.json +0 -24
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
package/src/swipe-listener.ts
DELETED
@@ -1,290 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Starts monitoring swipes on the given element and
|
3
|
-
* emits `swipe` event when a swipe gesture is performed.
|
4
|
-
* @param {DOMElement} element Element on which to listen for swipe gestures.
|
5
|
-
* @param {Object} options Optional: Options.
|
6
|
-
* @return {Object}
|
7
|
-
*/
|
8
|
-
export function SwipeListener(element: HTMLElement, options?: any) {
|
9
|
-
if (!element) return
|
10
|
-
|
11
|
-
// CustomEvent polyfill
|
12
|
-
if (typeof window !== 'undefined') {
|
13
|
-
;(function () {
|
14
|
-
if (typeof window.CustomEvent === 'function') return false
|
15
|
-
function CustomEvent(event: string, params: any) {
|
16
|
-
params = params || { bubbles: false, cancelable: false, detail: undefined }
|
17
|
-
var evt = document.createEvent('CustomEvent')
|
18
|
-
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)
|
19
|
-
return evt
|
20
|
-
}
|
21
|
-
CustomEvent.prototype = window.Event.prototype
|
22
|
-
;(window as any).CustomEvent = CustomEvent
|
23
|
-
})()
|
24
|
-
}
|
25
|
-
|
26
|
-
let defaultOpts = {
|
27
|
-
minHorizontal: 10, // Minimum number of pixels traveled to count as a horizontal swipe.
|
28
|
-
minVertical: 10, // Minimum number of pixels traveled to count as a vertical swipe.
|
29
|
-
deltaHorizontal: 3, // Delta for horizontal swipe
|
30
|
-
deltaVertical: 5, // Delta for vertical swipe
|
31
|
-
preventScroll: false, // Prevents scrolling when swiping.
|
32
|
-
lockAxis: true, // Select only one axis to be true instead of multiple.
|
33
|
-
touch: true, // Listen for touch events
|
34
|
-
mouse: true // Listen for mouse events
|
35
|
-
}
|
36
|
-
|
37
|
-
// Set options
|
38
|
-
if (!options) {
|
39
|
-
options = {}
|
40
|
-
}
|
41
|
-
options = {
|
42
|
-
...defaultOpts,
|
43
|
-
...options
|
44
|
-
}
|
45
|
-
|
46
|
-
// Store the touches
|
47
|
-
let touches: Array<{ x: number; y: number }> = []
|
48
|
-
|
49
|
-
// Not dragging by default.
|
50
|
-
let dragging = false
|
51
|
-
|
52
|
-
// When mouse-click is started, make dragging true.
|
53
|
-
const _mousedown = function (e: MouseEvent) {
|
54
|
-
dragging = true
|
55
|
-
}
|
56
|
-
|
57
|
-
// When mouse-click is released, make dragging false and signify end by imitating `touchend`.
|
58
|
-
const _mouseup = function (e: MouseEvent) {
|
59
|
-
dragging = false
|
60
|
-
_touchend(e as any)
|
61
|
-
}
|
62
|
-
|
63
|
-
// When mouse is moved while being clicked, imitate a `touchmove`.
|
64
|
-
const _mousemove = function (e: MouseEvent) {
|
65
|
-
if (dragging) {
|
66
|
-
;(e as any).changedTouches = [
|
67
|
-
{
|
68
|
-
clientX: e.clientX,
|
69
|
-
clientY: e.clientY
|
70
|
-
}
|
71
|
-
]
|
72
|
-
_touchmove(e as any)
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
if (options.mouse) {
|
77
|
-
element.addEventListener('mousedown', _mousedown)
|
78
|
-
element.addEventListener('mouseup', _mouseup)
|
79
|
-
element.addEventListener('mousemove', _mousemove)
|
80
|
-
}
|
81
|
-
|
82
|
-
// When the swipe is completed, calculate the direction.
|
83
|
-
const _touchend = function (e: TouchEvent) {
|
84
|
-
if (!touches.length) return
|
85
|
-
|
86
|
-
const touch = typeof TouchEvent === 'function' && e instanceof TouchEvent
|
87
|
-
|
88
|
-
let x = [],
|
89
|
-
y = []
|
90
|
-
|
91
|
-
let directions = {
|
92
|
-
top: false,
|
93
|
-
right: false,
|
94
|
-
bottom: false,
|
95
|
-
left: false
|
96
|
-
}
|
97
|
-
|
98
|
-
for (let i = 0; i < touches.length; i++) {
|
99
|
-
x.push(touches[i].x)
|
100
|
-
y.push(touches[i].y)
|
101
|
-
}
|
102
|
-
|
103
|
-
const xs = x[0],
|
104
|
-
xe = x[x.length - 1], // Start and end x-coords
|
105
|
-
ys = y[0],
|
106
|
-
ye = y[y.length - 1] // Start and end y-coords
|
107
|
-
|
108
|
-
const eventCoords = {
|
109
|
-
x: [xs, xe],
|
110
|
-
y: [ys, ye]
|
111
|
-
}
|
112
|
-
|
113
|
-
if (touches.length > 1) {
|
114
|
-
const swipeReleaseEventData = {
|
115
|
-
detail: {
|
116
|
-
touch,
|
117
|
-
target: e.target,
|
118
|
-
...eventCoords
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
let swipeReleaseEvent = new CustomEvent('swiperelease', swipeReleaseEventData)
|
123
|
-
element.dispatchEvent(swipeReleaseEvent)
|
124
|
-
}
|
125
|
-
|
126
|
-
// Determine left or right
|
127
|
-
let diff = x[0] - x[x.length - 1]
|
128
|
-
let swipe = 'none'
|
129
|
-
if (diff > 0) {
|
130
|
-
swipe = 'left'
|
131
|
-
} else {
|
132
|
-
swipe = 'right'
|
133
|
-
}
|
134
|
-
|
135
|
-
let min = Math.min(...x),
|
136
|
-
max = Math.max(...x),
|
137
|
-
_diff
|
138
|
-
|
139
|
-
// If minimum horizontal distance was travelled
|
140
|
-
if (Math.abs(diff) >= options.minHorizontal) {
|
141
|
-
switch (swipe) {
|
142
|
-
case 'left':
|
143
|
-
_diff = Math.abs(min - x[x.length - 1])
|
144
|
-
if (_diff <= options.deltaHorizontal) {
|
145
|
-
directions.left = true
|
146
|
-
}
|
147
|
-
break
|
148
|
-
case 'right':
|
149
|
-
_diff = Math.abs(max - x[x.length - 1])
|
150
|
-
if (_diff <= options.deltaHorizontal) {
|
151
|
-
directions.right = true
|
152
|
-
}
|
153
|
-
break
|
154
|
-
}
|
155
|
-
}
|
156
|
-
|
157
|
-
// Determine top or bottom
|
158
|
-
diff = y[0] - y[y.length - 1]
|
159
|
-
swipe = 'none'
|
160
|
-
if (diff > 0) {
|
161
|
-
swipe = 'top'
|
162
|
-
} else {
|
163
|
-
swipe = 'bottom'
|
164
|
-
}
|
165
|
-
|
166
|
-
min = Math.min(...y)
|
167
|
-
max = Math.max(...y)
|
168
|
-
|
169
|
-
// If minimum vertical distance was travelled
|
170
|
-
if (Math.abs(diff) >= options.minVertical) {
|
171
|
-
switch (swipe) {
|
172
|
-
case 'top':
|
173
|
-
_diff = Math.abs(min - y[y.length - 1])
|
174
|
-
if (_diff <= options.deltaVertical) {
|
175
|
-
directions.top = true
|
176
|
-
}
|
177
|
-
break
|
178
|
-
case 'bottom':
|
179
|
-
_diff = Math.abs(max - y[y.length - 1])
|
180
|
-
if (_diff <= options.deltaVertical) {
|
181
|
-
directions.bottom = true
|
182
|
-
}
|
183
|
-
break
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
// Clear touches array.
|
188
|
-
touches = []
|
189
|
-
|
190
|
-
// If there is a swipe direction, emit an event.
|
191
|
-
if (directions.top || directions.right || directions.bottom || directions.left) {
|
192
|
-
/**
|
193
|
-
* If lockAxis is true, determine which axis to select.
|
194
|
-
* The axis with the most travel is selected.
|
195
|
-
* TODO: Factor in for the orientation of the device
|
196
|
-
* and use it as a weight to determine the travel along an axis.
|
197
|
-
*/
|
198
|
-
if (options.lockAxis) {
|
199
|
-
if ((directions.left || directions.right) && Math.abs(xs - xe) > Math.abs(ys - ye)) {
|
200
|
-
directions.top = directions.bottom = false
|
201
|
-
} else if ((directions.top || directions.bottom) && Math.abs(xs - xe) < Math.abs(ys - ye)) {
|
202
|
-
directions.left = directions.right = false
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
|
-
const eventData = {
|
207
|
-
detail: {
|
208
|
-
directions,
|
209
|
-
touch,
|
210
|
-
target: e.target,
|
211
|
-
...eventCoords
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
let event = new CustomEvent('swipe', eventData)
|
216
|
-
element.dispatchEvent(event)
|
217
|
-
} else {
|
218
|
-
let cancelEvent = new CustomEvent('swipecancel', {
|
219
|
-
detail: {
|
220
|
-
touch,
|
221
|
-
target: e.target,
|
222
|
-
...eventCoords
|
223
|
-
}
|
224
|
-
})
|
225
|
-
element.dispatchEvent(cancelEvent)
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
// When a swipe is performed, store the coords.
|
230
|
-
const _touchmove = function (e: TouchEvent) {
|
231
|
-
let touch = e.changedTouches[0]
|
232
|
-
touches.push({
|
233
|
-
x: touch.clientX,
|
234
|
-
y: touch.clientY
|
235
|
-
})
|
236
|
-
|
237
|
-
// Emit a `swiping` event if there are more than one touch-points.
|
238
|
-
if (touches.length > 1) {
|
239
|
-
const xs = touches[0].x, // Start and end x-coords
|
240
|
-
xe = touches[touches.length - 1].x,
|
241
|
-
ys = touches[0].y, // Start and end y-coords
|
242
|
-
ye = touches[touches.length - 1].y,
|
243
|
-
eventData = {
|
244
|
-
detail: {
|
245
|
-
x: [xs, xe],
|
246
|
-
y: [ys, ye],
|
247
|
-
touch: typeof TouchEvent === 'function' && e instanceof TouchEvent,
|
248
|
-
target: e.target
|
249
|
-
}
|
250
|
-
}
|
251
|
-
let event = new CustomEvent('swiping', eventData)
|
252
|
-
|
253
|
-
const shouldPrevent =
|
254
|
-
options.preventScroll === true || (typeof options.preventScroll === 'function' && options.preventScroll(event))
|
255
|
-
|
256
|
-
if (shouldPrevent) {
|
257
|
-
e.preventDefault()
|
258
|
-
}
|
259
|
-
|
260
|
-
element.dispatchEvent(event)
|
261
|
-
}
|
262
|
-
}
|
263
|
-
|
264
|
-
// Test via a getter in the options object to see if the passive property is accessed
|
265
|
-
let passiveOptions: any = false
|
266
|
-
try {
|
267
|
-
const testOptions = Object.defineProperty({}, 'passive', {
|
268
|
-
get: function () {
|
269
|
-
passiveOptions = { passive: !options.preventScroll }
|
270
|
-
}
|
271
|
-
})
|
272
|
-
window.addEventListener('testPassive', null as any, testOptions)
|
273
|
-
window.removeEventListener('testPassive', null as any, testOptions)
|
274
|
-
} catch (e) {}
|
275
|
-
|
276
|
-
if (options.touch) {
|
277
|
-
element.addEventListener('touchmove', _touchmove, passiveOptions)
|
278
|
-
element.addEventListener('touchend', _touchend)
|
279
|
-
}
|
280
|
-
|
281
|
-
return {
|
282
|
-
off: function () {
|
283
|
-
element.removeEventListener('touchmove', _touchmove, passiveOptions)
|
284
|
-
element.removeEventListener('touchend', _touchend)
|
285
|
-
element.removeEventListener('mousedown', _mousedown)
|
286
|
-
element.removeEventListener('mouseup', _mouseup)
|
287
|
-
element.removeEventListener('mousemove', _mousemove)
|
288
|
-
}
|
289
|
-
}
|
290
|
-
}
|
package/src/timecapsule/index.ts
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
import { TimeCapsule } from './timecapsule'
|
2
|
-
import debounce from 'lodash-es/debounce'
|
3
|
-
|
4
|
-
/**
|
5
|
-
* A function that takes a SnapshotTaker as an argument and initiates snapshot creation
|
6
|
-
* using a debouncer to delay the process.
|
7
|
-
* @param {SnapshotTaker} taker - The SnapshotTaker instance to trigger snapshots for.
|
8
|
-
*/
|
9
|
-
var debouncer = debounce(
|
10
|
-
taker => {
|
11
|
-
if (!taker.brake) {
|
12
|
-
taker.take()
|
13
|
-
}
|
14
|
-
},
|
15
|
-
1000,
|
16
|
-
{ leading: true, trailing: false }
|
17
|
-
)
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Function to trigger snapshot creation for a SnapshotTaker instance.
|
21
|
-
* Checks if the taker is in a brake state or not dirty before triggering the snapshot.
|
22
|
-
* @param {SnapshotTaker} taker - The SnapshotTaker instance to create a snapshot for.
|
23
|
-
*/
|
24
|
-
function take_snapshot(taker: SnapshotTaker) {
|
25
|
-
if (taker.brake || !taker.dirty) return
|
26
|
-
debouncer(taker)
|
27
|
-
}
|
28
|
-
|
29
|
-
/**
|
30
|
-
* Type definition for holding state information.
|
31
|
-
* @typedef {Object} StateHolder
|
32
|
-
* @property {*} state - The state to be held.
|
33
|
-
*/
|
34
|
-
export type StateHolder = {
|
35
|
-
state: any
|
36
|
-
}
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Class responsible for taking and managing snapshots of state.
|
40
|
-
*/
|
41
|
-
export class SnapshotTaker {
|
42
|
-
private _brake: boolean = false
|
43
|
-
|
44
|
-
dirty: boolean = false
|
45
|
-
|
46
|
-
state_holder?: StateHolder
|
47
|
-
timecapsule?: TimeCapsule
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Creates an instance of SnapshotTaker.
|
51
|
-
* @param {*} state_holder - The object that holds the state to be snapshot.
|
52
|
-
* @param {TimeCapsule} timecapsule - The TimeCapsule instance associated with this SnapshotTaker.
|
53
|
-
*/
|
54
|
-
constructor(state_holder: any, timecapsule: TimeCapsule) {
|
55
|
-
this.state_holder = state_holder
|
56
|
-
this.timecapsule = timecapsule
|
57
|
-
this.timecapsule.snapshot_taker = this
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Disposes of the SnapshotTaker and clears associated references.
|
62
|
-
*/
|
63
|
-
dispose() {
|
64
|
-
delete this.state_holder
|
65
|
-
delete this.timecapsule
|
66
|
-
}
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Marks the SnapshotTaker as dirty and initiates snapshot creation.
|
70
|
-
*/
|
71
|
-
touch() {
|
72
|
-
this.dirty = true
|
73
|
-
take_snapshot(this)
|
74
|
-
}
|
75
|
-
|
76
|
-
/* 모든 조건에 관계없이 현재 상태를 snapshot으로 취한다. */
|
77
|
-
/**
|
78
|
-
* Takes a snapshot of the current state.
|
79
|
-
* @param {boolean} [force=false] - If true, the snapshot is taken even if not dirty.
|
80
|
-
*/
|
81
|
-
take(force: boolean = false) {
|
82
|
-
if (this.dirty || force) {
|
83
|
-
this.timecapsule?.snapshot(this.state_holder?.state)
|
84
|
-
this.dirty = false
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Gets the brake state of the SnapshotTaker.
|
90
|
-
* @returns {boolean} - true if the brake is active, false otherwise.
|
91
|
-
*/
|
92
|
-
get brake() {
|
93
|
-
return this._brake
|
94
|
-
}
|
95
|
-
|
96
|
-
/* 마우스를 드래깅하는 동안, 보통 brake 를 ON 시킨다. */
|
97
|
-
/**
|
98
|
-
* Sets the brake state of the SnapshotTaker and initiates snapshot creation.
|
99
|
-
* @param {boolean} brake - The new brake state.
|
100
|
-
*/
|
101
|
-
set brake(brake) {
|
102
|
-
this._brake = !!brake
|
103
|
-
take_snapshot(this)
|
104
|
-
}
|
105
|
-
}
|
@@ -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
|
-
});
|