@sitecore/sc-contenthub-blok 0.0.21 → 0.0.24
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/dist/BlokTheme.js +2 -2
- package/dist/BlokTheme.js.map +1 -1
- package/dist/Components/BlokBadge/BlokBadge.js +4 -1
- package/dist/Components/BlokBadge/BlokBadge.js.map +1 -1
- package/dist/Components/BlokButton/BlokButton.js +1 -1
- package/dist/Components/BlokButton/BlokButton.js.map +1 -1
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.d.ts +7 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.js +184 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.js.map +1 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.spec.d.ts +1 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.spec.js +58 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.spec.js.map +1 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.stories.d.ts +8 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.stories.js +59 -0
- package/dist/Components/BlokButtonSelect/BlokButtonSelect.stories.js.map +1 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.d.ts +106 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.js +316 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.js.map +1 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.spec.d.ts +1 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.spec.js +88 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.spec.js.map +1 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.stories.d.ts +9 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.stories.js +38 -0
- package/dist/Components/BlokSearchBox/BlokSearchBox.stories.js.map +1 -0
- package/dist/Components/BlokSelect/BlokSelect.d.ts +99 -0
- package/dist/Components/BlokSelect/BlokSelect.js +247 -0
- package/dist/Components/BlokSelect/BlokSelect.js.map +1 -0
- package/dist/Components/BlokSelect/BlokSelect.spec.d.ts +1 -0
- package/dist/Components/BlokSelect/BlokSelect.spec.js +54 -0
- package/dist/Components/BlokSelect/BlokSelect.spec.js.map +1 -0
- package/dist/Components/BlokSelect/BlokSelect.stories.d.ts +8 -0
- package/dist/Components/BlokSelect/BlokSelect.stories.js +59 -0
- package/dist/Components/BlokSelect/BlokSelect.stories.js.map +1 -0
- package/dist/Components/BlokTag/BlokTag.js +9 -1
- package/dist/Components/BlokTag/BlokTag.js.map +1 -1
- package/dist/Foundations/utils.d.ts +28 -0
- package/dist/Foundations/utils.js +21 -1
- package/dist/Foundations/utils.js.map +1 -1
- package/dist/customHooks/useIsMounted.d.ts +7 -0
- package/dist/customHooks/useIsMounted.js +19 -0
- package/dist/customHooks/useIsMounted.js.map +1 -0
- package/esm/BlokTheme.js +2 -2
- package/esm/BlokTheme.js.map +1 -1
- package/esm/Components/BlokBadge/BlokBadge.js +4 -1
- package/esm/Components/BlokBadge/BlokBadge.js.map +1 -1
- package/esm/Components/BlokButton/BlokButton.js +1 -1
- package/esm/Components/BlokButton/BlokButton.js.map +1 -1
- package/esm/Components/BlokButtonSelect/BlokButtonSelect.js +179 -0
- package/esm/Components/BlokButtonSelect/BlokButtonSelect.js.map +1 -0
- package/esm/Components/BlokSearchBox/BlokSearchBox.js +312 -0
- package/esm/Components/BlokSearchBox/BlokSearchBox.js.map +1 -0
- package/esm/Components/BlokSelect/BlokSelect.js +242 -0
- package/esm/Components/BlokSelect/BlokSelect.js.map +1 -0
- package/esm/Components/BlokTag/BlokTag.js +9 -1
- package/esm/Components/BlokTag/BlokTag.js.map +1 -1
- package/esm/Foundations/utils.js +18 -0
- package/esm/Foundations/utils.js.map +1 -1
- package/esm/customHooks/useIsMounted.js +17 -0
- package/esm/customHooks/useIsMounted.js.map +1 -0
- package/node_modules/@emotion/cache/node_modules/stylis/LICENSE +21 -0
- package/node_modules/@emotion/cache/node_modules/stylis/README.md +161 -0
- package/node_modules/@emotion/cache/node_modules/stylis/dist/stylis.mjs +2 -0
- package/node_modules/@emotion/cache/node_modules/stylis/dist/stylis.mjs.map +1 -0
- package/node_modules/@emotion/cache/node_modules/stylis/dist/umd/package.json +1 -0
- package/node_modules/@emotion/cache/node_modules/stylis/dist/umd/stylis.js +2 -0
- package/node_modules/@emotion/cache/node_modules/stylis/dist/umd/stylis.js.map +1 -0
- package/node_modules/@emotion/cache/node_modules/stylis/index.js +7 -0
- package/node_modules/@emotion/cache/node_modules/stylis/package.json +167 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Enum.js +21 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Middleware.js +108 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Parser.js +191 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Prefixer.js +145 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Serializer.js +36 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Tokenizer.js +246 -0
- package/node_modules/@emotion/cache/node_modules/stylis/src/Utility.js +115 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/LICENSE +21 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/README.md +161 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/dist/stylis.mjs +2 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/dist/stylis.mjs.map +1 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/dist/umd/package.json +1 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/dist/umd/stylis.js +2 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/dist/umd/stylis.js.map +1 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/index.js +7 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/package.json +167 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Enum.js +21 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Middleware.js +108 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Parser.js +191 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Prefixer.js +145 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Serializer.js +36 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Tokenizer.js +246 -0
- package/node_modules/@emotion/css-prettifier/node_modules/stylis/src/Utility.js +115 -0
- package/node_modules/@emotion/jest/node_modules/stylis/LICENSE +21 -0
- package/node_modules/@emotion/jest/node_modules/stylis/README.md +161 -0
- package/node_modules/@emotion/jest/node_modules/stylis/dist/stylis.mjs +2 -0
- package/node_modules/@emotion/jest/node_modules/stylis/dist/stylis.mjs.map +1 -0
- package/node_modules/@emotion/jest/node_modules/stylis/dist/umd/package.json +1 -0
- package/node_modules/@emotion/jest/node_modules/stylis/dist/umd/stylis.js +2 -0
- package/node_modules/@emotion/jest/node_modules/stylis/dist/umd/stylis.js.map +1 -0
- package/node_modules/@emotion/jest/node_modules/stylis/index.js +7 -0
- package/node_modules/@emotion/jest/node_modules/stylis/package.json +167 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Enum.js +21 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Middleware.js +108 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Parser.js +191 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Prefixer.js +145 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Serializer.js +36 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Tokenizer.js +246 -0
- package/node_modules/@emotion/jest/node_modules/stylis/src/Utility.js +115 -0
- package/package.json +6 -2
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/LICENSE +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/README.md +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/dist/stylis.mjs +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/dist/stylis.mjs.map +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/dist/umd/package.json +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/dist/umd/stylis.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/dist/umd/stylis.js.map +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/index.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/package.json +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Enum.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Middleware.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Parser.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Prefixer.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Serializer.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Tokenizer.js +0 -0
- /package/node_modules/{stylis → @emotion/babel-plugin/node_modules/stylis}/src/Utility.js +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {MS, MOZ, WEBKIT} from './Enum.js'
|
|
2
|
+
import {hash, charat, strlen, indexof, replace, substr, match} from './Utility.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} value
|
|
6
|
+
* @param {number} length
|
|
7
|
+
* @param {object[]} children
|
|
8
|
+
* @return {string}
|
|
9
|
+
*/
|
|
10
|
+
export function prefix (value, length, children) {
|
|
11
|
+
switch (hash(value, length)) {
|
|
12
|
+
// color-adjust
|
|
13
|
+
case 5103:
|
|
14
|
+
return WEBKIT + 'print-' + value + value
|
|
15
|
+
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
|
|
16
|
+
case 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921:
|
|
17
|
+
// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
|
|
18
|
+
case 5572: case 6356: case 5844: case 3191: case 6645: case 3005:
|
|
19
|
+
// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
|
|
20
|
+
case 6391: case 5879: case 5623: case 6135: case 4599: case 4855:
|
|
21
|
+
// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
|
|
22
|
+
case 4215: case 6389: case 5109: case 5365: case 5621: case 3829:
|
|
23
|
+
return WEBKIT + value + value
|
|
24
|
+
// tab-size
|
|
25
|
+
case 4789:
|
|
26
|
+
return MOZ + value + value
|
|
27
|
+
// appearance, user-select, transform, hyphens, text-size-adjust
|
|
28
|
+
case 5349: case 4246: case 4810: case 6968: case 2756:
|
|
29
|
+
return WEBKIT + value + MOZ + value + MS + value + value
|
|
30
|
+
// writing-mode
|
|
31
|
+
case 5936:
|
|
32
|
+
switch (charat(value, length + 11)) {
|
|
33
|
+
// vertical-l(r)
|
|
34
|
+
case 114:
|
|
35
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value
|
|
36
|
+
// vertical-r(l)
|
|
37
|
+
case 108:
|
|
38
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value
|
|
39
|
+
// horizontal(-)tb
|
|
40
|
+
case 45:
|
|
41
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value
|
|
42
|
+
// default: fallthrough to below
|
|
43
|
+
}
|
|
44
|
+
// flex, flex-direction, scroll-snap-type, writing-mode
|
|
45
|
+
case 6828: case 4268: case 2903:
|
|
46
|
+
return WEBKIT + value + MS + value + value
|
|
47
|
+
// order
|
|
48
|
+
case 6165:
|
|
49
|
+
return WEBKIT + value + MS + 'flex-' + value + value
|
|
50
|
+
// align-items
|
|
51
|
+
case 5187:
|
|
52
|
+
return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + 'box-$1$2' + MS + 'flex-$1$2') + value
|
|
53
|
+
// align-self
|
|
54
|
+
case 5443:
|
|
55
|
+
return WEBKIT + value + MS + 'flex-item-' + replace(value, /flex-|-self/g, '') + (!match(value, /flex-|baseline/) ? MS + 'grid-row-' + replace(value, /flex-|-self/g, '') : '') + value
|
|
56
|
+
// align-content
|
|
57
|
+
case 4675:
|
|
58
|
+
return WEBKIT + value + MS + 'flex-line-pack' + replace(value, /align-content|flex-|-self/g, '') + value
|
|
59
|
+
// flex-shrink
|
|
60
|
+
case 5548:
|
|
61
|
+
return WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value
|
|
62
|
+
// flex-basis
|
|
63
|
+
case 5292:
|
|
64
|
+
return WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value
|
|
65
|
+
// flex-grow
|
|
66
|
+
case 6060:
|
|
67
|
+
return WEBKIT + 'box-' + replace(value, '-grow', '') + WEBKIT + value + MS + replace(value, 'grow', 'positive') + value
|
|
68
|
+
// transition
|
|
69
|
+
case 4554:
|
|
70
|
+
return WEBKIT + replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') + value
|
|
71
|
+
// cursor
|
|
72
|
+
case 6187:
|
|
73
|
+
return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + '$1'), /(image-set)/, WEBKIT + '$1'), value, '') + value
|
|
74
|
+
// background, background-image
|
|
75
|
+
case 5495: case 3959:
|
|
76
|
+
return replace(value, /(image-set\([^]*)/, WEBKIT + '$1' + '$`$1')
|
|
77
|
+
// justify-content
|
|
78
|
+
case 4968:
|
|
79
|
+
return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + WEBKIT + value + value
|
|
80
|
+
// justify-self
|
|
81
|
+
case 4200:
|
|
82
|
+
if (!match(value, /flex-|baseline/)) return MS + 'grid-column-align' + substr(value, length) + value
|
|
83
|
+
break
|
|
84
|
+
// grid-template-(columns|rows)
|
|
85
|
+
case 2592: case 3360:
|
|
86
|
+
return MS + replace(value, 'template-', '') + value
|
|
87
|
+
// grid-(row|column)-start
|
|
88
|
+
case 4384: case 3616:
|
|
89
|
+
if (children && children.some(function (element, index) { return length = index, match(element.props, /grid-\w+-end/) })) {
|
|
90
|
+
return ~indexof(value + (children = children[length].value), 'span') ? value : (MS + replace(value, '-start', '') + value + MS + 'grid-row-span:' + (~indexof(children, 'span') ? match(children, /\d+/) : +match(children, /\d+/) - +match(value, /\d+/)) + ';')
|
|
91
|
+
}
|
|
92
|
+
return MS + replace(value, '-start', '') + value
|
|
93
|
+
// grid-(row|column)-end
|
|
94
|
+
case 4896: case 4128:
|
|
95
|
+
return (children && children.some(function (element) { return match(element.props, /grid-\w+-start/) })) ? value : MS + replace(replace(value, '-end', '-span'), 'span ', '') + value
|
|
96
|
+
// (margin|padding)-inline-(start|end)
|
|
97
|
+
case 4095: case 3583: case 4068: case 2532:
|
|
98
|
+
return replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value
|
|
99
|
+
// (min|max)?(width|height|inline-size|block-size)
|
|
100
|
+
case 8116: case 7059: case 5753: case 5535:
|
|
101
|
+
case 5445: case 5701: case 4933: case 4677:
|
|
102
|
+
case 5533: case 5789: case 5021: case 4765:
|
|
103
|
+
// stretch, max-content, min-content, fill-available
|
|
104
|
+
if (strlen(value) - 1 - length > 6)
|
|
105
|
+
switch (charat(value, length + 1)) {
|
|
106
|
+
// (m)ax-content, (m)in-content
|
|
107
|
+
case 109:
|
|
108
|
+
// -
|
|
109
|
+
if (charat(value, length + 4) !== 45)
|
|
110
|
+
break
|
|
111
|
+
// (f)ill-available, (f)it-content
|
|
112
|
+
case 102:
|
|
113
|
+
return replace(value, /(.+:)(.+)-([^]+)/, '$1' + WEBKIT + '$2-$3' + '$1' + MOZ + (charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value
|
|
114
|
+
// (s)tretch
|
|
115
|
+
case 115:
|
|
116
|
+
return ~indexof(value, 'stretch') ? prefix(replace(value, 'stretch', 'fill-available'), length, children) + value : value
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
// grid-(column|row)
|
|
120
|
+
case 5152: case 5920:
|
|
121
|
+
return replace(value, /(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/, function (_, a, b, c, d, e, f) { return (MS + a + ':' + b + f) + (c ? (MS + a + '-span:' + (d ? e : +e - +b)) + f : '') + value })
|
|
122
|
+
// position: sticky
|
|
123
|
+
case 4949:
|
|
124
|
+
// stick(y)?
|
|
125
|
+
if (charat(value, length + 6) === 121)
|
|
126
|
+
return replace(value, ':', ':' + WEBKIT) + value
|
|
127
|
+
break
|
|
128
|
+
// display: (flex|inline-flex|grid|inline-grid)
|
|
129
|
+
case 6444:
|
|
130
|
+
switch (charat(value, charat(value, 14) === 45 ? 18 : 11)) {
|
|
131
|
+
// (inline-)?fle(x)
|
|
132
|
+
case 120:
|
|
133
|
+
return replace(value, /(.+:)([^;\s!]+)(;|(\s+)?!.+)?/, '$1' + WEBKIT + (charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + WEBKIT + '$2$3' + '$1' + MS + '$2box$3') + value
|
|
134
|
+
// (inline-)?gri(d)
|
|
135
|
+
case 100:
|
|
136
|
+
return replace(value, ':', ':' + MS) + value
|
|
137
|
+
}
|
|
138
|
+
break
|
|
139
|
+
// scroll-margin, scroll-margin-(top|right|bottom|left)
|
|
140
|
+
case 5719: case 2647: case 2135: case 3927: case 2391:
|
|
141
|
+
return replace(value, 'scroll-', 'scroll-snap-') + value
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return value
|
|
145
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {IMPORT, LAYER, COMMENT, RULESET, DECLARATION, KEYFRAMES} from './Enum.js'
|
|
2
|
+
import {strlen, sizeof} from './Utility.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {object[]} children
|
|
6
|
+
* @param {function} callback
|
|
7
|
+
* @return {string}
|
|
8
|
+
*/
|
|
9
|
+
export function serialize (children, callback) {
|
|
10
|
+
var output = ''
|
|
11
|
+
var length = sizeof(children)
|
|
12
|
+
|
|
13
|
+
for (var i = 0; i < length; i++)
|
|
14
|
+
output += callback(children[i], i, children, callback) || ''
|
|
15
|
+
|
|
16
|
+
return output
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} element
|
|
21
|
+
* @param {number} index
|
|
22
|
+
* @param {object[]} children
|
|
23
|
+
* @param {function} callback
|
|
24
|
+
* @return {string}
|
|
25
|
+
*/
|
|
26
|
+
export function stringify (element, index, children, callback) {
|
|
27
|
+
switch (element.type) {
|
|
28
|
+
case LAYER: if (element.children.length) break
|
|
29
|
+
case IMPORT: case DECLARATION: return element.return = element.return || element.value
|
|
30
|
+
case COMMENT: return ''
|
|
31
|
+
case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'
|
|
32
|
+
case RULESET: element.value = element.props.join(',')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''
|
|
36
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {from, trim, charat, strlen, substr, append, assign} from './Utility.js'
|
|
2
|
+
|
|
3
|
+
export var line = 1
|
|
4
|
+
export var column = 1
|
|
5
|
+
export var length = 0
|
|
6
|
+
export var position = 0
|
|
7
|
+
export var character = 0
|
|
8
|
+
export var characters = ''
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} value
|
|
12
|
+
* @param {object | null} root
|
|
13
|
+
* @param {object | null} parent
|
|
14
|
+
* @param {string} type
|
|
15
|
+
* @param {string[] | string} props
|
|
16
|
+
* @param {object[] | string} children
|
|
17
|
+
* @param {number} length
|
|
18
|
+
*/
|
|
19
|
+
export function node (value, root, parent, type, props, children, length) {
|
|
20
|
+
return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: ''}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {object} root
|
|
25
|
+
* @param {object} props
|
|
26
|
+
* @return {object}
|
|
27
|
+
*/
|
|
28
|
+
export function copy (root, props) {
|
|
29
|
+
return assign(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @return {number}
|
|
34
|
+
*/
|
|
35
|
+
export function char () {
|
|
36
|
+
return character
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @return {number}
|
|
41
|
+
*/
|
|
42
|
+
export function prev () {
|
|
43
|
+
character = position > 0 ? charat(characters, --position) : 0
|
|
44
|
+
|
|
45
|
+
if (column--, character === 10)
|
|
46
|
+
column = 1, line--
|
|
47
|
+
|
|
48
|
+
return character
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @return {number}
|
|
53
|
+
*/
|
|
54
|
+
export function next () {
|
|
55
|
+
character = position < length ? charat(characters, position++) : 0
|
|
56
|
+
|
|
57
|
+
if (column++, character === 10)
|
|
58
|
+
column = 1, line++
|
|
59
|
+
|
|
60
|
+
return character
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @return {number}
|
|
65
|
+
*/
|
|
66
|
+
export function peek () {
|
|
67
|
+
return charat(characters, position)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @return {number}
|
|
72
|
+
*/
|
|
73
|
+
export function caret () {
|
|
74
|
+
return position
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {number} begin
|
|
79
|
+
* @param {number} end
|
|
80
|
+
* @return {string}
|
|
81
|
+
*/
|
|
82
|
+
export function slice (begin, end) {
|
|
83
|
+
return substr(characters, begin, end)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {number} type
|
|
88
|
+
* @return {number}
|
|
89
|
+
*/
|
|
90
|
+
export function token (type) {
|
|
91
|
+
switch (type) {
|
|
92
|
+
// \0 \t \n \r \s whitespace token
|
|
93
|
+
case 0: case 9: case 10: case 13: case 32:
|
|
94
|
+
return 5
|
|
95
|
+
// ! + , / > @ ~ isolate token
|
|
96
|
+
case 33: case 43: case 44: case 47: case 62: case 64: case 126:
|
|
97
|
+
// ; { } breakpoint token
|
|
98
|
+
case 59: case 123: case 125:
|
|
99
|
+
return 4
|
|
100
|
+
// : accompanied token
|
|
101
|
+
case 58:
|
|
102
|
+
return 3
|
|
103
|
+
// " ' ( [ opening delimit token
|
|
104
|
+
case 34: case 39: case 40: case 91:
|
|
105
|
+
return 2
|
|
106
|
+
// ) ] closing delimit token
|
|
107
|
+
case 41: case 93:
|
|
108
|
+
return 1
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return 0
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {string} value
|
|
116
|
+
* @return {any[]}
|
|
117
|
+
*/
|
|
118
|
+
export function alloc (value) {
|
|
119
|
+
return line = column = 1, length = strlen(characters = value), position = 0, []
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {any} value
|
|
124
|
+
* @return {any}
|
|
125
|
+
*/
|
|
126
|
+
export function dealloc (value) {
|
|
127
|
+
return characters = '', value
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {number} type
|
|
132
|
+
* @return {string}
|
|
133
|
+
*/
|
|
134
|
+
export function delimit (type) {
|
|
135
|
+
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {string} value
|
|
140
|
+
* @return {string[]}
|
|
141
|
+
*/
|
|
142
|
+
export function tokenize (value) {
|
|
143
|
+
return dealloc(tokenizer(alloc(value)))
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @param {number} type
|
|
148
|
+
* @return {string}
|
|
149
|
+
*/
|
|
150
|
+
export function whitespace (type) {
|
|
151
|
+
while (character = peek())
|
|
152
|
+
if (character < 33)
|
|
153
|
+
next()
|
|
154
|
+
else
|
|
155
|
+
break
|
|
156
|
+
|
|
157
|
+
return token(type) > 2 || token(character) > 3 ? '' : ' '
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {string[]} children
|
|
162
|
+
* @return {string[]}
|
|
163
|
+
*/
|
|
164
|
+
export function tokenizer (children) {
|
|
165
|
+
while (next())
|
|
166
|
+
switch (token(character)) {
|
|
167
|
+
case 0: append(identifier(position - 1), children)
|
|
168
|
+
break
|
|
169
|
+
case 2: append(delimit(character), children)
|
|
170
|
+
break
|
|
171
|
+
default: append(from(character), children)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return children
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {number} index
|
|
179
|
+
* @param {number} count
|
|
180
|
+
* @return {string}
|
|
181
|
+
*/
|
|
182
|
+
export function escaping (index, count) {
|
|
183
|
+
while (--count && next())
|
|
184
|
+
// not 0-9 A-F a-f
|
|
185
|
+
if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))
|
|
186
|
+
break
|
|
187
|
+
|
|
188
|
+
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @param {number} type
|
|
193
|
+
* @return {number}
|
|
194
|
+
*/
|
|
195
|
+
export function delimiter (type) {
|
|
196
|
+
while (next())
|
|
197
|
+
switch (character) {
|
|
198
|
+
// ] ) " '
|
|
199
|
+
case type:
|
|
200
|
+
return position
|
|
201
|
+
// " '
|
|
202
|
+
case 34: case 39:
|
|
203
|
+
if (type !== 34 && type !== 39)
|
|
204
|
+
delimiter(character)
|
|
205
|
+
break
|
|
206
|
+
// (
|
|
207
|
+
case 40:
|
|
208
|
+
if (type === 41)
|
|
209
|
+
delimiter(type)
|
|
210
|
+
break
|
|
211
|
+
// \
|
|
212
|
+
case 92:
|
|
213
|
+
next()
|
|
214
|
+
break
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return position
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @param {number} type
|
|
222
|
+
* @param {number} index
|
|
223
|
+
* @return {number}
|
|
224
|
+
*/
|
|
225
|
+
export function commenter (type, index) {
|
|
226
|
+
while (next())
|
|
227
|
+
// //
|
|
228
|
+
if (type + character === 47 + 10)
|
|
229
|
+
break
|
|
230
|
+
// /*
|
|
231
|
+
else if (type + character === 42 + 42 && peek() === 47)
|
|
232
|
+
break
|
|
233
|
+
|
|
234
|
+
return '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @param {number} index
|
|
239
|
+
* @return {string}
|
|
240
|
+
*/
|
|
241
|
+
export function identifier (index) {
|
|
242
|
+
while (!token(peek()))
|
|
243
|
+
next()
|
|
244
|
+
|
|
245
|
+
return slice(index, position)
|
|
246
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {number}
|
|
3
|
+
* @return {number}
|
|
4
|
+
*/
|
|
5
|
+
export var abs = Math.abs
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {number}
|
|
9
|
+
* @return {string}
|
|
10
|
+
*/
|
|
11
|
+
export var from = String.fromCharCode
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {object}
|
|
15
|
+
* @return {object}
|
|
16
|
+
*/
|
|
17
|
+
export var assign = Object.assign
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} value
|
|
21
|
+
* @param {number} length
|
|
22
|
+
* @return {number}
|
|
23
|
+
*/
|
|
24
|
+
export function hash (value, length) {
|
|
25
|
+
return charat(value, 0) ^ 45 ? (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) : 0
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} value
|
|
30
|
+
* @return {string}
|
|
31
|
+
*/
|
|
32
|
+
export function trim (value) {
|
|
33
|
+
return value.trim()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} value
|
|
38
|
+
* @param {RegExp} pattern
|
|
39
|
+
* @return {string?}
|
|
40
|
+
*/
|
|
41
|
+
export function match (value, pattern) {
|
|
42
|
+
return (value = pattern.exec(value)) ? value[0] : value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} value
|
|
47
|
+
* @param {(string|RegExp)} pattern
|
|
48
|
+
* @param {string} replacement
|
|
49
|
+
* @return {string}
|
|
50
|
+
*/
|
|
51
|
+
export function replace (value, pattern, replacement) {
|
|
52
|
+
return value.replace(pattern, replacement)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} value
|
|
57
|
+
* @param {string} search
|
|
58
|
+
* @return {number}
|
|
59
|
+
*/
|
|
60
|
+
export function indexof (value, search) {
|
|
61
|
+
return value.indexOf(search)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} value
|
|
66
|
+
* @param {number} index
|
|
67
|
+
* @return {number}
|
|
68
|
+
*/
|
|
69
|
+
export function charat (value, index) {
|
|
70
|
+
return value.charCodeAt(index) | 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} value
|
|
75
|
+
* @param {number} begin
|
|
76
|
+
* @param {number} end
|
|
77
|
+
* @return {string}
|
|
78
|
+
*/
|
|
79
|
+
export function substr (value, begin, end) {
|
|
80
|
+
return value.slice(begin, end)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {string} value
|
|
85
|
+
* @return {number}
|
|
86
|
+
*/
|
|
87
|
+
export function strlen (value) {
|
|
88
|
+
return value.length
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {any[]} value
|
|
93
|
+
* @return {number}
|
|
94
|
+
*/
|
|
95
|
+
export function sizeof (value) {
|
|
96
|
+
return value.length
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {any} value
|
|
101
|
+
* @param {any[]} array
|
|
102
|
+
* @return {any}
|
|
103
|
+
*/
|
|
104
|
+
export function append (value, array) {
|
|
105
|
+
return array.push(value), value
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {string[]} array
|
|
110
|
+
* @param {function} callback
|
|
111
|
+
* @return {string}
|
|
112
|
+
*/
|
|
113
|
+
export function combine (array, callback) {
|
|
114
|
+
return array.map(callback).join('')
|
|
115
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-present Sultan Tarimo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|