@globalbrain/sefirot 4.33.0 → 4.34.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.
- package/config/nuxt.js +29 -3
- package/config/vite.js +44 -6
- package/lib/composables/Markdown.ts +27 -18
- package/lib/dompurify/browser.js +5 -0
- package/lib/dompurify/index.d.ts +6 -0
- package/lib/dompurify/node.js +6 -0
- package/package.json +49 -26
package/config/nuxt.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
import icons from 'unplugin-icons/nuxt'
|
|
5
|
-
import
|
|
5
|
+
import * as vite from 'vite'
|
|
6
6
|
import { baseConfig as baseViteConfig } from './vite.js'
|
|
7
7
|
|
|
8
8
|
export const baseConfig = {
|
|
@@ -25,10 +25,36 @@ export const baseConfig = {
|
|
|
25
25
|
resolve: { ...baseViteConfig.resolve, alias: {} },
|
|
26
26
|
plugins: baseViteConfig.plugins?.filter(
|
|
27
27
|
(plugin) => plugin && 'name' in plugin && plugin.name !== 'unplugin-icons'
|
|
28
|
-
)
|
|
28
|
+
),
|
|
29
|
+
optimizeDeps: {
|
|
30
|
+
...(baseViteConfig.optimizeDeps || {}),
|
|
31
|
+
exclude: [
|
|
32
|
+
...(baseViteConfig.optimizeDeps?.exclude || []),
|
|
33
|
+
'@vue/devtools-core',
|
|
34
|
+
'@vue/devtools-kit'
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
nitro: {
|
|
39
|
+
rollupConfig: {
|
|
40
|
+
plugins: [{
|
|
41
|
+
name: 'custom:transpile-ts',
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} code
|
|
44
|
+
* @param {string} id
|
|
45
|
+
*/
|
|
46
|
+
transform(code, id) {
|
|
47
|
+
if (id.endsWith('.ts')) {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
if (vite.rolldownVersion) { return vite.transformWithOxc(code, id, { sourcemap: true }) }
|
|
50
|
+
return vite.transformWithEsbuild(code, id, { sourcemap: true, loader: 'ts' })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}]
|
|
54
|
+
}
|
|
29
55
|
}
|
|
30
56
|
}
|
|
31
57
|
|
|
32
58
|
export function defineConfig(config = {}) {
|
|
33
|
-
return mergeConfig(baseConfig, config)
|
|
59
|
+
return vite.mergeConfig(baseConfig, config)
|
|
34
60
|
}
|
package/config/vite.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
/// <reference lib="esnext" />
|
|
2
3
|
|
|
4
|
+
import { glob } from 'node:fs/promises'
|
|
5
|
+
import path from 'node:path'
|
|
3
6
|
import { fileURLToPath } from 'node:url'
|
|
4
7
|
import MagicString from 'magic-string'
|
|
5
8
|
import icons from 'unplugin-icons/vite'
|
|
6
|
-
import
|
|
9
|
+
import * as vite from 'vite'
|
|
10
|
+
|
|
11
|
+
const lib = `${path.resolve(import.meta.dirname, '../lib/')}/`
|
|
12
|
+
// eslint-disable-next-line antfu/no-top-level-await
|
|
13
|
+
const files = (await Array.fromAsync(glob(`**/*.ts`, { cwd: lib })))
|
|
14
|
+
.filter((file) => !file.endsWith('.d.ts'))
|
|
15
|
+
.map((file) => `sefirot/${file}`.replace(/(?:\/index)?\.ts$/, ''))
|
|
7
16
|
|
|
8
17
|
/** @type {import('vite').UserConfig} */
|
|
9
18
|
export const baseConfig = {
|
|
@@ -54,7 +63,6 @@ export const baseConfig = {
|
|
|
54
63
|
'file-saver',
|
|
55
64
|
'fuse.js',
|
|
56
65
|
'html2canvas',
|
|
57
|
-
'isomorphic-dompurify',
|
|
58
66
|
'lodash-es',
|
|
59
67
|
'markdown-it',
|
|
60
68
|
'normalize.css',
|
|
@@ -67,21 +75,51 @@ export const baseConfig = {
|
|
|
67
75
|
]
|
|
68
76
|
},
|
|
69
77
|
|
|
70
|
-
ssr: {
|
|
78
|
+
ssr: {
|
|
79
|
+
noExternal: [
|
|
80
|
+
/sentry/
|
|
81
|
+
],
|
|
82
|
+
optimizeDeps: {
|
|
83
|
+
include: [
|
|
84
|
+
'file-saver'
|
|
85
|
+
],
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
// eslint-disable-next-line style/multiline-ternary
|
|
88
|
+
esbuildOptions: vite.rolldownVersion ? undefined : {
|
|
89
|
+
define: {
|
|
90
|
+
'navigator.userAgent': '""'
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
// eslint-disable-next-line style/multiline-ternary
|
|
95
|
+
rolldownOptions: vite.rolldownVersion ? {
|
|
96
|
+
transform: {
|
|
97
|
+
define: {
|
|
98
|
+
'navigator.userAgent': '""'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} : undefined
|
|
102
|
+
}
|
|
103
|
+
},
|
|
71
104
|
|
|
72
105
|
optimizeDeps: {
|
|
73
106
|
include: [
|
|
107
|
+
...files,
|
|
108
|
+
'@globalbrain/sefirot/dompurify',
|
|
74
109
|
'dayjs',
|
|
75
110
|
'dayjs/plugin/relativeTime',
|
|
76
111
|
'dayjs/plugin/timezone',
|
|
77
112
|
'dayjs/plugin/utc',
|
|
78
113
|
'dompurify',
|
|
79
114
|
'file-saver',
|
|
80
|
-
'isomorphic-dompurify',
|
|
81
115
|
'markdown-it > argparse',
|
|
82
|
-
'markdown-it > entities'
|
|
116
|
+
'markdown-it > entities',
|
|
117
|
+
'qs'
|
|
83
118
|
],
|
|
84
119
|
exclude: [
|
|
120
|
+
'@vueuse/core',
|
|
121
|
+
'fuse.js',
|
|
122
|
+
'lodash-es',
|
|
85
123
|
'markdown-it'
|
|
86
124
|
]
|
|
87
125
|
}
|
|
@@ -92,5 +130,5 @@ export const baseConfig = {
|
|
|
92
130
|
*/
|
|
93
131
|
export function defineConfig(config = {}) {
|
|
94
132
|
return async (/** @type {import("vite").ConfigEnv} */ configEnv) =>
|
|
95
|
-
mergeConfig(baseConfig, await (typeof config === 'function' ? config(configEnv) : config))
|
|
133
|
+
vite.mergeConfig(baseConfig, await (typeof config === 'function' ? config(configEnv) : config))
|
|
96
134
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type DOMPurifyConfig, type DOMPurifyI, createDompurify } from '@globalbrain/sefirot/dompurify'
|
|
2
2
|
import MarkdownIt from 'markdown-it'
|
|
3
3
|
|
|
4
4
|
export type UseMarkdown = (source: string, inline?: boolean) => string
|
|
@@ -70,31 +70,40 @@ export interface UseMarkdownOptions extends MarkdownItOptions {
|
|
|
70
70
|
config?: (md: MarkdownIt) => void
|
|
71
71
|
/** @default false */
|
|
72
72
|
inline?: boolean
|
|
73
|
-
|
|
73
|
+
domPurifyInstance?: DOMPurifyI
|
|
74
|
+
domPurifyOptions?: DOMPurifyConfig
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i
|
|
77
78
|
|
|
78
|
-
DOMPurify
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
let DOMPurify: DOMPurifyI | undefined
|
|
80
|
+
|
|
81
|
+
export function getDomPurifySingleton(): DOMPurifyI {
|
|
82
|
+
if (DOMPurify) { return DOMPurify }
|
|
83
|
+
DOMPurify = createDompurify()
|
|
84
|
+
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
|
|
85
|
+
if (node.tagName === 'A') {
|
|
86
|
+
const target = node.getAttribute('target')
|
|
87
|
+
if (target && target !== '_blank' && target !== '_self') {
|
|
88
|
+
node.removeAttribute('target')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const href = node.getAttribute('href')
|
|
92
|
+
if (href && EXTERNAL_URL_RE.test(href)) {
|
|
93
|
+
node.setAttribute('target', '_blank')
|
|
94
|
+
node.setAttribute('rel', 'noreferrer')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
node.classList.add('SMarkdown-link')
|
|
83
98
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
node.setAttribute('target', '_blank')
|
|
88
|
-
node.setAttribute('rel', 'noreferrer')
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
node.classList.add('SMarkdown-link')
|
|
92
|
-
}
|
|
93
|
-
})
|
|
99
|
+
})
|
|
100
|
+
return DOMPurify
|
|
101
|
+
}
|
|
94
102
|
|
|
95
103
|
export function useMarkdown({
|
|
96
104
|
config,
|
|
97
105
|
inline: _inline,
|
|
106
|
+
domPurifyInstance,
|
|
98
107
|
domPurifyOptions,
|
|
99
108
|
...options
|
|
100
109
|
}: UseMarkdownOptions = {}): UseMarkdown {
|
|
@@ -115,7 +124,7 @@ export function useMarkdown({
|
|
|
115
124
|
|
|
116
125
|
return (source, inline = _inline) => {
|
|
117
126
|
const html = inline ? md.renderInline(source) : md.render(source)
|
|
118
|
-
return
|
|
127
|
+
return (domPurifyInstance || getDomPurifySingleton()).sanitize(html, {
|
|
119
128
|
USE_PROFILES: { html: true },
|
|
120
129
|
ADD_ATTR: ['target'],
|
|
121
130
|
...domPurifyOptions
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// must be imported from `@globalbrain/sefirot/dompurify`
|
|
2
|
+
// otherwise conditional exports in package.json won't work
|
|
3
|
+
|
|
4
|
+
export declare function createDompurify(): import('dompurify').DOMPurify
|
|
5
|
+
|
|
6
|
+
export type { Config as DOMPurifyConfig, DOMPurify as DOMPurifyI } from 'dompurify'
|
package/package.json
CHANGED
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@globalbrain/sefirot",
|
|
3
|
-
"
|
|
4
|
-
"version": "4.33.0",
|
|
5
|
-
"packageManager": "pnpm@10.28.0",
|
|
3
|
+
"version": "4.34.1",
|
|
6
4
|
"description": "Vue Components for Global Brain Design System.",
|
|
7
|
-
"
|
|
8
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vue",
|
|
7
|
+
"vue3",
|
|
8
|
+
"components",
|
|
9
|
+
"design-system",
|
|
10
|
+
"ui-library",
|
|
11
|
+
"globalbrain"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://sefirot.globalbrains.com/",
|
|
9
14
|
"repository": {
|
|
10
15
|
"type": "git",
|
|
11
|
-
"url": "git
|
|
16
|
+
"url": "git+https://github.com/globalbrain/sefirot.git"
|
|
12
17
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Kia Ishii <ka.ishii@globalbrains.com>",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./client": {
|
|
23
|
+
"types": "./client.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./config/nuxt": {
|
|
26
|
+
"types": "./config/nuxt.d.ts",
|
|
27
|
+
"import": "./config/nuxt.js"
|
|
28
|
+
},
|
|
29
|
+
"./config/vite": {
|
|
30
|
+
"types": "./config/vite.d.ts",
|
|
31
|
+
"import": "./config/vite.js"
|
|
32
|
+
},
|
|
33
|
+
"./dompurify": {
|
|
34
|
+
"types": "./lib/dompurify/index.d.ts",
|
|
35
|
+
"browser": "./lib/dompurify/browser.js",
|
|
36
|
+
"default": "./lib/dompurify/node.js"
|
|
37
|
+
},
|
|
38
|
+
"./shared": {
|
|
39
|
+
"types": "./shared.d.ts"
|
|
40
|
+
},
|
|
41
|
+
"./*": "./*"
|
|
15
42
|
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"sefirot",
|
|
18
|
-
"vue",
|
|
19
|
-
"vue component"
|
|
20
|
-
],
|
|
21
43
|
"files": [
|
|
22
44
|
"lib",
|
|
23
45
|
"config",
|
|
@@ -50,13 +72,12 @@
|
|
|
50
72
|
"@types/body-scroll-lock": "^3.1.2",
|
|
51
73
|
"@types/lodash-es": "^4.17.12",
|
|
52
74
|
"@types/markdown-it": "^14.1.2",
|
|
53
|
-
"@vue/reactivity": "^3.5.
|
|
75
|
+
"@vue/reactivity": "^3.5.27",
|
|
54
76
|
"@vuelidate/core": "^2.0.3",
|
|
55
77
|
"@vuelidate/validators": "^2.0.4",
|
|
56
78
|
"@vueuse/core": "^12 || ^13 || ^14",
|
|
57
79
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
58
80
|
"dayjs": "^1.11.19",
|
|
59
|
-
"dompurify": "^3.3.1",
|
|
60
81
|
"fuse.js": "^7.1.0",
|
|
61
82
|
"lodash-es": "^4.17.22",
|
|
62
83
|
"markdown-it": "^14.1.0",
|
|
@@ -65,12 +86,12 @@
|
|
|
65
86
|
"postcss": "^8.5.6",
|
|
66
87
|
"postcss-nested": "^7.0.2",
|
|
67
88
|
"v-calendar": "3.0.1",
|
|
68
|
-
"vue": "^3.5.
|
|
89
|
+
"vue": "^3.5.27",
|
|
69
90
|
"vue-router": "^4.6.4"
|
|
70
91
|
},
|
|
71
92
|
"dependencies": {
|
|
72
|
-
"@sentry/browser": "^10.
|
|
73
|
-
"@sentry/vue": "^10.
|
|
93
|
+
"@sentry/browser": "^10.35.0",
|
|
94
|
+
"@sentry/vue": "^10.35.0",
|
|
74
95
|
"@tanstack/vue-virtual": "3.0.0-beta.62",
|
|
75
96
|
"@tinyhttp/content-disposition": "^2.2.2",
|
|
76
97
|
"@tinyhttp/cookie": "^2.1.1",
|
|
@@ -79,13 +100,14 @@
|
|
|
79
100
|
"@types/file-saver": "^2.0.7",
|
|
80
101
|
"@types/qs": "^6.14.0",
|
|
81
102
|
"d3": "^7.9.0",
|
|
103
|
+
"dompurify": "^3.3.1",
|
|
82
104
|
"file-saver": "^2.0.5",
|
|
83
105
|
"html2canvas": "^1.4.1",
|
|
84
|
-
"
|
|
106
|
+
"jsdom": "^27.4.0",
|
|
85
107
|
"magic-string": "^0.30.21",
|
|
86
108
|
"ofetch": "^1.5.1",
|
|
87
109
|
"qs": "^6.14.1",
|
|
88
|
-
"unplugin-icons": "^
|
|
110
|
+
"unplugin-icons": "^23.0.1"
|
|
89
111
|
},
|
|
90
112
|
"devDependencies": {
|
|
91
113
|
"@globalbrain/eslint-config": "^2.1.0",
|
|
@@ -95,22 +117,22 @@
|
|
|
95
117
|
"@popperjs/core": "^2.11.8",
|
|
96
118
|
"@release-it/conventional-changelog": "^10.0.4",
|
|
97
119
|
"@types/body-scroll-lock": "^3.1.2",
|
|
120
|
+
"@types/jsdom": "^27.0.0",
|
|
98
121
|
"@types/lodash-es": "^4.17.12",
|
|
99
122
|
"@types/markdown-it": "^14.1.2",
|
|
100
|
-
"@types/node": "^25.0.
|
|
123
|
+
"@types/node": "^25.0.9",
|
|
101
124
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
102
125
|
"@vitest/coverage-v8": "^3.2.4",
|
|
103
|
-
"@vue/reactivity": "^3.5.
|
|
126
|
+
"@vue/reactivity": "^3.5.27",
|
|
104
127
|
"@vue/test-utils": "^2.4.6",
|
|
105
128
|
"@vuelidate/core": "^2.0.3",
|
|
106
129
|
"@vuelidate/validators": "^2.0.4",
|
|
107
130
|
"@vueuse/core": "^14.1.0",
|
|
108
131
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
109
132
|
"dayjs": "^1.11.19",
|
|
110
|
-
"dompurify": "^3.3.1",
|
|
111
133
|
"eslint": "^9.39.2",
|
|
112
134
|
"fuse.js": "^7.1.0",
|
|
113
|
-
"happy-dom": "^20.
|
|
135
|
+
"happy-dom": "^20.3.3",
|
|
114
136
|
"histoire": "0.16.5",
|
|
115
137
|
"lodash-es": "^4.17.22",
|
|
116
138
|
"markdown-it": "^14.1.0",
|
|
@@ -125,8 +147,9 @@
|
|
|
125
147
|
"vite": "^6.4.1",
|
|
126
148
|
"vitepress": "^2.0.0-alpha.15",
|
|
127
149
|
"vitest": "^3.2.4",
|
|
128
|
-
"vue": "^3.5.
|
|
150
|
+
"vue": "^3.5.27",
|
|
129
151
|
"vue-router": "^4.6.4",
|
|
130
152
|
"vue-tsc": "^3.2.2"
|
|
131
|
-
}
|
|
153
|
+
},
|
|
154
|
+
"packageManager": "pnpm@10.28.1"
|
|
132
155
|
}
|