create-microact-app 1.0.1

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 (213) hide show
  1. package/index.js +95 -0
  2. package/package.json +21 -0
  3. package/templates/vanilla/.github/workflows/deploy.yml +38 -0
  4. package/templates/vanilla/index.html +13 -0
  5. package/templates/vanilla/node_modules/.package-lock.json +207 -0
  6. package/templates/vanilla/node_modules/@esbuild/darwin-x64/README.md +3 -0
  7. package/templates/vanilla/node_modules/@esbuild/darwin-x64/bin/esbuild +0 -0
  8. package/templates/vanilla/node_modules/@esbuild/darwin-x64/package.json +17 -0
  9. package/templates/vanilla/node_modules/@monygroupcorp/microact/README.md +154 -0
  10. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js +1749 -0
  11. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js.map +1 -0
  12. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js +1743 -0
  13. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js.map +1 -0
  14. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js +2 -0
  15. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js.map +1 -0
  16. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.html +13 -0
  17. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.js +63 -0
  18. package/templates/vanilla/node_modules/@monygroupcorp/microact/package.json +38 -0
  19. package/templates/vanilla/node_modules/@monygroupcorp/microact/rollup.config.cjs +30 -0
  20. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Component.js +831 -0
  21. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/DOMUpdater.js +320 -0
  22. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/EventBus.js +123 -0
  23. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Router.js +253 -0
  24. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/UpdateScheduler.js +218 -0
  25. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/index.js +6 -0
  26. package/templates/vanilla/node_modules/esbuild/LICENSE.md +21 -0
  27. package/templates/vanilla/node_modules/esbuild/README.md +3 -0
  28. package/templates/vanilla/node_modules/esbuild/bin/esbuild +0 -0
  29. package/templates/vanilla/node_modules/esbuild/install.js +287 -0
  30. package/templates/vanilla/node_modules/esbuild/lib/main.d.ts +660 -0
  31. package/templates/vanilla/node_modules/esbuild/lib/main.js +2393 -0
  32. package/templates/vanilla/node_modules/esbuild/package.json +42 -0
  33. package/templates/vanilla/node_modules/nanoid/LICENSE +20 -0
  34. package/templates/vanilla/node_modules/nanoid/README.md +39 -0
  35. package/templates/vanilla/node_modules/nanoid/async/index.browser.cjs +69 -0
  36. package/templates/vanilla/node_modules/nanoid/async/index.browser.js +34 -0
  37. package/templates/vanilla/node_modules/nanoid/async/index.cjs +71 -0
  38. package/templates/vanilla/node_modules/nanoid/async/index.d.ts +56 -0
  39. package/templates/vanilla/node_modules/nanoid/async/index.js +35 -0
  40. package/templates/vanilla/node_modules/nanoid/async/index.native.js +26 -0
  41. package/templates/vanilla/node_modules/nanoid/async/package.json +12 -0
  42. package/templates/vanilla/node_modules/nanoid/bin/nanoid.cjs +55 -0
  43. package/templates/vanilla/node_modules/nanoid/index.browser.cjs +72 -0
  44. package/templates/vanilla/node_modules/nanoid/index.browser.js +34 -0
  45. package/templates/vanilla/node_modules/nanoid/index.cjs +85 -0
  46. package/templates/vanilla/node_modules/nanoid/index.d.cts +91 -0
  47. package/templates/vanilla/node_modules/nanoid/index.d.ts +91 -0
  48. package/templates/vanilla/node_modules/nanoid/index.js +45 -0
  49. package/templates/vanilla/node_modules/nanoid/nanoid.js +1 -0
  50. package/templates/vanilla/node_modules/nanoid/non-secure/index.cjs +34 -0
  51. package/templates/vanilla/node_modules/nanoid/non-secure/index.d.ts +33 -0
  52. package/templates/vanilla/node_modules/nanoid/non-secure/index.js +21 -0
  53. package/templates/vanilla/node_modules/nanoid/non-secure/package.json +6 -0
  54. package/templates/vanilla/node_modules/nanoid/package.json +89 -0
  55. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.cjs +7 -0
  56. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.js +3 -0
  57. package/templates/vanilla/node_modules/nanoid/url-alphabet/package.json +6 -0
  58. package/templates/vanilla/node_modules/picocolors/LICENSE +15 -0
  59. package/templates/vanilla/node_modules/picocolors/README.md +21 -0
  60. package/templates/vanilla/node_modules/picocolors/package.json +25 -0
  61. package/templates/vanilla/node_modules/picocolors/picocolors.browser.js +4 -0
  62. package/templates/vanilla/node_modules/picocolors/picocolors.d.ts +5 -0
  63. package/templates/vanilla/node_modules/picocolors/picocolors.js +75 -0
  64. package/templates/vanilla/node_modules/picocolors/types.d.ts +51 -0
  65. package/templates/vanilla/node_modules/postcss/LICENSE +20 -0
  66. package/templates/vanilla/node_modules/postcss/README.md +29 -0
  67. package/templates/vanilla/node_modules/postcss/lib/at-rule.d.ts +140 -0
  68. package/templates/vanilla/node_modules/postcss/lib/at-rule.js +25 -0
  69. package/templates/vanilla/node_modules/postcss/lib/comment.d.ts +68 -0
  70. package/templates/vanilla/node_modules/postcss/lib/comment.js +13 -0
  71. package/templates/vanilla/node_modules/postcss/lib/container.d.ts +483 -0
  72. package/templates/vanilla/node_modules/postcss/lib/container.js +447 -0
  73. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.d.ts +248 -0
  74. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.js +133 -0
  75. package/templates/vanilla/node_modules/postcss/lib/declaration.d.ts +151 -0
  76. package/templates/vanilla/node_modules/postcss/lib/declaration.js +24 -0
  77. package/templates/vanilla/node_modules/postcss/lib/document.d.ts +69 -0
  78. package/templates/vanilla/node_modules/postcss/lib/document.js +33 -0
  79. package/templates/vanilla/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  80. package/templates/vanilla/node_modules/postcss/lib/fromJSON.js +54 -0
  81. package/templates/vanilla/node_modules/postcss/lib/input.d.ts +227 -0
  82. package/templates/vanilla/node_modules/postcss/lib/input.js +265 -0
  83. package/templates/vanilla/node_modules/postcss/lib/lazy-result.d.ts +190 -0
  84. package/templates/vanilla/node_modules/postcss/lib/lazy-result.js +550 -0
  85. package/templates/vanilla/node_modules/postcss/lib/list.d.ts +60 -0
  86. package/templates/vanilla/node_modules/postcss/lib/list.js +58 -0
  87. package/templates/vanilla/node_modules/postcss/lib/map-generator.js +368 -0
  88. package/templates/vanilla/node_modules/postcss/lib/no-work-result.d.ts +46 -0
  89. package/templates/vanilla/node_modules/postcss/lib/no-work-result.js +138 -0
  90. package/templates/vanilla/node_modules/postcss/lib/node.d.ts +556 -0
  91. package/templates/vanilla/node_modules/postcss/lib/node.js +449 -0
  92. package/templates/vanilla/node_modules/postcss/lib/parse.d.ts +9 -0
  93. package/templates/vanilla/node_modules/postcss/lib/parse.js +42 -0
  94. package/templates/vanilla/node_modules/postcss/lib/parser.js +611 -0
  95. package/templates/vanilla/node_modules/postcss/lib/postcss.d.mts +69 -0
  96. package/templates/vanilla/node_modules/postcss/lib/postcss.d.ts +458 -0
  97. package/templates/vanilla/node_modules/postcss/lib/postcss.js +101 -0
  98. package/templates/vanilla/node_modules/postcss/lib/postcss.mjs +30 -0
  99. package/templates/vanilla/node_modules/postcss/lib/previous-map.d.ts +81 -0
  100. package/templates/vanilla/node_modules/postcss/lib/previous-map.js +144 -0
  101. package/templates/vanilla/node_modules/postcss/lib/processor.d.ts +115 -0
  102. package/templates/vanilla/node_modules/postcss/lib/processor.js +67 -0
  103. package/templates/vanilla/node_modules/postcss/lib/result.d.ts +205 -0
  104. package/templates/vanilla/node_modules/postcss/lib/result.js +42 -0
  105. package/templates/vanilla/node_modules/postcss/lib/root.d.ts +87 -0
  106. package/templates/vanilla/node_modules/postcss/lib/root.js +61 -0
  107. package/templates/vanilla/node_modules/postcss/lib/rule.d.ts +126 -0
  108. package/templates/vanilla/node_modules/postcss/lib/rule.js +27 -0
  109. package/templates/vanilla/node_modules/postcss/lib/stringifier.d.ts +46 -0
  110. package/templates/vanilla/node_modules/postcss/lib/stringifier.js +353 -0
  111. package/templates/vanilla/node_modules/postcss/lib/stringify.d.ts +9 -0
  112. package/templates/vanilla/node_modules/postcss/lib/stringify.js +11 -0
  113. package/templates/vanilla/node_modules/postcss/lib/symbols.js +5 -0
  114. package/templates/vanilla/node_modules/postcss/lib/terminal-highlight.js +70 -0
  115. package/templates/vanilla/node_modules/postcss/lib/tokenize.js +266 -0
  116. package/templates/vanilla/node_modules/postcss/lib/warn-once.js +13 -0
  117. package/templates/vanilla/node_modules/postcss/lib/warning.d.ts +147 -0
  118. package/templates/vanilla/node_modules/postcss/lib/warning.js +37 -0
  119. package/templates/vanilla/node_modules/postcss/package.json +88 -0
  120. package/templates/vanilla/node_modules/rollup/LICENSE.md +695 -0
  121. package/templates/vanilla/node_modules/rollup/README.md +125 -0
  122. package/templates/vanilla/node_modules/rollup/dist/bin/rollup +1715 -0
  123. package/templates/vanilla/node_modules/rollup/dist/es/getLogFilter.js +64 -0
  124. package/templates/vanilla/node_modules/rollup/dist/es/package.json +1 -0
  125. package/templates/vanilla/node_modules/rollup/dist/es/rollup.js +17 -0
  126. package/templates/vanilla/node_modules/rollup/dist/es/shared/node-entry.js +27273 -0
  127. package/templates/vanilla/node_modules/rollup/dist/es/shared/watch.js +4857 -0
  128. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.d.ts +5 -0
  129. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.js +69 -0
  130. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.d.ts +20 -0
  131. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.js +29 -0
  132. package/templates/vanilla/node_modules/rollup/dist/rollup.d.ts +1012 -0
  133. package/templates/vanilla/node_modules/rollup/dist/rollup.js +31 -0
  134. package/templates/vanilla/node_modules/rollup/dist/shared/fsevents-importer.js +37 -0
  135. package/templates/vanilla/node_modules/rollup/dist/shared/index.js +4571 -0
  136. package/templates/vanilla/node_modules/rollup/dist/shared/loadConfigFile.js +546 -0
  137. package/templates/vanilla/node_modules/rollup/dist/shared/rollup.js +27351 -0
  138. package/templates/vanilla/node_modules/rollup/dist/shared/watch-cli.js +561 -0
  139. package/templates/vanilla/node_modules/rollup/dist/shared/watch-proxy.js +87 -0
  140. package/templates/vanilla/node_modules/rollup/dist/shared/watch.js +316 -0
  141. package/templates/vanilla/node_modules/rollup/package.json +181 -0
  142. package/templates/vanilla/node_modules/source-map-js/LICENSE +28 -0
  143. package/templates/vanilla/node_modules/source-map-js/README.md +765 -0
  144. package/templates/vanilla/node_modules/source-map-js/lib/array-set.js +121 -0
  145. package/templates/vanilla/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  146. package/templates/vanilla/node_modules/source-map-js/lib/base64.js +67 -0
  147. package/templates/vanilla/node_modules/source-map-js/lib/binary-search.js +111 -0
  148. package/templates/vanilla/node_modules/source-map-js/lib/mapping-list.js +79 -0
  149. package/templates/vanilla/node_modules/source-map-js/lib/quick-sort.js +132 -0
  150. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  151. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  152. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  153. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  154. package/templates/vanilla/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  155. package/templates/vanilla/node_modules/source-map-js/lib/source-node.js +413 -0
  156. package/templates/vanilla/node_modules/source-map-js/lib/util.js +594 -0
  157. package/templates/vanilla/node_modules/source-map-js/package.json +71 -0
  158. package/templates/vanilla/node_modules/source-map-js/source-map.d.ts +104 -0
  159. package/templates/vanilla/node_modules/source-map-js/source-map.js +8 -0
  160. package/templates/vanilla/node_modules/vite/LICENSE.md +3396 -0
  161. package/templates/vanilla/node_modules/vite/README.md +20 -0
  162. package/templates/vanilla/node_modules/vite/bin/openChrome.applescript +95 -0
  163. package/templates/vanilla/node_modules/vite/bin/vite.js +61 -0
  164. package/templates/vanilla/node_modules/vite/client.d.ts +281 -0
  165. package/templates/vanilla/node_modules/vite/dist/client/client.mjs +725 -0
  166. package/templates/vanilla/node_modules/vite/dist/client/client.mjs.map +1 -0
  167. package/templates/vanilla/node_modules/vite/dist/client/env.mjs +30 -0
  168. package/templates/vanilla/node_modules/vite/dist/client/env.mjs.map +1 -0
  169. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-7ec6f216.js +914 -0
  170. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-827b23df.js +66713 -0
  171. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-c423598f.js +561 -0
  172. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f0c7dae0.js +7930 -0
  173. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f1e8587f.js +7646 -0
  174. package/templates/vanilla/node_modules/vite/dist/node/cli.js +929 -0
  175. package/templates/vanilla/node_modules/vite/dist/node/constants.js +130 -0
  176. package/templates/vanilla/node_modules/vite/dist/node/index.d.ts +3548 -0
  177. package/templates/vanilla/node_modules/vite/dist/node/index.js +158 -0
  178. package/templates/vanilla/node_modules/vite/dist/node-cjs/publicUtils.cjs +4555 -0
  179. package/templates/vanilla/node_modules/vite/index.cjs +34 -0
  180. package/templates/vanilla/node_modules/vite/package.json +173 -0
  181. package/templates/vanilla/node_modules/vite/types/customEvent.d.ts +35 -0
  182. package/templates/vanilla/node_modules/vite/types/hmrPayload.d.ts +61 -0
  183. package/templates/vanilla/node_modules/vite/types/hot.d.ts +32 -0
  184. package/templates/vanilla/node_modules/vite/types/importGlob.d.ts +97 -0
  185. package/templates/vanilla/node_modules/vite/types/importMeta.d.ts +26 -0
  186. package/templates/vanilla/node_modules/vite/types/metadata.d.ts +10 -0
  187. package/templates/vanilla/node_modules/vite/types/package.json +4 -0
  188. package/templates/vanilla/package-lock.json +589 -0
  189. package/templates/vanilla/package.json +17 -0
  190. package/templates/vanilla/src/components/App.js +60 -0
  191. package/templates/vanilla/src/components/Card.js +21 -0
  192. package/templates/vanilla/src/components/Hero.js +15 -0
  193. package/templates/vanilla/src/components/InteractiveDemo.js +59 -0
  194. package/templates/vanilla/src/main.js +9 -0
  195. package/templates/vanilla/src/style/main.css +172 -0
  196. package/templates/vanilla/vite.config.js +8 -0
  197. package/templates/web3/.env.example +15 -0
  198. package/templates/web3/.github/workflows/deploy.yml +38 -0
  199. package/templates/web3/README.md +33 -0
  200. package/templates/web3/contracts/foundry.toml +11 -0
  201. package/templates/web3/contracts/script/Deploy.s.sol +13 -0
  202. package/templates/web3/contracts/src/Counter.sol +21 -0
  203. package/templates/web3/index.html +13 -0
  204. package/templates/web3/package.json +25 -0
  205. package/templates/web3/scripts/chain-start.mjs +305 -0
  206. package/templates/web3/scripts/chain-stop.mjs +34 -0
  207. package/templates/web3/scripts/deploy.mjs +155 -0
  208. package/templates/web3/scripts/setup.mjs +42 -0
  209. package/templates/web3/src/components/App.js +49 -0
  210. package/templates/web3/src/components/CounterCard.js +111 -0
  211. package/templates/web3/src/main.js +54 -0
  212. package/templates/web3/src/style/main.css +345 -0
  213. package/templates/web3/vite.config.js +29 -0
@@ -0,0 +1,133 @@
1
+ 'use strict'
2
+
3
+ let pico = require('picocolors')
4
+
5
+ let terminalHighlight = require('./terminal-highlight')
6
+
7
+ class CssSyntaxError extends Error {
8
+ constructor(message, line, column, source, file, plugin) {
9
+ super(message)
10
+ this.name = 'CssSyntaxError'
11
+ this.reason = message
12
+
13
+ if (file) {
14
+ this.file = file
15
+ }
16
+ if (source) {
17
+ this.source = source
18
+ }
19
+ if (plugin) {
20
+ this.plugin = plugin
21
+ }
22
+ if (typeof line !== 'undefined' && typeof column !== 'undefined') {
23
+ if (typeof line === 'number') {
24
+ this.line = line
25
+ this.column = column
26
+ } else {
27
+ this.line = line.line
28
+ this.column = line.column
29
+ this.endLine = column.line
30
+ this.endColumn = column.column
31
+ }
32
+ }
33
+
34
+ this.setMessage()
35
+
36
+ if (Error.captureStackTrace) {
37
+ Error.captureStackTrace(this, CssSyntaxError)
38
+ }
39
+ }
40
+
41
+ setMessage() {
42
+ this.message = this.plugin ? this.plugin + ': ' : ''
43
+ this.message += this.file ? this.file : '<css input>'
44
+ if (typeof this.line !== 'undefined') {
45
+ this.message += ':' + this.line + ':' + this.column
46
+ }
47
+ this.message += ': ' + this.reason
48
+ }
49
+
50
+ showSourceCode(color) {
51
+ if (!this.source) return ''
52
+
53
+ let css = this.source
54
+ if (color == null) color = pico.isColorSupported
55
+
56
+ let aside = text => text
57
+ let mark = text => text
58
+ let highlight = text => text
59
+ if (color) {
60
+ let { bold, gray, red } = pico.createColors(true)
61
+ mark = text => bold(red(text))
62
+ aside = text => gray(text)
63
+ if (terminalHighlight) {
64
+ highlight = text => terminalHighlight(text)
65
+ }
66
+ }
67
+
68
+ let lines = css.split(/\r?\n/)
69
+ let start = Math.max(this.line - 3, 0)
70
+ let end = Math.min(this.line + 2, lines.length)
71
+ let maxWidth = String(end).length
72
+
73
+ return lines
74
+ .slice(start, end)
75
+ .map((line, index) => {
76
+ let number = start + 1 + index
77
+ let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | '
78
+ if (number === this.line) {
79
+ if (line.length > 160) {
80
+ let padding = 20
81
+ let subLineStart = Math.max(0, this.column - padding)
82
+ let subLineEnd = Math.max(
83
+ this.column + padding,
84
+ this.endColumn + padding
85
+ )
86
+ let subLine = line.slice(subLineStart, subLineEnd)
87
+
88
+ let spacing =
89
+ aside(gutter.replace(/\d/g, ' ')) +
90
+ line
91
+ .slice(0, Math.min(this.column - 1, padding - 1))
92
+ .replace(/[^\t]/g, ' ')
93
+
94
+ return (
95
+ mark('>') +
96
+ aside(gutter) +
97
+ highlight(subLine) +
98
+ '\n ' +
99
+ spacing +
100
+ mark('^')
101
+ )
102
+ }
103
+
104
+ let spacing =
105
+ aside(gutter.replace(/\d/g, ' ')) +
106
+ line.slice(0, this.column - 1).replace(/[^\t]/g, ' ')
107
+
108
+ return (
109
+ mark('>') +
110
+ aside(gutter) +
111
+ highlight(line) +
112
+ '\n ' +
113
+ spacing +
114
+ mark('^')
115
+ )
116
+ }
117
+
118
+ return ' ' + aside(gutter) + highlight(line)
119
+ })
120
+ .join('\n')
121
+ }
122
+
123
+ toString() {
124
+ let code = this.showSourceCode()
125
+ if (code) {
126
+ code = '\n\n' + code + '\n'
127
+ }
128
+ return this.name + ': ' + this.message + code
129
+ }
130
+ }
131
+
132
+ module.exports = CssSyntaxError
133
+ CssSyntaxError.default = CssSyntaxError
@@ -0,0 +1,151 @@
1
+ import { ContainerWithChildren } from './container.js'
2
+ import Node from './node.js'
3
+
4
+ declare namespace Declaration {
5
+ export interface DeclarationRaws extends Record<string, unknown> {
6
+ /**
7
+ * The space symbols before the node. It also stores `*`
8
+ * and `_` symbols before the declaration (IE hack).
9
+ */
10
+ before?: string
11
+
12
+ /**
13
+ * The symbols between the property and value for declarations.
14
+ */
15
+ between?: string
16
+
17
+ /**
18
+ * The content of the important statement, if it is not just `!important`.
19
+ */
20
+ important?: string
21
+
22
+ /**
23
+ * Declaration value with comments.
24
+ */
25
+ value?: {
26
+ raw: string
27
+ value: string
28
+ }
29
+ }
30
+
31
+ export interface DeclarationProps {
32
+ /** Whether the declaration has an `!important` annotation. */
33
+ important?: boolean
34
+ /** Name of the declaration. */
35
+ prop: string
36
+ /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
37
+ raws?: DeclarationRaws
38
+ /** Value of the declaration. */
39
+ value: string
40
+ }
41
+
42
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
+ export { Declaration_ as default }
44
+ }
45
+
46
+ /**
47
+ * It represents a class that handles
48
+ * [CSS declarations](https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax#css_declarations)
49
+ *
50
+ * ```js
51
+ * Once (root, { Declaration }) {
52
+ * const color = new Declaration({ prop: 'color', value: 'black' })
53
+ * root.append(color)
54
+ * }
55
+ * ```
56
+ *
57
+ * ```js
58
+ * const root = postcss.parse('a { color: black }')
59
+ * const decl = root.first?.first
60
+ *
61
+ * decl.type //=> 'decl'
62
+ * decl.toString() //=> ' color: black'
63
+ * ```
64
+ */
65
+ declare class Declaration_ extends Node {
66
+ parent: ContainerWithChildren | undefined
67
+ raws: Declaration.DeclarationRaws
68
+
69
+ type: 'decl'
70
+
71
+ /**
72
+ * It represents a specificity of the declaration.
73
+ *
74
+ * If true, the CSS declaration will have an
75
+ * [important](https://developer.mozilla.org/en-US/docs/Web/CSS/important)
76
+ * specifier.
77
+ *
78
+ * ```js
79
+ * const root = postcss.parse('a { color: black !important; color: red }')
80
+ *
81
+ * root.first.first.important //=> true
82
+ * root.first.last.important //=> undefined
83
+ * ```
84
+ */
85
+ get important(): boolean
86
+ set important(value: boolean)
87
+
88
+ /**
89
+ * The property name for a CSS declaration.
90
+ *
91
+ * ```js
92
+ * const root = postcss.parse('a { color: black }')
93
+ * const decl = root.first.first
94
+ *
95
+ * decl.prop //=> 'color'
96
+ * ```
97
+ */
98
+ get prop(): string
99
+
100
+ set prop(value: string)
101
+
102
+ /**
103
+ * The property value for a CSS declaration.
104
+ *
105
+ * Any CSS comments inside the value string will be filtered out.
106
+ * CSS comments present in the source value will be available in
107
+ * the `raws` property.
108
+ *
109
+ * Assigning new `value` would ignore the comments in `raws`
110
+ * property while compiling node to string.
111
+ *
112
+ * ```js
113
+ * const root = postcss.parse('a { color: black }')
114
+ * const decl = root.first.first
115
+ *
116
+ * decl.value //=> 'black'
117
+ * ```
118
+ */
119
+ get value(): string
120
+ set value(value: string)
121
+
122
+ /**
123
+ * It represents a getter that returns `true` if a declaration starts with
124
+ * `--` or `$`, which are used to declare variables in CSS and SASS/SCSS.
125
+ *
126
+ * ```js
127
+ * const root = postcss.parse(':root { --one: 1 }')
128
+ * const one = root.first.first
129
+ *
130
+ * one.variable //=> true
131
+ * ```
132
+ *
133
+ * ```js
134
+ * const root = postcss.parse('$one: 1')
135
+ * const one = root.first
136
+ *
137
+ * one.variable //=> true
138
+ * ```
139
+ */
140
+ get variable(): boolean
141
+ constructor(defaults?: Declaration.DeclarationProps)
142
+
143
+ assign(overrides: Declaration.DeclarationProps | object): this
144
+ clone(overrides?: Partial<Declaration.DeclarationProps>): this
145
+ cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
146
+ cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
147
+ }
148
+
149
+ declare class Declaration extends Declaration_ {}
150
+
151
+ export = Declaration
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ let Node = require('./node')
4
+
5
+ class Declaration extends Node {
6
+ get variable() {
7
+ return this.prop.startsWith('--') || this.prop[0] === '$'
8
+ }
9
+
10
+ constructor(defaults) {
11
+ if (
12
+ defaults &&
13
+ typeof defaults.value !== 'undefined' &&
14
+ typeof defaults.value !== 'string'
15
+ ) {
16
+ defaults = { ...defaults, value: String(defaults.value) }
17
+ }
18
+ super(defaults)
19
+ this.type = 'decl'
20
+ }
21
+ }
22
+
23
+ module.exports = Declaration
24
+ Declaration.default = Declaration
@@ -0,0 +1,69 @@
1
+ import Container, { ContainerProps } from './container.js'
2
+ import { ProcessOptions } from './postcss.js'
3
+ import Result from './result.js'
4
+ import Root from './root.js'
5
+
6
+ declare namespace Document {
7
+ export interface DocumentProps extends ContainerProps {
8
+ nodes?: readonly Root[]
9
+
10
+ /**
11
+ * Information to generate byte-to-byte equal node string as it was
12
+ * in the origin input.
13
+ *
14
+ * Every parser saves its own properties.
15
+ */
16
+ raws?: Record<string, any>
17
+ }
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
20
+ export { Document_ as default }
21
+ }
22
+
23
+ /**
24
+ * Represents a file and contains all its parsed nodes.
25
+ *
26
+ * **Experimental:** some aspects of this node could change within minor
27
+ * or patch version releases.
28
+ *
29
+ * ```js
30
+ * const document = htmlParser(
31
+ * '<html><style>a{color:black}</style><style>b{z-index:2}</style>'
32
+ * )
33
+ * document.type //=> 'document'
34
+ * document.nodes.length //=> 2
35
+ * ```
36
+ */
37
+ declare class Document_ extends Container<Root> {
38
+ nodes: Root[]
39
+ parent: undefined
40
+ type: 'document'
41
+
42
+ constructor(defaults?: Document.DocumentProps)
43
+
44
+ assign(overrides: Document.DocumentProps | object): this
45
+ clone(overrides?: Partial<Document.DocumentProps>): this
46
+ cloneAfter(overrides?: Partial<Document.DocumentProps>): this
47
+ cloneBefore(overrides?: Partial<Document.DocumentProps>): this
48
+
49
+ /**
50
+ * Returns a `Result` instance representing the document’s CSS roots.
51
+ *
52
+ * ```js
53
+ * const root1 = postcss.parse(css1, { from: 'a.css' })
54
+ * const root2 = postcss.parse(css2, { from: 'b.css' })
55
+ * const document = postcss.document()
56
+ * document.append(root1)
57
+ * document.append(root2)
58
+ * const result = document.toResult({ to: 'all.css', map: true })
59
+ * ```
60
+ *
61
+ * @param opts Options.
62
+ * @return Result with current document’s CSS.
63
+ */
64
+ toResult(options?: ProcessOptions): Result
65
+ }
66
+
67
+ declare class Document extends Document_ {}
68
+
69
+ export = Document
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ let Container = require('./container')
4
+
5
+ let LazyResult, Processor
6
+
7
+ class Document extends Container {
8
+ constructor(defaults) {
9
+ // type needs to be passed to super, otherwise child roots won't be normalized correctly
10
+ super({ type: 'document', ...defaults })
11
+
12
+ if (!this.nodes) {
13
+ this.nodes = []
14
+ }
15
+ }
16
+
17
+ toResult(opts = {}) {
18
+ let lazy = new LazyResult(new Processor(), this, opts)
19
+
20
+ return lazy.stringify()
21
+ }
22
+ }
23
+
24
+ Document.registerLazyResult = dependant => {
25
+ LazyResult = dependant
26
+ }
27
+
28
+ Document.registerProcessor = dependant => {
29
+ Processor = dependant
30
+ }
31
+
32
+ module.exports = Document
33
+ Document.default = Document
@@ -0,0 +1,9 @@
1
+ import { JSONHydrator } from './postcss.js'
2
+
3
+ interface FromJSON extends JSONHydrator {
4
+ default: FromJSON
5
+ }
6
+
7
+ declare const fromJSON: FromJSON
8
+
9
+ export = fromJSON
@@ -0,0 +1,54 @@
1
+ 'use strict'
2
+
3
+ let AtRule = require('./at-rule')
4
+ let Comment = require('./comment')
5
+ let Declaration = require('./declaration')
6
+ let Input = require('./input')
7
+ let PreviousMap = require('./previous-map')
8
+ let Root = require('./root')
9
+ let Rule = require('./rule')
10
+
11
+ function fromJSON(json, inputs) {
12
+ if (Array.isArray(json)) return json.map(n => fromJSON(n))
13
+
14
+ let { inputs: ownInputs, ...defaults } = json
15
+ if (ownInputs) {
16
+ inputs = []
17
+ for (let input of ownInputs) {
18
+ let inputHydrated = { ...input, __proto__: Input.prototype }
19
+ if (inputHydrated.map) {
20
+ inputHydrated.map = {
21
+ ...inputHydrated.map,
22
+ __proto__: PreviousMap.prototype
23
+ }
24
+ }
25
+ inputs.push(inputHydrated)
26
+ }
27
+ }
28
+ if (defaults.nodes) {
29
+ defaults.nodes = json.nodes.map(n => fromJSON(n, inputs))
30
+ }
31
+ if (defaults.source) {
32
+ let { inputId, ...source } = defaults.source
33
+ defaults.source = source
34
+ if (inputId != null) {
35
+ defaults.source.input = inputs[inputId]
36
+ }
37
+ }
38
+ if (defaults.type === 'root') {
39
+ return new Root(defaults)
40
+ } else if (defaults.type === 'decl') {
41
+ return new Declaration(defaults)
42
+ } else if (defaults.type === 'rule') {
43
+ return new Rule(defaults)
44
+ } else if (defaults.type === 'comment') {
45
+ return new Comment(defaults)
46
+ } else if (defaults.type === 'atrule') {
47
+ return new AtRule(defaults)
48
+ } else {
49
+ throw new Error('Unknown node type: ' + json.type)
50
+ }
51
+ }
52
+
53
+ module.exports = fromJSON
54
+ fromJSON.default = fromJSON
@@ -0,0 +1,227 @@
1
+ import { CssSyntaxError, ProcessOptions } from './postcss.js'
2
+ import PreviousMap from './previous-map.js'
3
+
4
+ declare namespace Input {
5
+ export interface FilePosition {
6
+ /**
7
+ * Column of inclusive start position in source file.
8
+ */
9
+ column: number
10
+
11
+ /**
12
+ * Column of exclusive end position in source file.
13
+ */
14
+ endColumn?: number
15
+
16
+ /**
17
+ * Line of exclusive end position in source file.
18
+ */
19
+ endLine?: number
20
+
21
+ /**
22
+ * Offset of exclusive end position in source file.
23
+ */
24
+ endOffset?: number
25
+
26
+ /**
27
+ * Absolute path to the source file.
28
+ */
29
+ file?: string
30
+
31
+ /**
32
+ * Line of inclusive start position in source file.
33
+ */
34
+ line: number
35
+
36
+ /**
37
+ * Offset of inclusive start position in source file.
38
+ */
39
+ offset: number
40
+
41
+ /**
42
+ * Source code.
43
+ */
44
+ source?: string
45
+
46
+ /**
47
+ * URL for the source file.
48
+ */
49
+ url: string
50
+ }
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
53
+ export { Input_ as default }
54
+ }
55
+
56
+ /**
57
+ * Represents the source CSS.
58
+ *
59
+ * ```js
60
+ * const root = postcss.parse(css, { from: file })
61
+ * const input = root.source.input
62
+ * ```
63
+ */
64
+ declare class Input_ {
65
+ /**
66
+ * Input CSS source.
67
+ *
68
+ * ```js
69
+ * const input = postcss.parse('a{}', { from: file }).input
70
+ * input.css //=> "a{}"
71
+ * ```
72
+ */
73
+ css: string
74
+
75
+ /**
76
+ * Input source with support for non-CSS documents.
77
+ *
78
+ * ```js
79
+ * const input = postcss.parse('a{}', { from: file, document: '<style>a {}</style>' }).input
80
+ * input.document //=> "<style>a {}</style>"
81
+ * input.css //=> "a{}"
82
+ * ```
83
+ */
84
+ document: string
85
+
86
+ /**
87
+ * The absolute path to the CSS source file defined
88
+ * with the `from` option.
89
+ *
90
+ * ```js
91
+ * const root = postcss.parse(css, { from: 'a.css' })
92
+ * root.source.input.file //=> '/home/ai/a.css'
93
+ * ```
94
+ */
95
+ file?: string
96
+
97
+ /**
98
+ * The flag to indicate whether or not the source code has Unicode BOM.
99
+ */
100
+ hasBOM: boolean
101
+
102
+ /**
103
+ * The unique ID of the CSS source. It will be created if `from` option
104
+ * is not provided (because PostCSS does not know the file path).
105
+ *
106
+ * ```js
107
+ * const root = postcss.parse(css)
108
+ * root.source.input.file //=> undefined
109
+ * root.source.input.id //=> "<input css 8LZeVF>"
110
+ * ```
111
+ */
112
+ id?: string
113
+
114
+ /**
115
+ * The input source map passed from a compilation step before PostCSS
116
+ * (for example, from Sass compiler).
117
+ *
118
+ * ```js
119
+ * root.source.input.map.consumer().sources //=> ['a.sass']
120
+ * ```
121
+ */
122
+ map: PreviousMap
123
+
124
+ /**
125
+ * The CSS source identifier. Contains `Input#file` if the user
126
+ * set the `from` option, or `Input#id` if they did not.
127
+ *
128
+ * ```js
129
+ * const root = postcss.parse(css, { from: 'a.css' })
130
+ * root.source.input.from //=> "/home/ai/a.css"
131
+ *
132
+ * const root = postcss.parse(css)
133
+ * root.source.input.from //=> "<input css 1>"
134
+ * ```
135
+ */
136
+ get from(): string
137
+
138
+ /**
139
+ * @param css Input CSS source.
140
+ * @param opts Process options.
141
+ */
142
+ constructor(css: string, opts?: ProcessOptions)
143
+
144
+ /**
145
+ * Returns `CssSyntaxError` with information about the error and its position.
146
+ */
147
+ error(
148
+ message: string,
149
+ start:
150
+ | {
151
+ column: number
152
+ line: number
153
+ }
154
+ | {
155
+ offset: number
156
+ },
157
+ end:
158
+ | {
159
+ column: number
160
+ line: number
161
+ }
162
+ | {
163
+ offset: number
164
+ },
165
+ opts?: { plugin?: CssSyntaxError['plugin'] }
166
+ ): CssSyntaxError
167
+ error(
168
+ message: string,
169
+ line: number,
170
+ column: number,
171
+ opts?: { plugin?: CssSyntaxError['plugin'] }
172
+ ): CssSyntaxError
173
+ error(
174
+ message: string,
175
+ offset: number,
176
+ opts?: { plugin?: CssSyntaxError['plugin'] }
177
+ ): CssSyntaxError
178
+
179
+ /**
180
+ * Converts source line and column to offset.
181
+ *
182
+ * @param line Source line.
183
+ * @param column Source column.
184
+ * @return Source offset.
185
+ */
186
+ fromLineAndColumn(line: number, column: number): number
187
+
188
+ /**
189
+ * Converts source offset to line and column.
190
+ *
191
+ * @param offset Source offset.
192
+ */
193
+ fromOffset(offset: number): { col: number; line: number } | null
194
+
195
+ /**
196
+ * Reads the input source map and returns a symbol position
197
+ * in the input source (e.g., in a Sass file that was compiled
198
+ * to CSS before being passed to PostCSS). Optionally takes an
199
+ * end position, exclusive.
200
+ *
201
+ * ```js
202
+ * root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
203
+ * root.source.input.origin(1, 1, 1, 4)
204
+ * //=> { file: 'a.css', line: 3, column: 1, endLine: 3, endColumn: 4 }
205
+ * ```
206
+ *
207
+ * @param line Line for inclusive start position in input CSS.
208
+ * @param column Column for inclusive start position in input CSS.
209
+ * @param endLine Line for exclusive end position in input CSS.
210
+ * @param endColumn Column for exclusive end position in input CSS.
211
+ *
212
+ * @return Position in input source.
213
+ */
214
+ origin(
215
+ line: number,
216
+ column: number,
217
+ endLine?: number,
218
+ endColumn?: number
219
+ ): false | Input.FilePosition
220
+
221
+ /** Converts this to a JSON-friendly object representation. */
222
+ toJSON(): object
223
+ }
224
+
225
+ declare class Input extends Input_ {}
226
+
227
+ export = Input