@universityofmaryland/web-model-library 1.0.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 (252) hide show
  1. package/README.md +138 -0
  2. package/dist/_types.d.ts +77 -0
  3. package/dist/_types.d.ts.map +1 -0
  4. package/dist/_virtual/___vite-browser-external.js +8 -0
  5. package/dist/_virtual/___vite-browser-external.js.map +1 -0
  6. package/dist/_virtual/___vite-browser-external.mjs +7 -0
  7. package/dist/_virtual/___vite-browser-external.mjs.map +1 -0
  8. package/dist/_virtual/__vite-browser-external.js +4 -0
  9. package/dist/_virtual/__vite-browser-external.js.map +1 -0
  10. package/dist/_virtual/__vite-browser-external.mjs +5 -0
  11. package/dist/_virtual/__vite-browser-external.mjs.map +1 -0
  12. package/dist/_virtual/_commonjsHelpers.js +37 -0
  13. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  14. package/dist/_virtual/_commonjsHelpers.mjs +37 -0
  15. package/dist/_virtual/_commonjsHelpers.mjs.map +1 -0
  16. package/dist/_virtual/index.js +7 -0
  17. package/dist/_virtual/index.js.map +1 -0
  18. package/dist/_virtual/index.mjs +8 -0
  19. package/dist/_virtual/index.mjs.map +1 -0
  20. package/dist/_virtual/picocolors.browser.js +5 -0
  21. package/dist/_virtual/picocolors.browser.js.map +1 -0
  22. package/dist/_virtual/picocolors.browser.mjs +5 -0
  23. package/dist/_virtual/picocolors.browser.mjs.map +1 -0
  24. package/dist/_virtual/postcss.js +7 -0
  25. package/dist/_virtual/postcss.js.map +1 -0
  26. package/dist/_virtual/postcss.mjs +8 -0
  27. package/dist/_virtual/postcss.mjs.map +1 -0
  28. package/dist/_virtual/symbols.js +5 -0
  29. package/dist/_virtual/symbols.js.map +1 -0
  30. package/dist/_virtual/symbols.mjs +5 -0
  31. package/dist/_virtual/symbols.mjs.map +1 -0
  32. package/dist/attributes/checks.d.ts +133 -0
  33. package/dist/attributes/checks.d.ts.map +1 -0
  34. package/dist/attributes/checks.js +757 -0
  35. package/dist/attributes/checks.js.map +1 -0
  36. package/dist/attributes/checks.mjs +740 -0
  37. package/dist/attributes/checks.mjs.map +1 -0
  38. package/dist/attributes/handler.d.ts +52 -0
  39. package/dist/attributes/handler.d.ts.map +1 -0
  40. package/dist/attributes/handler.js +205 -0
  41. package/dist/attributes/handler.js.map +1 -0
  42. package/dist/attributes/handler.mjs +206 -0
  43. package/dist/attributes/handler.mjs.map +1 -0
  44. package/dist/attributes/index.d.ts +7 -0
  45. package/dist/attributes/index.d.ts.map +1 -0
  46. package/dist/attributes/names.d.ts +132 -0
  47. package/dist/attributes/names.d.ts.map +1 -0
  48. package/dist/attributes/names.js +145 -0
  49. package/dist/attributes/names.js.map +1 -0
  50. package/dist/attributes/names.mjs +146 -0
  51. package/dist/attributes/names.mjs.map +1 -0
  52. package/dist/attributes/values.d.ts +70 -0
  53. package/dist/attributes/values.d.ts.map +1 -0
  54. package/dist/attributes/values.js +80 -0
  55. package/dist/attributes/values.js.map +1 -0
  56. package/dist/attributes/values.mjs +81 -0
  57. package/dist/attributes/values.mjs.map +1 -0
  58. package/dist/attributes.d.ts +2 -0
  59. package/dist/attributes.js +23 -0
  60. package/dist/attributes.js.map +1 -0
  61. package/dist/attributes.mjs +23 -0
  62. package/dist/attributes.mjs.map +1 -0
  63. package/dist/index.d.ts +10 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +13 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/index.mjs +13 -0
  68. package/dist/index.mjs.map +1 -0
  69. package/dist/model/index.d.ts +43 -0
  70. package/dist/model/index.d.ts.map +1 -0
  71. package/dist/model.d.ts +2 -0
  72. package/dist/model.js +259 -0
  73. package/dist/model.js.map +1 -0
  74. package/dist/model.mjs +259 -0
  75. package/dist/model.mjs.map +1 -0
  76. package/dist/node_modules/nanoid/non-secure/index.js +31 -0
  77. package/dist/node_modules/nanoid/non-secure/index.js.map +1 -0
  78. package/dist/node_modules/nanoid/non-secure/index.mjs +31 -0
  79. package/dist/node_modules/nanoid/non-secure/index.mjs.map +1 -0
  80. package/dist/node_modules/picocolors/picocolors.browser.js +17 -0
  81. package/dist/node_modules/picocolors/picocolors.browser.js.map +1 -0
  82. package/dist/node_modules/picocolors/picocolors.browser.mjs +17 -0
  83. package/dist/node_modules/picocolors/picocolors.browser.mjs.map +1 -0
  84. package/dist/node_modules/postcss/lib/at-rule.js +30 -0
  85. package/dist/node_modules/postcss/lib/at-rule.js.map +1 -0
  86. package/dist/node_modules/postcss/lib/at-rule.mjs +30 -0
  87. package/dist/node_modules/postcss/lib/at-rule.mjs.map +1 -0
  88. package/dist/node_modules/postcss/lib/comment.js +21 -0
  89. package/dist/node_modules/postcss/lib/comment.js.map +1 -0
  90. package/dist/node_modules/postcss/lib/comment.mjs +21 -0
  91. package/dist/node_modules/postcss/lib/comment.mjs.map +1 -0
  92. package/dist/node_modules/postcss/lib/container.js +383 -0
  93. package/dist/node_modules/postcss/lib/container.js.map +1 -0
  94. package/dist/node_modules/postcss/lib/container.mjs +383 -0
  95. package/dist/node_modules/postcss/lib/container.mjs.map +1 -0
  96. package/dist/node_modules/postcss/lib/css-syntax-error.js +92 -0
  97. package/dist/node_modules/postcss/lib/css-syntax-error.js.map +1 -0
  98. package/dist/node_modules/postcss/lib/css-syntax-error.mjs +92 -0
  99. package/dist/node_modules/postcss/lib/css-syntax-error.mjs.map +1 -0
  100. package/dist/node_modules/postcss/lib/declaration.js +27 -0
  101. package/dist/node_modules/postcss/lib/declaration.js.map +1 -0
  102. package/dist/node_modules/postcss/lib/declaration.mjs +27 -0
  103. package/dist/node_modules/postcss/lib/declaration.mjs.map +1 -0
  104. package/dist/node_modules/postcss/lib/document.js +34 -0
  105. package/dist/node_modules/postcss/lib/document.js.map +1 -0
  106. package/dist/node_modules/postcss/lib/document.mjs +34 -0
  107. package/dist/node_modules/postcss/lib/document.mjs.map +1 -0
  108. package/dist/node_modules/postcss/lib/fromJSON.js +67 -0
  109. package/dist/node_modules/postcss/lib/fromJSON.js.map +1 -0
  110. package/dist/node_modules/postcss/lib/fromJSON.mjs +67 -0
  111. package/dist/node_modules/postcss/lib/fromJSON.mjs.map +1 -0
  112. package/dist/node_modules/postcss/lib/input.js +216 -0
  113. package/dist/node_modules/postcss/lib/input.js.map +1 -0
  114. package/dist/node_modules/postcss/lib/input.mjs +216 -0
  115. package/dist/node_modules/postcss/lib/input.mjs.map +1 -0
  116. package/dist/node_modules/postcss/lib/lazy-result.js +467 -0
  117. package/dist/node_modules/postcss/lib/lazy-result.js.map +1 -0
  118. package/dist/node_modules/postcss/lib/lazy-result.mjs +467 -0
  119. package/dist/node_modules/postcss/lib/lazy-result.mjs.map +1 -0
  120. package/dist/node_modules/postcss/lib/list.js +60 -0
  121. package/dist/node_modules/postcss/lib/list.js.map +1 -0
  122. package/dist/node_modules/postcss/lib/list.mjs +60 -0
  123. package/dist/node_modules/postcss/lib/list.mjs.map +1 -0
  124. package/dist/node_modules/postcss/lib/map-generator.js +314 -0
  125. package/dist/node_modules/postcss/lib/map-generator.js.map +1 -0
  126. package/dist/node_modules/postcss/lib/map-generator.mjs +314 -0
  127. package/dist/node_modules/postcss/lib/map-generator.mjs.map +1 -0
  128. package/dist/node_modules/postcss/lib/no-work-result.js +113 -0
  129. package/dist/node_modules/postcss/lib/no-work-result.js.map +1 -0
  130. package/dist/node_modules/postcss/lib/no-work-result.mjs +113 -0
  131. package/dist/node_modules/postcss/lib/no-work-result.mjs.map +1 -0
  132. package/dist/node_modules/postcss/lib/node.js +335 -0
  133. package/dist/node_modules/postcss/lib/node.js.map +1 -0
  134. package/dist/node_modules/postcss/lib/node.mjs +335 -0
  135. package/dist/node_modules/postcss/lib/node.mjs.map +1 -0
  136. package/dist/node_modules/postcss/lib/parse.js +30 -0
  137. package/dist/node_modules/postcss/lib/parse.js.map +1 -0
  138. package/dist/node_modules/postcss/lib/parse.mjs +30 -0
  139. package/dist/node_modules/postcss/lib/parse.mjs.map +1 -0
  140. package/dist/node_modules/postcss/lib/parser.js +543 -0
  141. package/dist/node_modules/postcss/lib/parser.js.map +1 -0
  142. package/dist/node_modules/postcss/lib/parser.mjs +543 -0
  143. package/dist/node_modules/postcss/lib/parser.mjs.map +1 -0
  144. package/dist/node_modules/postcss/lib/postcss.js +28 -0
  145. package/dist/node_modules/postcss/lib/postcss.js.map +1 -0
  146. package/dist/node_modules/postcss/lib/postcss.mjs +29 -0
  147. package/dist/node_modules/postcss/lib/postcss.mjs.map +1 -0
  148. package/dist/node_modules/postcss/lib/postcss2.js +110 -0
  149. package/dist/node_modules/postcss/lib/postcss2.js.map +1 -0
  150. package/dist/node_modules/postcss/lib/postcss2.mjs +110 -0
  151. package/dist/node_modules/postcss/lib/postcss2.mjs.map +1 -0
  152. package/dist/node_modules/postcss/lib/previous-map.js +123 -0
  153. package/dist/node_modules/postcss/lib/previous-map.js.map +1 -0
  154. package/dist/node_modules/postcss/lib/previous-map.mjs +123 -0
  155. package/dist/node_modules/postcss/lib/previous-map.mjs.map +1 -0
  156. package/dist/node_modules/postcss/lib/processor.js +61 -0
  157. package/dist/node_modules/postcss/lib/processor.js.map +1 -0
  158. package/dist/node_modules/postcss/lib/processor.mjs +61 -0
  159. package/dist/node_modules/postcss/lib/processor.mjs.map +1 -0
  160. package/dist/node_modules/postcss/lib/result.js +44 -0
  161. package/dist/node_modules/postcss/lib/result.js.map +1 -0
  162. package/dist/node_modules/postcss/lib/result.mjs +44 -0
  163. package/dist/node_modules/postcss/lib/result.mjs.map +1 -0
  164. package/dist/node_modules/postcss/lib/root.js +58 -0
  165. package/dist/node_modules/postcss/lib/root.js.map +1 -0
  166. package/dist/node_modules/postcss/lib/root.mjs +58 -0
  167. package/dist/node_modules/postcss/lib/root.mjs.map +1 -0
  168. package/dist/node_modules/postcss/lib/rule.js +33 -0
  169. package/dist/node_modules/postcss/lib/rule.js.map +1 -0
  170. package/dist/node_modules/postcss/lib/rule.mjs +33 -0
  171. package/dist/node_modules/postcss/lib/rule.mjs.map +1 -0
  172. package/dist/node_modules/postcss/lib/stringifier.js +308 -0
  173. package/dist/node_modules/postcss/lib/stringifier.js.map +1 -0
  174. package/dist/node_modules/postcss/lib/stringifier.mjs +308 -0
  175. package/dist/node_modules/postcss/lib/stringifier.mjs.map +1 -0
  176. package/dist/node_modules/postcss/lib/stringify.js +19 -0
  177. package/dist/node_modules/postcss/lib/stringify.js.map +1 -0
  178. package/dist/node_modules/postcss/lib/stringify.mjs +19 -0
  179. package/dist/node_modules/postcss/lib/stringify.mjs.map +1 -0
  180. package/dist/node_modules/postcss/lib/symbols.js +13 -0
  181. package/dist/node_modules/postcss/lib/symbols.js.map +1 -0
  182. package/dist/node_modules/postcss/lib/symbols.mjs +13 -0
  183. package/dist/node_modules/postcss/lib/symbols.mjs.map +1 -0
  184. package/dist/node_modules/postcss/lib/tokenize.js +219 -0
  185. package/dist/node_modules/postcss/lib/tokenize.js.map +1 -0
  186. package/dist/node_modules/postcss/lib/tokenize.mjs +219 -0
  187. package/dist/node_modules/postcss/lib/tokenize.mjs.map +1 -0
  188. package/dist/node_modules/postcss/lib/warning.js +40 -0
  189. package/dist/node_modules/postcss/lib/warning.js.map +1 -0
  190. package/dist/node_modules/postcss/lib/warning.mjs +40 -0
  191. package/dist/node_modules/postcss/lib/warning.mjs.map +1 -0
  192. package/dist/packages/model/node_modules/postcss-discard-duplicates/src/index.js +130 -0
  193. package/dist/packages/model/node_modules/postcss-discard-duplicates/src/index.js.map +1 -0
  194. package/dist/packages/model/node_modules/postcss-discard-duplicates/src/index.mjs +130 -0
  195. package/dist/packages/model/node_modules/postcss-discard-duplicates/src/index.mjs.map +1 -0
  196. package/dist/slots/create.d.ts +15 -0
  197. package/dist/slots/create.d.ts.map +1 -0
  198. package/dist/slots/create.js +50 -0
  199. package/dist/slots/create.js.map +1 -0
  200. package/dist/slots/create.mjs +50 -0
  201. package/dist/slots/create.mjs.map +1 -0
  202. package/dist/slots/element.d.ts +3 -0
  203. package/dist/slots/element.d.ts.map +1 -0
  204. package/dist/slots/element.js +42 -0
  205. package/dist/slots/element.js.map +1 -0
  206. package/dist/slots/element.mjs +42 -0
  207. package/dist/slots/element.mjs.map +1 -0
  208. package/dist/slots/extract.d.ts +6 -0
  209. package/dist/slots/extract.d.ts.map +1 -0
  210. package/dist/slots/index.d.ts +140 -0
  211. package/dist/slots/index.d.ts.map +1 -0
  212. package/dist/slots/mapping.d.ts +82 -0
  213. package/dist/slots/mapping.d.ts.map +1 -0
  214. package/dist/slots/mapping.js +97 -0
  215. package/dist/slots/mapping.js.map +1 -0
  216. package/dist/slots/mapping.mjs +97 -0
  217. package/dist/slots/mapping.mjs.map +1 -0
  218. package/dist/slots/query.d.ts +9 -0
  219. package/dist/slots/query.d.ts.map +1 -0
  220. package/dist/slots/validate.d.ts +22 -0
  221. package/dist/slots/validate.d.ts.map +1 -0
  222. package/dist/slots.d.ts +6 -0
  223. package/dist/slots.js +73 -0
  224. package/dist/slots.js.map +1 -0
  225. package/dist/slots.mjs +74 -0
  226. package/dist/slots.mjs.map +1 -0
  227. package/dist/utilities/index.d.ts +4 -0
  228. package/dist/utilities/index.d.ts.map +1 -0
  229. package/dist/utilities/lifecycle.d.ts +12 -0
  230. package/dist/utilities/lifecycle.d.ts.map +1 -0
  231. package/dist/utilities/lifecycle.js +21 -0
  232. package/dist/utilities/lifecycle.js.map +1 -0
  233. package/dist/utilities/lifecycle.mjs +21 -0
  234. package/dist/utilities/lifecycle.mjs.map +1 -0
  235. package/dist/utilities/register.d.ts +17 -0
  236. package/dist/utilities/register.d.ts.map +1 -0
  237. package/dist/utilities/register.js +32 -0
  238. package/dist/utilities/register.js.map +1 -0
  239. package/dist/utilities/register.mjs +32 -0
  240. package/dist/utilities/register.mjs.map +1 -0
  241. package/dist/utilities/styles.d.ts +5 -0
  242. package/dist/utilities/styles.d.ts.map +1 -0
  243. package/dist/utilities/styles.js +79 -0
  244. package/dist/utilities/styles.js.map +1 -0
  245. package/dist/utilities/styles.mjs +80 -0
  246. package/dist/utilities/styles.mjs.map +1 -0
  247. package/dist/utilities.d.ts +2 -0
  248. package/dist/utilities.js +11 -0
  249. package/dist/utilities.js.map +1 -0
  250. package/dist/utilities.mjs +11 -0
  251. package/dist/utilities.mjs.map +1 -0
  252. package/package.json +69 -0
@@ -0,0 +1,216 @@
1
+ import require$$2 from "../../../_virtual/___vite-browser-external.mjs";
2
+ import { __require as requireNonSecure } from "../../nanoid/non-secure/index.mjs";
3
+ import { __require as requireCssSyntaxError } from "./css-syntax-error.mjs";
4
+ import { __require as requirePreviousMap } from "./previous-map.mjs";
5
+ var input;
6
+ var hasRequiredInput;
7
+ function requireInput() {
8
+ if (hasRequiredInput) return input;
9
+ hasRequiredInput = 1;
10
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
11
+ let { fileURLToPath, pathToFileURL } = require$$2;
12
+ let { isAbsolute, resolve } = require$$2;
13
+ let { nanoid } = /* @__PURE__ */ requireNonSecure();
14
+ let terminalHighlight = require$$2;
15
+ let CssSyntaxError = requireCssSyntaxError();
16
+ let PreviousMap = requirePreviousMap();
17
+ let fromOffsetCache = Symbol("fromOffsetCache");
18
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
19
+ let pathAvailable = Boolean(resolve && isAbsolute);
20
+ class Input {
21
+ constructor(css, opts = {}) {
22
+ if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
23
+ throw new Error(`PostCSS received ${css} instead of CSS string`);
24
+ }
25
+ this.css = css.toString();
26
+ if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
27
+ this.hasBOM = true;
28
+ this.css = this.css.slice(1);
29
+ } else {
30
+ this.hasBOM = false;
31
+ }
32
+ if (opts.from) {
33
+ if (!pathAvailable || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
34
+ this.file = opts.from;
35
+ } else {
36
+ this.file = resolve(opts.from);
37
+ }
38
+ }
39
+ if (pathAvailable && sourceMapAvailable) {
40
+ let map = new PreviousMap(this.css, opts);
41
+ if (map.text) {
42
+ this.map = map;
43
+ let file = map.consumer().file;
44
+ if (!this.file && file) this.file = this.mapResolve(file);
45
+ }
46
+ }
47
+ if (!this.file) {
48
+ this.id = "<input css " + nanoid(6) + ">";
49
+ }
50
+ if (this.map) this.map.file = this.from;
51
+ }
52
+ error(message, line, column, opts = {}) {
53
+ let result, endLine, endColumn;
54
+ if (line && typeof line === "object") {
55
+ let start = line;
56
+ let end = column;
57
+ if (typeof start.offset === "number") {
58
+ let pos = this.fromOffset(start.offset);
59
+ line = pos.line;
60
+ column = pos.col;
61
+ } else {
62
+ line = start.line;
63
+ column = start.column;
64
+ }
65
+ if (typeof end.offset === "number") {
66
+ let pos = this.fromOffset(end.offset);
67
+ endLine = pos.line;
68
+ endColumn = pos.col;
69
+ } else {
70
+ endLine = end.line;
71
+ endColumn = end.column;
72
+ }
73
+ } else if (!column) {
74
+ let pos = this.fromOffset(line);
75
+ line = pos.line;
76
+ column = pos.col;
77
+ }
78
+ let origin = this.origin(line, column, endLine, endColumn);
79
+ if (origin) {
80
+ result = new CssSyntaxError(
81
+ message,
82
+ origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
83
+ origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
84
+ origin.source,
85
+ origin.file,
86
+ opts.plugin
87
+ );
88
+ } else {
89
+ result = new CssSyntaxError(
90
+ message,
91
+ endLine === void 0 ? line : { column, line },
92
+ endLine === void 0 ? column : { column: endColumn, line: endLine },
93
+ this.css,
94
+ this.file,
95
+ opts.plugin
96
+ );
97
+ }
98
+ result.input = { column, endColumn, endLine, line, source: this.css };
99
+ if (this.file) {
100
+ if (pathToFileURL) {
101
+ result.input.url = pathToFileURL(this.file).toString();
102
+ }
103
+ result.input.file = this.file;
104
+ }
105
+ return result;
106
+ }
107
+ fromOffset(offset) {
108
+ let lastLine, lineToIndex;
109
+ if (!this[fromOffsetCache]) {
110
+ let lines = this.css.split("\n");
111
+ lineToIndex = new Array(lines.length);
112
+ let prevIndex = 0;
113
+ for (let i = 0, l = lines.length; i < l; i++) {
114
+ lineToIndex[i] = prevIndex;
115
+ prevIndex += lines[i].length + 1;
116
+ }
117
+ this[fromOffsetCache] = lineToIndex;
118
+ } else {
119
+ lineToIndex = this[fromOffsetCache];
120
+ }
121
+ lastLine = lineToIndex[lineToIndex.length - 1];
122
+ let min = 0;
123
+ if (offset >= lastLine) {
124
+ min = lineToIndex.length - 1;
125
+ } else {
126
+ let max = lineToIndex.length - 2;
127
+ let mid;
128
+ while (min < max) {
129
+ mid = min + (max - min >> 1);
130
+ if (offset < lineToIndex[mid]) {
131
+ max = mid - 1;
132
+ } else if (offset >= lineToIndex[mid + 1]) {
133
+ min = mid + 1;
134
+ } else {
135
+ min = mid;
136
+ break;
137
+ }
138
+ }
139
+ }
140
+ return {
141
+ col: offset - lineToIndex[min] + 1,
142
+ line: min + 1
143
+ };
144
+ }
145
+ mapResolve(file) {
146
+ if (/^\w+:\/\//.test(file)) {
147
+ return file;
148
+ }
149
+ return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file);
150
+ }
151
+ origin(line, column, endLine, endColumn) {
152
+ if (!this.map) return false;
153
+ let consumer = this.map.consumer();
154
+ let from = consumer.originalPositionFor({ column, line });
155
+ if (!from.source) return false;
156
+ let to;
157
+ if (typeof endLine === "number") {
158
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine });
159
+ }
160
+ let fromUrl;
161
+ if (isAbsolute(from.source)) {
162
+ fromUrl = pathToFileURL(from.source);
163
+ } else {
164
+ fromUrl = new URL(
165
+ from.source,
166
+ this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
167
+ );
168
+ }
169
+ let result = {
170
+ column: from.column,
171
+ endColumn: to && to.column,
172
+ endLine: to && to.line,
173
+ line: from.line,
174
+ url: fromUrl.toString()
175
+ };
176
+ if (fromUrl.protocol === "file:") {
177
+ if (fileURLToPath) {
178
+ result.file = fileURLToPath(fromUrl);
179
+ } else {
180
+ throw new Error(`file: protocol is not available in this PostCSS build`);
181
+ }
182
+ }
183
+ let source = consumer.sourceContentFor(from.source);
184
+ if (source) result.source = source;
185
+ return result;
186
+ }
187
+ toJSON() {
188
+ let json = {};
189
+ for (let name of ["hasBOM", "css", "file", "id"]) {
190
+ if (this[name] != null) {
191
+ json[name] = this[name];
192
+ }
193
+ }
194
+ if (this.map) {
195
+ json.map = { ...this.map };
196
+ if (json.map.consumerCache) {
197
+ json.map.consumerCache = void 0;
198
+ }
199
+ }
200
+ return json;
201
+ }
202
+ get from() {
203
+ return this.file || this.id;
204
+ }
205
+ }
206
+ input = Input;
207
+ Input.default = Input;
208
+ if (terminalHighlight && terminalHighlight.registerInput) {
209
+ terminalHighlight.registerInput(Input);
210
+ }
211
+ return input;
212
+ }
213
+ export {
214
+ requireInput as __require
215
+ };
216
+ //# sourceMappingURL=input.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.mjs","sources":["../../../../../../node_modules/postcss/lib/input.js"],"sourcesContent":["'use strict'\n\nlet { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')\nlet { fileURLToPath, pathToFileURL } = require('url')\nlet { isAbsolute, resolve } = require('path')\nlet { nanoid } = require('nanoid/non-secure')\n\nlet terminalHighlight = require('./terminal-highlight')\nlet CssSyntaxError = require('./css-syntax-error')\nlet PreviousMap = require('./previous-map')\n\nlet fromOffsetCache = Symbol('fromOffsetCache')\n\nlet sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)\nlet pathAvailable = Boolean(resolve && isAbsolute)\n\nclass Input {\n constructor(css, opts = {}) {\n if (\n css === null ||\n typeof css === 'undefined' ||\n (typeof css === 'object' && !css.toString)\n ) {\n throw new Error(`PostCSS received ${css} instead of CSS string`)\n }\n\n this.css = css.toString()\n\n if (this.css[0] === '\\uFEFF' || this.css[0] === '\\uFFFE') {\n this.hasBOM = true\n this.css = this.css.slice(1)\n } else {\n this.hasBOM = false\n }\n\n if (opts.from) {\n if (\n !pathAvailable ||\n /^\\w+:\\/\\//.test(opts.from) ||\n isAbsolute(opts.from)\n ) {\n this.file = opts.from\n } else {\n this.file = resolve(opts.from)\n }\n }\n\n if (pathAvailable && sourceMapAvailable) {\n let map = new PreviousMap(this.css, opts)\n if (map.text) {\n this.map = map\n let file = map.consumer().file\n if (!this.file && file) this.file = this.mapResolve(file)\n }\n }\n\n if (!this.file) {\n this.id = '<input css ' + nanoid(6) + '>'\n }\n if (this.map) this.map.file = this.from\n }\n\n error(message, line, column, opts = {}) {\n let result, endLine, endColumn\n\n if (line && typeof line === 'object') {\n let start = line\n let end = column\n if (typeof start.offset === 'number') {\n let pos = this.fromOffset(start.offset)\n line = pos.line\n column = pos.col\n } else {\n line = start.line\n column = start.column\n }\n if (typeof end.offset === 'number') {\n let pos = this.fromOffset(end.offset)\n endLine = pos.line\n endColumn = pos.col\n } else {\n endLine = end.line\n endColumn = end.column\n }\n } else if (!column) {\n let pos = this.fromOffset(line)\n line = pos.line\n column = pos.col\n }\n\n let origin = this.origin(line, column, endLine, endColumn)\n if (origin) {\n result = new CssSyntaxError(\n message,\n origin.endLine === undefined\n ? origin.line\n : { column: origin.column, line: origin.line },\n origin.endLine === undefined\n ? origin.column\n : { column: origin.endColumn, line: origin.endLine },\n origin.source,\n origin.file,\n opts.plugin\n )\n } else {\n result = new CssSyntaxError(\n message,\n endLine === undefined ? line : { column, line },\n endLine === undefined ? column : { column: endColumn, line: endLine },\n this.css,\n this.file,\n opts.plugin\n )\n }\n\n result.input = { column, endColumn, endLine, line, source: this.css }\n if (this.file) {\n if (pathToFileURL) {\n result.input.url = pathToFileURL(this.file).toString()\n }\n result.input.file = this.file\n }\n\n return result\n }\n\n fromOffset(offset) {\n let lastLine, lineToIndex\n if (!this[fromOffsetCache]) {\n let lines = this.css.split('\\n')\n lineToIndex = new Array(lines.length)\n let prevIndex = 0\n\n for (let i = 0, l = lines.length; i < l; i++) {\n lineToIndex[i] = prevIndex\n prevIndex += lines[i].length + 1\n }\n\n this[fromOffsetCache] = lineToIndex\n } else {\n lineToIndex = this[fromOffsetCache]\n }\n lastLine = lineToIndex[lineToIndex.length - 1]\n\n let min = 0\n if (offset >= lastLine) {\n min = lineToIndex.length - 1\n } else {\n let max = lineToIndex.length - 2\n let mid\n while (min < max) {\n mid = min + ((max - min) >> 1)\n if (offset < lineToIndex[mid]) {\n max = mid - 1\n } else if (offset >= lineToIndex[mid + 1]) {\n min = mid + 1\n } else {\n min = mid\n break\n }\n }\n }\n return {\n col: offset - lineToIndex[min] + 1,\n line: min + 1\n }\n }\n\n mapResolve(file) {\n if (/^\\w+:\\/\\//.test(file)) {\n return file\n }\n return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)\n }\n\n origin(line, column, endLine, endColumn) {\n if (!this.map) return false\n let consumer = this.map.consumer()\n\n let from = consumer.originalPositionFor({ column, line })\n if (!from.source) return false\n\n let to\n if (typeof endLine === 'number') {\n to = consumer.originalPositionFor({ column: endColumn, line: endLine })\n }\n\n let fromUrl\n\n if (isAbsolute(from.source)) {\n fromUrl = pathToFileURL(from.source)\n } else {\n fromUrl = new URL(\n from.source,\n this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)\n )\n }\n\n let result = {\n column: from.column,\n endColumn: to && to.column,\n endLine: to && to.line,\n line: from.line,\n url: fromUrl.toString()\n }\n\n if (fromUrl.protocol === 'file:') {\n if (fileURLToPath) {\n result.file = fileURLToPath(fromUrl)\n } else {\n /* c8 ignore next 2 */\n throw new Error(`file: protocol is not available in this PostCSS build`)\n }\n }\n\n let source = consumer.sourceContentFor(from.source)\n if (source) result.source = source\n\n return result\n }\n\n toJSON() {\n let json = {}\n for (let name of ['hasBOM', 'css', 'file', 'id']) {\n if (this[name] != null) {\n json[name] = this[name]\n }\n }\n if (this.map) {\n json.map = { ...this.map }\n if (json.map.consumerCache) {\n json.map.consumerCache = undefined\n }\n }\n return json\n }\n\n get from() {\n return this.file || this.id\n }\n}\n\nmodule.exports = Input\nInput.default = Input\n\nif (terminalHighlight && terminalHighlight.registerInput) {\n terminalHighl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AA,IAEE,SAAS;AACP,UAAI,OAAO,CAAA;AACX,eAAS,QAAQ,CAAC,UAAU,OAAO,QAAQ,IAAI,GAAG;AAChD,YAAI,KAAK,IAAI,KAAK,MAAM;AACtB,eAAK,IAAI,IAAI,KAAK,IAAI;AAAA,QAC9B;AAAA,MACA;AACI,UAAI,KAAK,KAAK;AACZ,aAAK,MAAM,EAAE,GAAG,KAAK,IAAG;AACxB,YAAI,KAAK,IAAI,eAAe;AAC1B,eAAK,IAAI,gBAAgB;AAAA,QACjC;AAAA,MACA;AACI,aAAO;AAAA,IACX;AAAA,IAEE,IAAI,OAAO;AACT,aAAO,KAAK,QAAQ,KAAK;AAAA,IAC7B;AAAA,EACA;AAEA,UAAiB;AACjB,QAAM,UAAU;AAEhB,MAAI,qBAAqB,kBAAkB,eAAe;AACxD,sBAAkB,cAAc,KAAK;AAAA,EACvC;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,467 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const symbols = require("./symbols.js");
4
+ const mapGenerator = require("./map-generator.js");
5
+ const stringify = require("./stringify.js");
6
+ const container = require("./container.js");
7
+ const document = require("./document.js");
8
+ const result = require("./result.js");
9
+ const parse = require("./parse.js");
10
+ const root = require("./root.js");
11
+ var lazyResult;
12
+ var hasRequiredLazyResult;
13
+ function requireLazyResult() {
14
+ if (hasRequiredLazyResult) return lazyResult;
15
+ hasRequiredLazyResult = 1;
16
+ let { isClean, my } = symbols.__require();
17
+ let MapGenerator = mapGenerator.__require();
18
+ let stringify$1 = stringify.__require();
19
+ let Container = container.__require();
20
+ let Document = document.__require();
21
+ let Result = result.__require();
22
+ let parse$1 = parse.__require();
23
+ let Root = root.__require();
24
+ const TYPE_TO_CLASS_NAME = {
25
+ atrule: "AtRule",
26
+ comment: "Comment",
27
+ decl: "Declaration",
28
+ document: "Document",
29
+ root: "Root",
30
+ rule: "Rule"
31
+ };
32
+ const PLUGIN_PROPS = {
33
+ AtRule: true,
34
+ AtRuleExit: true,
35
+ Comment: true,
36
+ CommentExit: true,
37
+ Declaration: true,
38
+ DeclarationExit: true,
39
+ Document: true,
40
+ DocumentExit: true,
41
+ Once: true,
42
+ OnceExit: true,
43
+ postcssPlugin: true,
44
+ prepare: true,
45
+ Root: true,
46
+ RootExit: true,
47
+ Rule: true,
48
+ RuleExit: true
49
+ };
50
+ const NOT_VISITORS = {
51
+ Once: true,
52
+ postcssPlugin: true,
53
+ prepare: true
54
+ };
55
+ const CHILDREN = 0;
56
+ function isPromise(obj) {
57
+ return typeof obj === "object" && typeof obj.then === "function";
58
+ }
59
+ function getEvents(node) {
60
+ let key = false;
61
+ let type = TYPE_TO_CLASS_NAME[node.type];
62
+ if (node.type === "decl") {
63
+ key = node.prop.toLowerCase();
64
+ } else if (node.type === "atrule") {
65
+ key = node.name.toLowerCase();
66
+ }
67
+ if (key && node.append) {
68
+ return [
69
+ type,
70
+ type + "-" + key,
71
+ CHILDREN,
72
+ type + "Exit",
73
+ type + "Exit-" + key
74
+ ];
75
+ } else if (key) {
76
+ return [type, type + "-" + key, type + "Exit", type + "Exit-" + key];
77
+ } else if (node.append) {
78
+ return [type, CHILDREN, type + "Exit"];
79
+ } else {
80
+ return [type, type + "Exit"];
81
+ }
82
+ }
83
+ function toStack(node) {
84
+ let events;
85
+ if (node.type === "document") {
86
+ events = ["Document", CHILDREN, "DocumentExit"];
87
+ } else if (node.type === "root") {
88
+ events = ["Root", CHILDREN, "RootExit"];
89
+ } else {
90
+ events = getEvents(node);
91
+ }
92
+ return {
93
+ eventIndex: 0,
94
+ events,
95
+ iterator: 0,
96
+ node,
97
+ visitorIndex: 0,
98
+ visitors: []
99
+ };
100
+ }
101
+ function cleanMarks(node) {
102
+ node[isClean] = false;
103
+ if (node.nodes) node.nodes.forEach((i) => cleanMarks(i));
104
+ return node;
105
+ }
106
+ let postcss = {};
107
+ class LazyResult {
108
+ constructor(processor, css, opts) {
109
+ this.stringified = false;
110
+ this.processed = false;
111
+ let root2;
112
+ if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) {
113
+ root2 = cleanMarks(css);
114
+ } else if (css instanceof LazyResult || css instanceof Result) {
115
+ root2 = cleanMarks(css.root);
116
+ if (css.map) {
117
+ if (typeof opts.map === "undefined") opts.map = {};
118
+ if (!opts.map.inline) opts.map.inline = false;
119
+ opts.map.prev = css.map;
120
+ }
121
+ } else {
122
+ let parser = parse$1;
123
+ if (opts.syntax) parser = opts.syntax.parse;
124
+ if (opts.parser) parser = opts.parser;
125
+ if (parser.parse) parser = parser.parse;
126
+ try {
127
+ root2 = parser(css, opts);
128
+ } catch (error) {
129
+ this.processed = true;
130
+ this.error = error;
131
+ }
132
+ if (root2 && !root2[my]) {
133
+ Container.rebuild(root2);
134
+ }
135
+ }
136
+ this.result = new Result(processor, root2, opts);
137
+ this.helpers = { ...postcss, postcss, result: this.result };
138
+ this.plugins = this.processor.plugins.map((plugin) => {
139
+ if (typeof plugin === "object" && plugin.prepare) {
140
+ return { ...plugin, ...plugin.prepare(this.result) };
141
+ } else {
142
+ return plugin;
143
+ }
144
+ });
145
+ }
146
+ async() {
147
+ if (this.error) return Promise.reject(this.error);
148
+ if (this.processed) return Promise.resolve(this.result);
149
+ if (!this.processing) {
150
+ this.processing = this.runAsync();
151
+ }
152
+ return this.processing;
153
+ }
154
+ catch(onRejected) {
155
+ return this.async().catch(onRejected);
156
+ }
157
+ finally(onFinally) {
158
+ return this.async().then(onFinally, onFinally);
159
+ }
160
+ getAsyncError() {
161
+ throw new Error("Use process(css).then(cb) to work with async plugins");
162
+ }
163
+ handleError(error, node) {
164
+ let plugin = this.result.lastPlugin;
165
+ try {
166
+ if (node) node.addToError(error);
167
+ this.error = error;
168
+ if (error.name === "CssSyntaxError" && !error.plugin) {
169
+ error.plugin = plugin.postcssPlugin;
170
+ error.setMessage();
171
+ } else if (plugin.postcssVersion) {
172
+ if (false) ;
173
+ }
174
+ } catch (err) {
175
+ if (console && console.error) console.error(err);
176
+ }
177
+ return error;
178
+ }
179
+ prepareVisitors() {
180
+ this.listeners = {};
181
+ let add = (plugin, type, cb) => {
182
+ if (!this.listeners[type]) this.listeners[type] = [];
183
+ this.listeners[type].push([plugin, cb]);
184
+ };
185
+ for (let plugin of this.plugins) {
186
+ if (typeof plugin === "object") {
187
+ for (let event in plugin) {
188
+ if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
189
+ throw new Error(
190
+ `Unknown event ${event} in ${plugin.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`
191
+ );
192
+ }
193
+ if (!NOT_VISITORS[event]) {
194
+ if (typeof plugin[event] === "object") {
195
+ for (let filter in plugin[event]) {
196
+ if (filter === "*") {
197
+ add(plugin, event, plugin[event][filter]);
198
+ } else {
199
+ add(
200
+ plugin,
201
+ event + "-" + filter.toLowerCase(),
202
+ plugin[event][filter]
203
+ );
204
+ }
205
+ }
206
+ } else if (typeof plugin[event] === "function") {
207
+ add(plugin, event, plugin[event]);
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ this.hasListener = Object.keys(this.listeners).length > 0;
214
+ }
215
+ async runAsync() {
216
+ this.plugin = 0;
217
+ for (let i = 0; i < this.plugins.length; i++) {
218
+ let plugin = this.plugins[i];
219
+ let promise = this.runOnRoot(plugin);
220
+ if (isPromise(promise)) {
221
+ try {
222
+ await promise;
223
+ } catch (error) {
224
+ throw this.handleError(error);
225
+ }
226
+ }
227
+ }
228
+ this.prepareVisitors();
229
+ if (this.hasListener) {
230
+ let root2 = this.result.root;
231
+ while (!root2[isClean]) {
232
+ root2[isClean] = true;
233
+ let stack = [toStack(root2)];
234
+ while (stack.length > 0) {
235
+ let promise = this.visitTick(stack);
236
+ if (isPromise(promise)) {
237
+ try {
238
+ await promise;
239
+ } catch (e) {
240
+ let node = stack[stack.length - 1].node;
241
+ throw this.handleError(e, node);
242
+ }
243
+ }
244
+ }
245
+ }
246
+ if (this.listeners.OnceExit) {
247
+ for (let [plugin, visitor] of this.listeners.OnceExit) {
248
+ this.result.lastPlugin = plugin;
249
+ try {
250
+ if (root2.type === "document") {
251
+ let roots = root2.nodes.map(
252
+ (subRoot) => visitor(subRoot, this.helpers)
253
+ );
254
+ await Promise.all(roots);
255
+ } else {
256
+ await visitor(root2, this.helpers);
257
+ }
258
+ } catch (e) {
259
+ throw this.handleError(e);
260
+ }
261
+ }
262
+ }
263
+ }
264
+ this.processed = true;
265
+ return this.stringify();
266
+ }
267
+ runOnRoot(plugin) {
268
+ this.result.lastPlugin = plugin;
269
+ try {
270
+ if (typeof plugin === "object" && plugin.Once) {
271
+ if (this.result.root.type === "document") {
272
+ let roots = this.result.root.nodes.map(
273
+ (root2) => plugin.Once(root2, this.helpers)
274
+ );
275
+ if (isPromise(roots[0])) {
276
+ return Promise.all(roots);
277
+ }
278
+ return roots;
279
+ }
280
+ return plugin.Once(this.result.root, this.helpers);
281
+ } else if (typeof plugin === "function") {
282
+ return plugin(this.result.root, this.result);
283
+ }
284
+ } catch (error) {
285
+ throw this.handleError(error);
286
+ }
287
+ }
288
+ stringify() {
289
+ if (this.error) throw this.error;
290
+ if (this.stringified) return this.result;
291
+ this.stringified = true;
292
+ this.sync();
293
+ let opts = this.result.opts;
294
+ let str = stringify$1;
295
+ if (opts.syntax) str = opts.syntax.stringify;
296
+ if (opts.stringifier) str = opts.stringifier;
297
+ if (str.stringify) str = str.stringify;
298
+ let map = new MapGenerator(str, this.result.root, this.result.opts);
299
+ let data = map.generate();
300
+ this.result.css = data[0];
301
+ this.result.map = data[1];
302
+ return this.result;
303
+ }
304
+ sync() {
305
+ if (this.error) throw this.error;
306
+ if (this.processed) return this.result;
307
+ this.processed = true;
308
+ if (this.processing) {
309
+ throw this.getAsyncError();
310
+ }
311
+ for (let plugin of this.plugins) {
312
+ let promise = this.runOnRoot(plugin);
313
+ if (isPromise(promise)) {
314
+ throw this.getAsyncError();
315
+ }
316
+ }
317
+ this.prepareVisitors();
318
+ if (this.hasListener) {
319
+ let root2 = this.result.root;
320
+ while (!root2[isClean]) {
321
+ root2[isClean] = true;
322
+ this.walkSync(root2);
323
+ }
324
+ if (this.listeners.OnceExit) {
325
+ if (root2.type === "document") {
326
+ for (let subRoot of root2.nodes) {
327
+ this.visitSync(this.listeners.OnceExit, subRoot);
328
+ }
329
+ } else {
330
+ this.visitSync(this.listeners.OnceExit, root2);
331
+ }
332
+ }
333
+ }
334
+ return this.result;
335
+ }
336
+ then(onFulfilled, onRejected) {
337
+ return this.async().then(onFulfilled, onRejected);
338
+ }
339
+ toString() {
340
+ return this.css;
341
+ }
342
+ visitSync(visitors, node) {
343
+ for (let [plugin, visitor] of visitors) {
344
+ this.result.lastPlugin = plugin;
345
+ let promise;
346
+ try {
347
+ promise = visitor(node, this.helpers);
348
+ } catch (e) {
349
+ throw this.handleError(e, node.proxyOf);
350
+ }
351
+ if (node.type !== "root" && node.type !== "document" && !node.parent) {
352
+ return true;
353
+ }
354
+ if (isPromise(promise)) {
355
+ throw this.getAsyncError();
356
+ }
357
+ }
358
+ }
359
+ visitTick(stack) {
360
+ let visit = stack[stack.length - 1];
361
+ let { node, visitors } = visit;
362
+ if (node.type !== "root" && node.type !== "document" && !node.parent) {
363
+ stack.pop();
364
+ return;
365
+ }
366
+ if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
367
+ let [plugin, visitor] = visitors[visit.visitorIndex];
368
+ visit.visitorIndex += 1;
369
+ if (visit.visitorIndex === visitors.length) {
370
+ visit.visitors = [];
371
+ visit.visitorIndex = 0;
372
+ }
373
+ this.result.lastPlugin = plugin;
374
+ try {
375
+ return visitor(node.toProxy(), this.helpers);
376
+ } catch (e) {
377
+ throw this.handleError(e, node);
378
+ }
379
+ }
380
+ if (visit.iterator !== 0) {
381
+ let iterator = visit.iterator;
382
+ let child;
383
+ while (child = node.nodes[node.indexes[iterator]]) {
384
+ node.indexes[iterator] += 1;
385
+ if (!child[isClean]) {
386
+ child[isClean] = true;
387
+ stack.push(toStack(child));
388
+ return;
389
+ }
390
+ }
391
+ visit.iterator = 0;
392
+ delete node.indexes[iterator];
393
+ }
394
+ let events = visit.events;
395
+ while (visit.eventIndex < events.length) {
396
+ let event = events[visit.eventIndex];
397
+ visit.eventIndex += 1;
398
+ if (event === CHILDREN) {
399
+ if (node.nodes && node.nodes.length) {
400
+ node[isClean] = true;
401
+ visit.iterator = node.getIterator();
402
+ }
403
+ return;
404
+ } else if (this.listeners[event]) {
405
+ visit.visitors = this.listeners[event];
406
+ return;
407
+ }
408
+ }
409
+ stack.pop();
410
+ }
411
+ walkSync(node) {
412
+ node[isClean] = true;
413
+ let events = getEvents(node);
414
+ for (let event of events) {
415
+ if (event === CHILDREN) {
416
+ if (node.nodes) {
417
+ node.each((child) => {
418
+ if (!child[isClean]) this.walkSync(child);
419
+ });
420
+ }
421
+ } else {
422
+ let visitors = this.listeners[event];
423
+ if (visitors) {
424
+ if (this.visitSync(visitors, node.toProxy())) return;
425
+ }
426
+ }
427
+ }
428
+ }
429
+ warnings() {
430
+ return this.sync().warnings();
431
+ }
432
+ get content() {
433
+ return this.stringify().content;
434
+ }
435
+ get css() {
436
+ return this.stringify().css;
437
+ }
438
+ get map() {
439
+ return this.stringify().map;
440
+ }
441
+ get messages() {
442
+ return this.sync().messages;
443
+ }
444
+ get opts() {
445
+ return this.result.opts;
446
+ }
447
+ get processor() {
448
+ return this.result.processor;
449
+ }
450
+ get root() {
451
+ return this.sync().root;
452
+ }
453
+ get [Symbol.toStringTag]() {
454
+ return "LazyResult";
455
+ }
456
+ }
457
+ LazyResult.registerPostcss = (dependant) => {
458
+ postcss = dependant;
459
+ };
460
+ lazyResult = LazyResult;
461
+ LazyResult.default = LazyResult;
462
+ Root.registerLazyResult(LazyResult);
463
+ Document.registerLazyResult(LazyResult);
464
+ return lazyResult;
465
+ }
466
+ exports.__require = requireLazyResult;
467
+ //# sourceMappingURL=lazy-result.js.map