@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.
- package/.xpertai-plugin/plugin.json +16 -6
- package/README.md +19 -5
- package/assets/upstream/UPSTREAM-BASELINE.md +27 -0
- package/assets/upstream/app/data/reicon-LICENSE.txt +21 -0
- package/dist/assets/upstream/UPSTREAM-BASELINE.md +27 -0
- package/dist/assets/upstream/app/data/reicon-LICENSE.txt +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/constants.d.ts +7 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +7 -0
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/entities/motion-export.entity.d.ts +13 -1
- package/dist/lib/entities/motion-export.entity.d.ts.map +1 -1
- package/dist/lib/entities/motion-export.entity.js +49 -1
- package/dist/lib/entities/motion-export.entity.js.map +1 -1
- package/dist/lib/entities/motion-project-version.entity.d.ts +3 -1
- package/dist/lib/entities/motion-project-version.entity.d.ts.map +1 -1
- package/dist/lib/entities/motion-project-version.entity.js +8 -0
- package/dist/lib/entities/motion-project-version.entity.js.map +1 -1
- package/dist/lib/entities/motion-project.entity.d.ts +4 -1
- package/dist/lib/entities/motion-project.entity.d.ts.map +1 -1
- package/dist/lib/entities/motion-project.entity.js +8 -0
- package/dist/lib/entities/motion-project.entity.js.map +1 -1
- package/dist/lib/hyperframes-composition.d.ts +16 -0
- package/dist/lib/hyperframes-composition.d.ts.map +1 -0
- package/dist/lib/hyperframes-composition.js +106 -0
- package/dist/lib/hyperframes-composition.js.map +1 -0
- package/dist/lib/motion-agent-response.d.ts +8 -0
- package/dist/lib/motion-agent-response.d.ts.map +1 -1
- package/dist/lib/motion-agent-response.js +13 -0
- package/dist/lib/motion-agent-response.js.map +1 -1
- package/dist/lib/motion-render.processor.d.ts +9 -0
- package/dist/lib/motion-render.processor.d.ts.map +1 -0
- package/dist/lib/motion-render.processor.js +25 -0
- package/dist/lib/motion-render.processor.js.map +1 -0
- package/dist/lib/motion-view.provider.d.ts.map +1 -1
- package/dist/lib/motion-view.provider.js +31 -2
- package/dist/lib/motion-view.provider.js.map +1 -1
- package/dist/lib/motion.middleware.d.ts.map +1 -1
- package/dist/lib/motion.middleware.js +20 -6
- package/dist/lib/motion.middleware.js.map +1 -1
- package/dist/lib/motion.plugin.d.ts.map +1 -1
- package/dist/lib/motion.plugin.js +2 -1
- package/dist/lib/motion.plugin.js.map +1 -1
- package/dist/lib/motion.service.d.ts +174 -3
- package/dist/lib/motion.service.d.ts.map +1 -1
- package/dist/lib/motion.service.js +376 -19
- package/dist/lib/motion.service.js.map +1 -1
- package/dist/lib/remote-components/motion-workbench/app.css +1 -1
- package/dist/lib/remote-components/motion-workbench/app.js +555 -946
- package/dist/lib/types.d.ts +26 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/sandbox-actions/hyperframes-render/action.json +10 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runner.mjs +188 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/darwin-arm64/README.md +3 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/darwin-arm64/package.json +20 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/linux-x64/README.md +3 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/linux-x64/bin/esbuild +0 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@esbuild/linux-x64/package.json +20 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/LICENSE +190 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/README.md +156 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/distributed.js +156122 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/hyperframe.manifest.json +22 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/hyperframe.runtime.iife.js +356 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/index.js +169375 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/public-server.js +167618 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/services/healthWorkerThread.js +53 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/dist/services/shaderTransitionWorker.js +606 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/@hyperframes/producer/package.json +109 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/LICENSE.md +21 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/README.md +3 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/bin/esbuild +0 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/install.js +289 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/lib/main.js +2532 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/esbuild/package.json +49 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/LICENSE +20 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/README.md +36 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.browser.cjs +42 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.browser.js +42 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.cjs +44 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.js +44 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/index.native.js +35 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/async/package.json +12 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/bin/nanoid.cjs +55 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.browser.cjs +44 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.browser.js +44 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.cjs +57 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.d.cts +91 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/index.js +62 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/nanoid.js +1 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/non-secure/index.cjs +24 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/non-secure/index.js +24 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/non-secure/package.json +6 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/package.json +89 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/url-alphabet/index.cjs +4 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/url-alphabet/index.js +4 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/nanoid/url-alphabet/package.json +6 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/LICENSE +15 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/README.md +21 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/package.json +25 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/picocolors.browser.js +4 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/picocolors/picocolors.js +75 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/LICENSE +20 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/README.md +25 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/at-rule.js +25 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/comment.js +13 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/container.js +447 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/css-syntax-error.js +133 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/declaration.js +24 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/document.js +33 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/fromJSON.js +68 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/input.js +276 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/lazy-result.js +563 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/list.js +58 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/map-generator.js +376 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/no-work-result.js +137 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/node.js +456 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/parse.js +42 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/parser.js +618 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/postcss.d.mts +66 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/postcss.js +101 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/postcss.mjs +30 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/previous-map.js +161 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/processor.js +67 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/result.js +42 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/root.js +61 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/rule.js +27 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/stringifier.js +374 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/stringify.js +11 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/symbols.js +5 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/terminal-highlight.js +70 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/tokenize.js +270 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/warn-once.js +13 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/warning.js +37 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/package.json +88 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/LICENSE +28 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/README.md +765 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/array-set.js +121 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/base64-vlq.js +140 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/base64.js +67 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/binary-search.js +111 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/mapping-list.js +79 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/quick-sort.js +132 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/source-map-generator.js +444 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/source-node.js +413 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/lib/util.js +594 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/package.json +71 -0
- package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/source-map-js/source-map.js +8 -0
- package/dist/xpert-motion-assistant.yaml +240 -37
- package/package.json +19 -10
- package/skills/motion-agent-skill/SKILL.md +19 -7
package/dist/sandbox-actions/hyperframes-render/bundle/runtime-modules/postcss/lib/stringifier.js
ADDED
|
@@ -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,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
|