@meistrari/tela-build 1.29.1 → 1.29.3
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.
|
@@ -786,11 +786,55 @@ function scrollToPage(page: number) {
|
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
-
function download(url: string) {
|
|
789
|
+
async function download(url: string) {
|
|
790
790
|
if (!url)
|
|
791
791
|
return
|
|
792
792
|
|
|
793
|
-
|
|
793
|
+
const filename = props.file.fileName || 'download'
|
|
794
|
+
|
|
795
|
+
function triggerAnchor(href: string, revokeAfter?: string) {
|
|
796
|
+
const a = document.createElement('a')
|
|
797
|
+
a.href = href
|
|
798
|
+
a.download = filename
|
|
799
|
+
document.body.appendChild(a)
|
|
800
|
+
a.click()
|
|
801
|
+
document.body.removeChild(a)
|
|
802
|
+
if (revokeAfter) {
|
|
803
|
+
setTimeout(() => URL.revokeObjectURL(revokeAfter), 10_000)
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (url.startsWith('data:')) {
|
|
808
|
+
try {
|
|
809
|
+
const response = await fetch(url)
|
|
810
|
+
const blob = await response.blob()
|
|
811
|
+
const blobUrl = URL.createObjectURL(blob)
|
|
812
|
+
triggerAnchor(blobUrl, blobUrl)
|
|
813
|
+
}
|
|
814
|
+
catch {
|
|
815
|
+
triggerAnchor(url)
|
|
816
|
+
}
|
|
817
|
+
return
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
try {
|
|
821
|
+
const response = await fetch(url)
|
|
822
|
+
if (!response.ok)
|
|
823
|
+
throw new Error(`HTTP ${response.status}`)
|
|
824
|
+
const blob = await response.blob()
|
|
825
|
+
const blobUrl = URL.createObjectURL(blob)
|
|
826
|
+
triggerAnchor(blobUrl, blobUrl)
|
|
827
|
+
}
|
|
828
|
+
catch {
|
|
829
|
+
const a = document.createElement('a')
|
|
830
|
+
a.href = url
|
|
831
|
+
a.download = filename
|
|
832
|
+
a.target = '_blank'
|
|
833
|
+
a.rel = 'noopener noreferrer'
|
|
834
|
+
document.body.appendChild(a)
|
|
835
|
+
a.click()
|
|
836
|
+
document.body.removeChild(a)
|
|
837
|
+
}
|
|
794
838
|
}
|
|
795
839
|
|
|
796
840
|
const isContainerHovered = ref(false)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import { execSync } from 'node:child_process'
|
|
3
|
+
import { existsSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
2
4
|
import { defineNuxtModule, createResolver } from '@nuxt/kit'
|
|
3
5
|
import { resolve } from 'pathe'
|
|
4
|
-
import { existsSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
5
6
|
import { collectComponentDocs, generateMarkdown, generateDocsToDirectory } from '../../lib/doc-generator'
|
|
6
7
|
import { ensureOverlayTsconfig } from '../../lib/extractors/volar-extract'
|
|
7
8
|
|
|
@@ -82,9 +83,11 @@ export default defineNuxtModule<TelaBuildDocsOptions>({
|
|
|
82
83
|
// Generate documentation (directory-first unless outFile explicitly set)
|
|
83
84
|
logger.log(`${colors.gray}[tela/build] ${colors.orange}◐${colors.gray} Generating documentation for ${componentDocs.length} components${colors.reset}`)
|
|
84
85
|
|
|
86
|
+
const baseDir = findGitRoot(nuxt.options.rootDir) ?? nuxt.options.rootDir
|
|
87
|
+
|
|
85
88
|
if (options.outFile) {
|
|
86
89
|
// Single-file mode (legacy)
|
|
87
|
-
const outPath = resolve(
|
|
90
|
+
const outPath = resolve(baseDir, options.outFile)
|
|
88
91
|
const outDir = resolve(outPath, '..')
|
|
89
92
|
if (!existsSync(outDir)) {
|
|
90
93
|
mkdirSync(outDir, { recursive: true })
|
|
@@ -95,7 +98,7 @@ export default defineNuxtModule<TelaBuildDocsOptions>({
|
|
|
95
98
|
}
|
|
96
99
|
else {
|
|
97
100
|
// Directory output: single Skill (tela-build) + supporting component pages
|
|
98
|
-
const outDir = resolve(
|
|
101
|
+
const outDir = resolve(baseDir, options.outDir!)
|
|
99
102
|
generateDocsToDirectory(componentDocs, typeResolver, outDir, layerPath)
|
|
100
103
|
logger.log(`${colors.gray}[tela/build] ${colors.green}●${colors.gray} Documentation complete → ${outDir}${colors.reset}`)
|
|
101
104
|
}
|
|
@@ -124,6 +127,15 @@ export default defineNuxtModule<TelaBuildDocsOptions>({
|
|
|
124
127
|
},
|
|
125
128
|
})
|
|
126
129
|
|
|
130
|
+
function findGitRoot(cwd: string): string | null {
|
|
131
|
+
try {
|
|
132
|
+
return execSync('git rev-parse --show-toplevel', { cwd, encoding: 'utf-8' }).trim()
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
127
139
|
function resolveLayerPath(): string | null {
|
|
128
140
|
// Use createResolver to resolve paths relative to this module
|
|
129
141
|
// This works correctly even when the module is installed from npm/github
|