@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,456 @@
1
+ 'use strict'
2
+
3
+ let CssSyntaxError = require('./css-syntax-error')
4
+ let Stringifier = require('./stringifier')
5
+ let stringify = require('./stringify')
6
+ let { isClean, my } = require('./symbols')
7
+
8
+ function cloneNode(obj, parent) {
9
+ let cloned = new obj.constructor()
10
+
11
+ for (let i in obj) {
12
+ if (!Object.prototype.hasOwnProperty.call(obj, i)) {
13
+ /* c8 ignore next 2 */
14
+ continue
15
+ }
16
+ if (i === 'proxyCache') continue
17
+ let value = obj[i]
18
+ let type = typeof value
19
+
20
+ if (i === 'parent' && type === 'object') {
21
+ if (parent) cloned[i] = parent
22
+ } else if (i === 'source') {
23
+ cloned[i] = value
24
+ } else if (Array.isArray(value)) {
25
+ cloned[i] = value.map(j => cloneNode(j, cloned))
26
+ } else {
27
+ if (type === 'object' && value !== null) value = cloneNode(value)
28
+ cloned[i] = value
29
+ }
30
+ }
31
+
32
+ return cloned
33
+ }
34
+
35
+ function sourceOffset(inputCSS, position) {
36
+ // Not all custom syntaxes support `offset` in `source.start` and `source.end`
37
+ if (position && typeof position.offset !== 'undefined') {
38
+ return position.offset
39
+ }
40
+
41
+ let column = 1
42
+ let line = 1
43
+ let offset = 0
44
+
45
+ for (let i = 0; i < inputCSS.length; i++) {
46
+ if (line === position.line && column === position.column) {
47
+ offset = i
48
+ break
49
+ }
50
+
51
+ if (inputCSS[i] === '\n') {
52
+ column = 1
53
+ line += 1
54
+ } else {
55
+ column += 1
56
+ }
57
+ }
58
+
59
+ return offset
60
+ }
61
+
62
+ class Node {
63
+ get proxyOf() {
64
+ return this
65
+ }
66
+
67
+ constructor(defaults = {}) {
68
+ this.raws = {}
69
+ this[isClean] = false
70
+ this[my] = true
71
+
72
+ for (let name in defaults) {
73
+ if (name === 'nodes') {
74
+ this.nodes = []
75
+ for (let node of defaults[name]) {
76
+ // Clone only nodes that already belong to another tree, so passing a
77
+ // freshly created (parent-less) node adopts that instance instead of
78
+ // a copy and keeps the caller's reference usable. See #1987.
79
+ if (typeof node.clone === 'function' && node.parent) {
80
+ this.append(node.clone())
81
+ } else {
82
+ this.append(node)
83
+ }
84
+ }
85
+ } else {
86
+ this[name] = defaults[name]
87
+ }
88
+ }
89
+ }
90
+
91
+ addToError(error) {
92
+ error.postcssNode = this
93
+ if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
94
+ let s = this.source
95
+ error.stack = error.stack.replace(
96
+ /\n\s{4}at /,
97
+ `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
98
+ )
99
+ }
100
+ return error
101
+ }
102
+
103
+ after(add) {
104
+ this.parent.insertAfter(this, add)
105
+ return this
106
+ }
107
+
108
+ assign(overrides = {}) {
109
+ for (let name in overrides) {
110
+ this[name] = overrides[name]
111
+ }
112
+ return this
113
+ }
114
+
115
+ before(add) {
116
+ this.parent.insertBefore(this, add)
117
+ return this
118
+ }
119
+
120
+ cleanRaws(keepBetween) {
121
+ delete this.raws.before
122
+ delete this.raws.after
123
+ if (!keepBetween) delete this.raws.between
124
+ }
125
+
126
+ clone(overrides = {}) {
127
+ let cloned = cloneNode(this)
128
+ for (let name in overrides) {
129
+ cloned[name] = overrides[name]
130
+ }
131
+ return cloned
132
+ }
133
+
134
+ cloneAfter(overrides = {}) {
135
+ let cloned = this.clone(overrides)
136
+ this.parent.insertAfter(this, cloned)
137
+ return cloned
138
+ }
139
+
140
+ cloneBefore(overrides = {}) {
141
+ let cloned = this.clone(overrides)
142
+ this.parent.insertBefore(this, cloned)
143
+ return cloned
144
+ }
145
+
146
+ error(message, opts = {}) {
147
+ if (this.source) {
148
+ let { end, start } = this.rangeBy(opts)
149
+ return this.source.input.error(
150
+ message,
151
+ { column: start.column, line: start.line },
152
+ { column: end.column, line: end.line },
153
+ opts
154
+ )
155
+ }
156
+ return new CssSyntaxError(message)
157
+ }
158
+
159
+ getProxyProcessor() {
160
+ return {
161
+ get(node, prop) {
162
+ if (prop === 'proxyOf') {
163
+ return node
164
+ } else if (prop === 'root') {
165
+ return () => node.root().toProxy()
166
+ } else {
167
+ return node[prop]
168
+ }
169
+ },
170
+
171
+ set(node, prop, value) {
172
+ if (node[prop] === value) return true
173
+ node[prop] = value
174
+ if (
175
+ prop === 'prop' ||
176
+ prop === 'value' ||
177
+ prop === 'name' ||
178
+ prop === 'params' ||
179
+ prop === 'important' ||
180
+ /* c8 ignore next */
181
+ prop === 'text'
182
+ ) {
183
+ node.markDirty()
184
+ }
185
+ return true
186
+ }
187
+ }
188
+ }
189
+
190
+ /* c8 ignore next 3 */
191
+ markClean() {
192
+ this[isClean] = true
193
+ }
194
+
195
+ markDirty() {
196
+ if (this[isClean]) {
197
+ this[isClean] = false
198
+ let next = this
199
+ while ((next = next.parent)) {
200
+ next[isClean] = false
201
+ }
202
+ }
203
+ }
204
+
205
+ next() {
206
+ if (!this.parent) return undefined
207
+ let index = this.parent.index(this)
208
+ return this.parent.nodes[index + 1]
209
+ }
210
+
211
+ positionBy(opts = {}) {
212
+ let inputString =
213
+ 'document' in this.source.input
214
+ ? this.source.input.document
215
+ : this.source.input.css
216
+ let pos = {
217
+ column: this.source.start.column,
218
+ line: this.source.start.line,
219
+ offset: sourceOffset(inputString, this.source.start)
220
+ }
221
+ if (opts.index) {
222
+ pos = this.positionInside(opts.index)
223
+ } else if (opts.word) {
224
+ let stringRepresentation = inputString.slice(
225
+ sourceOffset(inputString, this.source.start),
226
+ sourceOffset(inputString, this.source.end)
227
+ )
228
+ let index = stringRepresentation.indexOf(opts.word)
229
+ if (index !== -1) pos = this.positionInside(index)
230
+ }
231
+ return pos
232
+ }
233
+
234
+ positionInside(index) {
235
+ let column = this.source.start.column
236
+ let line = this.source.start.line
237
+ let inputString =
238
+ 'document' in this.source.input
239
+ ? this.source.input.document
240
+ : this.source.input.css
241
+ let offset = sourceOffset(inputString, this.source.start)
242
+ let end = offset + index
243
+
244
+ for (let i = offset; i < end; i++) {
245
+ if (inputString[i] === '\n') {
246
+ column = 1
247
+ line += 1
248
+ } else {
249
+ column += 1
250
+ }
251
+ }
252
+
253
+ return { column, line, offset: end }
254
+ }
255
+
256
+ prev() {
257
+ if (!this.parent) return undefined
258
+ let index = this.parent.index(this)
259
+ return this.parent.nodes[index - 1]
260
+ }
261
+
262
+ rangeBy(opts = {}) {
263
+ let inputString =
264
+ 'document' in this.source.input
265
+ ? this.source.input.document
266
+ : this.source.input.css
267
+ let start = {
268
+ column: this.source.start.column,
269
+ line: this.source.start.line,
270
+ offset: sourceOffset(inputString, this.source.start)
271
+ }
272
+ let end = this.source.end
273
+ ? {
274
+ column: this.source.end.column + 1,
275
+ line: this.source.end.line,
276
+ offset:
277
+ typeof this.source.end.offset === 'number'
278
+ ? // `source.end.offset` is exclusive, so we don't need to add 1
279
+ this.source.end.offset
280
+ : // Since line/column in this.source.end is inclusive,
281
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
282
+ // So, we add 1 to convert it to exclusive.
283
+ sourceOffset(inputString, this.source.end) + 1
284
+ }
285
+ : {
286
+ column: start.column + 1,
287
+ line: start.line,
288
+ offset: start.offset + 1
289
+ }
290
+
291
+ if (opts.word) {
292
+ let stringRepresentation = inputString.slice(
293
+ sourceOffset(inputString, this.source.start),
294
+ sourceOffset(inputString, this.source.end)
295
+ )
296
+ let index = stringRepresentation.indexOf(opts.word)
297
+ if (index !== -1) {
298
+ start = this.positionInside(index)
299
+ end = this.positionInside(index + opts.word.length)
300
+ }
301
+ } else {
302
+ if (opts.start) {
303
+ start = {
304
+ column: opts.start.column,
305
+ line: opts.start.line,
306
+ offset: sourceOffset(inputString, opts.start)
307
+ }
308
+ } else if (typeof opts.index === 'number') {
309
+ start = this.positionInside(opts.index)
310
+ }
311
+
312
+ if (opts.end) {
313
+ end = {
314
+ column: opts.end.column,
315
+ line: opts.end.line,
316
+ offset: sourceOffset(inputString, opts.end)
317
+ }
318
+ } else if (typeof opts.endIndex === 'number') {
319
+ end = this.positionInside(opts.endIndex)
320
+ } else if (typeof opts.index === 'number') {
321
+ end = this.positionInside(opts.index + 1)
322
+ }
323
+ }
324
+
325
+ if (
326
+ end.line < start.line ||
327
+ (end.line === start.line && end.column <= start.column)
328
+ ) {
329
+ end = {
330
+ column: start.column + 1,
331
+ line: start.line,
332
+ offset: start.offset + 1
333
+ }
334
+ }
335
+
336
+ return { end, start }
337
+ }
338
+
339
+ raw(prop, defaultType) {
340
+ let str = new Stringifier()
341
+ return str.raw(this, prop, defaultType)
342
+ }
343
+
344
+ remove() {
345
+ if (this.parent) {
346
+ this.parent.removeChild(this)
347
+ }
348
+ this.parent = undefined
349
+ return this
350
+ }
351
+
352
+ replaceWith(...nodes) {
353
+ if (this.parent) {
354
+ let bookmark = this
355
+ let foundSelf = false
356
+ for (let node of nodes) {
357
+ if (node === this) {
358
+ foundSelf = true
359
+ } else if (foundSelf) {
360
+ this.parent.insertAfter(bookmark, node)
361
+ bookmark = node
362
+ } else {
363
+ this.parent.insertBefore(bookmark, node)
364
+ }
365
+ }
366
+
367
+ if (!foundSelf) {
368
+ this.remove()
369
+ }
370
+ }
371
+
372
+ return this
373
+ }
374
+
375
+ root() {
376
+ let result = this
377
+ while (result.parent && result.parent.type !== 'document') {
378
+ result = result.parent
379
+ }
380
+ return result
381
+ }
382
+
383
+ toJSON(_, inputs) {
384
+ let fixed = {}
385
+ let emitInputs = inputs == null
386
+ inputs = inputs || new Map()
387
+ let inputsNextIndex = 0
388
+
389
+ for (let name in this) {
390
+ if (!Object.prototype.hasOwnProperty.call(this, name)) {
391
+ /* c8 ignore next 2 */
392
+ continue
393
+ }
394
+ if (name === 'parent' || name === 'proxyCache') continue
395
+ let value = this[name]
396
+
397
+ if (Array.isArray(value)) {
398
+ fixed[name] = value.map(i => {
399
+ if (typeof i === 'object' && i.toJSON) {
400
+ return i.toJSON(null, inputs)
401
+ } else {
402
+ return i
403
+ }
404
+ })
405
+ } else if (typeof value === 'object' && value.toJSON) {
406
+ fixed[name] = value.toJSON(null, inputs)
407
+ } else if (name === 'source') {
408
+ if (value == null) continue
409
+ let inputId = inputs.get(value.input)
410
+ if (inputId == null) {
411
+ inputId = inputsNextIndex
412
+ inputs.set(value.input, inputsNextIndex)
413
+ inputsNextIndex++
414
+ }
415
+ fixed[name] = {
416
+ end: value.end,
417
+ inputId,
418
+ start: value.start
419
+ }
420
+ } else {
421
+ fixed[name] = value
422
+ }
423
+ }
424
+
425
+ if (emitInputs) {
426
+ fixed.inputs = [...inputs.keys()].map(input => input.toJSON())
427
+ }
428
+
429
+ return fixed
430
+ }
431
+
432
+ toProxy() {
433
+ if (!this.proxyCache) {
434
+ this.proxyCache = new Proxy(this, this.getProxyProcessor())
435
+ }
436
+ return this.proxyCache
437
+ }
438
+
439
+ toString(stringifier = stringify) {
440
+ if (stringifier.stringify) stringifier = stringifier.stringify
441
+ let result = ''
442
+ stringifier(this, i => {
443
+ result += i
444
+ })
445
+ return result
446
+ }
447
+
448
+ warn(result, text, opts = {}) {
449
+ let data = { node: this }
450
+ for (let i in opts) data[i] = opts[i]
451
+ return result.warn(text, data)
452
+ }
453
+ }
454
+
455
+ module.exports = Node
456
+ Node.default = Node
@@ -0,0 +1,42 @@
1
+ 'use strict'
2
+
3
+ let Container = require('./container')
4
+ let Input = require('./input')
5
+ let Parser = require('./parser')
6
+
7
+ function parse(css, opts) {
8
+ let input = new Input(css, opts)
9
+ let parser = new Parser(input)
10
+ try {
11
+ parser.parse()
12
+ } catch (e) {
13
+ if (process.env.NODE_ENV !== 'production') {
14
+ if (e.name === 'CssSyntaxError' && opts && opts.from) {
15
+ if (/\.scss$/i.test(opts.from)) {
16
+ e.message +=
17
+ '\nYou tried to parse SCSS with ' +
18
+ 'the standard CSS parser; ' +
19
+ 'try again with the postcss-scss parser'
20
+ } else if (/\.sass/i.test(opts.from)) {
21
+ e.message +=
22
+ '\nYou tried to parse Sass with ' +
23
+ 'the standard CSS parser; ' +
24
+ 'try again with the postcss-sass parser'
25
+ } else if (/\.less$/i.test(opts.from)) {
26
+ e.message +=
27
+ '\nYou tried to parse Less with ' +
28
+ 'the standard CSS parser; ' +
29
+ 'try again with the postcss-less parser'
30
+ }
31
+ }
32
+ }
33
+ throw e
34
+ }
35
+
36
+ return parser.root
37
+ }
38
+
39
+ module.exports = parse
40
+ parse.default = parse
41
+
42
+ Container.registerParse(parse)