plugin-build-guide-block 1.0.2 → 1.0.4

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 (108) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/client/models/UserGuideBlockModel.d.ts +6 -0
  3. package/dist/client/schemas/spacesSchema.d.ts +21 -5
  4. package/dist/node_modules/sanitize-html/LICENSE +7 -0
  5. package/dist/node_modules/sanitize-html/index.js +7 -0
  6. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.cjs +34 -0
  7. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.js +34 -0
  8. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.cjs +35 -0
  9. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.d.ts +56 -0
  10. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.js +35 -0
  11. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.native.js +26 -0
  12. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/package.json +12 -0
  13. package/dist/node_modules/sanitize-html/node_modules/nanoid/bin/nanoid.cjs +55 -0
  14. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.cjs +34 -0
  15. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.js +34 -0
  16. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.cjs +45 -0
  17. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.cts +91 -0
  18. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.ts +91 -0
  19. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.js +45 -0
  20. package/dist/node_modules/sanitize-html/node_modules/nanoid/nanoid.js +1 -0
  21. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.cjs +21 -0
  22. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.d.ts +33 -0
  23. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.js +21 -0
  24. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/package.json +6 -0
  25. package/dist/node_modules/sanitize-html/node_modules/nanoid/package.json +88 -0
  26. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.cjs +3 -0
  27. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.js +3 -0
  28. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/package.json +6 -0
  29. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.d.ts +115 -0
  30. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.js +25 -0
  31. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.d.ts +67 -0
  32. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.js +13 -0
  33. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.d.ts +452 -0
  34. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.js +439 -0
  35. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.d.ts +248 -0
  36. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.js +100 -0
  37. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.d.ts +148 -0
  38. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.js +24 -0
  39. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.d.ts +68 -0
  40. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.js +33 -0
  41. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  42. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.js +54 -0
  43. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.d.ts +194 -0
  44. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.js +248 -0
  45. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.d.ts +190 -0
  46. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.js +550 -0
  47. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.d.ts +57 -0
  48. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.js +58 -0
  49. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/map-generator.js +359 -0
  50. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.d.ts +46 -0
  51. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.js +135 -0
  52. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.d.ts +536 -0
  53. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.js +381 -0
  54. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.d.ts +9 -0
  55. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.js +42 -0
  56. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parser.js +610 -0
  57. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.mts +72 -0
  58. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.ts +441 -0
  59. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.js +101 -0
  60. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.d.ts +81 -0
  61. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.js +142 -0
  62. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.d.ts +115 -0
  63. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.js +67 -0
  64. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.d.ts +206 -0
  65. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.js +42 -0
  66. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.d.ts +86 -0
  67. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.js +61 -0
  68. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.d.ts +113 -0
  69. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.js +27 -0
  70. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.d.ts +46 -0
  71. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.js +353 -0
  72. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.d.ts +9 -0
  73. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.js +11 -0
  74. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/symbols.js +5 -0
  75. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/terminal-highlight.js +70 -0
  76. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/tokenize.js +266 -0
  77. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warn-once.js +13 -0
  78. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.d.ts +147 -0
  79. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.js +37 -0
  80. package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid +15 -0
  81. package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid.cmd +7 -0
  82. package/dist/node_modules/sanitize-html/node_modules/postcss/package.json +88 -0
  83. package/dist/node_modules/sanitize-html/package.json +1 -0
  84. package/package.json +9 -1
  85. package/src/client/UserGuideBlock.tsx +53 -0
  86. package/src/client/UserGuideBlockInitializer.tsx +26 -0
  87. package/src/client/UserGuideBlockProvider.tsx +12 -0
  88. package/src/client/UserGuideManager.tsx +107 -0
  89. package/src/client/client.d.ts +249 -0
  90. package/src/client/components/BuildButton.tsx +43 -0
  91. package/src/client/components/LLMServiceSelect.tsx +44 -0
  92. package/src/client/components/ModelSelect.tsx +41 -0
  93. package/src/client/components/StatusTag.tsx +17 -0
  94. package/src/client/index.tsx +1 -0
  95. package/src/client/models/UserGuideBlockModel.ts +54 -0
  96. package/src/client/models/index.ts +12 -0
  97. package/src/client/plugin.tsx +30 -0
  98. package/src/client/schemas/spacesSchema.ts +322 -0
  99. package/src/index.ts +2 -0
  100. package/src/locale/en-US.json +27 -0
  101. package/src/locale/vi-VN.json +27 -0
  102. package/src/locale/zh-CN.json +27 -0
  103. package/src/server/actions/build.ts +171 -0
  104. package/src/server/actions/getHtml.ts +26 -0
  105. package/src/server/collections/.gitkeep +0 -0
  106. package/src/server/collections/ai-build-guide-spaces.ts +49 -0
  107. package/src/server/index.ts +1 -0
  108. package/src/server/plugin.ts +42 -0
@@ -0,0 +1,248 @@
1
+ 'use strict'
2
+
3
+ let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
4
+ let { fileURLToPath, pathToFileURL } = require('url')
5
+ let { isAbsolute, resolve } = require('path')
6
+ let { nanoid } = require('nanoid/non-secure')
7
+
8
+ let terminalHighlight = require('./terminal-highlight')
9
+ let CssSyntaxError = require('./css-syntax-error')
10
+ let PreviousMap = require('./previous-map')
11
+
12
+ let fromOffsetCache = Symbol('fromOffsetCache')
13
+
14
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)
15
+ let pathAvailable = Boolean(resolve && isAbsolute)
16
+
17
+ class Input {
18
+ constructor(css, opts = {}) {
19
+ if (
20
+ css === null ||
21
+ typeof css === 'undefined' ||
22
+ (typeof css === 'object' && !css.toString)
23
+ ) {
24
+ throw new Error(`PostCSS received ${css} instead of CSS string`)
25
+ }
26
+
27
+ this.css = css.toString()
28
+
29
+ if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
30
+ this.hasBOM = true
31
+ this.css = this.css.slice(1)
32
+ } else {
33
+ this.hasBOM = false
34
+ }
35
+
36
+ if (opts.from) {
37
+ if (
38
+ !pathAvailable ||
39
+ /^\w+:\/\//.test(opts.from) ||
40
+ isAbsolute(opts.from)
41
+ ) {
42
+ this.file = opts.from
43
+ } else {
44
+ this.file = resolve(opts.from)
45
+ }
46
+ }
47
+
48
+ if (pathAvailable && sourceMapAvailable) {
49
+ let map = new PreviousMap(this.css, opts)
50
+ if (map.text) {
51
+ this.map = map
52
+ let file = map.consumer().file
53
+ if (!this.file && file) this.file = this.mapResolve(file)
54
+ }
55
+ }
56
+
57
+ if (!this.file) {
58
+ this.id = '<input css ' + nanoid(6) + '>'
59
+ }
60
+ if (this.map) this.map.file = this.from
61
+ }
62
+
63
+ error(message, line, column, opts = {}) {
64
+ let result, endLine, endColumn
65
+
66
+ if (line && typeof line === 'object') {
67
+ let start = line
68
+ let end = column
69
+ if (typeof start.offset === 'number') {
70
+ let pos = this.fromOffset(start.offset)
71
+ line = pos.line
72
+ column = pos.col
73
+ } else {
74
+ line = start.line
75
+ column = start.column
76
+ }
77
+ if (typeof end.offset === 'number') {
78
+ let pos = this.fromOffset(end.offset)
79
+ endLine = pos.line
80
+ endColumn = pos.col
81
+ } else {
82
+ endLine = end.line
83
+ endColumn = end.column
84
+ }
85
+ } else if (!column) {
86
+ let pos = this.fromOffset(line)
87
+ line = pos.line
88
+ column = pos.col
89
+ }
90
+
91
+ let origin = this.origin(line, column, endLine, endColumn)
92
+ if (origin) {
93
+ result = new CssSyntaxError(
94
+ message,
95
+ origin.endLine === undefined
96
+ ? origin.line
97
+ : { column: origin.column, line: origin.line },
98
+ origin.endLine === undefined
99
+ ? origin.column
100
+ : { column: origin.endColumn, line: origin.endLine },
101
+ origin.source,
102
+ origin.file,
103
+ opts.plugin
104
+ )
105
+ } else {
106
+ result = new CssSyntaxError(
107
+ message,
108
+ endLine === undefined ? line : { column, line },
109
+ endLine === undefined ? column : { column: endColumn, line: endLine },
110
+ this.css,
111
+ this.file,
112
+ opts.plugin
113
+ )
114
+ }
115
+
116
+ result.input = { column, endColumn, endLine, line, source: this.css }
117
+ if (this.file) {
118
+ if (pathToFileURL) {
119
+ result.input.url = pathToFileURL(this.file).toString()
120
+ }
121
+ result.input.file = this.file
122
+ }
123
+
124
+ return result
125
+ }
126
+
127
+ fromOffset(offset) {
128
+ let lastLine, lineToIndex
129
+ if (!this[fromOffsetCache]) {
130
+ let lines = this.css.split('\n')
131
+ lineToIndex = new Array(lines.length)
132
+ let prevIndex = 0
133
+
134
+ for (let i = 0, l = lines.length; i < l; i++) {
135
+ lineToIndex[i] = prevIndex
136
+ prevIndex += lines[i].length + 1
137
+ }
138
+
139
+ this[fromOffsetCache] = lineToIndex
140
+ } else {
141
+ lineToIndex = this[fromOffsetCache]
142
+ }
143
+ lastLine = lineToIndex[lineToIndex.length - 1]
144
+
145
+ let min = 0
146
+ if (offset >= lastLine) {
147
+ min = lineToIndex.length - 1
148
+ } else {
149
+ let max = lineToIndex.length - 2
150
+ let mid
151
+ while (min < max) {
152
+ mid = min + ((max - min) >> 1)
153
+ if (offset < lineToIndex[mid]) {
154
+ max = mid - 1
155
+ } else if (offset >= lineToIndex[mid + 1]) {
156
+ min = mid + 1
157
+ } else {
158
+ min = mid
159
+ break
160
+ }
161
+ }
162
+ }
163
+ return {
164
+ col: offset - lineToIndex[min] + 1,
165
+ line: min + 1
166
+ }
167
+ }
168
+
169
+ mapResolve(file) {
170
+ if (/^\w+:\/\//.test(file)) {
171
+ return file
172
+ }
173
+ return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
174
+ }
175
+
176
+ origin(line, column, endLine, endColumn) {
177
+ if (!this.map) return false
178
+ let consumer = this.map.consumer()
179
+
180
+ let from = consumer.originalPositionFor({ column, line })
181
+ if (!from.source) return false
182
+
183
+ let to
184
+ if (typeof endLine === 'number') {
185
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine })
186
+ }
187
+
188
+ let fromUrl
189
+
190
+ if (isAbsolute(from.source)) {
191
+ fromUrl = pathToFileURL(from.source)
192
+ } else {
193
+ fromUrl = new URL(
194
+ from.source,
195
+ this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
196
+ )
197
+ }
198
+
199
+ let result = {
200
+ column: from.column,
201
+ endColumn: to && to.column,
202
+ endLine: to && to.line,
203
+ line: from.line,
204
+ url: fromUrl.toString()
205
+ }
206
+
207
+ if (fromUrl.protocol === 'file:') {
208
+ if (fileURLToPath) {
209
+ result.file = fileURLToPath(fromUrl)
210
+ } else {
211
+ /* c8 ignore next 2 */
212
+ throw new Error(`file: protocol is not available in this PostCSS build`)
213
+ }
214
+ }
215
+
216
+ let source = consumer.sourceContentFor(from.source)
217
+ if (source) result.source = source
218
+
219
+ return result
220
+ }
221
+
222
+ toJSON() {
223
+ let json = {}
224
+ for (let name of ['hasBOM', 'css', 'file', 'id']) {
225
+ if (this[name] != null) {
226
+ json[name] = this[name]
227
+ }
228
+ }
229
+ if (this.map) {
230
+ json.map = { ...this.map }
231
+ if (json.map.consumerCache) {
232
+ json.map.consumerCache = undefined
233
+ }
234
+ }
235
+ return json
236
+ }
237
+
238
+ get from() {
239
+ return this.file || this.id
240
+ }
241
+ }
242
+
243
+ module.exports = Input
244
+ Input.default = Input
245
+
246
+ if (terminalHighlight && terminalHighlight.registerInput) {
247
+ terminalHighlight.registerInput(Input)
248
+ }
@@ -0,0 +1,190 @@
1
+ import Document from './document.js'
2
+ import { SourceMap } from './postcss.js'
3
+ import Processor from './processor.js'
4
+ import Result, { Message, ResultOptions } from './result.js'
5
+ import Root from './root.js'
6
+ import Warning from './warning.js'
7
+
8
+ declare namespace LazyResult {
9
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
10
+ export { LazyResult_ as default }
11
+ }
12
+
13
+ /**
14
+ * A Promise proxy for the result of PostCSS transformations.
15
+ *
16
+ * A `LazyResult` instance is returned by `Processor#process`.
17
+ *
18
+ * ```js
19
+ * const lazy = postcss([autoprefixer]).process(css)
20
+ * ```
21
+ */
22
+ declare class LazyResult_<RootNode = Document | Root>
23
+ implements PromiseLike<Result<RootNode>>
24
+ {
25
+ /**
26
+ * Processes input CSS through synchronous and asynchronous plugins
27
+ * and calls onRejected for each error thrown in any plugin.
28
+ *
29
+ * It implements standard Promise API.
30
+ *
31
+ * ```js
32
+ * postcss([autoprefixer]).process(css).then(result => {
33
+ * console.log(result.css)
34
+ * }).catch(error => {
35
+ * console.error(error)
36
+ * })
37
+ * ```
38
+ */
39
+ catch: Promise<Result<RootNode>>['catch']
40
+
41
+ /**
42
+ * Processes input CSS through synchronous and asynchronous plugins
43
+ * and calls onFinally on any error or when all plugins will finish work.
44
+ *
45
+ * It implements standard Promise API.
46
+ *
47
+ * ```js
48
+ * postcss([autoprefixer]).process(css).finally(() => {
49
+ * console.log('processing ended')
50
+ * })
51
+ * ```
52
+ */
53
+ finally: Promise<Result<RootNode>>['finally']
54
+
55
+ /**
56
+ * Processes input CSS through synchronous and asynchronous plugins
57
+ * and calls `onFulfilled` with a Result instance. If a plugin throws
58
+ * an error, the `onRejected` callback will be executed.
59
+ *
60
+ * It implements standard Promise API.
61
+ *
62
+ * ```js
63
+ * postcss([autoprefixer]).process(css, { from: cssPath }).then(result => {
64
+ * console.log(result.css)
65
+ * })
66
+ * ```
67
+ */
68
+ then: Promise<Result<RootNode>>['then']
69
+
70
+ /**
71
+ * @param processor Processor used for this transformation.
72
+ * @param css CSS to parse and transform.
73
+ * @param opts Options from the `Processor#process` or `Root#toResult`.
74
+ */
75
+ constructor(processor: Processor, css: string, opts: ResultOptions)
76
+
77
+ /**
78
+ * Run plugin in async way and return `Result`.
79
+ *
80
+ * @return Result with output content.
81
+ */
82
+ async(): Promise<Result<RootNode>>
83
+
84
+ /**
85
+ * Run plugin in sync way and return `Result`.
86
+ *
87
+ * @return Result with output content.
88
+ */
89
+ sync(): Result<RootNode>
90
+
91
+ /**
92
+ * Alias for the `LazyResult#css` property.
93
+ *
94
+ * ```js
95
+ * lazy + '' === lazy.css
96
+ * ```
97
+ *
98
+ * @return Output CSS.
99
+ */
100
+ toString(): string
101
+
102
+ /**
103
+ * Processes input CSS through synchronous plugins
104
+ * and calls `Result#warnings`.
105
+ *
106
+ * @return Warnings from plugins.
107
+ */
108
+ warnings(): Warning[]
109
+
110
+ /**
111
+ * An alias for the `css` property. Use it with syntaxes
112
+ * that generate non-CSS output.
113
+ *
114
+ * This property will only work with synchronous plugins.
115
+ * If the processor contains any asynchronous plugins
116
+ * it will throw an error.
117
+ *
118
+ * PostCSS runners should always use `LazyResult#then`.
119
+ */
120
+ get content(): string
121
+
122
+ /**
123
+ * Processes input CSS through synchronous plugins, converts `Root`
124
+ * to a CSS string and returns `Result#css`.
125
+ *
126
+ * This property will only work with synchronous plugins.
127
+ * If the processor contains any asynchronous plugins
128
+ * it will throw an error.
129
+ *
130
+ * PostCSS runners should always use `LazyResult#then`.
131
+ */
132
+ get css(): string
133
+
134
+ /**
135
+ * Processes input CSS through synchronous plugins
136
+ * and returns `Result#map`.
137
+ *
138
+ * This property will only work with synchronous plugins.
139
+ * If the processor contains any asynchronous plugins
140
+ * it will throw an error.
141
+ *
142
+ * PostCSS runners should always use `LazyResult#then`.
143
+ */
144
+ get map(): SourceMap
145
+
146
+ /**
147
+ * Processes input CSS through synchronous plugins
148
+ * and returns `Result#messages`.
149
+ *
150
+ * This property will only work with synchronous plugins. If the processor
151
+ * contains any asynchronous plugins it will throw an error.
152
+ *
153
+ * PostCSS runners should always use `LazyResult#then`.
154
+ */
155
+ get messages(): Message[]
156
+
157
+ /**
158
+ * Options from the `Processor#process` call.
159
+ */
160
+ get opts(): ResultOptions
161
+
162
+ /**
163
+ * Returns a `Processor` instance, which will be used
164
+ * for CSS transformations.
165
+ */
166
+ get processor(): Processor
167
+
168
+ /**
169
+ * Processes input CSS through synchronous plugins
170
+ * and returns `Result#root`.
171
+ *
172
+ * This property will only work with synchronous plugins. If the processor
173
+ * contains any asynchronous plugins it will throw an error.
174
+ *
175
+ * PostCSS runners should always use `LazyResult#then`.
176
+ */
177
+ get root(): RootNode
178
+
179
+ /**
180
+ * Returns the default string description of an object.
181
+ * Required to implement the Promise interface.
182
+ */
183
+ get [Symbol.toStringTag](): string
184
+ }
185
+
186
+ declare class LazyResult<
187
+ RootNode = Document | Root
188
+ > extends LazyResult_<RootNode> {}
189
+
190
+ export = LazyResult