mirror of https://github.com/sveltejs/svelte
parent
56f00b8e77
commit
557d06f392
@ -1,72 +0,0 @@
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, protoDev } from "svelte/shared.js";
|
||||
|
||||
function bar({ foo }) {
|
||||
return foo * 2;
|
||||
}
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
var p, text_value = state.Math.max(0, state.foo), text, text_1, text_2;
|
||||
|
||||
return {
|
||||
c: function create() {
|
||||
p = createElement("p");
|
||||
text = createText(text_value);
|
||||
text_1 = createText("\n\t");
|
||||
text_2 = createText(state.bar);
|
||||
},
|
||||
|
||||
m: function mount(target, anchor) {
|
||||
insertNode(p, target, anchor);
|
||||
appendNode(text, p);
|
||||
appendNode(text_1, p);
|
||||
appendNode(text_2, p);
|
||||
},
|
||||
|
||||
p: function update(changed, state) {
|
||||
if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) {
|
||||
text.data = text_value;
|
||||
}
|
||||
|
||||
if (changed.bar) {
|
||||
text_2.data = state.bar;
|
||||
}
|
||||
},
|
||||
|
||||
u: function unmount() {
|
||||
detachNode(p);
|
||||
},
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
function SvelteComponent(options) {
|
||||
this._debugName = '<SvelteComponent>';
|
||||
if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option");
|
||||
init(this, options);
|
||||
this._state = assign({ Math : Math }, options.data);
|
||||
this._recompute({ foo: 1 }, this._state);
|
||||
if (!('foo' in this._state)) console.warn("<SvelteComponent> was created without expected data property 'foo'");
|
||||
|
||||
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(SvelteComponent.prototype, protoDev);
|
||||
|
||||
SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) {
|
||||
if ('bar' in newState && !this._updatingReadonlyProperty) throw new Error("<SvelteComponent>: Cannot set read-only property 'bar'");
|
||||
};
|
||||
|
||||
SvelteComponent.prototype._recompute = function _recompute(changed, state) {
|
||||
if (changed.foo) {
|
||||
if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true;
|
||||
}
|
||||
}
|
||||
export default SvelteComponent;
|
@ -0,0 +1,169 @@
|
||||
function noop() {}
|
||||
|
||||
function assign(tar, src) {
|
||||
for (var k in src) tar[k] = src[k];
|
||||
return tar;
|
||||
}
|
||||
|
||||
function blankObject() {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
class Base {
|
||||
constructor() {
|
||||
this._handlers = blankObject();
|
||||
}
|
||||
|
||||
fire(eventName, data) {
|
||||
const handlers = eventName in this._handlers && this._handlers[eventName].slice();
|
||||
if (!handlers) return;
|
||||
|
||||
for (let i = 0; i < handlers.length; i += 1) {
|
||||
const handler = handlers[i];
|
||||
|
||||
if (!handler.__calling) {
|
||||
handler.__calling = true;
|
||||
handler.call(this, data);
|
||||
handler.__calling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get() {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
on(eventName, handler) {
|
||||
const handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
||||
handlers.push(handler);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
const index = handlers.indexOf(handler);
|
||||
if (~index) handlers.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_differs(a, b) {
|
||||
return _differsImmutable(a, b) || ((a && typeof a === 'object') || typeof a === 'function');
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends Base {
|
||||
constructor(options) {
|
||||
super();
|
||||
this._init(options);
|
||||
}
|
||||
|
||||
destroy(detach) {
|
||||
this.destroy = noop;
|
||||
this.fire('destroy');
|
||||
this.set = this.get = noop;
|
||||
|
||||
if (detach !== false) this._fragment.u();
|
||||
this._fragment.d();
|
||||
this._fragment = this._state = null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_init(options) {
|
||||
this._bind = options._bind;
|
||||
|
||||
this.options = options;
|
||||
this.root = options.root || this;
|
||||
this.store = this.root.store || options.store;
|
||||
}
|
||||
|
||||
_set(newState) {
|
||||
const previous = this._state;
|
||||
const changed = {};
|
||||
let dirty = false;
|
||||
|
||||
for (var key in newState) {
|
||||
if (this._differs(newState[key], previous[key])) changed[key] = dirty = 1;
|
||||
}
|
||||
|
||||
if (!dirty) return;
|
||||
|
||||
this._state = assign(assign({}, previous), newState);
|
||||
this._recompute(changed, this._state);
|
||||
if (this._bind) this._bind(changed, this._state);
|
||||
|
||||
if (this._fragment) {
|
||||
this.fire("state", { changed, current: this._state, previous });
|
||||
this._fragment.p(changed, this._state);
|
||||
this.fire("update", { changed, current: this._state, previous });
|
||||
}
|
||||
}
|
||||
|
||||
_mount(target, anchor) {
|
||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
||||
}
|
||||
|
||||
_recompute() {}
|
||||
|
||||
_unmount() {
|
||||
if (this._fragment) this._fragment.u();
|
||||
}
|
||||
}
|
||||
|
||||
function _differsImmutable(a, b) {
|
||||
return a != a ? b == b : a !== b;
|
||||
}
|
||||
|
||||
function callAll(fns) {
|
||||
while (fns && fns.length) fns.shift()();
|
||||
}
|
||||
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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);
|
||||
}
|
||||
}
|
||||
|
||||
foo() { return console.log('foo'); }
|
||||
|
||||
bar(x) { return console.log(x); }
|
||||
|
||||
baz(x) { return console.log(x); }
|
||||
|
||||
qux() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
export default SvelteComponent;
|
@ -0,0 +1,42 @@
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
import { Component, assign, noop } from "svelte/shared.js";
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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);
|
||||
}
|
||||
}
|
||||
|
||||
foo() { return console.log('foo'); }
|
||||
|
||||
bar(x) { return console.log(x); }
|
||||
|
||||
baz(x) { return console.log(x); }
|
||||
|
||||
qux() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
export default SvelteComponent;
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
foo: () => console.log('foo'),
|
||||
bar: x => console.log(x),
|
||||
baz: (x) => console.log(x),
|
||||
qux: () => {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,163 @@
|
||||
function noop() {}
|
||||
|
||||
function assign(tar, src) {
|
||||
for (var k in src) tar[k] = src[k];
|
||||
return tar;
|
||||
}
|
||||
|
||||
function blankObject() {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
class Base {
|
||||
constructor() {
|
||||
this._handlers = blankObject();
|
||||
}
|
||||
|
||||
fire(eventName, data) {
|
||||
const handlers = eventName in this._handlers && this._handlers[eventName].slice();
|
||||
if (!handlers) return;
|
||||
|
||||
for (let i = 0; i < handlers.length; i += 1) {
|
||||
const handler = handlers[i];
|
||||
|
||||
if (!handler.__calling) {
|
||||
handler.__calling = true;
|
||||
handler.call(this, data);
|
||||
handler.__calling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get() {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
on(eventName, handler) {
|
||||
const handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
||||
handlers.push(handler);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
const index = handlers.indexOf(handler);
|
||||
if (~index) handlers.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_differs(a, b) {
|
||||
return _differsImmutable(a, b) || ((a && typeof a === 'object') || typeof a === 'function');
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends Base {
|
||||
constructor(options) {
|
||||
super();
|
||||
this._init(options);
|
||||
}
|
||||
|
||||
destroy(detach) {
|
||||
this.destroy = noop;
|
||||
this.fire('destroy');
|
||||
this.set = this.get = noop;
|
||||
|
||||
if (detach !== false) this._fragment.u();
|
||||
this._fragment.d();
|
||||
this._fragment = this._state = null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_init(options) {
|
||||
this._bind = options._bind;
|
||||
|
||||
this.options = options;
|
||||
this.root = options.root || this;
|
||||
this.store = this.root.store || options.store;
|
||||
}
|
||||
|
||||
_set(newState) {
|
||||
const previous = this._state;
|
||||
const changed = {};
|
||||
let dirty = false;
|
||||
|
||||
for (var key in newState) {
|
||||
if (this._differs(newState[key], previous[key])) changed[key] = dirty = 1;
|
||||
}
|
||||
|
||||
if (!dirty) return;
|
||||
|
||||
this._state = assign(assign({}, previous), newState);
|
||||
this._recompute(changed, this._state);
|
||||
if (this._bind) this._bind(changed, this._state);
|
||||
|
||||
if (this._fragment) {
|
||||
this.fire("state", { changed, current: this._state, previous });
|
||||
this._fragment.p(changed, this._state);
|
||||
this.fire("update", { changed, current: this._state, previous });
|
||||
}
|
||||
}
|
||||
|
||||
_mount(target, anchor) {
|
||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
||||
}
|
||||
|
||||
_recompute() {}
|
||||
|
||||
_unmount() {
|
||||
if (this._fragment) this._fragment.u();
|
||||
}
|
||||
}
|
||||
|
||||
function _differsImmutable(a, b) {
|
||||
return a != a ? b == b : a !== b;
|
||||
}
|
||||
|
||||
function callAll(fns) {
|
||||
while (fns && fns.length) fns.shift()();
|
||||
}
|
||||
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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);
|
||||
}
|
||||
}
|
||||
|
||||
async foo() {}
|
||||
|
||||
*bar() {}
|
||||
}
|
||||
|
||||
export default SvelteComponent;
|
@ -0,0 +1,36 @@
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
import { Component, assign, noop } from "svelte/shared.js";
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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);
|
||||
}
|
||||
}
|
||||
|
||||
async foo() {}
|
||||
|
||||
*bar() {}
|
||||
}
|
||||
export default SvelteComponent;
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
async foo () {},
|
||||
*bar () {}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,163 @@
|
||||
function noop() {}
|
||||
|
||||
function assign(tar, src) {
|
||||
for (var k in src) tar[k] = src[k];
|
||||
return tar;
|
||||
}
|
||||
|
||||
function blankObject() {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
class Base {
|
||||
constructor() {
|
||||
this._handlers = blankObject();
|
||||
}
|
||||
|
||||
fire(eventName, data) {
|
||||
const handlers = eventName in this._handlers && this._handlers[eventName].slice();
|
||||
if (!handlers) return;
|
||||
|
||||
for (let i = 0; i < handlers.length; i += 1) {
|
||||
const handler = handlers[i];
|
||||
|
||||
if (!handler.__calling) {
|
||||
handler.__calling = true;
|
||||
handler.call(this, data);
|
||||
handler.__calling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get() {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
on(eventName, handler) {
|
||||
const handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
||||
handlers.push(handler);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
const index = handlers.indexOf(handler);
|
||||
if (~index) handlers.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_differs(a, b) {
|
||||
return _differsImmutable(a, b) || ((a && typeof a === 'object') || typeof a === 'function');
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends Base {
|
||||
constructor(options) {
|
||||
super();
|
||||
this._init(options);
|
||||
}
|
||||
|
||||
destroy(detach) {
|
||||
this.destroy = noop;
|
||||
this.fire('destroy');
|
||||
this.set = this.get = noop;
|
||||
|
||||
if (detach !== false) this._fragment.u();
|
||||
this._fragment.d();
|
||||
this._fragment = this._state = null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_init(options) {
|
||||
this._bind = options._bind;
|
||||
|
||||
this.options = options;
|
||||
this.root = options.root || this;
|
||||
this.store = this.root.store || options.store;
|
||||
}
|
||||
|
||||
_set(newState) {
|
||||
const previous = this._state;
|
||||
const changed = {};
|
||||
let dirty = false;
|
||||
|
||||
for (var key in newState) {
|
||||
if (this._differs(newState[key], previous[key])) changed[key] = dirty = 1;
|
||||
}
|
||||
|
||||
if (!dirty) return;
|
||||
|
||||
this._state = assign(assign({}, previous), newState);
|
||||
this._recompute(changed, this._state);
|
||||
if (this._bind) this._bind(changed, this._state);
|
||||
|
||||
if (this._fragment) {
|
||||
this.fire("state", { changed, current: this._state, previous });
|
||||
this._fragment.p(changed, this._state);
|
||||
this.fire("update", { changed, current: this._state, previous });
|
||||
}
|
||||
}
|
||||
|
||||
_mount(target, anchor) {
|
||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
||||
}
|
||||
|
||||
_recompute() {}
|
||||
|
||||
_unmount() {
|
||||
if (this._fragment) this._fragment.u();
|
||||
}
|
||||
}
|
||||
|
||||
function _differsImmutable(a, b) {
|
||||
return a != a ? b == b : a !== b;
|
||||
}
|
||||
|
||||
function callAll(fns) {
|
||||
while (fns && fns.length) fns.shift()();
|
||||
}
|
||||
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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);
|
||||
}
|
||||
}
|
||||
|
||||
foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
}
|
||||
|
||||
export default SvelteComponent;
|
@ -0,0 +1,36 @@
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
import { Component, assign, noop } from "svelte/shared.js";
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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);
|
||||
}
|
||||
}
|
||||
|
||||
foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
}
|
||||
export default SvelteComponent;
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
foo: function() {
|
||||
console.log('foo');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,175 @@
|
||||
function noop() {}
|
||||
|
||||
function assign(tar, src) {
|
||||
for (var k in src) tar[k] = src[k];
|
||||
return tar;
|
||||
}
|
||||
|
||||
function blankObject() {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
class Base {
|
||||
constructor() {
|
||||
this._handlers = blankObject();
|
||||
}
|
||||
|
||||
fire(eventName, data) {
|
||||
const handlers = eventName in this._handlers && this._handlers[eventName].slice();
|
||||
if (!handlers) return;
|
||||
|
||||
for (let i = 0; i < handlers.length; i += 1) {
|
||||
const handler = handlers[i];
|
||||
|
||||
if (!handler.__calling) {
|
||||
handler.__calling = true;
|
||||
handler.call(this, data);
|
||||
handler.__calling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get() {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
on(eventName, handler) {
|
||||
const handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
|
||||
handlers.push(handler);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
const index = handlers.indexOf(handler);
|
||||
if (~index) handlers.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_differs(a, b) {
|
||||
return _differsImmutable(a, b) || ((a && typeof a === 'object') || typeof a === 'function');
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends Base {
|
||||
constructor(options) {
|
||||
super();
|
||||
this._init(options);
|
||||
}
|
||||
|
||||
destroy(detach) {
|
||||
this.destroy = noop;
|
||||
this.fire('destroy');
|
||||
this.set = this.get = noop;
|
||||
|
||||
if (detach !== false) this._fragment.u();
|
||||
this._fragment.d();
|
||||
this._fragment = this._state = null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_init(options) {
|
||||
this._bind = options._bind;
|
||||
|
||||
this.options = options;
|
||||
this.root = options.root || this;
|
||||
this.store = this.root.store || options.store;
|
||||
}
|
||||
|
||||
_set(newState) {
|
||||
const previous = this._state;
|
||||
const changed = {};
|
||||
let dirty = false;
|
||||
|
||||
for (var key in newState) {
|
||||
if (this._differs(newState[key], previous[key])) changed[key] = dirty = 1;
|
||||
}
|
||||
|
||||
if (!dirty) return;
|
||||
|
||||
this._state = assign(assign({}, previous), newState);
|
||||
this._recompute(changed, this._state);
|
||||
if (this._bind) this._bind(changed, this._state);
|
||||
|
||||
if (this._fragment) {
|
||||
this.fire("state", { changed, current: this._state, previous });
|
||||
this._fragment.p(changed, this._state);
|
||||
this.fire("update", { changed, current: this._state, previous });
|
||||
}
|
||||
}
|
||||
|
||||
_mount(target, anchor) {
|
||||
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
|
||||
}
|
||||
|
||||
_recompute() {}
|
||||
|
||||
_unmount() {
|
||||
if (this._fragment) this._fragment.u();
|
||||
}
|
||||
}
|
||||
|
||||
function _differsImmutable(a, b) {
|
||||
return a != a ? b == b : a !== b;
|
||||
}
|
||||
|
||||
function callAll(fns) {
|
||||
while (fns && fns.length) fns.shift()();
|
||||
}
|
||||
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
|
||||
function foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
|
||||
function bar() {
|
||||
console.log('bar');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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(SvelteComponent.prototype, {
|
||||
foo,
|
||||
|
||||
bar: [bar][0]
|
||||
});
|
||||
|
||||
export default SvelteComponent;
|
@ -0,0 +1,48 @@
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
import { Component, assign, noop } from "svelte/shared.js";
|
||||
|
||||
function foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
|
||||
function bar() {
|
||||
console.log('bar');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function create_main_fragment(component, state) {
|
||||
|
||||
return {
|
||||
c: noop,
|
||||
|
||||
m: noop,
|
||||
|
||||
p: noop,
|
||||
|
||||
u: noop,
|
||||
|
||||
d: noop
|
||||
};
|
||||
}
|
||||
|
||||
class SvelteComponent extends Component {
|
||||
constructor(options) {
|
||||
super(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(SvelteComponent.prototype, {
|
||||
foo,
|
||||
|
||||
bar: [bar][0]
|
||||
});
|
||||
export default SvelteComponent;
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
function foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
|
||||
function bar() {
|
||||
console.log('bar');
|
||||
}
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
foo,
|
||||
bar: [bar][0]
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue