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