@symbo.ls/utils 3.2.3 → 3.14.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/LICENSE +25 -12
- package/README.md +106 -0
- package/array.js +162 -0
- package/assets.js +117 -0
- package/cache.js +7 -0
- package/cdn.js +83 -0
- package/component.js +25 -0
- package/cookie.js +78 -0
- package/{src/detectHeight.js → detectHeight.js} +3 -3
- package/dist/cjs/detectHeight.js +10 -21
- package/dist/cjs/domqlv3hacks.js +3845 -0
- package/dist/cjs/index.js +3910 -251
- package/dist/cjs/scaling.js +3 -149
- package/element.js +148 -0
- package/env.js +15 -0
- package/events.js +19 -0
- package/extends.js +519 -0
- package/function.js +145 -0
- package/globals.js +8 -0
- package/if.js +30 -0
- package/index.js +42 -0
- package/key.js +20 -0
- package/keys.js +176 -0
- package/log.js +12 -0
- package/metadata.js +392 -0
- package/methods.js +684 -0
- package/node.js +37 -0
- package/object.js +837 -0
- package/package.json +38 -22
- package/projectKeys.js +30 -0
- package/props.js +327 -0
- package/{src/scaling.js → scaling.js} +1 -1
- package/scope.js +32 -0
- package/sharedLibraries.js +184 -0
- package/state.js +203 -0
- package/{src/index.js → string-extra.js} +11 -17
- package/string.js +206 -0
- package/tags.js +176 -0
- package/triggerEvent.js +102 -0
- package/types.js +55 -0
- package/update.js +27 -0
- /package/{src/browser.js → browser.js} +0 -0
- /package/{src/date.js → date.js} +0 -0
- /package/{src/fibonacci.js → fibonacci.js} +0 -0
- /package/{src/files.js → files.js} +0 -0
- /package/{src/load.js → load.js} +0 -0
- /package/{src/style.js → style.js} +0 -0
package/dist/cjs/scaling.js
CHANGED
|
@@ -25,166 +25,20 @@ __export(scaling_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(scaling_exports);
|
|
27
27
|
|
|
28
|
-
// ../../../domql/packages/utils/
|
|
28
|
+
// ../../../domql/packages/utils/globals.js
|
|
29
29
|
var window2 = globalThis;
|
|
30
30
|
var document2 = window2.document;
|
|
31
31
|
|
|
32
|
-
// ../../../domql/packages/utils/
|
|
32
|
+
// ../../../domql/packages/utils/types.js
|
|
33
33
|
var isObject = (arg) => {
|
|
34
34
|
if (arg === null) return false;
|
|
35
35
|
return typeof arg === "object" && arg.constructor === Object;
|
|
36
36
|
};
|
|
37
37
|
var isArray = (arg) => Array.isArray(arg);
|
|
38
38
|
|
|
39
|
-
// ../../../domql/packages/utils/
|
|
40
|
-
var STATE_METHODS = [
|
|
41
|
-
"update",
|
|
42
|
-
"parse",
|
|
43
|
-
"clean",
|
|
44
|
-
"create",
|
|
45
|
-
"destroy",
|
|
46
|
-
"add",
|
|
47
|
-
"toggle",
|
|
48
|
-
"remove",
|
|
49
|
-
"apply",
|
|
50
|
-
"set",
|
|
51
|
-
"reset",
|
|
52
|
-
"replace",
|
|
53
|
-
"quietReplace",
|
|
54
|
-
"quietUpdate",
|
|
55
|
-
"applyReplace",
|
|
56
|
-
"applyFunction",
|
|
57
|
-
"keys",
|
|
58
|
-
"values",
|
|
59
|
-
"ref",
|
|
60
|
-
"rootUpdate",
|
|
61
|
-
"parentUpdate",
|
|
62
|
-
"parent",
|
|
63
|
-
"__element",
|
|
64
|
-
"__depends",
|
|
65
|
-
"__ref",
|
|
66
|
-
"__children",
|
|
67
|
-
"root",
|
|
68
|
-
"setByPath",
|
|
69
|
-
"setPathCollection",
|
|
70
|
-
"removeByPath",
|
|
71
|
-
"removePathCollection",
|
|
72
|
-
"getByPath"
|
|
73
|
-
];
|
|
74
|
-
var PROPS_METHODS = ["update", "__element"];
|
|
75
|
-
var METHODS = [
|
|
76
|
-
"set",
|
|
77
|
-
"reset",
|
|
78
|
-
"update",
|
|
79
|
-
"remove",
|
|
80
|
-
"updateContent",
|
|
81
|
-
"removeContent",
|
|
82
|
-
"lookup",
|
|
83
|
-
"lookdown",
|
|
84
|
-
"lookdownAll",
|
|
85
|
-
"getRef",
|
|
86
|
-
"getPath",
|
|
87
|
-
"setNodeStyles",
|
|
88
|
-
"spotByPath",
|
|
89
|
-
"keys",
|
|
90
|
-
"parse",
|
|
91
|
-
"setProps",
|
|
92
|
-
"parseDeep",
|
|
93
|
-
"variables",
|
|
94
|
-
"if",
|
|
95
|
-
"log",
|
|
96
|
-
"verbose",
|
|
97
|
-
"warn",
|
|
98
|
-
"error",
|
|
99
|
-
"call",
|
|
100
|
-
"nextElement",
|
|
101
|
-
"previousElement"
|
|
102
|
-
];
|
|
103
|
-
var METHODS_EXL = [
|
|
104
|
-
...["node", "context", "extends", "__element", "__ref"],
|
|
105
|
-
...METHODS,
|
|
106
|
-
...STATE_METHODS,
|
|
107
|
-
...PROPS_METHODS
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
// ../../../domql/packages/utils/dist/esm/cookie.js
|
|
39
|
+
// ../../../domql/packages/utils/cookie.js
|
|
111
40
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
112
41
|
|
|
113
|
-
// ../../../domql/packages/event/dist/esm/keys.js
|
|
114
|
-
var STATE_METHODS2 = [
|
|
115
|
-
"update",
|
|
116
|
-
"parse",
|
|
117
|
-
"clean",
|
|
118
|
-
"create",
|
|
119
|
-
"destroy",
|
|
120
|
-
"add",
|
|
121
|
-
"toggle",
|
|
122
|
-
"remove",
|
|
123
|
-
"apply",
|
|
124
|
-
"set",
|
|
125
|
-
"reset",
|
|
126
|
-
"replace",
|
|
127
|
-
"quietReplace",
|
|
128
|
-
"quietUpdate",
|
|
129
|
-
"applyReplace",
|
|
130
|
-
"applyFunction",
|
|
131
|
-
"keys",
|
|
132
|
-
"values",
|
|
133
|
-
"ref",
|
|
134
|
-
"rootUpdate",
|
|
135
|
-
"parentUpdate",
|
|
136
|
-
"parent",
|
|
137
|
-
"__element",
|
|
138
|
-
"__depends",
|
|
139
|
-
"__ref",
|
|
140
|
-
"__children",
|
|
141
|
-
"root",
|
|
142
|
-
"setByPath",
|
|
143
|
-
"setPathCollection",
|
|
144
|
-
"removeByPath",
|
|
145
|
-
"removePathCollection",
|
|
146
|
-
"getByPath"
|
|
147
|
-
];
|
|
148
|
-
var PROPS_METHODS2 = ["update", "__element"];
|
|
149
|
-
var METHODS2 = [
|
|
150
|
-
"set",
|
|
151
|
-
"reset",
|
|
152
|
-
"update",
|
|
153
|
-
"remove",
|
|
154
|
-
"updateContent",
|
|
155
|
-
"removeContent",
|
|
156
|
-
"lookup",
|
|
157
|
-
"lookdown",
|
|
158
|
-
"lookdownAll",
|
|
159
|
-
"getRef",
|
|
160
|
-
"getPath",
|
|
161
|
-
"setNodeStyles",
|
|
162
|
-
"spotByPath",
|
|
163
|
-
"keys",
|
|
164
|
-
"parse",
|
|
165
|
-
"setProps",
|
|
166
|
-
"parseDeep",
|
|
167
|
-
"variables",
|
|
168
|
-
"if",
|
|
169
|
-
"log",
|
|
170
|
-
"verbose",
|
|
171
|
-
"warn",
|
|
172
|
-
"error",
|
|
173
|
-
"call",
|
|
174
|
-
"nextElement",
|
|
175
|
-
"previousElement"
|
|
176
|
-
];
|
|
177
|
-
var METHODS_EXL2 = [
|
|
178
|
-
...["node", "context", "extends", "__element", "__ref"],
|
|
179
|
-
...METHODS2,
|
|
180
|
-
...STATE_METHODS2,
|
|
181
|
-
...PROPS_METHODS2
|
|
182
|
-
];
|
|
183
|
-
|
|
184
|
-
// ../../../domql/packages/event/dist/esm/globals.js
|
|
185
|
-
var window3 = globalThis;
|
|
186
|
-
var document3 = window3.document;
|
|
187
|
-
|
|
188
42
|
// src/scaling.js
|
|
189
43
|
var findClosestNumber = (number, arr) => {
|
|
190
44
|
return (isArray(arr) ? arr : Object.values(arr)).reduce((prev, curr) => {
|
package/element.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { createExtends } from './extends.js'
|
|
4
|
+
import { createKey } from './key.js'
|
|
5
|
+
import { isNode } from './node.js'
|
|
6
|
+
import { createProps } from './props.js'
|
|
7
|
+
import { HTML_TAGS } from './tags.js'
|
|
8
|
+
import { is, isFunction } from './types.js'
|
|
9
|
+
|
|
10
|
+
const ENV = process.env.NODE_ENV
|
|
11
|
+
|
|
12
|
+
export const returnValueAsText = (element, parent, key) => {
|
|
13
|
+
const childExtendsTag = parent.childExtends && parent.childExtends.tag
|
|
14
|
+
const childPropsTag = parent.childProps && parent.childProps.tag
|
|
15
|
+
const isKeyValidHTMLTag = HTML_TAGS.body.has(key) && key
|
|
16
|
+
return {
|
|
17
|
+
text: element,
|
|
18
|
+
tag: childExtendsTag || childPropsTag || isKeyValidHTMLTag || 'string'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const createBasedOnType = (element, parent, key) => {
|
|
23
|
+
// if ELEMENT is not given
|
|
24
|
+
if (element === undefined) {
|
|
25
|
+
if (ENV === 'test' || ENV === 'development') {
|
|
26
|
+
console.warn(
|
|
27
|
+
key,
|
|
28
|
+
'element is undefined in',
|
|
29
|
+
parent?.__ref?.path
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
return {}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (element === null) return
|
|
36
|
+
if (element === true) return {}
|
|
37
|
+
|
|
38
|
+
if (is(element)('string', 'number')) {
|
|
39
|
+
return returnValueAsText(element, parent, key)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (isFunction(element)) {
|
|
43
|
+
return { props: element }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return element
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const addRef = (element, parent) => {
|
|
50
|
+
const ref = {}
|
|
51
|
+
ref.origin = element
|
|
52
|
+
ref.parent = parent
|
|
53
|
+
return ref
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const createParent = (element, parent, key, options, root) => {
|
|
57
|
+
if (!parent) return root
|
|
58
|
+
if (isNode(parent)) {
|
|
59
|
+
const parentNodeWrapper = { key: ':root', node: parent }
|
|
60
|
+
root[`${key}_parent`] = parentNodeWrapper
|
|
61
|
+
return parentNodeWrapper
|
|
62
|
+
}
|
|
63
|
+
return parent
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const createRoot = (element, parent) => {
|
|
67
|
+
const { __ref: ref } = element
|
|
68
|
+
const { __ref: parentRef } = parent
|
|
69
|
+
|
|
70
|
+
const hasRoot = parent && parent.key === ':root'
|
|
71
|
+
if (!ref?.root) {
|
|
72
|
+
ref.root = hasRoot ? element : parentRef?.root
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const createPath = (element, parent, key) => {
|
|
77
|
+
let { __ref: parentRef } = parent
|
|
78
|
+
// set the PATH array
|
|
79
|
+
if (!parentRef) parentRef = parent.ref = {}
|
|
80
|
+
if (!parentRef.path) parentRef.path = []
|
|
81
|
+
return parentRef.path.concat(key)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const addContext = (element, parent, key, options, root) => {
|
|
85
|
+
const forcedOptionsContext =
|
|
86
|
+
options.context && !root.context && !element.context
|
|
87
|
+
if (forcedOptionsContext) root.context = options.context
|
|
88
|
+
|
|
89
|
+
// inherit from parent or root
|
|
90
|
+
return options.context || parent.context || root.context || element.context
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const addCaching = (element, parent, key) => {
|
|
94
|
+
const ref = addRef(element, parent)
|
|
95
|
+
|
|
96
|
+
element.__ref = ref
|
|
97
|
+
|
|
98
|
+
// enable CACHING
|
|
99
|
+
if (!ref.__defineCache) ref.__defineCache = {}
|
|
100
|
+
|
|
101
|
+
// enable EXEC
|
|
102
|
+
if (!ref.__exec) ref.__exec = {}
|
|
103
|
+
if (!ref.__execProps) ref.__execProps = {}
|
|
104
|
+
|
|
105
|
+
// enable CLASS CACHING
|
|
106
|
+
if (!ref.__class) ref.__class = {}
|
|
107
|
+
if (!ref.__classNames) ref.__classNames = {}
|
|
108
|
+
|
|
109
|
+
// enable CLASS CACHING
|
|
110
|
+
if (!ref.__attr) ref.__attr = {}
|
|
111
|
+
|
|
112
|
+
// enable CHANGES storing
|
|
113
|
+
if (!ref.__changes) ref.__changes = []
|
|
114
|
+
|
|
115
|
+
// enable CHANGES storing
|
|
116
|
+
if (!ref.__children) ref.__children = []
|
|
117
|
+
|
|
118
|
+
ref.__extends = createExtends(element, parent, key)
|
|
119
|
+
ref.path = createPath(element, parent, key)
|
|
120
|
+
|
|
121
|
+
return ref
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const createElement = (passedProps, parentEl, passedKey, opts, root) => {
|
|
125
|
+
const hashed = passedProps?.__hash
|
|
126
|
+
const element = hashed
|
|
127
|
+
? { extends: [passedProps] }
|
|
128
|
+
: createBasedOnType(passedProps, parentEl, passedKey)
|
|
129
|
+
if (!element) return
|
|
130
|
+
|
|
131
|
+
const parent = createParent(element, parentEl, passedKey, opts, root)
|
|
132
|
+
const key = createKey(element, parent, passedKey)
|
|
133
|
+
|
|
134
|
+
addCaching(element, parent, key)
|
|
135
|
+
|
|
136
|
+
const props = createProps(element, parent, key)
|
|
137
|
+
const context = addContext(element, parent, key, opts, root)
|
|
138
|
+
const on = element.on || {}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
...element,
|
|
142
|
+
key,
|
|
143
|
+
props,
|
|
144
|
+
parent,
|
|
145
|
+
context,
|
|
146
|
+
on
|
|
147
|
+
}
|
|
148
|
+
}
|
package/env.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// @preserve-env
|
|
4
|
+
export const NODE_ENV = process.env.NODE_ENV
|
|
5
|
+
export const ENV = NODE_ENV
|
|
6
|
+
|
|
7
|
+
export const isProduction = (env = NODE_ENV) => env === 'production'
|
|
8
|
+
export const isTest = (env = NODE_ENV) => env === 'testing' || env === 'test'
|
|
9
|
+
export const isTesting = isTest
|
|
10
|
+
export const isStaging = (env = NODE_ENV) => env === 'staging'
|
|
11
|
+
export const isLocal = (env = NODE_ENV) => env === 'local'
|
|
12
|
+
export const isDevelopment = (env = NODE_ENV) =>
|
|
13
|
+
env === 'development' || env === 'dev' || env === 'local'
|
|
14
|
+
export const getNev = (key, env = NODE_ENV) => env[key]
|
|
15
|
+
export const isNotProduction = (env = NODE_ENV) => !isProduction(env)
|
package/events.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { lowercaseFirstLetter } from './string.js'
|
|
4
|
+
import { isFunction } from './types.js'
|
|
5
|
+
|
|
6
|
+
export function addEventFromProps (key, obj) {
|
|
7
|
+
const { props, on } = obj
|
|
8
|
+
const eventName = lowercaseFirstLetter(key.split('on')[1])
|
|
9
|
+
const origEvent = on[eventName]
|
|
10
|
+
const funcFromProps = props[key]
|
|
11
|
+
if (isFunction(origEvent)) {
|
|
12
|
+
on[eventName] = (...args) => {
|
|
13
|
+
const originalEventRetunrs = origEvent(...args)
|
|
14
|
+
if (originalEventRetunrs !== false) {
|
|
15
|
+
if (isFunction(funcFromProps)) return funcFromProps(...args)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
} else on[eventName] = funcFromProps
|
|
19
|
+
}
|