@symbo.ls/utils 3.14.2 → 3.14.4
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 +13 -0
- package/dist/cjs/array.cjs +1 -0
- package/dist/cjs/assets.cjs +1 -0
- package/dist/cjs/browser.cjs +1 -0
- package/dist/cjs/cache.cjs +1 -0
- package/dist/cjs/cdn.cjs +3 -0
- package/dist/cjs/component.cjs +1 -0
- package/dist/cjs/cookie.cjs +1 -0
- package/dist/cjs/date.cjs +1 -0
- package/dist/cjs/detectHeight.cjs +1 -0
- package/dist/cjs/element.cjs +1 -0
- package/dist/cjs/env.cjs +2 -0
- package/dist/cjs/events.cjs +1 -0
- package/dist/cjs/extends.cjs +1 -0
- package/dist/cjs/fibonacci.cjs +1 -0
- package/dist/cjs/files.cjs +1 -0
- package/dist/cjs/function.cjs +1 -0
- package/dist/cjs/globals.cjs +1 -0
- package/dist/cjs/if.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/key.cjs +1 -0
- package/dist/cjs/keys.cjs +1 -0
- package/dist/cjs/load.cjs +1 -0
- package/dist/cjs/log.cjs +1 -0
- package/dist/cjs/metadata.cjs +2 -0
- package/dist/cjs/methods.cjs +10 -0
- package/dist/cjs/node.cjs +1 -0
- package/dist/cjs/object.cjs +12 -0
- package/dist/cjs/projectKeys.cjs +1 -0
- package/dist/cjs/props.cjs +1 -0
- package/dist/cjs/scaling.cjs +1 -0
- package/dist/cjs/scope.cjs +1 -0
- package/dist/cjs/sharedLibraries.cjs +1 -0
- package/dist/cjs/state.cjs +1 -0
- package/dist/cjs/string-extra.cjs +1 -0
- package/dist/cjs/string.cjs +3 -0
- package/dist/cjs/style.cjs +1 -0
- package/dist/cjs/tags.cjs +1 -0
- package/dist/cjs/triggerEvent.cjs +1 -0
- package/dist/cjs/types.cjs +1 -0
- package/dist/cjs/update.cjs +1 -0
- package/dist/esm/array.js +1 -0
- package/dist/esm/assets.js +1 -0
- package/dist/esm/browser.js +1 -0
- package/dist/esm/cache.js +1 -0
- package/dist/esm/cdn.js +3 -0
- package/dist/esm/component.js +1 -0
- package/dist/esm/cookie.js +1 -0
- package/dist/esm/date.js +1 -0
- package/dist/esm/detectHeight.js +1 -0
- package/dist/esm/element.js +1 -0
- package/dist/esm/env.js +2 -0
- package/dist/esm/events.js +1 -0
- package/dist/esm/extends.js +1 -0
- package/dist/esm/fibonacci.js +1 -0
- package/dist/esm/files.js +1 -0
- package/dist/esm/function.js +1 -0
- package/dist/esm/globals.js +1 -0
- package/dist/esm/if.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/key.js +1 -0
- package/dist/esm/keys.js +1 -0
- package/dist/esm/load.js +1 -0
- package/dist/esm/log.js +1 -0
- package/dist/esm/metadata.js +2 -0
- package/dist/esm/methods.js +10 -0
- package/dist/esm/node.js +1 -0
- package/dist/esm/object.js +12 -0
- package/dist/esm/projectKeys.js +1 -0
- package/dist/esm/props.js +1 -0
- package/dist/esm/scaling.js +1 -0
- package/dist/esm/scope.js +1 -0
- package/dist/esm/sharedLibraries.js +1 -0
- package/dist/esm/state.js +1 -0
- package/dist/esm/string-extra.js +1 -0
- package/dist/esm/string.js +3 -0
- package/dist/esm/style.js +1 -0
- package/dist/esm/tags.js +1 -0
- package/dist/esm/triggerEvent.js +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/update.js +1 -0
- package/package.json +35 -18
- package/array.js +0 -162
- package/assets.js +0 -117
- package/browser.js +0 -13
- package/cache.js +0 -7
- package/cdn.js +0 -83
- package/component.js +0 -25
- package/cookie.js +0 -78
- package/date.js +0 -10
- package/detectHeight.js +0 -42
- package/element.js +0 -148
- package/env.js +0 -15
- package/events.js +0 -19
- package/extends.js +0 -519
- package/fibonacci.js +0 -9
- package/files.js +0 -3
- package/function.js +0 -145
- package/globals.js +0 -8
- package/if.js +0 -30
- package/index.js +0 -42
- package/key.js +0 -20
- package/keys.js +0 -176
- package/load.js +0 -236
- package/log.js +0 -12
- package/metadata.js +0 -392
- package/methods.js +0 -684
- package/node.js +0 -37
- package/object.js +0 -837
- package/projectKeys.js +0 -30
- package/props.js +0 -327
- package/scaling.js +0 -15
- package/scope.js +0 -32
- package/sharedLibraries.js +0 -184
- package/state.js +0 -203
- package/string-extra.js +0 -69
- package/string.js +0 -206
- package/style.js +0 -23
- package/tags.js +0 -176
- package/triggerEvent.js +0 -102
- package/types.js +0 -55
- package/update.js +0 -27
package/triggerEvent.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { isFunction } from './types.js'
|
|
4
|
-
import { resolveHandler, runPluginHook } from './function.js'
|
|
5
|
-
|
|
6
|
-
const getOnOrPropsEvent = (param, element) => {
|
|
7
|
-
const propKey = 'on' + param.charAt(0).toUpperCase() + param.slice(1)
|
|
8
|
-
return element[propKey]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const applyEvent = (param, element, state, context, options) => {
|
|
12
|
-
param = resolveHandler(param, element)
|
|
13
|
-
if (!isFunction(param)) return
|
|
14
|
-
try {
|
|
15
|
-
const result = param.call(
|
|
16
|
-
element,
|
|
17
|
-
element,
|
|
18
|
-
state || element.state,
|
|
19
|
-
context || element.context,
|
|
20
|
-
options
|
|
21
|
-
)
|
|
22
|
-
if (result && typeof result.then === 'function') {
|
|
23
|
-
result.catch((err) => {
|
|
24
|
-
element.error = err
|
|
25
|
-
if (err instanceof ReferenceError) console.warn('[DOMQL] Async event warning:', err.message)
|
|
26
|
-
else console.error('[DOMQL] Async event error:', err)
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
return result
|
|
30
|
-
} catch (err) {
|
|
31
|
-
element.error = err
|
|
32
|
-
// In SSR/brender mode, ReferenceErrors for missing client-only helpers
|
|
33
|
-
// are expected (e.g. DOM animation functions). Log concisely.
|
|
34
|
-
if (err instanceof ReferenceError) {
|
|
35
|
-
console.warn('[DOMQL] Event handler warning:', err.message)
|
|
36
|
-
} else {
|
|
37
|
-
console.error('[DOMQL] Event handler error:', err)
|
|
38
|
-
}
|
|
39
|
-
if (element.context?.strictMode) throw err
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const triggerEventOn = (param, element, options) => {
|
|
44
|
-
if (!element) {
|
|
45
|
-
throw new Error('Element is required')
|
|
46
|
-
}
|
|
47
|
-
runPluginHook(param, element, options)
|
|
48
|
-
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
49
|
-
if (appliedFunction) {
|
|
50
|
-
const { state, context } = element
|
|
51
|
-
return applyEvent(appliedFunction, element, state, context, options)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const applyEventUpdate = (
|
|
56
|
-
param,
|
|
57
|
-
updatedObj,
|
|
58
|
-
element,
|
|
59
|
-
state,
|
|
60
|
-
context,
|
|
61
|
-
options
|
|
62
|
-
) => {
|
|
63
|
-
param = resolveHandler(param, element)
|
|
64
|
-
if (!isFunction(param)) return
|
|
65
|
-
try {
|
|
66
|
-
const result = param.call(
|
|
67
|
-
element,
|
|
68
|
-
updatedObj,
|
|
69
|
-
element,
|
|
70
|
-
state || element.state,
|
|
71
|
-
context || element.context,
|
|
72
|
-
options
|
|
73
|
-
)
|
|
74
|
-
if (result && typeof result.then === 'function') {
|
|
75
|
-
result.catch((err) => {
|
|
76
|
-
element.error = err
|
|
77
|
-
console.error('[DOMQL] Async event update error:', err)
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
return result
|
|
81
|
-
} catch (err) {
|
|
82
|
-
element.error = err
|
|
83
|
-
console.error('[DOMQL] Event update error:', err)
|
|
84
|
-
if (element.context?.strictMode) throw err
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const triggerEventOnUpdate = (param, updatedObj, element, options) => {
|
|
89
|
-
runPluginHook(param, element, updatedObj, options)
|
|
90
|
-
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
91
|
-
if (appliedFunction) {
|
|
92
|
-
const { state, context } = element
|
|
93
|
-
return applyEventUpdate(
|
|
94
|
-
appliedFunction,
|
|
95
|
-
updatedObj,
|
|
96
|
-
element,
|
|
97
|
-
state,
|
|
98
|
-
context,
|
|
99
|
-
options
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
}
|
package/types.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { isHtmlElement, isNode } from './node.js'
|
|
4
|
-
|
|
5
|
-
export const isObject = arg => {
|
|
6
|
-
if (arg === null) return false
|
|
7
|
-
return typeof arg === 'object' && arg.constructor === Object
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const isString = arg => typeof arg === 'string'
|
|
11
|
-
|
|
12
|
-
export const isNumber = arg => typeof arg === 'number'
|
|
13
|
-
|
|
14
|
-
export const isFunction = arg => typeof arg === 'function'
|
|
15
|
-
|
|
16
|
-
export const isBoolean = arg => arg === true || arg === false
|
|
17
|
-
|
|
18
|
-
export const isNull = arg => arg === null
|
|
19
|
-
|
|
20
|
-
export const isArray = arg => Array.isArray(arg)
|
|
21
|
-
|
|
22
|
-
export const isDate = d => d instanceof Date
|
|
23
|
-
|
|
24
|
-
export const isObjectLike = arg => {
|
|
25
|
-
if (arg === null) return false
|
|
26
|
-
// if (isArray(arg)) return false
|
|
27
|
-
return typeof arg === 'object'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const isDefined = arg => arg !== undefined
|
|
31
|
-
|
|
32
|
-
export const isUndefined = arg => arg === undefined
|
|
33
|
-
|
|
34
|
-
export const TYPES = {
|
|
35
|
-
boolean: isBoolean,
|
|
36
|
-
array: isArray,
|
|
37
|
-
object: isObject,
|
|
38
|
-
string: isString,
|
|
39
|
-
date: isDate,
|
|
40
|
-
number: isNumber,
|
|
41
|
-
null: isNull,
|
|
42
|
-
function: isFunction,
|
|
43
|
-
objectLike: isObjectLike,
|
|
44
|
-
node: isNode,
|
|
45
|
-
htmlElement: isHtmlElement,
|
|
46
|
-
defined: isDefined
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const is = arg => {
|
|
50
|
-
return (...args) => args.some(val => TYPES[val](arg))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const isNot = arg => {
|
|
54
|
-
return (...args) => !args.some(val => TYPES[val](arg))
|
|
55
|
-
}
|
package/update.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { createSnapshotId } from './key.js'
|
|
4
|
-
|
|
5
|
-
const snapshot = {
|
|
6
|
-
snapshotId: createSnapshotId
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const captureSnapshot = (element, options) => {
|
|
10
|
-
const ref = element.__ref
|
|
11
|
-
|
|
12
|
-
const { currentSnapshot, calleeElement } = options
|
|
13
|
-
const isCallee = calleeElement === element
|
|
14
|
-
if (!calleeElement || isCallee) {
|
|
15
|
-
const createdStanpshot = snapshot.snapshotId()
|
|
16
|
-
ref.__currentSnapshot = createdStanpshot
|
|
17
|
-
return [createdStanpshot, element]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const snapshotOnCallee = calleeElement.__ref.__currentSnapshot
|
|
21
|
-
|
|
22
|
-
if (currentSnapshot < snapshotOnCallee) {
|
|
23
|
-
return [snapshotOnCallee, calleeElement, true]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return [snapshotOnCallee, calleeElement]
|
|
27
|
-
}
|