@omnitron-dev/lumen 0.4.11 → 0.4.13

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 (188) hide show
  1. package/README.md +6 -0
  2. package/dist/config/define.d.ts.map +1 -1
  3. package/dist/config/define.js +1 -0
  4. package/dist/config/define.js.map +1 -1
  5. package/dist/config/schema.d.ts +2 -0
  6. package/dist/config/schema.d.ts.map +1 -1
  7. package/dist/config/schema.js +1 -0
  8. package/dist/config/schema.js.map +1 -1
  9. package/dist/corpus/routes.d.ts +1 -0
  10. package/dist/corpus/routes.d.ts.map +1 -1
  11. package/dist/corpus/routes.js +3 -0
  12. package/dist/corpus/routes.js.map +1 -1
  13. package/dist/search/index-builder.d.ts.map +1 -1
  14. package/dist/search/index-builder.js +8 -6
  15. package/dist/search/index-builder.js.map +1 -1
  16. package/dist/ssg/default-client.js +6 -2
  17. package/dist/ssg/default-client.js.map +1 -1
  18. package/dist/ssg/ssg-engine.d.ts.map +1 -1
  19. package/dist/ssg/ssg-engine.js +32 -16
  20. package/dist/ssg/ssg-engine.js.map +1 -1
  21. package/node_modules/fdir/LICENSE +7 -0
  22. package/node_modules/fdir/README.md +91 -0
  23. package/node_modules/fdir/dist/index.cjs +588 -0
  24. package/node_modules/fdir/dist/index.d.cts +155 -0
  25. package/node_modules/fdir/dist/index.d.mts +155 -0
  26. package/node_modules/fdir/dist/index.mjs +570 -0
  27. package/node_modules/fdir/package.json +103 -0
  28. package/node_modules/nanoid/LICENSE +20 -0
  29. package/node_modules/nanoid/README.md +39 -0
  30. package/node_modules/nanoid/async/index.browser.cjs +43 -0
  31. package/node_modules/nanoid/async/index.browser.js +43 -0
  32. package/node_modules/nanoid/async/index.cjs +47 -0
  33. package/node_modules/nanoid/async/index.d.cts +56 -0
  34. package/node_modules/nanoid/async/index.d.ts +56 -0
  35. package/node_modules/nanoid/async/index.js +47 -0
  36. package/node_modules/nanoid/async/index.native.js +38 -0
  37. package/node_modules/nanoid/async/package.json +12 -0
  38. package/node_modules/nanoid/bin/nanoid.cjs +55 -0
  39. package/node_modules/nanoid/index.browser.cjs +45 -0
  40. package/node_modules/nanoid/index.browser.js +45 -0
  41. package/node_modules/nanoid/index.cjs +63 -0
  42. package/node_modules/nanoid/index.d.cts +91 -0
  43. package/node_modules/nanoid/index.d.ts +91 -0
  44. package/node_modules/nanoid/index.js +63 -0
  45. package/node_modules/nanoid/nanoid.js +1 -0
  46. package/node_modules/nanoid/non-secure/index.cjs +24 -0
  47. package/node_modules/nanoid/non-secure/index.d.ts +33 -0
  48. package/node_modules/nanoid/non-secure/index.js +24 -0
  49. package/node_modules/nanoid/non-secure/package.json +6 -0
  50. package/node_modules/nanoid/package.json +89 -0
  51. package/node_modules/nanoid/url-alphabet/index.cjs +4 -0
  52. package/node_modules/nanoid/url-alphabet/index.js +4 -0
  53. package/node_modules/nanoid/url-alphabet/package.json +6 -0
  54. package/node_modules/picocolors/LICENSE +15 -0
  55. package/node_modules/picocolors/README.md +21 -0
  56. package/node_modules/picocolors/package.json +25 -0
  57. package/node_modules/picocolors/picocolors.browser.js +4 -0
  58. package/node_modules/picocolors/picocolors.d.ts +5 -0
  59. package/node_modules/picocolors/picocolors.js +75 -0
  60. package/node_modules/picocolors/types.d.ts +51 -0
  61. package/node_modules/picomatch/LICENSE +21 -0
  62. package/node_modules/picomatch/README.md +743 -0
  63. package/node_modules/picomatch/index.js +17 -0
  64. package/node_modules/picomatch/lib/constants.js +184 -0
  65. package/node_modules/picomatch/lib/parse.js +1439 -0
  66. package/node_modules/picomatch/lib/picomatch.js +361 -0
  67. package/node_modules/picomatch/lib/scan.js +403 -0
  68. package/node_modules/picomatch/lib/utils.js +72 -0
  69. package/node_modules/picomatch/package.json +83 -0
  70. package/node_modules/picomatch/posix.js +3 -0
  71. package/node_modules/postcss/LICENSE +20 -0
  72. package/node_modules/postcss/README.md +27 -0
  73. package/node_modules/postcss/lib/at-rule.d.ts +139 -0
  74. package/node_modules/postcss/lib/at-rule.js +25 -0
  75. package/node_modules/postcss/lib/comment.d.ts +67 -0
  76. package/node_modules/postcss/lib/comment.js +13 -0
  77. package/node_modules/postcss/lib/container.d.ts +474 -0
  78. package/node_modules/postcss/lib/container.js +494 -0
  79. package/node_modules/postcss/lib/css-syntax-error.d.ts +247 -0
  80. package/node_modules/postcss/lib/css-syntax-error.js +133 -0
  81. package/node_modules/postcss/lib/declaration.d.ts +150 -0
  82. package/node_modules/postcss/lib/declaration.js +24 -0
  83. package/node_modules/postcss/lib/document.d.ts +68 -0
  84. package/node_modules/postcss/lib/document.js +33 -0
  85. package/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  86. package/node_modules/postcss/lib/fromJSON.js +107 -0
  87. package/node_modules/postcss/lib/input.d.ts +226 -0
  88. package/node_modules/postcss/lib/input.js +282 -0
  89. package/node_modules/postcss/lib/lazy-result.d.ts +189 -0
  90. package/node_modules/postcss/lib/lazy-result.js +626 -0
  91. package/node_modules/postcss/lib/list.d.ts +60 -0
  92. package/node_modules/postcss/lib/list.js +79 -0
  93. package/node_modules/postcss/lib/map-generator.js +383 -0
  94. package/node_modules/postcss/lib/no-work-result.d.ts +45 -0
  95. package/node_modules/postcss/lib/no-work-result.js +137 -0
  96. package/node_modules/postcss/lib/node.d.ts +555 -0
  97. package/node_modules/postcss/lib/node.js +494 -0
  98. package/node_modules/postcss/lib/parse.d.ts +9 -0
  99. package/node_modules/postcss/lib/parse.js +42 -0
  100. package/node_modules/postcss/lib/parser.js +626 -0
  101. package/node_modules/postcss/lib/postcss.d.mts +66 -0
  102. package/node_modules/postcss/lib/postcss.d.ts +464 -0
  103. package/node_modules/postcss/lib/postcss.js +101 -0
  104. package/node_modules/postcss/lib/postcss.mjs +30 -0
  105. package/node_modules/postcss/lib/previous-map.d.ts +80 -0
  106. package/node_modules/postcss/lib/previous-map.js +176 -0
  107. package/node_modules/postcss/lib/processor.d.ts +114 -0
  108. package/node_modules/postcss/lib/processor.js +67 -0
  109. package/node_modules/postcss/lib/result.d.ts +204 -0
  110. package/node_modules/postcss/lib/result.js +42 -0
  111. package/node_modules/postcss/lib/root.d.ts +86 -0
  112. package/node_modules/postcss/lib/root.js +76 -0
  113. package/node_modules/postcss/lib/rule.d.ts +126 -0
  114. package/node_modules/postcss/lib/rule.js +27 -0
  115. package/node_modules/postcss/lib/stringifier.d.ts +45 -0
  116. package/node_modules/postcss/lib/stringifier.js +457 -0
  117. package/node_modules/postcss/lib/stringify.d.ts +9 -0
  118. package/node_modules/postcss/lib/stringify.js +93 -0
  119. package/node_modules/postcss/lib/symbols.js +5 -0
  120. package/node_modules/postcss/lib/terminal-highlight.js +70 -0
  121. package/node_modules/postcss/lib/tokenize.js +270 -0
  122. package/node_modules/postcss/lib/warn-once.js +13 -0
  123. package/node_modules/postcss/lib/warning.d.ts +146 -0
  124. package/node_modules/postcss/lib/warning.js +48 -0
  125. package/node_modules/postcss/package.json +88 -0
  126. package/node_modules/source-map-js/LICENSE +28 -0
  127. package/node_modules/source-map-js/README.md +765 -0
  128. package/node_modules/source-map-js/lib/array-set.js +121 -0
  129. package/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  130. package/node_modules/source-map-js/lib/base64.js +67 -0
  131. package/node_modules/source-map-js/lib/binary-search.js +111 -0
  132. package/node_modules/source-map-js/lib/mapping-list.js +79 -0
  133. package/node_modules/source-map-js/lib/quick-sort.js +141 -0
  134. package/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  135. package/node_modules/source-map-js/lib/source-map-consumer.js +1236 -0
  136. package/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  137. package/node_modules/source-map-js/lib/source-map-generator.js +446 -0
  138. package/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  139. package/node_modules/source-map-js/lib/source-node.js +420 -0
  140. package/node_modules/source-map-js/lib/util.js +594 -0
  141. package/node_modules/source-map-js/package.json +71 -0
  142. package/node_modules/source-map-js/source-map.d.ts +104 -0
  143. package/node_modules/source-map-js/source-map.js +8 -0
  144. package/{LICENSE → node_modules/tinyglobby/LICENSE} +1 -1
  145. package/node_modules/tinyglobby/README.md +25 -0
  146. package/node_modules/tinyglobby/dist/index.cjs +335 -0
  147. package/node_modules/tinyglobby/dist/index.d.cts +148 -0
  148. package/node_modules/tinyglobby/dist/index.d.mts +148 -0
  149. package/node_modules/tinyglobby/dist/index.mjs +307 -0
  150. package/node_modules/tinyglobby/package.json +70 -0
  151. package/node_modules/vite/LICENSE.md +2084 -0
  152. package/node_modules/vite/README.md +20 -0
  153. package/node_modules/vite/bin/openChrome.js +68 -0
  154. package/node_modules/vite/bin/vite.js +90 -0
  155. package/node_modules/vite/client.d.ts +285 -0
  156. package/node_modules/vite/dist/client/bundledDevClient.mjs +1642 -0
  157. package/node_modules/vite/dist/client/client.mjs +1331 -0
  158. package/node_modules/vite/dist/client/env.mjs +18 -0
  159. package/node_modules/vite/dist/node/chunks/build.js +5833 -0
  160. package/node_modules/vite/dist/node/chunks/dist.js +7029 -0
  161. package/node_modules/vite/dist/node/chunks/lib.js +371 -0
  162. package/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +95 -0
  163. package/node_modules/vite/dist/node/chunks/node.js +38364 -0
  164. package/node_modules/vite/dist/node/chunks/postcss-import.js +465 -0
  165. package/node_modules/vite/dist/node/cli.js +849 -0
  166. package/node_modules/vite/dist/node/index.d.ts +4064 -0
  167. package/node_modules/vite/dist/node/index.js +1 -0
  168. package/node_modules/vite/dist/node/internal.d.ts +2 -0
  169. package/node_modules/vite/dist/node/internal.js +1 -0
  170. package/node_modules/vite/dist/node/module-runner.d.ts +314 -0
  171. package/node_modules/vite/dist/node/module-runner.js +1296 -0
  172. package/node_modules/vite/misc/false.js +1 -0
  173. package/node_modules/vite/misc/true.js +1 -0
  174. package/node_modules/vite/package.json +195 -0
  175. package/node_modules/vite/types/customEvent.d.ts +83 -0
  176. package/node_modules/vite/types/hmrPayload.d.ts +96 -0
  177. package/node_modules/vite/types/hot.d.ts +39 -0
  178. package/node_modules/vite/types/import-meta.d.ts +5 -0
  179. package/node_modules/vite/types/importGlob.d.ts +131 -0
  180. package/node_modules/vite/types/importMeta.d.ts +30 -0
  181. package/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
  182. package/node_modules/vite/types/internal/devtoolsOptions.d.ts +9 -0
  183. package/node_modules/vite/types/internal/esbuildOptions.d.ts +28 -0
  184. package/node_modules/vite/types/internal/lightningcssOptions.d.ts +18 -0
  185. package/node_modules/vite/types/internal/rollupTypeCompat.d.ts +24 -0
  186. package/node_modules/vite/types/internal/terserOptions.d.ts +11 -0
  187. package/node_modules/vite/types/metadata.d.ts +47 -0
  188. package/package.json +15 -7
@@ -0,0 +1,457 @@
1
+ 'use strict'
2
+
3
+ // Characters that end an at-rule name, mirroring RE_AT_END in the tokenizer.
4
+ // Params starting with anything else need a space to stay separate tokens.
5
+ const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/
6
+
7
+ const DEFAULT_RAW = {
8
+ after: '\n',
9
+ beforeClose: '\n',
10
+ beforeComment: '\n',
11
+ beforeDecl: '\n',
12
+ beforeOpen: ' ',
13
+ beforeRule: '\n',
14
+ colon: ': ',
15
+ commentLeft: ' ',
16
+ commentRight: ' ',
17
+ emptyBody: '',
18
+ indent: ' ',
19
+ semicolon: false
20
+ }
21
+
22
+ function capitalize(str) {
23
+ return str[0].toUpperCase() + str.slice(1)
24
+ }
25
+
26
+ function atruleStart(str, node) {
27
+ let name = '@' + node.name
28
+ let params = node.params ? str.rawValue(node, 'params') : ''
29
+ let afterName = node.raws.afterName
30
+
31
+ if (typeof afterName === 'undefined') {
32
+ afterName = params ? ' ' : ''
33
+ } else if (afterName === '' && params && !AT_NAME_END.test(params[0])) {
34
+ afterName = ' '
35
+ }
36
+
37
+ return name + afterName + params
38
+ }
39
+
40
+ // `*--x` is not a custom property: the parser checks the first token, and the
41
+ // `*`/`_` hack prefix moves from `prop` into `before` only after that. A free
42
+ // semicolon in front of the declaration also ends up in `before`.
43
+ function isCustomProperty(node) {
44
+ if (!node.prop.startsWith('--')) return false
45
+ let before = node.raws.before
46
+ return typeof before === 'undefined' || !/[^\s;]$/.test(before)
47
+ }
48
+
49
+ function pushBody(str, stack, node) {
50
+ let nodes = node.nodes
51
+ let last = nodes.length - 1
52
+ while (last > 0) {
53
+ if (nodes[last].type !== 'comment') break
54
+ last -= 1
55
+ }
56
+
57
+ let semicolon = str.raw(node, 'semicolon')
58
+ let isDocument = node.type === 'document'
59
+ for (let i = nodes.length - 1; i >= 0; i--) {
60
+ let child = nodes[i]
61
+ let childSemicolon = last !== i || semicolon
62
+ // A childless at-rule or a custom property declaration that still has
63
+ // following siblings must be terminated. Without the semicolon those
64
+ // trailing comments are folded into the at-rule's prelude or the custom
65
+ // property's value and disappear when the output is re-parsed.
66
+ if (
67
+ !childSemicolon &&
68
+ i < nodes.length - 1 &&
69
+ ((child.type === 'atrule' && !child.nodes) ||
70
+ (child.type === 'decl' && isCustomProperty(child)))
71
+ ) {
72
+ childSemicolon = true
73
+ }
74
+ stack.push({
75
+ document: isDocument,
76
+ node: child,
77
+ semicolon: childSemicolon
78
+ })
79
+ }
80
+ }
81
+
82
+ function pushBlock(str, stack, node, start) {
83
+ let between = str.raw(node, 'between', 'beforeOpen')
84
+ str.builder(start + between + '{', node, 'start')
85
+
86
+ let hasNodes = node.nodes && node.nodes.length
87
+ let close = () => {
88
+ let after = hasNodes
89
+ ? str.raw(node, 'after')
90
+ : str.raw(node, 'after', 'emptyBody')
91
+ if (after) str.builder(after)
92
+ str.builder('}', node, 'end')
93
+ if (node.type === 'rule' && node.raws.ownSemicolon) {
94
+ str.builder(node.raws.ownSemicolon, node, 'end')
95
+ }
96
+ }
97
+
98
+ if (hasNodes) {
99
+ stack.push(close)
100
+ pushBody(str, stack, node)
101
+ } else {
102
+ close()
103
+ }
104
+ }
105
+
106
+ class Stringifier {
107
+ constructor(builder) {
108
+ this.builder = builder
109
+ }
110
+
111
+ atrule(node, semicolon) {
112
+ let start = atruleStart(this, node)
113
+ if (node.nodes) {
114
+ this.block(node, start)
115
+ } else {
116
+ let end = (node.raws.between || '') + (semicolon ? ';' : '')
117
+ this.builder(start + end, node)
118
+ }
119
+ }
120
+
121
+ beforeAfter(node, detect) {
122
+ let value
123
+ if (node.type === 'decl') {
124
+ value = this.raw(node, null, 'beforeDecl')
125
+ } else if (node.type === 'comment') {
126
+ value = this.raw(node, null, 'beforeComment')
127
+ } else if (detect === 'before') {
128
+ value = this.raw(node, null, 'beforeRule')
129
+ } else {
130
+ value = this.raw(node, null, 'beforeClose')
131
+ }
132
+
133
+ let buf = node.parent
134
+ let depth = 0
135
+ while (buf && buf.type !== 'root') {
136
+ depth += 1
137
+ buf = buf.parent
138
+ }
139
+
140
+ if (value.includes('\n')) {
141
+ let indent = this.raw(node, null, 'indent')
142
+ if (indent.length) {
143
+ for (let step = 0; step < depth; step++) value += indent
144
+ }
145
+ }
146
+
147
+ return value
148
+ }
149
+
150
+ block(node, start) {
151
+ let between = this.raw(node, 'between', 'beforeOpen')
152
+ this.builder(start + between + '{', node, 'start')
153
+
154
+ let after
155
+ if (node.nodes && node.nodes.length) {
156
+ this.body(node)
157
+ after = this.raw(node, 'after')
158
+ } else {
159
+ after = this.raw(node, 'after', 'emptyBody')
160
+ }
161
+
162
+ if (after) this.builder(after)
163
+ this.builder('}', node, 'end')
164
+ }
165
+
166
+ body(node) {
167
+ // Rules and at-rules are expanded into an explicit stack instead of
168
+ // recursive `stringify()` calls to survive deeply nested trees.
169
+ // If a subclass changes the traversal methods, its children go
170
+ // through `stringify()` to keep the override in charge.
171
+ let proto = Stringifier.prototype
172
+ let expandable = ['atrule', 'block', 'body', 'rule', 'stringify'].every(
173
+ method => this[method] === proto[method]
174
+ )
175
+
176
+ let stack = []
177
+ pushBody(this, stack, node)
178
+
179
+ while (stack.length > 0) {
180
+ let entry = stack.pop()
181
+ if (typeof entry === 'function') {
182
+ entry()
183
+ continue
184
+ }
185
+
186
+ let child = entry.node
187
+ let before = this.raw(child, 'before')
188
+ if (before) {
189
+ this.builder(before)
190
+ }
191
+
192
+ if (expandable && child.type === 'rule') {
193
+ pushBlock(this, stack, child, this.rawValue(child, 'selector'))
194
+ } else if (expandable && child.type === 'atrule' && child.nodes) {
195
+ pushBlock(this, stack, child, atruleStart(this, child))
196
+ } else {
197
+ this.stringify(child, entry.semicolon)
198
+ }
199
+ }
200
+ }
201
+
202
+ comment(node) {
203
+ let left = this.raw(node, 'left', 'commentLeft')
204
+ let right = this.raw(node, 'right', 'commentRight')
205
+ this.builder('/*' + left + node.text + right + '*/', node)
206
+ }
207
+
208
+ decl(node, semicolon) {
209
+ let raws = node.raws
210
+ let between = this.raw(node, 'between', 'colon')
211
+
212
+ let string = node.prop + between + this.rawValue(node, 'value')
213
+
214
+ if (node.important) {
215
+ string += raws.important || ' !important'
216
+ }
217
+
218
+ if (semicolon) string += ';'
219
+ this.builder(string, node)
220
+ }
221
+
222
+ document(node) {
223
+ this.body(node)
224
+ }
225
+
226
+ raw(node, own, detect) {
227
+ let value
228
+ if (!detect) detect = own
229
+
230
+ // Already had
231
+ if (own) {
232
+ value = node.raws[own]
233
+ if (typeof value !== 'undefined') return value
234
+ }
235
+
236
+ let parent = node.parent
237
+
238
+ if (detect === 'before') {
239
+ // Hack for first rule in CSS
240
+ if (!parent || (parent.type === 'root' && parent.first === node)) {
241
+ return ''
242
+ }
243
+
244
+ // `root` nodes in `document` should use only their own raws
245
+ if (parent && parent.type === 'document') {
246
+ return ''
247
+ }
248
+ }
249
+
250
+ // Floating child without parent
251
+ if (!parent) return DEFAULT_RAW[detect]
252
+
253
+ // Detect style by other nodes
254
+ let root = node.root()
255
+ let cache = root.rawCache || (root.rawCache = {})
256
+ if (typeof cache[detect] !== 'undefined') {
257
+ return cache[detect]
258
+ }
259
+
260
+ if (detect === 'before' || detect === 'after') {
261
+ return this.beforeAfter(node, detect)
262
+ } else {
263
+ let method = 'raw' + capitalize(detect)
264
+ if (this[method]) {
265
+ value = this[method](root, node)
266
+ } else {
267
+ root.walk(i => {
268
+ value = i.raws[own]
269
+ if (typeof value !== 'undefined') return false
270
+ })
271
+ }
272
+ }
273
+
274
+ if (typeof value === 'undefined') value = DEFAULT_RAW[detect]
275
+
276
+ cache[detect] = value
277
+ return value
278
+ }
279
+
280
+ rawBeforeClose(root) {
281
+ let value
282
+ root.walk(i => {
283
+ if (i.nodes && i.nodes.length > 0) {
284
+ if (typeof i.raws.after !== 'undefined') {
285
+ value = i.raws.after
286
+ if (value.includes('\n')) {
287
+ value = value.replace(/[^\n]+$/, '')
288
+ }
289
+ return false
290
+ }
291
+ }
292
+ })
293
+ if (value) value = value.replace(/\S/g, '')
294
+ return value
295
+ }
296
+
297
+ rawBeforeComment(root, node) {
298
+ let value
299
+ root.walkComments(i => {
300
+ if (typeof i.raws.before !== 'undefined') {
301
+ value = i.raws.before
302
+ if (value.includes('\n')) {
303
+ value = value.replace(/[^\n]+$/, '')
304
+ }
305
+ return false
306
+ }
307
+ })
308
+ if (typeof value === 'undefined') {
309
+ value = this.raw(node, null, 'beforeDecl')
310
+ } else if (value) {
311
+ value = value.replace(/\S/g, '')
312
+ }
313
+ return value
314
+ }
315
+
316
+ rawBeforeDecl(root, node) {
317
+ let value
318
+ root.walkDecls(i => {
319
+ if (typeof i.raws.before !== 'undefined') {
320
+ value = i.raws.before
321
+ if (value.includes('\n')) {
322
+ value = value.replace(/[^\n]+$/, '')
323
+ }
324
+ return false
325
+ }
326
+ })
327
+ if (typeof value === 'undefined') {
328
+ value = this.raw(node, null, 'beforeRule')
329
+ } else if (value) {
330
+ value = value.replace(/\S/g, '')
331
+ }
332
+ return value
333
+ }
334
+
335
+ rawBeforeOpen(root) {
336
+ let value
337
+ root.walk(i => {
338
+ if (i.type !== 'decl') {
339
+ value = i.raws.between
340
+ if (typeof value !== 'undefined') return false
341
+ }
342
+ })
343
+ return value
344
+ }
345
+
346
+ rawBeforeRule(root) {
347
+ let value
348
+ root.walk(i => {
349
+ if (i.nodes && (i.parent !== root || root.first !== i)) {
350
+ if (typeof i.raws.before !== 'undefined') {
351
+ value = i.raws.before
352
+ if (value.includes('\n')) {
353
+ value = value.replace(/[^\n]+$/, '')
354
+ }
355
+ return false
356
+ }
357
+ }
358
+ })
359
+ if (value) value = value.replace(/\S/g, '')
360
+ return value
361
+ }
362
+
363
+ rawColon(root) {
364
+ let value
365
+ root.walkDecls(i => {
366
+ if (typeof i.raws.between !== 'undefined') {
367
+ value = i.raws.between.replace(/[^\s:]/g, '')
368
+ return false
369
+ }
370
+ })
371
+ return value
372
+ }
373
+
374
+ rawEmptyBody(root) {
375
+ let value
376
+ root.walk(i => {
377
+ if (i.nodes && i.nodes.length === 0) {
378
+ value = i.raws.after
379
+ if (typeof value !== 'undefined') return false
380
+ }
381
+ })
382
+ return value
383
+ }
384
+
385
+ rawIndent(root) {
386
+ if (root.raws.indent) return root.raws.indent
387
+ let value
388
+ root.walk(i => {
389
+ let p = i.parent
390
+ if (p && p !== root && p.parent && p.parent === root) {
391
+ if (typeof i.raws.before !== 'undefined') {
392
+ let parts = i.raws.before.split('\n')
393
+ value = parts[parts.length - 1]
394
+ value = value.replace(/\S/g, '')
395
+ return false
396
+ }
397
+ }
398
+ })
399
+ return value
400
+ }
401
+
402
+ rawSemicolon(root) {
403
+ let value
404
+ root.walk(i => {
405
+ if (i.nodes && i.nodes.length && i.last.type === 'decl') {
406
+ value = i.raws.semicolon
407
+ if (typeof value !== 'undefined') return false
408
+ }
409
+ })
410
+ return value
411
+ }
412
+
413
+ rawValue(node, prop) {
414
+ let value = node[prop]
415
+ let raw = node.raws[prop]
416
+ if (raw && raw.value === value) {
417
+ return raw.raw
418
+ }
419
+
420
+ return value
421
+ }
422
+
423
+ root(node) {
424
+ let inDocument = node.parent && node.parent.type === 'document'
425
+ if (!inDocument && node.source && node.source.input.hasBOM) {
426
+ this.builder('\uFEFF', node, 'start')
427
+ }
428
+ this.body(node)
429
+ if (node.raws.after) {
430
+ this.builder(node.raws.after)
431
+ }
432
+ }
433
+
434
+ rule(node) {
435
+ this.block(node, this.rawValue(node, 'selector'))
436
+ if (node.raws.ownSemicolon) {
437
+ this.builder(node.raws.ownSemicolon, node, 'end')
438
+ }
439
+ }
440
+
441
+ stringify(node, semicolon) {
442
+ /* c8 ignore start */
443
+ if (!this[node.type]) {
444
+ throw new Error(
445
+ 'Unknown AST node type ' +
446
+ node.type +
447
+ '. ' +
448
+ 'Maybe you need to change PostCSS stringifier.'
449
+ )
450
+ }
451
+ /* c8 ignore stop */
452
+ this[node.type](node, semicolon)
453
+ }
454
+ }
455
+
456
+ module.exports = Stringifier
457
+ Stringifier.default = Stringifier
@@ -0,0 +1,9 @@
1
+ import { Stringifier } from './postcss.js'
2
+
3
+ interface Stringify extends Stringifier {
4
+ default: Stringify
5
+ }
6
+
7
+ declare let stringify: Stringify
8
+
9
+ export = stringify
@@ -0,0 +1,93 @@
1
+ 'use strict'
2
+
3
+ let Stringifier = require('./stringifier')
4
+
5
+ const STYLE_TAG = /(<)(\/?style\b)/gi
6
+ const COMMENT_OPEN = /(<)(!--)/g
7
+
8
+ function escapeHTMLInCSS(str) {
9
+ if (!str.includes('<')) return str
10
+ return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
11
+ }
12
+
13
+ function cutEscaped(chunks, css, escaped) {
14
+ let parts = []
15
+ let at = 0
16
+ let into = 0
17
+ for (let i = 0; i < chunks.length; i += 3) {
18
+ let from = into
19
+ let end = at + chunks[i].length
20
+ while (at < end) {
21
+ if (css[at] === escaped[into]) {
22
+ at += 1
23
+ into += 1
24
+ } else {
25
+ // The `<` of this pair was replaced by the `\3c ` in front of it
26
+ at += 1
27
+ into += 4
28
+ }
29
+ }
30
+ parts.push(escaped.slice(from, into))
31
+ }
32
+ return parts
33
+ }
34
+
35
+ class SafeStringifier extends Stringifier {
36
+ escapeHTML(print) {
37
+ let builder = this.builder
38
+ let chunks, css
39
+ this.builder = (str, child, type) => {
40
+ if (chunks) {
41
+ css += str
42
+ chunks.push(str, child, type)
43
+ } else if (str.includes('<')) {
44
+ // Dangerous sequences start with `<`, so everything before
45
+ // the first `<` is safe to pass through. The rest is buffered
46
+ // to escape it as a whole.
47
+ css = str
48
+ chunks = [str, child, type]
49
+ } else {
50
+ builder(str, child, type)
51
+ }
52
+ }
53
+ print()
54
+ this.builder = builder
55
+ if (!chunks) return
56
+
57
+ let escaped = escapeHTMLInCSS(css)
58
+ if (escaped === css) {
59
+ // Keep the chunks to get a precise source map
60
+ for (let i = 0; i < chunks.length; i += 3) {
61
+ builder(chunks[i], chunks[i + 1], chunks[i + 2])
62
+ }
63
+ } else {
64
+ let parts = cutEscaped(chunks, css, escaped)
65
+ for (let i = 0; i < chunks.length; i += 3) {
66
+ builder(parts[i / 3], chunks[i + 1], chunks[i + 2])
67
+ }
68
+ }
69
+ }
70
+
71
+ root(node) {
72
+ if (node.parent && node.parent.type === 'document') {
73
+ // Document raws around the Root hold markup and are kept as is since CSS in Document can be marked with <style>
74
+ this.escapeHTML(() => this.body(node))
75
+ if (node.raws.after) this.builder(node.raws.after)
76
+ } else {
77
+ this.escapeHTML(() => super.root(node))
78
+ }
79
+ }
80
+ }
81
+
82
+ function stringify(node, builder) {
83
+ let str = new SafeStringifier(builder)
84
+ // Root escapes its own output and keeps markup in Document raws
85
+ if (node.type === 'root' || node.type === 'document') {
86
+ str.stringify(node)
87
+ } else {
88
+ str.escapeHTML(() => str.stringify(node))
89
+ }
90
+ }
91
+
92
+ module.exports = stringify
93
+ stringify.default = stringify
@@ -0,0 +1,5 @@
1
+ 'use strict'
2
+
3
+ module.exports.isClean = Symbol('isClean')
4
+
5
+ module.exports.my = Symbol('my')
@@ -0,0 +1,70 @@
1
+ 'use strict'
2
+
3
+ let pico = require('picocolors')
4
+
5
+ let tokenizer = require('./tokenize')
6
+
7
+ let Input
8
+
9
+ function registerInput(dependant) {
10
+ Input = dependant
11
+ }
12
+
13
+ const HIGHLIGHT_THEME = {
14
+ ';': pico.yellow,
15
+ ':': pico.yellow,
16
+ '(': pico.cyan,
17
+ ')': pico.cyan,
18
+ '[': pico.yellow,
19
+ ']': pico.yellow,
20
+ '{': pico.yellow,
21
+ '}': pico.yellow,
22
+ 'at-word': pico.cyan,
23
+ 'brackets': pico.cyan,
24
+ 'call': pico.cyan,
25
+ 'class': pico.yellow,
26
+ 'comment': pico.gray,
27
+ 'hash': pico.magenta,
28
+ 'string': pico.green
29
+ }
30
+
31
+ function getTokenType([type, value], processor) {
32
+ if (type === 'word') {
33
+ if (value[0] === '.') {
34
+ return 'class'
35
+ }
36
+ if (value[0] === '#') {
37
+ return 'hash'
38
+ }
39
+ }
40
+
41
+ if (!processor.endOfFile()) {
42
+ let next = processor.nextToken()
43
+ processor.back(next)
44
+ if (next[0] === 'brackets' || next[0] === '(') return 'call'
45
+ }
46
+
47
+ return type
48
+ }
49
+
50
+ function terminalHighlight(css) {
51
+ let processor = tokenizer(new Input(css), { ignoreErrors: true })
52
+ let result = ''
53
+ while (!processor.endOfFile()) {
54
+ let token = processor.nextToken()
55
+ let color = HIGHLIGHT_THEME[getTokenType(token, processor)]
56
+ if (color) {
57
+ result += token[1]
58
+ .split(/\r?\n/)
59
+ .map(i => color(i))
60
+ .join('\n')
61
+ } else {
62
+ result += token[1]
63
+ }
64
+ }
65
+ return result
66
+ }
67
+
68
+ terminalHighlight.registerInput = registerInput
69
+
70
+ module.exports = terminalHighlight