@olenbetong/appframe-vite 4.1.5 → 4.1.6

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.
Files changed (2) hide show
  1. package/lib/devServer.js +14 -2
  2. package/package.json +3 -3
package/lib/devServer.js CHANGED
@@ -62,13 +62,14 @@ async function transformArticleHtml(html) {
62
62
  else if (await exists(resolve(process.cwd(), "./src/index.ts"))) {
63
63
  entry = "/src/index.ts";
64
64
  }
65
- else if (await exists(resolve(process.cwd(), "./src/index.js"))) {
65
+ else {
66
66
  entry = "/src/index.js";
67
67
  }
68
68
  let article = appframe.article?.id;
69
69
  let { hostname } = await getLoginInfo();
70
70
  let dom = new JSDOM(html);
71
71
  let nodesToRemove = [];
72
+ let mainScriptAdded = false;
72
73
  dom.window.document.querySelectorAll("script").forEach((script) => {
73
74
  if (script.src?.startsWith(`/file/article/script/${article}/main`)) {
74
75
  let mainScript = dom.window.document.createElement("script");
@@ -76,6 +77,7 @@ async function transformArticleHtml(html) {
76
77
  mainScript.src = entry;
77
78
  script.insertAdjacentElement("beforebegin", mainScript);
78
79
  nodesToRemove.push(script);
80
+ mainScriptAdded = true;
79
81
  }
80
82
  else if (script.src?.includes("bugsnag")) {
81
83
  nodesToRemove.push(script);
@@ -95,6 +97,12 @@ async function transformArticleHtml(html) {
95
97
  script.insertAdjacentElement("afterend", localizeScript);
96
98
  }
97
99
  });
100
+ if (!mainScriptAdded) {
101
+ let mainScript = dom.window.document.createElement("script");
102
+ mainScript.type = "module";
103
+ mainScript.src = entry;
104
+ dom.window.document.body.appendChild(mainScript);
105
+ }
98
106
  dom.window.document.querySelectorAll("link").forEach((link) => {
99
107
  if (link.rel === "stylesheet" && link.href?.startsWith(`/file/article/style/${article}`)) {
100
108
  nodesToRemove.push(link);
@@ -114,11 +122,15 @@ async function transformArticleHtml(html) {
114
122
  async function getArticleHtml() {
115
123
  let { hostname, username, password } = await getLoginInfo();
116
124
  let article = appframe.article?.id;
125
+ console.log(hostname);
117
126
  let client = new Client(hostname);
118
- await client.login(username, password);
127
+ console.log(article);
128
+ let re = await client.login(username, password);
129
+ console.log("login", username, password, re);
119
130
  let response = await client.afFetch(`/${article}`, {
120
131
  timeout: 30000,
121
132
  });
133
+ console.log("afFetch", response.status);
122
134
  if (response.ok) {
123
135
  return await response.text();
124
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-vite",
3
- "version": "4.1.5",
3
+ "version": "4.1.6",
4
4
  "description": "Tools to use and deploy Vite applications to Appframe",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@olenbetong/appframe-data": "0.9.2",
22
+ "@olenbetong/appframe-data": "0.9.3",
23
23
  "body-parser": "^1.20.2",
24
24
  "chalk": "^5.3.0",
25
25
  "chokidar": "^3.5.3",
@@ -40,5 +40,5 @@
40
40
  "open": "^9.1.0",
41
41
  "tcp-port-used": "^1.0.2"
42
42
  },
43
- "gitHead": "c0fd9902c79c03be9d7234195845896012616789"
43
+ "gitHead": "54e7bf8d61f5f3ada6a635175d6c6fa564b2e62b"
44
44
  }