@cocreate/server-side-render 1.12.6 → 1.12.8
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/.github/workflows/automated.yml +5 -5
- package/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/index.js +45 -6
|
@@ -22,13 +22,13 @@ jobs:
|
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
steps:
|
|
24
24
|
- name: Checkout
|
|
25
|
-
uses: actions/checkout@
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
26
|
- name: Setup Node.js
|
|
27
|
-
uses: actions/setup-node@
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
28
|
with:
|
|
29
|
-
node-version:
|
|
29
|
+
node-version: 22 # Required for the latest semantic-release plugins
|
|
30
30
|
- name: Semantic Release
|
|
31
|
-
uses: cycjimmy/semantic-release-action@
|
|
31
|
+
uses: cycjimmy/semantic-release-action@v4 # Update to v4 for better Node 20+ support
|
|
32
32
|
id: semantic
|
|
33
33
|
with:
|
|
34
34
|
extra_plugins: |
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
@semantic-release/git
|
|
37
37
|
@semantic-release/github
|
|
38
38
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.
|
|
39
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Use the built-in token if possible
|
|
40
40
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
41
41
|
outputs:
|
|
42
42
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.12.8](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.12.7...v1.12.8) (2026-04-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* enhance chunk rendering logic to support outerHTML insertion ([b605d4a](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/b605d4a775dd7dfb2493d8450f63022e553da5ee))
|
|
7
|
+
* svg images not rendering in server-side rendering ([01a6882](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/01a688296c369bf5ffe32c6b0fb8c8f38e70b243))
|
|
8
|
+
|
|
9
|
+
## [1.12.7](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.12.6...v1.12.7) (2025-10-11)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* add theme injection to HTML rendering for improved client-side styling ([e849c72](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/e849c72cf4112c8e6caa44187bca3fada5ff72cc))
|
|
15
|
+
|
|
1
16
|
## [1.12.6](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.12.5...v1.12.6) (2025-10-11)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/server-side-render",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.8",
|
|
4
4
|
"description": "A simple server-side-render component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"server-side-render",
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@ class CoCreateServerSideRender {
|
|
|
7
7
|
this.crud = crud;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
async HTML(file, organization, urlObject, langRegion, lang) {
|
|
10
|
+
async HTML(file, organization, urlObject, langRegion, lang, theme) {
|
|
11
11
|
const self = this;
|
|
12
12
|
let ignoreElement = {
|
|
13
13
|
INPUT: true,
|
|
@@ -141,6 +141,10 @@ class CoCreateServerSideRender {
|
|
|
141
141
|
) {
|
|
142
142
|
let chunk = data.object[0].src;
|
|
143
143
|
|
|
144
|
+
if (typeof chunk === "string" && chunk.startsWith("data:image/svg+xml;base64,")) {
|
|
145
|
+
chunk = Buffer.from(chunk.split(",")[1], "base64").toString("utf-8");
|
|
146
|
+
}
|
|
147
|
+
|
|
144
148
|
// Replace $relativePath in the fetched chunk
|
|
145
149
|
let path =
|
|
146
150
|
el.getAttribute("path") || getRelativePath(file.path);
|
|
@@ -158,11 +162,24 @@ class CoCreateServerSideRender {
|
|
|
158
162
|
let chunkDom = parse(chunk);
|
|
159
163
|
chunkDom = await render(chunkDom);
|
|
160
164
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
// If element requests outerHTML insertion, replace the element
|
|
166
|
+
// with the fetched chunk's content. Otherwise append children.
|
|
167
|
+
const valueType = el.getAttribute && el.getAttribute("value-type");
|
|
168
|
+
if (valueType === "outerHTML") {
|
|
169
|
+
// Replace the element with the parsed chunk's child nodes
|
|
170
|
+
// spread child nodes so we don't create an extra wrapper
|
|
171
|
+
if (chunkDom.childNodes && chunkDom.childNodes.length) {
|
|
172
|
+
el.replaceWith(...chunkDom.childNodes);
|
|
173
|
+
} else {
|
|
174
|
+
// If no child nodes, just remove the element
|
|
175
|
+
el.remove();
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
el.setAttribute("rendered", "");
|
|
179
|
+
el.innerHTML = "";
|
|
180
|
+
for (const child of chunkDom.childNodes) {
|
|
181
|
+
el.appendChild(child);
|
|
182
|
+
}
|
|
166
183
|
}
|
|
167
184
|
}
|
|
168
185
|
}
|
|
@@ -176,6 +193,28 @@ class CoCreateServerSideRender {
|
|
|
176
193
|
dom = await this.translate(dom, file, langRegion, lang);
|
|
177
194
|
}
|
|
178
195
|
|
|
196
|
+
// Inject preferred theme into the DOM so client gets server-rendered theme
|
|
197
|
+
if (theme) {
|
|
198
|
+
const htmlEl = dom.querySelector("html");
|
|
199
|
+
try {
|
|
200
|
+
if (htmlEl && htmlEl.setAttribute) htmlEl.setAttribute("data-bs-theme", theme);
|
|
201
|
+
|
|
202
|
+
const head = dom.querySelector("head");
|
|
203
|
+
if (head) {
|
|
204
|
+
// add or update color-scheme meta tag
|
|
205
|
+
let meta = head.querySelector('meta[name="color-scheme"]');
|
|
206
|
+
if (meta && meta.setAttribute) {
|
|
207
|
+
meta.setAttribute("content", theme);
|
|
208
|
+
} else {
|
|
209
|
+
const metaNode = parse(`<meta name="color-scheme" content="${theme}">`);
|
|
210
|
+
head.appendChild(metaNode);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (e) {
|
|
214
|
+
// fail-safe: don't abort rendering if theme injection fails
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
179
218
|
if (organization.languages && organization.languages.length > 0) {
|
|
180
219
|
let langLinkTags = this.createLanguageLinkTags(
|
|
181
220
|
file,
|