@codebit-programando-solucoes/codebit-web 1.1.7 → 1.1.9
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.
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
loadImage: ()=>loadImage,
|
|
28
|
+
markdownItBrEmptyLines: ()=>markdownItBrEmptyLines,
|
|
28
29
|
ErrorCode: ()=>ErrorCode,
|
|
29
30
|
ApiNetworkError: ()=>ApiNetworkError,
|
|
30
31
|
Logger: ()=>Logger,
|
|
@@ -67,7 +68,7 @@ async function createApiError(response, request) {
|
|
|
67
68
|
let responseData;
|
|
68
69
|
try {
|
|
69
70
|
const contentType = response.headers.get('content-type');
|
|
70
|
-
responseData = response.bodyUsed ? null : contentType
|
|
71
|
+
responseData = response.bodyUsed ? null : contentType?.includes('application/json') ? await response.json() : await response.text();
|
|
71
72
|
} catch {
|
|
72
73
|
responseData = null;
|
|
73
74
|
}
|
|
@@ -178,7 +179,7 @@ async function makeRequest(url, options = {}) {
|
|
|
178
179
|
}
|
|
179
180
|
if (!response.ok) throw await createApiError(response, config);
|
|
180
181
|
const contentType = response.headers.get('content-type');
|
|
181
|
-
if (contentType
|
|
182
|
+
if (contentType?.includes('application/json')) {
|
|
182
183
|
const data = await response.json();
|
|
183
184
|
return {
|
|
184
185
|
data,
|
|
@@ -318,20 +319,24 @@ async function fetchImageAsBlob(imageUrl) {
|
|
|
318
319
|
if (!response.ok) throw new Error(`Failed to fetch image: ${response.statusText} (${response.status})`);
|
|
319
320
|
return response.blob();
|
|
320
321
|
}
|
|
321
|
-
function _define_property(obj, key, value) {
|
|
322
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
323
|
-
value: value,
|
|
324
|
-
enumerable: true,
|
|
325
|
-
configurable: true,
|
|
326
|
-
writable: true
|
|
327
|
-
});
|
|
328
|
-
else obj[key] = value;
|
|
329
|
-
return obj;
|
|
330
|
-
}
|
|
331
322
|
class Logger {
|
|
323
|
+
static LOG_LEVELS = {
|
|
324
|
+
TRACE: 0,
|
|
325
|
+
DEBUG: 1,
|
|
326
|
+
INFO: 2,
|
|
327
|
+
WARN: 3,
|
|
328
|
+
ERROR: 4,
|
|
329
|
+
OFF: 5
|
|
330
|
+
};
|
|
331
|
+
static _defaultLevel = Logger.LOG_LEVELS.INFO;
|
|
332
332
|
static setDefaultLevel(level) {
|
|
333
333
|
Logger._defaultLevel = level;
|
|
334
334
|
}
|
|
335
|
+
constructor(name, level = Logger._defaultLevel){
|
|
336
|
+
if (!name || 'string' != typeof name) throw new Error('Logger name must be a non-empty string.');
|
|
337
|
+
this.name = name;
|
|
338
|
+
this.level = level;
|
|
339
|
+
}
|
|
335
340
|
debug(...args) {
|
|
336
341
|
if (this.level <= Logger.LOG_LEVELS.DEBUG) this._safeLog('debug', ...args);
|
|
337
342
|
}
|
|
@@ -354,21 +359,30 @@ class Logger {
|
|
|
354
359
|
const consoleMethod = console[method] || console.log;
|
|
355
360
|
consoleMethod(`[${this.name}]`, ...args);
|
|
356
361
|
}
|
|
357
|
-
constructor(name, level = Logger._defaultLevel){
|
|
358
|
-
if (!name || 'string' != typeof name) throw new Error('Logger name must be a non-empty string.');
|
|
359
|
-
this.name = name;
|
|
360
|
-
this.level = level;
|
|
361
|
-
}
|
|
362
362
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
363
|
+
const markdownItBrEmptyLines = (md)=>{
|
|
364
|
+
md.core.ruler.after('inline', 'br-on-empty-lines', (state)=>{
|
|
365
|
+
const tokens = state.tokens;
|
|
366
|
+
for(let i = 0; i < tokens.length; i++){
|
|
367
|
+
const nextOpen = tokens[i];
|
|
368
|
+
if (nextOpen?.type !== 'paragraph_open') continue;
|
|
369
|
+
const prevClose = tokens[i - 1];
|
|
370
|
+
const prevInline = tokens[i - 2];
|
|
371
|
+
const prevOpen = tokens[i - 3];
|
|
372
|
+
if (!prevClose || !prevInline || !prevOpen || 'paragraph_close' !== prevClose.type || 'inline' !== prevInline.type || 'paragraph_open' !== prevOpen.type) continue;
|
|
373
|
+
const prevMap = prevOpen.map;
|
|
374
|
+
const nextMap = nextOpen.map;
|
|
375
|
+
if (!prevMap || !nextMap) continue;
|
|
376
|
+
const emptyLines = nextMap[0] - prevMap[1];
|
|
377
|
+
if (emptyLines <= 0) continue;
|
|
378
|
+
const children = prevInline.children || (prevInline.children = []);
|
|
379
|
+
for(let k = 0; k < emptyLines; k++){
|
|
380
|
+
const br = new state.Token('hardbreak', 'br', 0);
|
|
381
|
+
children.push(br);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
};
|
|
372
386
|
exports.Api = __webpack_exports__.Api;
|
|
373
387
|
exports.ApiError = __webpack_exports__.ApiError;
|
|
374
388
|
exports.ApiNetworkError = __webpack_exports__.ApiNetworkError;
|
|
@@ -377,6 +391,7 @@ exports.Logger = __webpack_exports__.Logger;
|
|
|
377
391
|
exports.copyToClipboard = __webpack_exports__.copyToClipboard;
|
|
378
392
|
exports.fetchImageAsBlob = __webpack_exports__.fetchImageAsBlob;
|
|
379
393
|
exports.loadImage = __webpack_exports__.loadImage;
|
|
394
|
+
exports.markdownItBrEmptyLines = __webpack_exports__.markdownItBrEmptyLines;
|
|
380
395
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
381
396
|
"Api",
|
|
382
397
|
"ApiError",
|
|
@@ -385,7 +400,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
385
400
|
"Logger",
|
|
386
401
|
"copyToClipboard",
|
|
387
402
|
"fetchImageAsBlob",
|
|
388
|
-
"loadImage"
|
|
403
|
+
"loadImage",
|
|
404
|
+
"markdownItBrEmptyLines"
|
|
389
405
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
390
406
|
Object.defineProperty(exports, '__esModule', {
|
|
391
407
|
value: true
|
package/dist/util/index.d.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown‑It plugin that inserts `<br>` tokens for each empty line between
|
|
3
|
+
* consecutive paragraphs, effectively turning blank lines into hard line breaks.
|
|
4
|
+
*
|
|
5
|
+
* @param md - The `markdown-it` instance to which the plugin will be attached.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```js
|
|
9
|
+
* import MarkdownIt from 'markdown-it';
|
|
10
|
+
* import { markdownItBrEmptyLines } from './MarkdownItBrEmptyLines';
|
|
11
|
+
*
|
|
12
|
+
* const md = new MarkdownIt();
|
|
13
|
+
* md.use(markdownItBrEmptyLines);
|
|
14
|
+
*
|
|
15
|
+
* const result = md.render('Paragraph 1\\n\\n\\nParagraph 2');
|
|
16
|
+
* // result contains a <br> for each empty line between the paragraphs
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const markdownItBrEmptyLines: (md: import('markdown-it')) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MarkdownItBrEmptyLines';
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebit-programando-solucoes/codebit-web",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"types": "./
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"description": "",
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "UNLICENSED",
|
|
@@ -18,16 +18,18 @@
|
|
|
18
18
|
"default": "./dist/index.cjs"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"dependencies": {},
|
|
22
21
|
"peerDependencies": {
|
|
22
|
+
"prop-types": ">=15.8.1",
|
|
23
23
|
"react": ">=19.2.0",
|
|
24
24
|
"react-dom": ">=19.2.0",
|
|
25
25
|
"react-router": ">=7.12.0",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"sass": ">=1.89.0",
|
|
27
|
+
"markdown-it": "^14.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@eslint/js": "^9.39.2",
|
|
31
|
+
"@rsbuild/plugin-react": "1.4.3",
|
|
32
|
+
"@rsbuild/plugin-sass": "1.4.1",
|
|
31
33
|
"@rslib/core": "^0.18.0",
|
|
32
34
|
"@swc/core": "^1.13.5",
|
|
33
35
|
"cross-env": "^10.0.0",
|
|
@@ -39,12 +41,10 @@
|
|
|
39
41
|
"eslint-plugin-react": "^7.37.5",
|
|
40
42
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
41
43
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
44
|
+
"glob": "11.1.0",
|
|
42
45
|
"globals": "^16.3.0",
|
|
43
46
|
"prettier": "^3.6.2",
|
|
44
|
-
"prettier-plugin-jsdoc": "^1.3.3"
|
|
45
|
-
"glob": "11.1.0",
|
|
46
|
-
"@rsbuild/plugin-react": "1.4.3",
|
|
47
|
-
"@rsbuild/plugin-sass": "1.4.1"
|
|
47
|
+
"prettier-plugin-jsdoc": "^1.3.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"format:write": "prettier --write \"src/**/*.{js,jsx,mjs}\"",
|