@casterly/components
Advanced tools
Comparing version 0.4.1 to 0.4.2
import React from 'react'; | ||
export declare const Scripts: React.FC; | ||
export declare const Scripts: React.FC<Omit<React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>, 'src' | 'type' | 'async'>>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -9,6 +31,18 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var RootContext_1 = require("./RootContext"); | ||
var Scripts = function () { | ||
var _a = RootContext_1.useRootContext(), matchedRoutesAssets = _a.matchedRoutesAssets, matchedRoutes = _a.matchedRoutes, mainAssets = _a.mainAssets, version = _a.version; | ||
var Scripts = function (_a) { | ||
var nonce = _a.nonce, | ||
// @ts-ignore: You could still pass them if you're | ||
// using pure JavaScript | ||
src = _a.src, | ||
// @ts-ignore | ||
type = _a.type, | ||
// @ts-ignore | ||
async = _a.async, props = __rest(_a, ["nonce", "src", "type", "async"]); | ||
var _b = RootContext_1.useRootContext(), matchedRoutesAssets = _b.matchedRoutesAssets, matchedRoutes = _b.matchedRoutes, mainAssets = _b.mainAssets, version = _b.version; | ||
return (react_1.default.createElement(react_1.default.Fragment, null, | ||
react_1.default.createElement("script", { dangerouslySetInnerHTML: { | ||
react_1.default.createElement("script", { | ||
// We only need to add `nonce` to script tags with | ||
// inlined content, hence we don't add it to the scripts | ||
// below | ||
nonce: nonce, dangerouslySetInnerHTML: { | ||
__html: 'window.__serverContext = JSON.parse(' + | ||
@@ -26,4 +60,4 @@ JSON.stringify(JSON.stringify({ | ||
.filter(function (file) { return file.endsWith('.js'); }) | ||
.map(function (scriptSource) { return (react_1.default.createElement("script", { key: scriptSource, defer: true, src: scriptSource })); }))); | ||
.map(function (scriptSource) { return (react_1.default.createElement("script", __assign({ key: scriptSource }, props, { defer: true, src: scriptSource }))); }))); | ||
}; | ||
exports.Scripts = Scripts; |
import React from 'react'; | ||
export declare const Styles: React.FC; | ||
export declare const Styles: React.FC<Omit<React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>, 'type' | 'rel' | 'href'>>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -9,9 +31,17 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var RootContext_1 = require("./RootContext"); | ||
var Styles = function () { | ||
var _a = RootContext_1.useRootContext(), matchedRoutesAssets = _a.matchedRoutesAssets, mainAssets = _a.mainAssets; | ||
var Styles = function (_a) { | ||
var | ||
// @ts-ignore: You could still pass them if you're | ||
// using pure JavaScript | ||
type = _a.type, | ||
// @ts-ignore | ||
rel = _a.rel, | ||
// @ts-ignore | ||
href = _a.href, props = __rest(_a, ["type", "rel", "href"]); | ||
var _b = RootContext_1.useRootContext(), matchedRoutesAssets = _b.matchedRoutesAssets, mainAssets = _b.mainAssets; | ||
return (react_1.default.createElement(react_1.default.Fragment, null, matchedRoutesAssets | ||
.concat(mainAssets) | ||
.filter(function (file) { return file.endsWith('.css'); }) | ||
.map(function (file) { return (react_1.default.createElement("link", { key: file, rel: "stylesheet", type: "text/css", href: file })); }))); | ||
.map(function (file) { return (react_1.default.createElement("link", __assign({ key: file }, props, { rel: "stylesheet", type: "text/css", href: file }))); }))); | ||
}; | ||
exports.Styles = Styles; |
{ | ||
"name": "@casterly/components", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Base Casterly components", | ||
@@ -54,3 +54,3 @@ "author": "Lucas Cordeiro <ecdb.lucas@gmail.com>", | ||
}, | ||
"gitHead": "6011784f93827f201c16ef74e6fc09e801180255" | ||
"gitHead": "e7499d8789bc9bbc3a16005cc95046f21efbe017" | ||
} |
24090
483