@fiduswriter/frontend 0.1.63 → 0.1.64
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/css/manifest.json +15 -1
- package/package.json +1 -1
- package/scripts/aggregate-assets.js +104 -17
package/dist/css/manifest.json
CHANGED
|
@@ -36,11 +36,25 @@
|
|
|
36
36
|
"fwtoolkit/css/ui_tabs.css"
|
|
37
37
|
],
|
|
38
38
|
"additive": [
|
|
39
|
+
"@fiduswriter/frontend/css/colors.css",
|
|
39
40
|
"@fiduswriter/editor/css/colors.css",
|
|
40
41
|
"@fiduswriter/bibliography-manager/css/colors.css",
|
|
41
42
|
"@fiduswriter/bibliography-manager/css/forms.css"
|
|
42
43
|
],
|
|
43
|
-
"chrome": [
|
|
44
|
+
"chrome": [
|
|
45
|
+
"@fiduswriter/frontend/css/fonts.css",
|
|
46
|
+
"@fiduswriter/frontend/css/header_menu.css",
|
|
47
|
+
"@fiduswriter/frontend/css/admin.css",
|
|
48
|
+
"@fiduswriter/frontend/css/flatpage.css",
|
|
49
|
+
"@fiduswriter/frontend/css/prelogin.css",
|
|
50
|
+
"@fiduswriter/frontend/css/document_overview.css",
|
|
51
|
+
"@fiduswriter/frontend/css/document_template_admin.css",
|
|
52
|
+
"@fiduswriter/frontend/css/show_profile.css",
|
|
53
|
+
"@fiduswriter/frontend/css/two_factor.css",
|
|
54
|
+
"@fiduswriter/frontend/css/feedback.css",
|
|
55
|
+
"@fiduswriter/frontend/css/user_template_manager.css",
|
|
56
|
+
"@fiduswriter/frontend/css/errorlist.css"
|
|
57
|
+
],
|
|
44
58
|
"editor": [
|
|
45
59
|
"@fiduswriter/editor/css/editor.css",
|
|
46
60
|
"@fiduswriter/editor/css/document.css",
|
package/package.json
CHANGED
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs"
|
|
17
17
|
import { cpSync, readdirSync } from "node:fs"
|
|
18
|
+
import { createRequire } from "node:module"
|
|
18
19
|
import { join, dirname, relative } from "node:path"
|
|
19
20
|
import { fileURLToPath } from "node:url"
|
|
20
21
|
|
|
22
|
+
const require = createRequire(import.meta.url)
|
|
23
|
+
|
|
21
24
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
22
25
|
const root = join(__dirname, "..")
|
|
23
26
|
const dist = join(root, "dist")
|
|
@@ -54,14 +57,84 @@ function copyDir(src, dest) {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
|
-
*
|
|
60
|
+
* Locate an installed dependency's package root.
|
|
61
|
+
*
|
|
62
|
+
* Node's own module resolution is used first, then the nearest
|
|
63
|
+
* package.json with a matching name is found by walking up from the
|
|
64
|
+
* resolved entry point. Unlike join(root, "node_modules", ...), this
|
|
65
|
+
* works under every package manager's node_modules layout: npm flat,
|
|
66
|
+
* npm nested, pnpm's virtual store, and this repository's own
|
|
67
|
+
* development checkout (where the package underfoot resolves as
|
|
68
|
+
* itself). Returns null when the package cannot be resolved.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} pkgName e.g. "fwtoolkit" or "@fiduswriter/editor"
|
|
71
|
+
* @returns {string|null}
|
|
72
|
+
*/
|
|
73
|
+
function resolveDepRoot(pkgName) {
|
|
74
|
+
let entry = null
|
|
75
|
+
try {
|
|
76
|
+
entry = require.resolve(pkgName)
|
|
77
|
+
} catch {
|
|
78
|
+
// No CommonJS entry — try ESM resolution below.
|
|
79
|
+
}
|
|
80
|
+
if (entry === null) {
|
|
81
|
+
try {
|
|
82
|
+
entry = fileURLToPath(import.meta.resolve(pkgName))
|
|
83
|
+
} catch {
|
|
84
|
+
// Not resolvable by either condition set.
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (entry) {
|
|
88
|
+
let dir = dirname(entry)
|
|
89
|
+
for (;;) {
|
|
90
|
+
const pkgJsonPath = join(dir, "package.json")
|
|
91
|
+
if (existsSync(pkgJsonPath)) {
|
|
92
|
+
try {
|
|
93
|
+
if (
|
|
94
|
+
JSON.parse(readFileSync(pkgJsonPath, "utf8")).name ===
|
|
95
|
+
pkgName
|
|
96
|
+
) {
|
|
97
|
+
return dir
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
// A package.json that does not parse cannot be the one.
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const parent = dirname(dir)
|
|
104
|
+
if (parent === dir) {
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
dir = parent
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Development checkout: the package underfoot is its own dependency.
|
|
111
|
+
try {
|
|
112
|
+
if (
|
|
113
|
+
JSON.parse(readFileSync(join(root, "package.json"), "utf8"))
|
|
114
|
+
.name === pkgName
|
|
115
|
+
) {
|
|
116
|
+
return root
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
// Root package.json unreadable — not the dev checkout either.
|
|
120
|
+
}
|
|
121
|
+
return null
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Read a dependency's package.json.
|
|
58
126
|
* @param {string} pkgName e.g. "fwtoolkit" or "@fiduswriter/editor"
|
|
59
127
|
* @returns {object|null}
|
|
60
128
|
*/
|
|
61
129
|
function readDepPackage(pkgName) {
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
64
|
-
|
|
130
|
+
const depRoot = resolveDepRoot(pkgName)
|
|
131
|
+
if (!depRoot) return null
|
|
132
|
+
const path = join(depRoot, "package.json")
|
|
133
|
+
try {
|
|
134
|
+
return JSON.parse(readFileSync(path, "utf8"))
|
|
135
|
+
} catch {
|
|
136
|
+
return null
|
|
137
|
+
}
|
|
65
138
|
}
|
|
66
139
|
|
|
67
140
|
// ---------------------------------------------------------------------------
|
|
@@ -87,8 +160,9 @@ if (existsSync(join(root, "static"))) {
|
|
|
87
160
|
// ---------------------------------------------------------------------------
|
|
88
161
|
console.log("Step 1c: Copying @fiduswriter/editor static assets...")
|
|
89
162
|
|
|
90
|
-
const
|
|
91
|
-
|
|
163
|
+
const editorRoot = resolveDepRoot("@fiduswriter/editor")
|
|
164
|
+
const editorStatic = editorRoot ? join(editorRoot, "static") : null
|
|
165
|
+
if (editorStatic && existsSync(editorStatic)) {
|
|
92
166
|
copyDir(editorStatic, distStatic)
|
|
93
167
|
} else {
|
|
94
168
|
console.log(" (not found)")
|
|
@@ -122,7 +196,12 @@ const subDeps = [
|
|
|
122
196
|
]
|
|
123
197
|
|
|
124
198
|
for (const dep of subDeps) {
|
|
125
|
-
const
|
|
199
|
+
const depRoot = resolveDepRoot(dep.name)
|
|
200
|
+
if (!depRoot) {
|
|
201
|
+
console.log(` ${dep.name}: skipped (not installed)`)
|
|
202
|
+
continue
|
|
203
|
+
}
|
|
204
|
+
const src = join(depRoot, dep.cssDir)
|
|
126
205
|
const dest = join(distCss, dep.destDir)
|
|
127
206
|
if (!existsSync(src)) {
|
|
128
207
|
console.log(` ${dep.name}: skipped (not found at ${src})`)
|
|
@@ -178,17 +257,25 @@ manifest.tokens.push("fwtoolkit/css/colors.css")
|
|
|
178
257
|
manifest.typography.push("@fiduswriter/frontend/css/fonts.css")
|
|
179
258
|
|
|
180
259
|
// Layer 3: All fwtoolkit component CSS (used by the full SPA)
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
// and reset.css (already in the reset layer)
|
|
186
|
-
const fwtComponents = allFwtCss
|
|
187
|
-
.filter(
|
|
188
|
-
(f) => f !== "colors.css" && f !== "fwtoolkit.css" && f !== "reset.css"
|
|
260
|
+
const fwtoolkitRoot = resolveDepRoot("fwtoolkit")
|
|
261
|
+
if (fwtoolkitRoot) {
|
|
262
|
+
const allFwtCss = readdirSync(join(fwtoolkitRoot, "css")).filter((f) =>
|
|
263
|
+
f.endsWith(".css")
|
|
189
264
|
)
|
|
190
|
-
.
|
|
191
|
-
|
|
265
|
+
// Remove colors.css (already in tokens), common.css (goes in components),
|
|
266
|
+
// and reset.css (already in the reset layer)
|
|
267
|
+
const fwtComponents = allFwtCss
|
|
268
|
+
.filter(
|
|
269
|
+
(f) =>
|
|
270
|
+
f !== "colors.css" && f !== "fwtoolkit.css" && f !== "reset.css"
|
|
271
|
+
)
|
|
272
|
+
.map((f) => `fwtoolkit/css/${f}`)
|
|
273
|
+
manifest.components.push(...fwtComponents)
|
|
274
|
+
} else {
|
|
275
|
+
console.warn(
|
|
276
|
+
" fwtoolkit could not be resolved; the manifest will lack its component layer"
|
|
277
|
+
)
|
|
278
|
+
}
|
|
192
279
|
|
|
193
280
|
// Layer 4: Additive overrides from all packages
|
|
194
281
|
const additivePackages = [
|