mirror of https://github.com/sveltejs/svelte
parent
60516aff0d
commit
86c273192f
@ -1,173 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "Hello world!";
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Main;
|
|
@ -1,198 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "Hello world!";
|
|
||||||
this.c = noop;
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Main extends HTMLElement {
|
|
||||||
constructor(options = {}) {
|
|
||||||
super();
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this.attachShadow({ mode: 'open' });
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
this._fragment.c();
|
|
||||||
this._fragment.m(this.shadowRoot, null);
|
|
||||||
|
|
||||||
if (options.target) this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
static get observedAttributes() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
attributeChangedCallback(attr, oldValue, newValue) {
|
|
||||||
this.set({ [attr]: newValue });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
assign(Main.prototype, {
|
|
||||||
_mount(target, anchor) {
|
|
||||||
target.insertBefore(this, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
_unmount() {
|
|
||||||
this.parentNode.removeChild(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
customElements.define("my-element", Main);
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Main;
|
|
@ -1,197 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c: function create() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "Hello world!";
|
|
||||||
},
|
|
||||||
|
|
||||||
m: function mount(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u: function unmount() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
this._debugName = '<Main>';
|
|
||||||
if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option");
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroyDev,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: setDev,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._checkReadOnly = function _checkReadOnly(newState) {
|
|
||||||
};
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroyDev(detach) {
|
|
||||||
destroy.call(this, detach);
|
|
||||||
this.destroy = function() {
|
|
||||||
console.warn('Component was already destroyed');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDev(newState) {
|
|
||||||
if (typeof newState !== 'object') {
|
|
||||||
throw new Error(
|
|
||||||
this._debugName + '.set was called without an object of data key-values to update.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._checkReadOnly(newState);
|
|
||||||
set.call(this, newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Main;
|
|
@ -1,181 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
import Widget from './Widget.html';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
|
|
||||||
var widget = new Widget({
|
|
||||||
root: component.root
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
widget._fragment.c();
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
widget._mount(target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
widget._unmount();
|
|
||||||
},
|
|
||||||
|
|
||||||
d() {
|
|
||||||
widget.destroy(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
if (!options.root) {
|
|
||||||
this._oncreate = [];
|
|
||||||
this._beforecreate = [];
|
|
||||||
this._aftercreate = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
|
|
||||||
this._lock = true;
|
|
||||||
callAll(this._beforecreate);
|
|
||||||
callAll(this._oncreate);
|
|
||||||
callAll(this._aftercreate);
|
|
||||||
this._lock = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
export default Main;
|
|
||||||
//# sourceMappingURL=Main.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["<Widget/>\n\n<script>\n\timport Widget from './Widget.html';\n\n\texport default {\n\t\tcomponents: {\n\t\t\tWidget\n\t\t}\n\t};\n</script>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@ -1,174 +0,0 @@
|
|||||||
/* src/Widget.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "widget";
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Widget(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Widget.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Widget.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Widget;
|
|
||||||
//# sourceMappingURL=Widget.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["<p>widget</p>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@ -1,180 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
import Widget from './widget/Widget.html';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
|
|
||||||
var widget = new Widget({
|
|
||||||
root: component.root
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
widget._fragment.c();
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
widget._mount(target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
widget._unmount();
|
|
||||||
},
|
|
||||||
|
|
||||||
d() {
|
|
||||||
widget.destroy(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
if (!options.root) {
|
|
||||||
this._oncreate = [];
|
|
||||||
this._beforecreate = [];
|
|
||||||
this._aftercreate = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
|
|
||||||
this._lock = true;
|
|
||||||
callAll(this._beforecreate);
|
|
||||||
callAll(this._oncreate);
|
|
||||||
callAll(this._aftercreate);
|
|
||||||
this._lock = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
export default Main;
|
|
@ -1,173 +0,0 @@
|
|||||||
/* src/widget/Widget.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "widget";
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Widget(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Widget.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Widget.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Widget;
|
|
@ -1,180 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
import Widget from './Widget.html';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
|
|
||||||
var widget = new Widget({
|
|
||||||
root: component.root
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
widget._fragment.c();
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
widget._mount(target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
widget._unmount();
|
|
||||||
},
|
|
||||||
|
|
||||||
d() {
|
|
||||||
widget.destroy(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
if (!options.root) {
|
|
||||||
this._oncreate = [];
|
|
||||||
this._beforecreate = [];
|
|
||||||
this._aftercreate = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
|
|
||||||
this._lock = true;
|
|
||||||
callAll(this._beforecreate);
|
|
||||||
callAll(this._oncreate);
|
|
||||||
callAll(this._aftercreate);
|
|
||||||
this._lock = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
export default Main;
|
|
@ -1,173 +0,0 @@
|
|||||||
/* src/Widget.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "widget";
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Widget(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Widget.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Widget.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Widget;
|
|
@ -1,197 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
var Main = (function(answer) { "use strict";
|
|
||||||
answer = (answer && answer.__esModule) ? answer["default"] : answer;
|
|
||||||
|
|
||||||
function data() {
|
|
||||||
return {
|
|
||||||
answer: answer
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p, text, text_1;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
text = createText("The answer is ");
|
|
||||||
text_1 = createText(ctx.answer);
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
appendNode(text, p);
|
|
||||||
appendNode(text_1, p);
|
|
||||||
},
|
|
||||||
|
|
||||||
p(changed, ctx) {
|
|
||||||
if (changed.answer) {
|
|
||||||
text_1.data = ctx.answer;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign(data(), options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createText(data) {
|
|
||||||
return document.createTextNode(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendNode(node, target) {
|
|
||||||
target.appendChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
return Main;
|
|
||||||
}(theAnswer));
|
|
@ -1,174 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "Hello world!";
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Main;
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
|
|
@ -1,174 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var p;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
p = createElement("p");
|
|
||||||
p.textContent = "Hello world!";
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(p, target, anchor);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(p);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign({}, options.data);
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Main;
|
|
||||||
//# sourceMappingURL=Main.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["<p>Hello world!</p>\n\n<script>\n\texport default {\n\t\tonrender () {\n\t\t\tconsole.log( 'here' );\n\t\t}\n\t};\n</script>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@ -1,48 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var Main = {};
|
|
||||||
|
|
||||||
Main.filename = "src/Main.html";
|
|
||||||
|
|
||||||
Main.data = function() {
|
|
||||||
return {};
|
|
||||||
};
|
|
||||||
|
|
||||||
Main.render = function(state, options = {}) {
|
|
||||||
var components = new Set();
|
|
||||||
|
|
||||||
function addComponent(component) {
|
|
||||||
components.add(component);
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = { head: '', addComponent };
|
|
||||||
var html = Main._render(result, state, options);
|
|
||||||
|
|
||||||
var cssCode = Array.from(components).map(c => c.css && c.css.code).filter(Boolean).join('\n');
|
|
||||||
|
|
||||||
return {
|
|
||||||
html,
|
|
||||||
head: result.head,
|
|
||||||
css: { code: cssCode, map: null },
|
|
||||||
toString() {
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Main._render = function(__result, ctx, options) {
|
|
||||||
__result.addComponent(Main);
|
|
||||||
|
|
||||||
ctx = Object.assign({}, ctx);
|
|
||||||
|
|
||||||
return `<p>Hello world!</p>`;
|
|
||||||
};
|
|
||||||
|
|
||||||
Main.css = {
|
|
||||||
code: '',
|
|
||||||
map: null
|
|
||||||
};
|
|
||||||
|
|
||||||
var warned = false;
|
|
||||||
|
|
||||||
module.exports = Main;
|
|
@ -1,195 +0,0 @@
|
|||||||
/* src/Main.html generated by Svelte v2.3.0 */
|
|
||||||
|
|
||||||
function create_main_fragment(component, ctx) {
|
|
||||||
var h1, text, text_1;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
h1 = createElement("h1");
|
|
||||||
text = createText("Hello ");
|
|
||||||
text_1 = createText(ctx.$name);
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insertNode(h1, target, anchor);
|
|
||||||
appendNode(text, h1);
|
|
||||||
appendNode(text_1, h1);
|
|
||||||
},
|
|
||||||
|
|
||||||
p(changed, ctx) {
|
|
||||||
if (changed.$name) {
|
|
||||||
text_1.data = ctx.$name;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
u() {
|
|
||||||
detachNode(h1);
|
|
||||||
},
|
|
||||||
|
|
||||||
d: noop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main(options) {
|
|
||||||
init(this, options);
|
|
||||||
this._state = assign(this.store._init(["name"]), options.data);
|
|
||||||
this.store._add(this, ["name"]);
|
|
||||||
|
|
||||||
this._handlers.destroy = [removeFromStore];
|
|
||||||
|
|
||||||
this._fragment = create_main_fragment(this, this._state);
|
|
||||||
|
|
||||||
if (options.target) {
|
|
||||||
this._fragment.c();
|
|
||||||
this._mount(options.target, options.anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(Main.prototype, {
|
|
||||||
destroy: destroy,
|
|
||||||
get: get,
|
|
||||||
fire: fire,
|
|
||||||
on: on,
|
|
||||||
set: set,
|
|
||||||
_set: _set,
|
|
||||||
_mount: _mount,
|
|
||||||
_unmount: _unmount,
|
|
||||||
_differs: _differs
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.prototype._recompute = noop;
|
|
||||||
|
|
||||||
function createElement(name) {
|
|
||||||
return document.createElement(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createText(data) {
|
|
||||||
return document.createTextNode(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNode(node, target, anchor) {
|
|
||||||
target.insertBefore(node, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendNode(node, target) {
|
|
||||||
target.appendChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function detachNode(node) {
|
|
||||||
node.parentNode.removeChild(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
function init(component, options) {
|
|
||||||
component._handlers = blankObject();
|
|
||||||
component._bind = options._bind;
|
|
||||||
|
|
||||||
component.options = options;
|
|
||||||
component.root = options.root || component;
|
|
||||||
component.store = component.root.store || options.store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assign(tar, src) {
|
|
||||||
for (var k in src) tar[k] = src[k];
|
|
||||||
return tar;
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeFromStore() {
|
|
||||||
this.store._remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroy(detach) {
|
|
||||||
this.destroy = noop;
|
|
||||||
this.fire('destroy');
|
|
||||||
this.set = noop;
|
|
||||||
|
|
||||||
if (detach !== false) this._fragment.u();
|
|
||||||
this._fragment.d();
|
|
||||||
this._fragment = null;
|
|
||||||
this._state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function get() {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fire(eventName, data) {
|
|
||||||
var handlers =
|
|
||||||
eventName in this._handlers && this._handlers[eventName].slice();
|
|
||||||
if (!handlers) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < handlers.length; i += 1) {
|
|
||||||
var handler = handlers[i];
|
|
||||||
|
|
||||||
if (!handler.__calling) {
|
|
||||||
handler.__calling = true;
|
|
||||||
handler.call(this, data);
|
|
||||||
handler.__calling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function on(eventName, handler) {
|
|
||||||
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
|
||||||
handlers.push(handler);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cancel: function() {
|
|
||||||
var index = handlers.indexOf(handler);
|
|
||||||
if (~index) handlers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(newState) {
|
|
||||||
this._set(assign({}, newState));
|
|
||||||
if (this.root._lock) return;
|
|
||||||
this.root._lock = true;
|
|
||||||
callAll(this.root._beforecreate);
|
|
||||||
callAll(this.root._oncreate);
|
|
||||||
callAll(this.root._aftercreate);
|
|
||||||
this.root._lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _set(newState) {
|
|
||||||
var oldState = this._state,
|
|
||||||
changed = {},
|
|
||||||
dirty = false;
|
|
||||||
|
|
||||||
for (var key in newState) {
|
|
||||||
if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true;
|
|
||||||
}
|
|
||||||
if (!dirty) return;
|
|
||||||
|
|
||||||
this._state = assign(assign({}, oldState), newState);
|
|
||||||
this._recompute(changed, this._state);
|
|
||||||
if (this._bind) this._bind(changed, this._state);
|
|
||||||
|
|
||||||
if (this._fragment) {
|
|
||||||
this.fire("state", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
this._fragment.p(changed, this._state);
|
|
||||||
this.fire("update", { changed: changed, current: this._state, previous: oldState });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _mount(target, anchor) {
|
|
||||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _unmount() {
|
|
||||||
if (this._fragment) this._fragment.u();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _differs(a, b) {
|
|
||||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
function blankObject() {
|
|
||||||
return Object.create(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAll(fns) {
|
|
||||||
while (fns && fns.length) fns.shift()();
|
|
||||||
}
|
|
||||||
export default Main;
|
|
Loading…
Reference in new issue