mirror of
https://github.com/woutdp/live_svelte
synced 2026-05-24 09:28:21 +00:00
Build assets
This commit is contained in:
parent
80f66dabb6
commit
f23472ce3b
6 changed files with 79 additions and 73 deletions
|
|
@ -19,17 +19,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|||
// js/live_svelte/index.js
|
||||
var live_svelte_exports = {};
|
||||
__export(live_svelte_exports, {
|
||||
exportSvelteComponents: () => exportSvelteComponents,
|
||||
getHooks: () => getHooks,
|
||||
render: () => render
|
||||
getRender: () => getRender
|
||||
});
|
||||
module.exports = __toCommonJS(live_svelte_exports);
|
||||
|
||||
// js/live_svelte/utils.js
|
||||
function normalizeComponents(components) {
|
||||
if (!Array.isArray(components.default) || !Array.isArray(components.filenames))
|
||||
return components;
|
||||
const normalized = {};
|
||||
for (const [index, module2] of components.default.entries()) {
|
||||
const Component = module2.default;
|
||||
const name = components.filenames[index].replace("../svelte/", "").replace(".svelte", "");
|
||||
normalized[name] = Component;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// js/live_svelte/render.js
|
||||
function render(name, props, slots) {
|
||||
const component = require(__filename)[name];
|
||||
const $$slots = Object.fromEntries(Object.entries(slots).map(([k, v]) => [k, () => v]));
|
||||
return component.render(props, { $$slots });
|
||||
function getRender(components) {
|
||||
components = normalizeComponents(components);
|
||||
return function render(name, props, slots) {
|
||||
const Component = components[name];
|
||||
const $$slots = Object.fromEntries(Object.entries(slots).map(([k, v]) => [k, () => v]));
|
||||
return Component.render(props, { $$slots });
|
||||
};
|
||||
}
|
||||
|
||||
// ../node_modules/svelte/internal/index.mjs
|
||||
|
|
@ -149,13 +164,6 @@ if (typeof HTMLElement === "function") {
|
|||
};
|
||||
}
|
||||
|
||||
// js/live_svelte/utils.js
|
||||
function exportSvelteComponents(components) {
|
||||
let { default: modules, filenames } = components;
|
||||
filenames = filenames.map((name) => name.replace("../svelte/", "")).map((name) => name.replace(".svelte", ""));
|
||||
return Object.assign({}, ...modules.map((m, index) => ({ [filenames[index]]: m.default })));
|
||||
}
|
||||
|
||||
// js/live_svelte/hooks.js
|
||||
function base64ToElement(base64) {
|
||||
const template = document.createElement("div");
|
||||
|
|
@ -218,8 +226,7 @@ function getProps(ref) {
|
|||
return {
|
||||
...dataAttributeToJson("data-props", ref.el),
|
||||
...getLiveJsonProps(ref),
|
||||
pushEvent: (event, data, callback) => ref.pushEvent(event, data, callback),
|
||||
pushEventTo: (selectorOrTarget, event, data, callback) => ref.pushEventTo(selectorOrTarget, event, data, callback),
|
||||
live: ref,
|
||||
$$slots: createSlots(dataAttributeToJson("data-slots", ref.el), ref),
|
||||
$$scope: {}
|
||||
};
|
||||
|
|
@ -227,8 +234,8 @@ function getProps(ref) {
|
|||
function findSlotCtx(component) {
|
||||
return component.$$.ctx.find((ctxElement) => ctxElement?.default);
|
||||
}
|
||||
function getHooks(Components) {
|
||||
const components = exportSvelteComponents(Components);
|
||||
function getHooks(components) {
|
||||
components = normalizeComponents(components);
|
||||
const SvelteHook = {
|
||||
mounted() {
|
||||
const componentName = this.el.getAttribute("data-name");
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,16 +1,24 @@
|
|||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined")
|
||||
return require.apply(this, arguments);
|
||||
throw new Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
// js/live_svelte/utils.js
|
||||
function normalizeComponents(components) {
|
||||
if (!Array.isArray(components.default) || !Array.isArray(components.filenames))
|
||||
return components;
|
||||
const normalized = {};
|
||||
for (const [index, module] of components.default.entries()) {
|
||||
const Component = module.default;
|
||||
const name = components.filenames[index].replace("../svelte/", "").replace(".svelte", "");
|
||||
normalized[name] = Component;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// js/live_svelte/render.js
|
||||
function render(name, props, slots) {
|
||||
const component = __require(__filename)[name];
|
||||
const $$slots = Object.fromEntries(Object.entries(slots).map(([k, v]) => [k, () => v]));
|
||||
return component.render(props, { $$slots });
|
||||
function getRender(components) {
|
||||
components = normalizeComponents(components);
|
||||
return function render(name, props, slots) {
|
||||
const Component = components[name];
|
||||
const $$slots = Object.fromEntries(Object.entries(slots).map(([k, v]) => [k, () => v]));
|
||||
return Component.render(props, { $$slots });
|
||||
};
|
||||
}
|
||||
|
||||
// ../node_modules/svelte/internal/index.mjs
|
||||
|
|
@ -130,13 +138,6 @@ if (typeof HTMLElement === "function") {
|
|||
};
|
||||
}
|
||||
|
||||
// js/live_svelte/utils.js
|
||||
function exportSvelteComponents(components) {
|
||||
let { default: modules, filenames } = components;
|
||||
filenames = filenames.map((name) => name.replace("../svelte/", "")).map((name) => name.replace(".svelte", ""));
|
||||
return Object.assign({}, ...modules.map((m, index) => ({ [filenames[index]]: m.default })));
|
||||
}
|
||||
|
||||
// js/live_svelte/hooks.js
|
||||
function base64ToElement(base64) {
|
||||
const template = document.createElement("div");
|
||||
|
|
@ -199,8 +200,7 @@ function getProps(ref) {
|
|||
return {
|
||||
...dataAttributeToJson("data-props", ref.el),
|
||||
...getLiveJsonProps(ref),
|
||||
pushEvent: (event, data, callback) => ref.pushEvent(event, data, callback),
|
||||
pushEventTo: (selectorOrTarget, event, data, callback) => ref.pushEventTo(selectorOrTarget, event, data, callback),
|
||||
live: ref,
|
||||
$$slots: createSlots(dataAttributeToJson("data-slots", ref.el), ref),
|
||||
$$scope: {}
|
||||
};
|
||||
|
|
@ -208,8 +208,8 @@ function getProps(ref) {
|
|||
function findSlotCtx(component) {
|
||||
return component.$$.ctx.find((ctxElement) => ctxElement?.default);
|
||||
}
|
||||
function getHooks(Components) {
|
||||
const components = exportSvelteComponents(Components);
|
||||
function getHooks(components) {
|
||||
components = normalizeComponents(components);
|
||||
const SvelteHook = {
|
||||
mounted() {
|
||||
const componentName = this.el.getAttribute("data-name");
|
||||
|
|
@ -245,8 +245,7 @@ function getHooks(Components) {
|
|||
};
|
||||
}
|
||||
export {
|
||||
exportSvelteComponents,
|
||||
getHooks,
|
||||
render
|
||||
getRender
|
||||
};
|
||||
//# sourceMappingURL=live_svelte.esm.js.map
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -20,13 +20,6 @@ var LiveSvelte = (() => {
|
|||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined")
|
||||
return require.apply(this, arguments);
|
||||
throw new Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
|
|
@ -44,16 +37,31 @@ var LiveSvelte = (() => {
|
|||
// js/live_svelte/index.js
|
||||
var live_svelte_exports = {};
|
||||
__export(live_svelte_exports, {
|
||||
exportSvelteComponents: () => exportSvelteComponents,
|
||||
getHooks: () => getHooks,
|
||||
render: () => render
|
||||
getRender: () => getRender
|
||||
});
|
||||
|
||||
// js/live_svelte/utils.js
|
||||
function normalizeComponents(components) {
|
||||
if (!Array.isArray(components.default) || !Array.isArray(components.filenames))
|
||||
return components;
|
||||
const normalized = {};
|
||||
for (const [index, module] of components.default.entries()) {
|
||||
const Component = module.default;
|
||||
const name = components.filenames[index].replace("../svelte/", "").replace(".svelte", "");
|
||||
normalized[name] = Component;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// js/live_svelte/render.js
|
||||
function render(name, props, slots) {
|
||||
const component = __require(__filename)[name];
|
||||
const $$slots = Object.fromEntries(Object.entries(slots).map(([k, v]) => [k, () => v]));
|
||||
return component.render(props, { $$slots });
|
||||
function getRender(components) {
|
||||
components = normalizeComponents(components);
|
||||
return function render(name, props, slots) {
|
||||
const Component = components[name];
|
||||
const $$slots = Object.fromEntries(Object.entries(slots).map(([k, v]) => [k, () => v]));
|
||||
return Component.render(props, { $$slots });
|
||||
};
|
||||
}
|
||||
|
||||
// ../node_modules/svelte/internal/index.mjs
|
||||
|
|
@ -173,13 +181,6 @@ var LiveSvelte = (() => {
|
|||
};
|
||||
}
|
||||
|
||||
// js/live_svelte/utils.js
|
||||
function exportSvelteComponents(components) {
|
||||
let { default: modules, filenames } = components;
|
||||
filenames = filenames.map((name) => name.replace("../svelte/", "")).map((name) => name.replace(".svelte", ""));
|
||||
return Object.assign({}, ...modules.map((m, index) => ({ [filenames[index]]: m.default })));
|
||||
}
|
||||
|
||||
// js/live_svelte/hooks.js
|
||||
function base64ToElement(base64) {
|
||||
const template = document.createElement("div");
|
||||
|
|
@ -240,8 +241,7 @@ var LiveSvelte = (() => {
|
|||
}
|
||||
function getProps(ref) {
|
||||
return __spreadProps(__spreadValues(__spreadValues({}, dataAttributeToJson("data-props", ref.el)), getLiveJsonProps(ref)), {
|
||||
pushEvent: (event, data, callback) => ref.pushEvent(event, data, callback),
|
||||
pushEventTo: (selectorOrTarget, event, data, callback) => ref.pushEventTo(selectorOrTarget, event, data, callback),
|
||||
live: ref,
|
||||
$$slots: createSlots(dataAttributeToJson("data-slots", ref.el), ref),
|
||||
$$scope: {}
|
||||
});
|
||||
|
|
@ -249,8 +249,8 @@ var LiveSvelte = (() => {
|
|||
function findSlotCtx(component) {
|
||||
return component.$$.ctx.find((ctxElement) => ctxElement == null ? void 0 : ctxElement.default);
|
||||
}
|
||||
function getHooks(Components) {
|
||||
const components = exportSvelteComponents(Components);
|
||||
function getHooks(components) {
|
||||
components = normalizeComponents(components);
|
||||
const SvelteHook = {
|
||||
mounted() {
|
||||
const componentName = this.el.getAttribute("data-name");
|
||||
|
|
|
|||
2
priv/static/live_svelte.min.js
vendored
2
priv/static/live_svelte.min.js
vendored
|
|
@ -1 +1 @@
|
|||
var LiveSvelte=(()=>{var f=Object.defineProperty,T=Object.defineProperties,j=Object.getOwnPropertyDescriptor,D=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var w=(t,e,n)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,h=(t,e)=>{for(var n in e||(e={}))v.call(e,n)&&w(t,n,e[n]);if($)for(var n of $(e))N.call(e,n)&&w(t,n,e[n]);return t},F=(t,e)=>T(t,D(e));var x=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var L=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},P=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of M(e))!v.call(t,o)&&o!==n&&f(t,o,{get:()=>e[o],enumerable:!(i=j(e,o))||i.enumerable});return t};var R=t=>P(f({},"__esModule",{value:!0}),t);var V={};L(V,{exportSvelteComponents:()=>d,getHooks:()=>C,render:()=>E});function E(t,e,n){let i=x(__filename)[t],o=Object.fromEntries(Object.entries(n).map(([r,c])=>[r,()=>c]));return i.render(e,{$$slots:o})}function l(){}function A(t){return t()}function O(t){t.forEach(A)}function k(t){return typeof t=="function"}function q(t){return Object.keys(t).length===0}function p(t,e,n){t.insertBefore(e,n||null)}function m(t){t.parentNode&&t.parentNode.removeChild(t)}var S=[];function I(t){let e=[],n=[];S.forEach(i=>t.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),S=e}var Q=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var B=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],Z=new Set([...B]);function H(t,e){let n=t.$$;n.fragment!==null&&(I(n.after_update),O(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}var z;typeof HTMLElement=="function"&&(z=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(A).filter(k);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){O(this.$$.on_disconnect)}$destroy(){H(this,1),this.$destroy=l}$on(t,e){if(!k(e))return l;let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!q(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});function d(t){let{default:e,filenames:n}=t;return n=n.map(i=>i.replace("../svelte/","")).map(i=>i.replace(".svelte","")),Object.assign({},...e.map((i,o)=>({[n[o]]:i.default})))}function J(t){let e=document.createElement("div");return e.innerHTML=atob(t).trim(),e}function u(t,e){let n=e.getAttribute(t);return n?JSON.parse(n):{}}function G(t,e){let n=(o,r)=>{let c,y,a;return()=>({getElement(){return J(u("data-slots",r.el)[o])},update(){let s=this.getElement();m(a),p(c,s,y),a=s},c:l,m(s,g){let b=this.getElement();c=s,y=g,a=b,p(s,b,g)},d(s){s&&m(a)},l})},i={};for(let o in t)i[o]=[n(o,e)];return i}function W(t){let e=u("data-live-json",t.el);if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e;let n={};for(let i of e){let o=window[i];o&&(n[i]=o)}return n}function _(t){return F(h(h({},u("data-props",t.el)),W(t)),{pushEvent:(e,n,i)=>t.pushEvent(e,n,i),pushEventTo:(e,n,i,o)=>t.pushEventTo(e,n,i,o),$$slots:G(u("data-slots",t.el),t),$$scope:{}})}function U(t){return t.$$.ctx.find(e=>e==null?void 0:e.default)}function C(t){let e=d(t);return{SvelteHook:{mounted(){let i=this.el.getAttribute("data-name");if(!i)throw new Error("Component name must be provided");let o=e[i];if(!o)throw new Error(`Unable to find ${i} component.`);for(let r of Object.keys(u("data-live-json",this.el)))window.addEventListener(`${r}_initialized`,c=>this._instance.$set(_(this)),!1),window.addEventListener(`${r}_patched`,c=>this._instance.$set(_(this)),!1);this._instance=new o({target:this.el,props:_(this),hydrate:this.el.hasAttribute("data-ssr")})},updated(){this._instance.$set(_(this));let i=U(this._instance);for(let o in i)i[o][0]().update()},destroyed(){}}}}return R(V);})();
|
||||
var LiveSvelte=(()=>{var d=Object.defineProperty,C=Object.defineProperties,D=Object.getOwnPropertyDescriptor,M=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var w=(t,e,n)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,p=(t,e)=>{for(var n in e||(e={}))F.call(e,n)&&w(t,n,e[n]);if($)for(var n of $(e))j.call(e,n)&&w(t,n,e[n]);return t},v=(t,e)=>C(t,M(e));var N=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},L=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of T(e))!F.call(t,o)&&o!==n&&d(t,o,{get:()=>e[o],enumerable:!(i=D(e,o))||i.enumerable});return t};var P=t=>L(d({},"__esModule",{value:!0}),t);var U={};N(U,{getHooks:()=>O,getRender:()=>x});function _(t){if(!Array.isArray(t.default)||!Array.isArray(t.filenames))return t;let e={};for(let[n,i]of t.default.entries()){let o=i.default,s=t.filenames[n].replace("../svelte/","").replace(".svelte","");e[s]=o}return e}function x(t){return t=_(t),function(n,i,o){let s=t[n],a=Object.fromEntries(Object.entries(o).map(([f,c])=>[f,()=>c]));return s.render(i,{$$slots:a})}}function l(){}function S(t){return t()}function A(t){t.forEach(S)}function E(t){return typeof t=="function"}function R(t){return Object.keys(t).length===0}function m(t,e,n){t.insertBefore(e,n||null)}function y(t){t.parentNode&&t.parentNode.removeChild(t)}var k=[];function q(t){let e=[],n=[];k.forEach(i=>t.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),k=e}var Q=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var z=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],Z=new Set([...z]);function I(t,e){let n=t.$$;n.fragment!==null&&(q(n.after_update),A(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}var B;typeof HTMLElement=="function"&&(B=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(S).filter(E);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){A(this.$$.on_disconnect)}$destroy(){I(this,1),this.$destroy=l}$on(t,e){if(!E(e))return l;let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!R(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});function H(t){let e=document.createElement("div");return e.innerHTML=atob(t).trim(),e}function u(t,e){let n=e.getAttribute(t);return n?JSON.parse(n):{}}function J(t,e){let n=(o,s)=>{let a,f,c;return()=>({getElement(){return H(u("data-slots",s.el)[o])},update(){let r=this.getElement();y(c),m(a,r,f),c=r},c:l,m(r,g){let b=this.getElement();a=r,f=g,c=b,m(r,b,g)},d(r){r&&y(c)},l})},i={};for(let o in t)i[o]=[n(o,e)];return i}function G(t){let e=u("data-live-json",t.el);if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e;let n={};for(let i of e){let o=window[i];o&&(n[i]=o)}return n}function h(t){return v(p(p({},u("data-props",t.el)),G(t)),{live:t,$$slots:J(u("data-slots",t.el),t),$$scope:{}})}function W(t){return t.$$.ctx.find(e=>e==null?void 0:e.default)}function O(t){return t=_(t),{SvelteHook:{mounted(){let n=this.el.getAttribute("data-name");if(!n)throw new Error("Component name must be provided");let i=t[n];if(!i)throw new Error(`Unable to find ${n} component.`);for(let o of Object.keys(u("data-live-json",this.el)))window.addEventListener(`${o}_initialized`,s=>this._instance.$set(h(this)),!1),window.addEventListener(`${o}_patched`,s=>this._instance.$set(h(this)),!1);this._instance=new i({target:this.el,props:h(this),hydrate:this.el.hasAttribute("data-ssr")})},updated(){this._instance.$set(h(this));let n=W(this._instance);for(let i in n)n[i][0]().update()},destroyed(){}}}}return P(U);})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue