@olenbetong/appframe-vite 5.1.30 → 5.1.31
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/lib/build.d.ts +1 -1
- package/lib/devServer.d.ts +1 -1
- package/lib/devServer.js +14 -9
- package/lib/index.d.ts +1 -1
- package/lib/localization.d.ts +1 -1
- package/package.json +9 -9
package/lib/build.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UserConfig } from "vite";
|
|
1
|
+
import type { UserConfig } from "vite";
|
|
2
2
|
export declare function addAppframeBuildConfig(config: UserConfig): Promise<UserConfig>;
|
package/lib/devServer.d.ts
CHANGED
package/lib/devServer.js
CHANGED
|
@@ -70,7 +70,8 @@ async function transformArticleHtml(html) {
|
|
|
70
70
|
let dom = new JSDOM(html);
|
|
71
71
|
let nodesToRemove = [];
|
|
72
72
|
let mainScriptAdded = false;
|
|
73
|
-
dom.window.document.querySelectorAll("script")
|
|
73
|
+
let scriptTags = dom.window.document.querySelectorAll("script");
|
|
74
|
+
for (let script of scriptTags) {
|
|
74
75
|
if (script.src?.startsWith(`/file/article/script/${article}/main`)) {
|
|
75
76
|
let mainScript = dom.window.document.createElement("script");
|
|
76
77
|
mainScript.type = "module";
|
|
@@ -96,27 +97,31 @@ async function transformArticleHtml(html) {
|
|
|
96
97
|
localizeScript.textContent = `Object.assign(af.article.i18n, ${JSON.stringify(cachedStrings)})`;
|
|
97
98
|
script.insertAdjacentElement("afterend", localizeScript);
|
|
98
99
|
}
|
|
99
|
-
}
|
|
100
|
+
}
|
|
100
101
|
if (!mainScriptAdded) {
|
|
101
102
|
let mainScript = dom.window.document.createElement("script");
|
|
102
103
|
mainScript.type = "module";
|
|
103
104
|
mainScript.src = entry;
|
|
104
105
|
dom.window.document.body.appendChild(mainScript);
|
|
105
106
|
}
|
|
106
|
-
dom.window.document.querySelectorAll("link")
|
|
107
|
+
let linkTags = dom.window.document.querySelectorAll("link");
|
|
108
|
+
for (let link of linkTags) {
|
|
107
109
|
if (link.rel === "stylesheet" && link.href?.startsWith(`/file/article/style/${article}`)) {
|
|
108
110
|
nodesToRemove.push(link);
|
|
109
111
|
}
|
|
110
112
|
else if (link.rel === "prefetch" && link.href?.startsWith(`/file/article`)) {
|
|
111
113
|
nodesToRemove.push(link);
|
|
112
114
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
}
|
|
116
|
+
for (let node of nodesToRemove) {
|
|
117
|
+
node.remove();
|
|
118
|
+
}
|
|
119
|
+
let anchors = dom.window.document.querySelectorAll("a");
|
|
120
|
+
for (let anchor of anchors) {
|
|
116
121
|
if (anchor.href?.startsWith("/") && !anchor.href?.startsWith(`/${article}`)) {
|
|
117
122
|
anchor.href = `https://${hostname}${anchor.href}`;
|
|
118
123
|
}
|
|
119
|
-
}
|
|
124
|
+
}
|
|
120
125
|
return dom.serialize();
|
|
121
126
|
}
|
|
122
127
|
async function getArticleHtml() {
|
|
@@ -171,10 +176,10 @@ export function createDevMiddleware(vite) {
|
|
|
171
176
|
let url = req.originalUrl;
|
|
172
177
|
let article = appPkg.appframe.article.id;
|
|
173
178
|
let isLogin = article === "login";
|
|
174
|
-
let isRootArticle = isLogin ? url === "/" : url?.startsWith(
|
|
179
|
+
let isRootArticle = isLogin ? url === "/" : url?.startsWith(`/${appPkg.appframe.article.id}`);
|
|
175
180
|
if (!isRootArticle && Array.isArray(appPkg.appframe.article.altNames)) {
|
|
176
181
|
for (let name of appPkg.appframe.article.altNames) {
|
|
177
|
-
if (url?.startsWith(
|
|
182
|
+
if (url?.startsWith(`/${name}`)) {
|
|
178
183
|
isRootArticle = true;
|
|
179
184
|
break;
|
|
180
185
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/localization.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connect } from "vite";
|
|
1
|
+
import type { Connect } from "vite";
|
|
2
2
|
export declare function addStringToCache(text: string, translation: string): void;
|
|
3
3
|
export declare const localizeMiddleware: Connect.NextHandleFunction;
|
|
4
4
|
export declare function getStringCache(): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-vite",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.31",
|
|
4
4
|
"description": "Tools to use and deploy Vite applications to Appframe",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,28 +19,28 @@
|
|
|
19
19
|
"author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@olenbetong/appframe-data": "1.0.
|
|
22
|
+
"@olenbetong/appframe-data": "1.0.12",
|
|
23
23
|
"body-parser": "^2.2.0",
|
|
24
24
|
"chalk": "^5.4.1",
|
|
25
25
|
"chokidar": "^4.0.3",
|
|
26
|
-
"dotenv": "^16.
|
|
27
|
-
"jsdom": "^26.
|
|
26
|
+
"dotenv": "^16.5.0",
|
|
27
|
+
"jsdom": "^26.1.0",
|
|
28
28
|
"rollup-plugin-visualizer": "^5.14.0",
|
|
29
29
|
"vite-plugin-externals": "^0.6.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/jsdom": "^21.1.7",
|
|
33
|
-
"@types/node": "^22.14.
|
|
34
|
-
"typescript": "^5.
|
|
35
|
-
"vite": "^6.
|
|
33
|
+
"@types/node": "^22.14.1",
|
|
34
|
+
"typescript": "^5.8.3",
|
|
35
|
+
"vite": "^6.3.3"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"vite": ">=5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
41
|
"@types/tcp-port-used": "^1.0.4",
|
|
42
|
-
"open": "^10.1.
|
|
42
|
+
"open": "^10.1.1",
|
|
43
43
|
"tcp-port-used": "^1.0.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "bc10814d960b65e6959fb8506259e4d369f094ab"
|
|
46
46
|
}
|