@olenbetong/appframe-vite 5.1.30 → 5.1.32
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 +41 -45
- package/LICENSE +0 -21
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,46 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"tcp-port-used": "^1.0.2"
|
|
44
|
-
},
|
|
45
|
-
"gitHead": "3ba4d2b626e9c8f9607e141d7bf8ce9be2a3a8a8"
|
|
46
|
-
}
|
|
2
|
+
"name": "@olenbetong/appframe-vite",
|
|
3
|
+
"version": "5.1.32",
|
|
4
|
+
"description": "Tools to use and deploy Vite applications to Appframe",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"default": "./lib/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"lib"
|
|
13
|
+
],
|
|
14
|
+
"author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"body-parser": "^2.2.0",
|
|
18
|
+
"chalk": "^5.4.1",
|
|
19
|
+
"chokidar": "^4.0.3",
|
|
20
|
+
"dotenv": "^16.5.0",
|
|
21
|
+
"jsdom": "^26.1.0",
|
|
22
|
+
"rollup-plugin-visualizer": "^5.14.0",
|
|
23
|
+
"vite-plugin-externals": "^0.6.2",
|
|
24
|
+
"@olenbetong/appframe-data": "1.0.13"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jsdom": "^21.1.7",
|
|
28
|
+
"@types/node": "^22.14.1",
|
|
29
|
+
"typescript": "^5.8.3",
|
|
30
|
+
"vite": "^6.3.3"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"vite": ">=5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"optionalDependencies": {
|
|
36
|
+
"@types/tcp-port-used": "^1.0.4",
|
|
37
|
+
"open": "^10.1.1",
|
|
38
|
+
"tcp-port-used": "^1.0.2"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "ef3839cfde6097aa12488f72913680b3ce22706e",
|
|
41
|
+
"scripts": {}
|
|
42
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Ølen Betong
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|