@xpert-ai/plugin-motion 0.1.0 → 0.3.0

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 (157) hide show
  1. package/.xpertai-plugin/plugin.json +16 -6
  2. package/README.md +19 -5
  3. package/assets/upstream/UPSTREAM-BASELINE.md +27 -0
  4. package/assets/upstream/app/data/reicon-LICENSE.txt +21 -0
  5. package/dist/assets/upstream/UPSTREAM-BASELINE.md +27 -0
  6. package/dist/assets/upstream/app/data/reicon-LICENSE.txt +21 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +18 -9
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/constants.d.ts +7 -1
  12. package/dist/lib/constants.d.ts.map +1 -1
  13. package/dist/lib/constants.js +7 -0
  14. package/dist/lib/constants.js.map +1 -1
  15. package/dist/lib/entities/motion-export.entity.d.ts +13 -1
  16. package/dist/lib/entities/motion-export.entity.d.ts.map +1 -1
  17. package/dist/lib/entities/motion-export.entity.js +49 -1
  18. package/dist/lib/entities/motion-export.entity.js.map +1 -1
  19. package/dist/lib/entities/motion-project-version.entity.d.ts +3 -1
  20. package/dist/lib/entities/motion-project-version.entity.d.ts.map +1 -1
  21. package/dist/lib/entities/motion-project-version.entity.js +8 -0
  22. package/dist/lib/entities/motion-project-version.entity.js.map +1 -1
  23. package/dist/lib/entities/motion-project.entity.d.ts +4 -1
  24. package/dist/lib/entities/motion-project.entity.d.ts.map +1 -1
  25. package/dist/lib/entities/motion-project.entity.js +8 -0
  26. package/dist/lib/entities/motion-project.entity.js.map +1 -1
  27. package/dist/lib/hyperframes-composition.d.ts +16 -0
  28. package/dist/lib/hyperframes-composition.d.ts.map +1 -0
  29. package/dist/lib/hyperframes-composition.js +106 -0
  30. package/dist/lib/hyperframes-composition.js.map +1 -0
  31. package/dist/lib/motion-agent-response.d.ts +8 -0
  32. package/dist/lib/motion-agent-response.d.ts.map +1 -1
  33. package/dist/lib/motion-agent-response.js +13 -0
  34. package/dist/lib/motion-agent-response.js.map +1 -1
  35. package/dist/lib/motion-render.processor.d.ts +9 -0
  36. package/dist/lib/motion-render.processor.d.ts.map +1 -0
  37. package/dist/lib/motion-render.processor.js +25 -0
  38. package/dist/lib/motion-render.processor.js.map +1 -0
  39. package/dist/lib/motion-view.provider.d.ts.map +1 -1
  40. package/dist/lib/motion-view.provider.js +31 -2
  41. package/dist/lib/motion-view.provider.js.map +1 -1
  42. package/dist/lib/motion.middleware.d.ts.map +1 -1
  43. package/dist/lib/motion.middleware.js +20 -6
  44. package/dist/lib/motion.middleware.js.map +1 -1
  45. package/dist/lib/motion.plugin.d.ts.map +1 -1
  46. package/dist/lib/motion.plugin.js +2 -1
  47. package/dist/lib/motion.plugin.js.map +1 -1
  48. package/dist/lib/motion.service.d.ts +174 -3
  49. package/dist/lib/motion.service.d.ts.map +1 -1
  50. package/dist/lib/motion.service.js +376 -19
  51. package/dist/lib/motion.service.js.map +1 -1
  52. package/dist/lib/remote-components/motion-workbench/app.css +1 -1
  53. package/dist/lib/remote-components/motion-workbench/app.js +555 -946
  54. package/dist/lib/types.d.ts +26 -1
  55. package/dist/lib/types.d.ts.map +1 -1
  56. package/dist/lib/types.js.map +1 -1
  57. package/dist/sandbox-actions/hyperframes-render/action.json +10 -0
  58. package/dist/sandbox-actions/hyperframes-render/bundle/runner.mjs +188 -0
  59. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/darwin-arm64/README.md +3 -0
  60. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  61. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/darwin-arm64/package.json +20 -0
  62. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/linux-x64/README.md +3 -0
  63. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/linux-x64/bin/esbuild +0 -0
  64. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/linux-x64/package.json +20 -0
  65. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/LICENSE +190 -0
  66. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/README.md +156 -0
  67. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/distributed.js +156122 -0
  68. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/hyperframe.manifest.json +22 -0
  69. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/hyperframe.runtime.iife.js +356 -0
  70. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/index.js +169375 -0
  71. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/public-server.js +167618 -0
  72. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/services/healthWorkerThread.js +53 -0
  73. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/services/shaderTransitionWorker.js +606 -0
  74. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/package.json +109 -0
  75. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/LICENSE.md +21 -0
  76. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/README.md +3 -0
  77. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/bin/esbuild +0 -0
  78. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/install.js +289 -0
  79. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/lib/main.js +2532 -0
  80. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/package.json +49 -0
  81. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/LICENSE +20 -0
  82. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/README.md +36 -0
  83. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.browser.cjs +42 -0
  84. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.browser.js +42 -0
  85. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.cjs +44 -0
  86. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.js +44 -0
  87. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.native.js +35 -0
  88. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/package.json +12 -0
  89. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/bin/nanoid.cjs +55 -0
  90. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.browser.cjs +44 -0
  91. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.browser.js +44 -0
  92. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.cjs +57 -0
  93. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.d.cts +91 -0
  94. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.js +62 -0
  95. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/nanoid.js +1 -0
  96. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/non-secure/index.cjs +24 -0
  97. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/non-secure/index.js +24 -0
  98. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/non-secure/package.json +6 -0
  99. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/package.json +89 -0
  100. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/url-alphabet/index.cjs +4 -0
  101. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/url-alphabet/index.js +4 -0
  102. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/url-alphabet/package.json +6 -0
  103. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/LICENSE +15 -0
  104. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/README.md +21 -0
  105. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/package.json +25 -0
  106. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/picocolors.browser.js +4 -0
  107. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/picocolors.js +75 -0
  108. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/LICENSE +20 -0
  109. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/README.md +25 -0
  110. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/at-rule.js +25 -0
  111. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/comment.js +13 -0
  112. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/container.js +447 -0
  113. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/css-syntax-error.js +133 -0
  114. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/declaration.js +24 -0
  115. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/document.js +33 -0
  116. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/fromJSON.js +68 -0
  117. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/input.js +276 -0
  118. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/lazy-result.js +563 -0
  119. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/list.js +58 -0
  120. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/map-generator.js +376 -0
  121. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/no-work-result.js +137 -0
  122. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/node.js +456 -0
  123. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/parse.js +42 -0
  124. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/parser.js +618 -0
  125. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/postcss.d.mts +66 -0
  126. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/postcss.js +101 -0
  127. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/postcss.mjs +30 -0
  128. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/previous-map.js +161 -0
  129. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/processor.js +67 -0
  130. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/result.js +42 -0
  131. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/root.js +61 -0
  132. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/rule.js +27 -0
  133. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/stringifier.js +374 -0
  134. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/stringify.js +11 -0
  135. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/symbols.js +5 -0
  136. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/terminal-highlight.js +70 -0
  137. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/tokenize.js +270 -0
  138. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/warn-once.js +13 -0
  139. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/warning.js +37 -0
  140. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/package.json +88 -0
  141. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/LICENSE +28 -0
  142. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/README.md +765 -0
  143. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/array-set.js +121 -0
  144. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/base64-vlq.js +140 -0
  145. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/base64.js +67 -0
  146. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/binary-search.js +111 -0
  147. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/mapping-list.js +79 -0
  148. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/quick-sort.js +132 -0
  149. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/source-map-consumer.js +1188 -0
  150. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/source-map-generator.js +444 -0
  151. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/source-node.js +413 -0
  152. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/util.js +594 -0
  153. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/package.json +71 -0
  154. package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/source-map.js +8 -0
  155. package/dist/xpert-motion-assistant.yaml +240 -37
  156. package/package.json +19 -10
  157. package/skills/motion-agent-skill/SKILL.md +19 -7
@@ -0,0 +1,374 @@
1
+ 'use strict'
2
+
3
+ // Escapes sequences that could break out of an HTML <style> context.
4
+ // Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed
5
+ // correctly by all compliant CSS consumers.
6
+ const STYLE_TAG = /(<)(\/?style\b)/gi
7
+ const COMMENT_OPEN = /(<)(!--)/g
8
+
9
+ function escapeHTMLInCSS(str) {
10
+ if (typeof str !== 'string') return str
11
+ if (!str.includes('<')) return str
12
+ return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
13
+ }
14
+
15
+ const DEFAULT_RAW = {
16
+ after: '\n',
17
+ beforeClose: '\n',
18
+ beforeComment: '\n',
19
+ beforeDecl: '\n',
20
+ beforeOpen: ' ',
21
+ beforeRule: '\n',
22
+ colon: ': ',
23
+ commentLeft: ' ',
24
+ commentRight: ' ',
25
+ emptyBody: '',
26
+ indent: ' ',
27
+ semicolon: false
28
+ }
29
+
30
+ function capitalize(str) {
31
+ return str[0].toUpperCase() + str.slice(1)
32
+ }
33
+
34
+ class Stringifier {
35
+ constructor(builder) {
36
+ this.builder = builder
37
+ }
38
+
39
+ atrule(node, semicolon) {
40
+ let raws = node.raws
41
+ let name = '@' + node.name
42
+ let params = node.params ? this.rawValue(node, 'params') : ''
43
+
44
+ if (typeof raws.afterName !== 'undefined') {
45
+ name += raws.afterName
46
+ } else if (params) {
47
+ name += ' '
48
+ }
49
+
50
+ if (node.nodes) {
51
+ this.block(node, name + params)
52
+ } else {
53
+ let end = (raws.between || '') + (semicolon ? ';' : '')
54
+ this.builder(escapeHTMLInCSS(name + params + end), node)
55
+ }
56
+ }
57
+
58
+ beforeAfter(node, detect) {
59
+ let value
60
+ if (node.type === 'decl') {
61
+ value = this.raw(node, null, 'beforeDecl')
62
+ } else if (node.type === 'comment') {
63
+ value = this.raw(node, null, 'beforeComment')
64
+ } else if (detect === 'before') {
65
+ value = this.raw(node, null, 'beforeRule')
66
+ } else {
67
+ value = this.raw(node, null, 'beforeClose')
68
+ }
69
+
70
+ let buf = node.parent
71
+ let depth = 0
72
+ while (buf && buf.type !== 'root') {
73
+ depth += 1
74
+ buf = buf.parent
75
+ }
76
+
77
+ if (value.includes('\n')) {
78
+ let indent = this.raw(node, null, 'indent')
79
+ if (indent.length) {
80
+ for (let step = 0; step < depth; step++) value += indent
81
+ }
82
+ }
83
+
84
+ return value
85
+ }
86
+
87
+ block(node, start) {
88
+ let between = this.raw(node, 'between', 'beforeOpen')
89
+ this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
90
+
91
+ let after
92
+ if (node.nodes && node.nodes.length) {
93
+ this.body(node)
94
+ after = this.raw(node, 'after')
95
+ } else {
96
+ after = this.raw(node, 'after', 'emptyBody')
97
+ }
98
+
99
+ if (after) this.builder(escapeHTMLInCSS(after))
100
+ this.builder('}', node, 'end')
101
+ }
102
+
103
+ body(node) {
104
+ let nodes = node.nodes
105
+ let last = nodes.length - 1
106
+ while (last > 0) {
107
+ if (nodes[last].type !== 'comment') break
108
+ last -= 1
109
+ }
110
+
111
+ let semicolon = this.raw(node, 'semicolon')
112
+ let isDocument = node.type === 'document'
113
+ for (let i = 0; i < nodes.length; i++) {
114
+ let child = nodes[i]
115
+ let before = this.raw(child, 'before')
116
+ if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before))
117
+ this.stringify(child, last !== i || semicolon)
118
+ }
119
+ }
120
+
121
+ comment(node) {
122
+ let left = this.raw(node, 'left', 'commentLeft')
123
+ let right = this.raw(node, 'right', 'commentRight')
124
+ this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
125
+ }
126
+
127
+ decl(node, semicolon) {
128
+ let raws = node.raws
129
+ let between = this.raw(node, 'between', 'colon')
130
+
131
+ let string = node.prop + between + this.rawValue(node, 'value')
132
+
133
+ if (node.important) {
134
+ string += raws.important || ' !important'
135
+ }
136
+
137
+ if (semicolon) string += ';'
138
+ this.builder(escapeHTMLInCSS(string), node)
139
+ }
140
+
141
+ document(node) {
142
+ this.body(node)
143
+ }
144
+
145
+ raw(node, own, detect) {
146
+ let value
147
+ if (!detect) detect = own
148
+
149
+ // Already had
150
+ if (own) {
151
+ value = node.raws[own]
152
+ if (typeof value !== 'undefined') return value
153
+ }
154
+
155
+ let parent = node.parent
156
+
157
+ if (detect === 'before') {
158
+ // Hack for first rule in CSS
159
+ if (!parent || (parent.type === 'root' && parent.first === node)) {
160
+ return ''
161
+ }
162
+
163
+ // `root` nodes in `document` should use only their own raws
164
+ if (parent && parent.type === 'document') {
165
+ return ''
166
+ }
167
+ }
168
+
169
+ // Floating child without parent
170
+ if (!parent) return DEFAULT_RAW[detect]
171
+
172
+ // Detect style by other nodes
173
+ let root = node.root()
174
+ let cache = root.rawCache || (root.rawCache = {})
175
+ if (typeof cache[detect] !== 'undefined') {
176
+ return cache[detect]
177
+ }
178
+
179
+ if (detect === 'before' || detect === 'after') {
180
+ return this.beforeAfter(node, detect)
181
+ } else {
182
+ let method = 'raw' + capitalize(detect)
183
+ if (this[method]) {
184
+ value = this[method](root, node)
185
+ } else {
186
+ root.walk(i => {
187
+ value = i.raws[own]
188
+ if (typeof value !== 'undefined') return false
189
+ })
190
+ }
191
+ }
192
+
193
+ if (typeof value === 'undefined') value = DEFAULT_RAW[detect]
194
+
195
+ cache[detect] = value
196
+ return value
197
+ }
198
+
199
+ rawBeforeClose(root) {
200
+ let value
201
+ root.walk(i => {
202
+ if (i.nodes && i.nodes.length > 0) {
203
+ if (typeof i.raws.after !== 'undefined') {
204
+ value = i.raws.after
205
+ if (value.includes('\n')) {
206
+ value = value.replace(/[^\n]+$/, '')
207
+ }
208
+ return false
209
+ }
210
+ }
211
+ })
212
+ if (value) value = value.replace(/\S/g, '')
213
+ return value
214
+ }
215
+
216
+ rawBeforeComment(root, node) {
217
+ let value
218
+ root.walkComments(i => {
219
+ if (typeof i.raws.before !== 'undefined') {
220
+ value = i.raws.before
221
+ if (value.includes('\n')) {
222
+ value = value.replace(/[^\n]+$/, '')
223
+ }
224
+ return false
225
+ }
226
+ })
227
+ if (typeof value === 'undefined') {
228
+ value = this.raw(node, null, 'beforeDecl')
229
+ } else if (value) {
230
+ value = value.replace(/\S/g, '')
231
+ }
232
+ return value
233
+ }
234
+
235
+ rawBeforeDecl(root, node) {
236
+ let value
237
+ root.walkDecls(i => {
238
+ if (typeof i.raws.before !== 'undefined') {
239
+ value = i.raws.before
240
+ if (value.includes('\n')) {
241
+ value = value.replace(/[^\n]+$/, '')
242
+ }
243
+ return false
244
+ }
245
+ })
246
+ if (typeof value === 'undefined') {
247
+ value = this.raw(node, null, 'beforeRule')
248
+ } else if (value) {
249
+ value = value.replace(/\S/g, '')
250
+ }
251
+ return value
252
+ }
253
+
254
+ rawBeforeOpen(root) {
255
+ let value
256
+ root.walk(i => {
257
+ if (i.type !== 'decl') {
258
+ value = i.raws.between
259
+ if (typeof value !== 'undefined') return false
260
+ }
261
+ })
262
+ return value
263
+ }
264
+
265
+ rawBeforeRule(root) {
266
+ let value
267
+ root.walk(i => {
268
+ if (i.nodes && (i.parent !== root || root.first !== i)) {
269
+ if (typeof i.raws.before !== 'undefined') {
270
+ value = i.raws.before
271
+ if (value.includes('\n')) {
272
+ value = value.replace(/[^\n]+$/, '')
273
+ }
274
+ return false
275
+ }
276
+ }
277
+ })
278
+ if (value) value = value.replace(/\S/g, '')
279
+ return value
280
+ }
281
+
282
+ rawColon(root) {
283
+ let value
284
+ root.walkDecls(i => {
285
+ if (typeof i.raws.between !== 'undefined') {
286
+ value = i.raws.between.replace(/[^\s:]/g, '')
287
+ return false
288
+ }
289
+ })
290
+ return value
291
+ }
292
+
293
+ rawEmptyBody(root) {
294
+ let value
295
+ root.walk(i => {
296
+ if (i.nodes && i.nodes.length === 0) {
297
+ value = i.raws.after
298
+ if (typeof value !== 'undefined') return false
299
+ }
300
+ })
301
+ return value
302
+ }
303
+
304
+ rawIndent(root) {
305
+ if (root.raws.indent) return root.raws.indent
306
+ let value
307
+ root.walk(i => {
308
+ let p = i.parent
309
+ if (p && p !== root && p.parent && p.parent === root) {
310
+ if (typeof i.raws.before !== 'undefined') {
311
+ let parts = i.raws.before.split('\n')
312
+ value = parts[parts.length - 1]
313
+ value = value.replace(/\S/g, '')
314
+ return false
315
+ }
316
+ }
317
+ })
318
+ return value
319
+ }
320
+
321
+ rawSemicolon(root) {
322
+ let value
323
+ root.walk(i => {
324
+ if (i.nodes && i.nodes.length && i.last.type === 'decl') {
325
+ value = i.raws.semicolon
326
+ if (typeof value !== 'undefined') return false
327
+ }
328
+ })
329
+ return value
330
+ }
331
+
332
+ rawValue(node, prop) {
333
+ let value = node[prop]
334
+ let raw = node.raws[prop]
335
+ if (raw && raw.value === value) {
336
+ return raw.raw
337
+ }
338
+
339
+ return value
340
+ }
341
+
342
+ root(node) {
343
+ this.body(node)
344
+ if (node.raws.after) {
345
+ let after = node.raws.after
346
+ let isDocument = node.parent && node.parent.type === 'document'
347
+ this.builder(isDocument ? after : escapeHTMLInCSS(after))
348
+ }
349
+ }
350
+
351
+ rule(node) {
352
+ this.block(node, this.rawValue(node, 'selector'))
353
+ if (node.raws.ownSemicolon) {
354
+ this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')
355
+ }
356
+ }
357
+
358
+ stringify(node, semicolon) {
359
+ /* c8 ignore start */
360
+ if (!this[node.type]) {
361
+ throw new Error(
362
+ 'Unknown AST node type ' +
363
+ node.type +
364
+ '. ' +
365
+ 'Maybe you need to change PostCSS stringifier.'
366
+ )
367
+ }
368
+ /* c8 ignore stop */
369
+ this[node.type](node, semicolon)
370
+ }
371
+ }
372
+
373
+ module.exports = Stringifier
374
+ Stringifier.default = Stringifier
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ let Stringifier = require('./stringifier')
4
+
5
+ function stringify(node, builder) {
6
+ let str = new Stringifier(builder)
7
+ str.stringify(node)
8
+ }
9
+
10
+ module.exports = stringify
11
+ 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