vatts 1.0.2 → 1.0.4-alpha.1

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/renderer.js CHANGED
@@ -119,6 +119,14 @@ function generateMetaTags(metadata) {
119
119
  tags.push(`<meta name="${key}" content="${value}">`);
120
120
  }
121
121
  }
122
+ if (metadata.scripts) {
123
+ for (const [key, value] of Object.entries(metadata.scripts)) {
124
+ const rest = Object.entries(value).map((r) => {
125
+ return '' + r[0] + '="' + r[1] + '"';
126
+ });
127
+ tags.push(`<script src="${key}" ${rest.join(" ")}></script>`);
128
+ }
129
+ }
122
130
  return tags.join('\n');
123
131
  }
124
132
  function obfuscateData(data) {
@@ -161,15 +169,14 @@ function getJavaScriptUrls(req) {
161
169
  }
162
170
  }
163
171
  function ServerRoot({ lang, title, metaTagsHtml, initialDataScript, hotReloadScript, dataScript, children }) {
164
- return ((0, jsx_runtime_1.jsxs)("html", { lang: lang, children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("title", { children: title }), initialDataScript && ((0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: { __html: initialDataScript } })), metaTagsHtml && ((0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: {
165
- __html: `
166
- (() => {
167
- const tpl = document.createElement('template');
168
- tpl.innerHTML = ${JSON.stringify(metaTagsHtml)};
169
- document.head.append(...tpl.content.childNodes);
170
- })();
171
- `
172
- } }))] }), (0, jsx_runtime_1.jsxs)("body", { children: [dataScript, (0, jsx_runtime_1.jsx)("div", { id: "root", children: children }), hotReloadScript && (0, jsx_runtime_1.jsx)("span", { dangerouslySetInnerHTML: { __html: hotReloadScript } })] })] }));
172
+ // Concatena tudo que vai no head em uma única string
173
+ const headContent = `
174
+ <meta charset="utf-8" />
175
+ <title>${title}</title>
176
+ ${initialDataScript ? `<script>${initialDataScript}</script>` : ''}
177
+ ${metaTagsHtml || ''}
178
+ `;
179
+ return ((0, jsx_runtime_1.jsxs)("html", { lang: lang, children: [(0, jsx_runtime_1.jsx)("head", { dangerouslySetInnerHTML: { __html: headContent } }), (0, jsx_runtime_1.jsxs)("body", { children: [dataScript, (0, jsx_runtime_1.jsx)("div", { id: "root", children: children }), hotReloadScript && ((0, jsx_runtime_1.jsx)("div", { style: { display: 'none' }, dangerouslySetInnerHTML: { __html: hotReloadScript } }))] })] }));
173
180
  }
174
181
  async function renderAsStream({ req, res, route, params, allRoutes }) {
175
182
  const { generateMetadata } = route;
package/dist/types.d.ts CHANGED
@@ -187,6 +187,7 @@ export interface Metadata {
187
187
  appleTouchIcon?: string;
188
188
  manifest?: string;
189
189
  other?: Record<string, string>;
190
+ scripts?: Record<string, Record<string, string>>;
190
191
  }
191
192
  export interface RouteConfig {
192
193
  pattern: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vatts",
3
- "version": "1.0.2",
3
+ "version": "1.0.4-alpha.1",
4
4
  "description": "Vatts.js is a high-level framework for building web applications with ease and speed. It provides a robust set of tools and features to streamline development and enhance productivity.",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "itsmuzin",