@xpert-ai/plugin-motion 0.2.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 +553 -38
  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 +17 -9
  157. package/skills/motion-agent-skill/SKILL.md +19 -7
@@ -0,0 +1,101 @@
1
+ 'use strict'
2
+
3
+ let AtRule = require('./at-rule')
4
+ let Comment = require('./comment')
5
+ let Container = require('./container')
6
+ let CssSyntaxError = require('./css-syntax-error')
7
+ let Declaration = require('./declaration')
8
+ let Document = require('./document')
9
+ let fromJSON = require('./fromJSON')
10
+ let Input = require('./input')
11
+ let LazyResult = require('./lazy-result')
12
+ let list = require('./list')
13
+ let Node = require('./node')
14
+ let parse = require('./parse')
15
+ let Processor = require('./processor')
16
+ let Result = require('./result.js')
17
+ let Root = require('./root')
18
+ let Rule = require('./rule')
19
+ let stringify = require('./stringify')
20
+ let Warning = require('./warning')
21
+
22
+ function postcss(...plugins) {
23
+ if (plugins.length === 1 && Array.isArray(plugins[0])) {
24
+ plugins = plugins[0]
25
+ }
26
+ return new Processor(plugins)
27
+ }
28
+
29
+ postcss.plugin = function plugin(name, initializer) {
30
+ let warningPrinted = false
31
+ function creator(...args) {
32
+ // eslint-disable-next-line no-console
33
+ if (console && console.warn && !warningPrinted) {
34
+ warningPrinted = true
35
+ // eslint-disable-next-line no-console
36
+ console.warn(
37
+ name +
38
+ ': postcss.plugin was deprecated. Migration guide:\n' +
39
+ 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
40
+ )
41
+ if (process.env.LANG && process.env.LANG.startsWith('cn')) {
42
+ /* c8 ignore next 7 */
43
+ // eslint-disable-next-line no-console
44
+ console.warn(
45
+ name +
46
+ ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
47
+ 'https://www.w3ctech.com/topic/2226'
48
+ )
49
+ }
50
+ }
51
+ let transformer = initializer(...args)
52
+ transformer.postcssPlugin = name
53
+ transformer.postcssVersion = new Processor().version
54
+ return transformer
55
+ }
56
+
57
+ let cache
58
+ Object.defineProperty(creator, 'postcss', {
59
+ get() {
60
+ if (!cache) cache = creator()
61
+ return cache
62
+ }
63
+ })
64
+
65
+ creator.process = function (css, processOpts, pluginOpts) {
66
+ return postcss([creator(pluginOpts)]).process(css, processOpts)
67
+ }
68
+
69
+ return creator
70
+ }
71
+
72
+ postcss.stringify = stringify
73
+ postcss.parse = parse
74
+ postcss.fromJSON = fromJSON
75
+ postcss.list = list
76
+
77
+ postcss.comment = defaults => new Comment(defaults)
78
+ postcss.atRule = defaults => new AtRule(defaults)
79
+ postcss.decl = defaults => new Declaration(defaults)
80
+ postcss.rule = defaults => new Rule(defaults)
81
+ postcss.root = defaults => new Root(defaults)
82
+ postcss.document = defaults => new Document(defaults)
83
+
84
+ postcss.CssSyntaxError = CssSyntaxError
85
+ postcss.Declaration = Declaration
86
+ postcss.Container = Container
87
+ postcss.Processor = Processor
88
+ postcss.Document = Document
89
+ postcss.Comment = Comment
90
+ postcss.Warning = Warning
91
+ postcss.AtRule = AtRule
92
+ postcss.Result = Result
93
+ postcss.Input = Input
94
+ postcss.Rule = Rule
95
+ postcss.Root = Root
96
+ postcss.Node = Node
97
+
98
+ LazyResult.registerPostcss(postcss)
99
+
100
+ module.exports = postcss
101
+ postcss.default = postcss
@@ -0,0 +1,30 @@
1
+ import postcss from './postcss.js'
2
+
3
+ export default postcss
4
+
5
+ export const stringify = postcss.stringify
6
+ export const fromJSON = postcss.fromJSON
7
+ export const plugin = postcss.plugin
8
+ export const parse = postcss.parse
9
+ export const list = postcss.list
10
+
11
+ export const document = postcss.document
12
+ export const comment = postcss.comment
13
+ export const atRule = postcss.atRule
14
+ export const rule = postcss.rule
15
+ export const decl = postcss.decl
16
+ export const root = postcss.root
17
+
18
+ export const CssSyntaxError = postcss.CssSyntaxError
19
+ export const Declaration = postcss.Declaration
20
+ export const Container = postcss.Container
21
+ export const Processor = postcss.Processor
22
+ export const Document = postcss.Document
23
+ export const Comment = postcss.Comment
24
+ export const Warning = postcss.Warning
25
+ export const AtRule = postcss.AtRule
26
+ export const Result = postcss.Result
27
+ export const Input = postcss.Input
28
+ export const Rule = postcss.Rule
29
+ export const Root = postcss.Root
30
+ export const Node = postcss.Node
@@ -0,0 +1,161 @@
1
+ 'use strict'
2
+
3
+ let { existsSync, readFileSync } = require('fs')
4
+ let { dirname, join } = require('path')
5
+ let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
6
+
7
+ function fromBase64(str) {
8
+ if (Buffer) {
9
+ return Buffer.from(str, 'base64').toString()
10
+ } else {
11
+ /* c8 ignore next 2 */
12
+ return window.atob(str)
13
+ }
14
+ }
15
+
16
+ class PreviousMap {
17
+ constructor(css, opts) {
18
+ if (opts.map === false) return
19
+ if (opts.unsafeMap) this.unsafeMap = true
20
+ this.loadAnnotation(css)
21
+ this.inline = this.startWith(this.annotation, 'data:')
22
+
23
+ let prev = opts.map ? opts.map.prev : undefined
24
+ let text = this.loadMap(opts.from, prev)
25
+ if (!this.mapFile && opts.from) {
26
+ this.mapFile = opts.from
27
+ }
28
+ if (this.mapFile) this.root = dirname(this.mapFile)
29
+ if (text) this.text = text
30
+ }
31
+
32
+ consumer() {
33
+ if (!this.consumerCache) {
34
+ this.consumerCache = new SourceMapConsumer(this.json || this.text)
35
+ }
36
+ return this.consumerCache
37
+ }
38
+
39
+ decodeInline(text) {
40
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/
41
+ let baseUri = /^data:application\/json;base64,/
42
+ let charsetUri = /^data:application\/json;charset=utf-?8,/
43
+ let uri = /^data:application\/json,/
44
+
45
+ let uriMatch = text.match(charsetUri) || text.match(uri)
46
+ if (uriMatch) {
47
+ return decodeURIComponent(text.substr(uriMatch[0].length))
48
+ }
49
+
50
+ let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri)
51
+ if (baseUriMatch) {
52
+ return fromBase64(text.substr(baseUriMatch[0].length))
53
+ }
54
+
55
+ let encoding = text.slice('data:application/json;'.length)
56
+ encoding = encoding.slice(0, encoding.indexOf(','))
57
+ throw new Error('Unsupported source map encoding ' + encoding)
58
+ }
59
+
60
+ getAnnotationURL(sourceMapString) {
61
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
62
+ }
63
+
64
+ isMap(map) {
65
+ if (typeof map !== 'object') return false
66
+ return (
67
+ typeof map.mappings === 'string' ||
68
+ typeof map._mappings === 'string' ||
69
+ Array.isArray(map.sections)
70
+ )
71
+ }
72
+
73
+ loadAnnotation(css) {
74
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/g)
75
+ if (!comments) return
76
+
77
+ // sourceMappingURLs from comments, strings, etc.
78
+ let start = css.lastIndexOf(comments.pop())
79
+ let end = css.indexOf('*/', start)
80
+
81
+ if (start > -1 && end > -1) {
82
+ // Locate the last sourceMappingURL to avoid pickin
83
+ this.annotation = this.getAnnotationURL(css.substring(start, end))
84
+ }
85
+ }
86
+
87
+ loadFile(path, cssFile, trusted) {
88
+ /* c8 ignore next 5 */
89
+ if (!trusted && !this.unsafeMap) {
90
+ if (!/\.map$/i.test(path)) {
91
+ return undefined
92
+ }
93
+ }
94
+ this.root = dirname(path)
95
+ if (existsSync(path)) {
96
+ this.mapFile = path
97
+ return readFileSync(path, 'utf-8').toString().trim()
98
+ }
99
+ }
100
+
101
+ loadMap(file, prev) {
102
+ if (prev === false) return false
103
+
104
+ if (prev) {
105
+ if (typeof prev === 'string') {
106
+ return prev
107
+ } else if (typeof prev === 'function') {
108
+ let prevPath = prev(file)
109
+ if (prevPath) {
110
+ let map = this.loadFile(prevPath, file, true)
111
+ if (!map) {
112
+ throw new Error(
113
+ 'Unable to load previous source map: ' + prevPath.toString()
114
+ )
115
+ }
116
+ return map
117
+ }
118
+ } else if (prev instanceof SourceMapConsumer) {
119
+ return SourceMapGenerator.fromSourceMap(prev).toString()
120
+ } else if (prev instanceof SourceMapGenerator) {
121
+ return prev.toString()
122
+ } else if (this.isMap(prev)) {
123
+ return JSON.stringify(prev)
124
+ } else {
125
+ throw new Error(
126
+ 'Unsupported previous source map format: ' + prev.toString()
127
+ )
128
+ }
129
+ } else if (this.inline) {
130
+ return this.decodeInline(this.annotation)
131
+ } else if (this.annotation) {
132
+ let map = this.annotation
133
+ if (file) map = join(dirname(file), map)
134
+ let unknown = this.loadFile(map, file, false)
135
+ if (unknown) {
136
+ try {
137
+ /* c8 ignore next 4 */
138
+ this.json = JSON.parse(unknown.replace(/^\)]}'[^\n]*\n/, ''))
139
+ } catch {
140
+ return undefined
141
+ }
142
+ }
143
+ return unknown
144
+ }
145
+ }
146
+
147
+ startWith(string, start) {
148
+ if (!string) return false
149
+ return string.substr(0, start.length) === start
150
+ }
151
+
152
+ withContent() {
153
+ return !!(
154
+ this.consumer().sourcesContent &&
155
+ this.consumer().sourcesContent.length > 0
156
+ )
157
+ }
158
+ }
159
+
160
+ module.exports = PreviousMap
161
+ PreviousMap.default = PreviousMap
@@ -0,0 +1,67 @@
1
+ 'use strict'
2
+
3
+ let Document = require('./document')
4
+ let LazyResult = require('./lazy-result')
5
+ let NoWorkResult = require('./no-work-result')
6
+ let Root = require('./root')
7
+
8
+ class Processor {
9
+ constructor(plugins = []) {
10
+ this.version = '8.5.16'
11
+ this.plugins = this.normalize(plugins)
12
+ }
13
+
14
+ normalize(plugins) {
15
+ let normalized = []
16
+ for (let i of plugins) {
17
+ if (i.postcss === true) {
18
+ i = i()
19
+ } else if (i.postcss) {
20
+ i = i.postcss
21
+ }
22
+
23
+ if (typeof i === 'object' && Array.isArray(i.plugins)) {
24
+ normalized = normalized.concat(i.plugins)
25
+ } else if (typeof i === 'object' && i.postcssPlugin) {
26
+ normalized.push(i)
27
+ } else if (typeof i === 'function') {
28
+ normalized.push(i)
29
+ } else if (typeof i === 'object' && (i.parse || i.stringify)) {
30
+ if (process.env.NODE_ENV !== 'production') {
31
+ throw new Error(
32
+ 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
33
+ 'one of the syntax/parser/stringifier options as outlined ' +
34
+ 'in your PostCSS runner documentation.'
35
+ )
36
+ }
37
+ } else {
38
+ throw new Error(i + ' is not a PostCSS plugin')
39
+ }
40
+ }
41
+ return normalized
42
+ }
43
+
44
+ process(css, opts = {}) {
45
+ if (
46
+ !this.plugins.length &&
47
+ !opts.parser &&
48
+ !opts.stringifier &&
49
+ !opts.syntax
50
+ ) {
51
+ return new NoWorkResult(this, css, opts)
52
+ } else {
53
+ return new LazyResult(this, css, opts)
54
+ }
55
+ }
56
+
57
+ use(plugin) {
58
+ this.plugins = this.plugins.concat(this.normalize([plugin]))
59
+ return this
60
+ }
61
+ }
62
+
63
+ module.exports = Processor
64
+ Processor.default = Processor
65
+
66
+ Root.registerProcessor(Processor)
67
+ Document.registerProcessor(Processor)
@@ -0,0 +1,42 @@
1
+ 'use strict'
2
+
3
+ let Warning = require('./warning')
4
+
5
+ class Result {
6
+ get content() {
7
+ return this.css
8
+ }
9
+
10
+ constructor(processor, root, opts) {
11
+ this.processor = processor
12
+ this.messages = []
13
+ this.root = root
14
+ this.opts = opts
15
+ this.css = ''
16
+ this.map = undefined
17
+ }
18
+
19
+ toString() {
20
+ return this.css
21
+ }
22
+
23
+ warn(text, opts = {}) {
24
+ if (!opts.plugin) {
25
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
26
+ opts.plugin = this.lastPlugin.postcssPlugin
27
+ }
28
+ }
29
+
30
+ let warning = new Warning(text, opts)
31
+ this.messages.push(warning)
32
+
33
+ return warning
34
+ }
35
+
36
+ warnings() {
37
+ return this.messages.filter(i => i.type === 'warning')
38
+ }
39
+ }
40
+
41
+ module.exports = Result
42
+ Result.default = Result
@@ -0,0 +1,61 @@
1
+ 'use strict'
2
+
3
+ let Container = require('./container')
4
+
5
+ let LazyResult, Processor
6
+
7
+ class Root extends Container {
8
+ constructor(defaults) {
9
+ super(defaults)
10
+ this.type = 'root'
11
+ if (!this.nodes) this.nodes = []
12
+ }
13
+
14
+ normalize(child, sample, type) {
15
+ let nodes = super.normalize(child)
16
+
17
+ if (sample) {
18
+ if (type === 'prepend') {
19
+ if (this.nodes.length > 1) {
20
+ sample.raws.before = this.nodes[1].raws.before
21
+ } else {
22
+ delete sample.raws.before
23
+ }
24
+ } else if (this.first !== sample) {
25
+ for (let node of nodes) {
26
+ node.raws.before = sample.raws.before
27
+ }
28
+ }
29
+ }
30
+
31
+ return nodes
32
+ }
33
+
34
+ removeChild(child, ignore) {
35
+ let index = this.index(child)
36
+
37
+ if (!ignore && index === 0 && this.nodes.length > 1) {
38
+ this.nodes[1].raws.before = this.nodes[index].raws.before
39
+ }
40
+
41
+ return super.removeChild(child)
42
+ }
43
+
44
+ toResult(opts = {}) {
45
+ let lazy = new LazyResult(new Processor(), this, opts)
46
+ return lazy.stringify()
47
+ }
48
+ }
49
+
50
+ Root.registerLazyResult = dependant => {
51
+ LazyResult = dependant
52
+ }
53
+
54
+ Root.registerProcessor = dependant => {
55
+ Processor = dependant
56
+ }
57
+
58
+ module.exports = Root
59
+ Root.default = Root
60
+
61
+ Container.registerRoot(Root)
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ let Container = require('./container')
4
+ let list = require('./list')
5
+
6
+ class Rule extends Container {
7
+ get selectors() {
8
+ return list.comma(this.selector)
9
+ }
10
+
11
+ set selectors(values) {
12
+ let match = this.selector ? this.selector.match(/,\s*/) : null
13
+ let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen')
14
+ this.selector = values.join(sep)
15
+ }
16
+
17
+ constructor(defaults) {
18
+ super(defaults)
19
+ this.type = 'rule'
20
+ if (!this.nodes) this.nodes = []
21
+ }
22
+ }
23
+
24
+ module.exports = Rule
25
+ Rule.default = Rule
26
+
27
+ Container.registerRule(Rule)