122 lines
3.7 KiB
JavaScript
122 lines
3.7 KiB
JavaScript
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
var stdin_exports = {};
|
|
__export(stdin_exports, {
|
|
a: () => each,
|
|
b: () => add_attribute,
|
|
c: () => create_ssr_component,
|
|
e: () => escape,
|
|
m: () => missing_component,
|
|
s: () => setContext,
|
|
v: () => validate_component
|
|
});
|
|
module.exports = __toCommonJS(stdin_exports);
|
|
function run(fn) {
|
|
return fn();
|
|
}
|
|
function blank_object() {
|
|
return /* @__PURE__ */ Object.create(null);
|
|
}
|
|
function run_all(fns) {
|
|
fns.forEach(run);
|
|
}
|
|
let current_component;
|
|
function set_current_component(component) {
|
|
current_component = component;
|
|
}
|
|
function get_current_component() {
|
|
if (!current_component)
|
|
throw new Error("Function called outside component initialization");
|
|
return current_component;
|
|
}
|
|
function setContext(key, context) {
|
|
get_current_component().$$.context.set(key, context);
|
|
}
|
|
Promise.resolve();
|
|
const escaped = {
|
|
'"': """,
|
|
"'": "'",
|
|
"&": "&",
|
|
"<": "<",
|
|
">": ">"
|
|
};
|
|
function escape(html) {
|
|
return String(html).replace(/["'&<>]/g, (match) => escaped[match]);
|
|
}
|
|
function escape_attribute_value(value) {
|
|
return typeof value === "string" ? escape(value) : value;
|
|
}
|
|
function each(items, fn) {
|
|
let str = "";
|
|
for (let i = 0; i < items.length; i += 1) {
|
|
str += fn(items[i], i);
|
|
}
|
|
return str;
|
|
}
|
|
const missing_component = {
|
|
$$render: () => ""
|
|
};
|
|
function validate_component(component, name) {
|
|
if (!component || !component.$$render) {
|
|
if (name === "svelte:component")
|
|
name += " this={...}";
|
|
throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);
|
|
}
|
|
return component;
|
|
}
|
|
let on_destroy;
|
|
function create_ssr_component(fn) {
|
|
function $$render(result, props, bindings, slots, context) {
|
|
const parent_component = current_component;
|
|
const $$ = {
|
|
on_destroy,
|
|
context: new Map(context || (parent_component ? parent_component.$$.context : [])),
|
|
on_mount: [],
|
|
before_update: [],
|
|
after_update: [],
|
|
callbacks: blank_object()
|
|
};
|
|
set_current_component({ $$ });
|
|
const html = fn(result, props, bindings, slots);
|
|
set_current_component(parent_component);
|
|
return html;
|
|
}
|
|
return {
|
|
render: (props = {}, { $$slots = {}, context = /* @__PURE__ */ new Map() } = {}) => {
|
|
on_destroy = [];
|
|
const result = { title: "", head: "", css: /* @__PURE__ */ new Set() };
|
|
const html = $$render(result, props, {}, $$slots, context);
|
|
run_all(on_destroy);
|
|
return {
|
|
html,
|
|
css: {
|
|
code: Array.from(result.css).map((css) => css.code).join("\n"),
|
|
map: null
|
|
},
|
|
head: result.title + result.head
|
|
};
|
|
},
|
|
$$render
|
|
};
|
|
}
|
|
function add_attribute(name, value, boolean) {
|
|
if (value == null || boolean && !value)
|
|
return "";
|
|
const assignment = boolean && value === true ? "" : `="${escape_attribute_value(value.toString())}"`;
|
|
return ` ${name}${assignment}`;
|
|
}
|