merge master -> restructure-docs

pull/2179/head
Richard Harris 7 years ago
commit d331af9e32

2
.gitignore vendored

@ -3,7 +3,6 @@
node_modules node_modules
*.map *.map
/src/compile/internal-exports.ts /src/compile/internal-exports.ts
/cli/
/compiler.js /compiler.js
/index.js /index.js
/internal.* /internal.*
@ -14,7 +13,6 @@ node_modules
/scratch/ /scratch/
/coverage/ /coverage/
/coverage.lcov/ /coverage.lcov/
/test/cli/samples/*/actual
/test/sourcemaps/samples/*/output.js /test/sourcemaps/samples/*/output.js
/test/sourcemaps/samples/*/output.js.map /test/sourcemaps/samples/*/output.js.map
/test/sourcemaps/samples/*/output.css /test/sourcemaps/samples/*/output.css

81
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "svelte", "name": "svelte",
"version": "3.0.0-beta.8", "version": "3.0.0-beta.10",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1950,12 +1950,6 @@
} }
} }
}, },
"interpret": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz",
"integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==",
"dev": true
},
"invert-kv": { "invert-kv": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz",
@ -2697,12 +2691,6 @@
} }
} }
}, },
"mri": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz",
"integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==",
"dev": true
},
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
@ -2831,33 +2819,6 @@
"integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=",
"dev": true "dev": true
}, },
"node-resolve": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/node-resolve/-/node-resolve-1.3.4.tgz",
"integrity": "sha512-yQ8Qn3GGR4cyunvggEHg7fb37V/6atft1K/xU6b2OEfJDbi8zbRSNIKxClzJszAV6tjtYyZt1vHlBgdORMcPXg==",
"dev": true,
"requires": {
"is-builtin-module": "^3.0.0",
"lodash": "^4.13.1"
},
"dependencies": {
"builtin-modules": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.0.0.tgz",
"integrity": "sha512-hMIeU4K2ilbXV6Uv93ZZ0Avg/M91RaKXucQ+4me2Do1txxBDyDZWCBa5bJSLqoNTRpXTLwEzIk1KmloenDDjhg==",
"dev": true
},
"is-builtin-module": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.0.0.tgz",
"integrity": "sha512-/93sDihsAD652hrMEbJGbMAVBf1qc96kyThHQ0CAOONHaE3aROLpTjDe4WQ5aoC5ITHFxEq1z8XqSU7km+8amw==",
"dev": true,
"requires": {
"builtin-modules": "^3.0.0"
}
}
}
},
"normalize-package-data": { "normalize-package-data": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
@ -3374,15 +3335,6 @@
"util-deprecate": "^1.0.1" "util-deprecate": "^1.0.1"
} }
}, },
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"dev": true,
"requires": {
"resolve": "^1.1.6"
}
},
"redent": { "redent": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz",
@ -3951,15 +3903,6 @@
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
}, },
"sade": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/sade/-/sade-1.4.2.tgz",
"integrity": "sha512-MTrQm+Nhl4m1mbssYDgAculC/HbShjj08QtHnA2GTpzivfU5aUp8EoHlECmrIHEaa8hZRZSp2Gygv8VMlpXEBw==",
"dev": true,
"requires": {
"mri": "^1.1.0"
}
},
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
@ -3981,17 +3924,6 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true "dev": true
}, },
"sander": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/sander/-/sander-0.6.0.tgz",
"integrity": "sha1-rxYkzX+2362Y6+9WUxn5IAeNqSU=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.3",
"mkdirp": "^0.5.1",
"rimraf": "^2.5.2"
}
},
"saxes": { "saxes": {
"version": "3.1.6", "version": "3.1.6",
"resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.6.tgz", "resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.6.tgz",
@ -4051,17 +3983,6 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true "dev": true
}, },
"shelljs": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz",
"integrity": "sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==",
"dev": true,
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
}
},
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",

@ -1,14 +1,10 @@
{ {
"name": "svelte", "name": "svelte",
"version": "3.0.0-beta.8", "version": "3.0.0-beta.10",
"description": "The magical disappearing UI framework", "description": "The magical disappearing UI framework",
"module": "index.mjs", "module": "index.mjs",
"main": "index", "main": "index",
"bin": {
"svelte": "svelte"
},
"files": [ "files": [
"cli",
"compiler.js", "compiler.js",
"register.js", "register.js",
"index.*", "index.*",
@ -72,7 +68,6 @@
"magic-string": "^0.25.2", "magic-string": "^0.25.2",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"nightmare": "^3.0.1", "nightmare": "^3.0.1",
"node-resolve": "^1.3.3",
"rollup": "^1.1.2", "rollup": "^1.1.2",
"rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-json": "^3.0.0", "rollup-plugin-json": "^3.0.0",
@ -81,9 +76,6 @@
"rollup-plugin-sucrase": "^2.1.0", "rollup-plugin-sucrase": "^2.1.0",
"rollup-plugin-typescript": "^1.0.0", "rollup-plugin-typescript": "^1.0.0",
"rollup-plugin-virtual": "^1.0.1", "rollup-plugin-virtual": "^1.0.1",
"sade": "^1.4.0",
"sander": "^0.6.0",
"shelljs": "^0.8.2",
"source-map": "0.6", "source-map": "0.6",
"source-map-support": "^0.5.4", "source-map-support": "^0.5.4",
"tiny-glob": "^0.2.1", "tiny-glob": "^0.2.1",

@ -69,27 +69,6 @@ export default [
: id => id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree') : id => id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree')
}, },
/* cli/*.js */
{
input: ['src/cli/index.ts'],
output: {
dir: 'cli',
format: 'cjs',
paths: {
svelte: '../compiler.js'
}
},
external: ['fs', 'path', 'os', 'svelte'],
plugins: [
json(),
commonjs(),
resolve(),
typescript({
typescript: require('typescript')
})
]
},
/* motion.mjs */ /* motion.mjs */
{ {
input: `src/motion/index.js`, input: `src/motion/index.js`,

@ -53,6 +53,10 @@
"rollup-plugin-svelte": "^5.0.3", "rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^4.0.4", "rollup-plugin-terser": "^4.0.4",
"sapper": "^0.26.0-alpha.10", "sapper": "^0.26.0-alpha.10",
<<<<<<< HEAD
"svelte": "^3.0.0-beta.10" "svelte": "^3.0.0-beta.10"
=======
"svelte": "^3.0.0-beta.8"
>>>>>>> master
} }
} }

@ -1,131 +0,0 @@
import * as path from 'path';
import * as fs from 'fs';
import * as svelte from 'svelte';
import error from './error.js';
function mkdirp(dir) {
const parent = path.dirname(dir);
if (dir === parent) return;
mkdirp(parent);
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
}
export function compile(input, opts) {
if (opts._.length > 0) {
error(`Can only compile a single file or directory`);
}
const output = opts.output;
const stats = fs.statSync(input);
const isDir = stats.isDirectory();
if (isDir) {
if (!output) {
error(`You must specify an --output (-o) option when compiling a directory of files`);
}
if (opts.name || opts.amdId) {
error(`Cannot specify --${opts.name ? 'name' : 'amdId'} when compiling a directory`);
}
}
const options = {
name: opts.name,
format: opts.format,
css: opts.css !== false,
dev: opts.dev,
immutable: opts.immutable,
generate: opts.generate || 'dom',
customElement: opts.customElement,
sveltePath: opts.sveltePath
};
if (isDir) {
mkdirp(output);
compileDirectory(input, output, options, opts.sourcemap);
} else {
compileFile(input, output, options, opts.sourcemap);
}
}
function compileDirectory(input, output, options, sourcemap) {
fs.readdirSync(input).forEach(file => {
const src = path.resolve(input, file);
const dest = path.resolve(output, file);
if (path.extname(file) === '.html') {
compileFile(
src,
dest.substring(0, dest.lastIndexOf('.html')) + '.js',
options,
sourcemap
);
} else {
const stats = fs.statSync(src);
if (stats.isDirectory()) {
compileDirectory(src, dest, options, sourcemap);
}
}
});
}
let SOURCEMAPPING_URL = 'sourceMa';
SOURCEMAPPING_URL += 'ppingURL';
function compileFile(input, output, options, sourcemap) {
console.error(`compiling ${path.relative(process.cwd(), input)}...`); // eslint-disable-line no-console
options = Object.assign({}, options);
if (!options.name) options.name = getName(input);
options.filename = input;
options.outputFilename = output;
const inline = sourcemap === 'inline';
let source = fs.readFileSync(input, 'utf-8');
if (source[0] === 0xfeff) source = source.slice(1);
let compiled;
try {
compiled = svelte.compile(source, options);
} catch (err) {
error(err);
}
const { js, warnings } = compiled;
warnings.forEach(warning => console.warn(warning.toString()));
if (sourcemap) {
js.code += `\n//# ${SOURCEMAPPING_URL}=${inline || !output
? js.map.toUrl()
: `${path.basename(output)}.map`}\n`;
}
if (output) {
const outputDir = path.dirname(output);
mkdirp(outputDir);
fs.writeFileSync(output, js.code);
console.error(`wrote ${path.relative(process.cwd(), output)}`); // eslint-disable-line no-console
if (sourcemap && !inline) {
fs.writeFileSync(`${output}.map`, js.map);
console.error(`wrote ${path.relative(process.cwd(), `${output}.map`)}`); // eslint-disable-line no-console
}
} else {
process.stdout.write(js.code);
}
}
function getName(input) {
return path
.basename(input)
.replace(path.extname(input), '')
.replace(/[^a-zA-Z_$0-9]+/g, '_')
.replace(/^_/, '')
.replace(/_$/, '')
.replace(/^(\d)/, '_$1');
}

@ -1,17 +0,0 @@
import c from 'kleur';
function stderr(msg) {
console.error(msg); // eslint-disable-line no-console
}
export default function error(err) {
stderr(c.red(err.message || err));
if (err.frame) {
stderr(err.frame);
} else if (err.stack) {
stderr(c.gray(err.stack));
}
process.exit(1);
}

@ -1,30 +0,0 @@
import sade from 'sade';
import * as pkg from '../../package.json';
const prog = sade('svelte').version(pkg.version);
prog
.command('compile <input>')
.option('-o, --output', 'Output (if absent, prints to stdout)')
.option('-f, --format', 'Type of output (cjs or esm)', 'esm')
.option('-n, --name', 'Name for IIFE/UMD export (inferred from filename by default)')
.option('-m, --sourcemap', 'Generate sourcemap (`-m inline` for inline map)')
.option('-d, --dev', 'Add dev mode warnings and errors')
.option('--generate', 'Change generate format between `dom` and `ssr`')
.option('--no-css', `Don't include CSS (useful with SSR)`)
.option('--immutable', 'Support immutable data structures')
.option('--shared', 'Don\'t include shared helpers')
.option('--customElement', 'Generate a custom element')
.example('compile App.html > App.js')
.example('compile src -o dest')
.example('compile -f umd MyComponent.html > MyComponent.js')
.action((input, opts) => {
import('./compile').then(({ compile }) => {
compile(input, opts);
});
})
.parse(process.argv);

@ -826,6 +826,7 @@ export default class Component {
declarators: [declarator], declarators: [declarator],
insert: get_insert(variable) insert: get_insert(variable)
}); });
current_group = null;
} else { } else {
if (current_group && current_group.kind !== node.kind) { if (current_group && current_group.kind !== node.kind) {
current_group = null; current_group = null;

@ -14,6 +14,7 @@ export default class Action extends Node {
component.warn_if_undefined(info, scope); component.warn_if_undefined(info, scope);
this.name = info.name; this.name = info.name;
component.qualify(info.name);
this.expression = info.expression this.expression = info.expression
? new Expression(component, this, scope, info.expression) ? new Expression(component, this, scope, info.expression)

@ -13,6 +13,7 @@ export default class Animation extends Node {
component.warn_if_undefined(info, scope); component.warn_if_undefined(info, scope);
this.name = info.name; this.name = info.name;
component.qualify(info.name);
if (parent.animation) { if (parent.animation) {
component.error(this, { component.error(this, {

@ -32,7 +32,7 @@ export default class EventHandler extends Node {
if (node && node.type === 'VariableDeclaration') { if (node && node.type === 'VariableDeclaration') {
// for `const handleClick = () => {...}`, we want the [arrow] function expression node // for `const handleClick = () => {...}`, we want the [arrow] function expression node
const declarator = node.declarations.find(d => d.id.name === info.expression.name); const declarator = node.declarations.find(d => d.id.name === info.expression.name);
node = declarator.init; node = declarator && declarator.init;
} }
if (node && /Function/.test(node.type) && node.params.length === 0) { if (node && /Function/.test(node.type) && node.params.length === 0) {

@ -15,6 +15,8 @@ export default class Transition extends Node {
component.warn_if_undefined(info, scope); component.warn_if_undefined(info, scope);
this.name = info.name; this.name = info.name;
component.qualify(info.name);
this.directive = info.intro && info.outro ? 'transition' : info.intro ? 'in' : 'out'; this.directive = info.intro && info.outro ? 'transition' : info.intro ? 'in' : 'out';
this.is_local = info.modifiers.includes('local'); this.is_local = info.modifiers.includes('local');

@ -86,7 +86,18 @@ export default function mustache(parser: Parser) {
block.end = parser.index; block.end = parser.index;
parser.stack.pop(); parser.stack.pop();
} else if (parser.eat(':elseif')) { } else if (parser.eat(':else')) {
if (parser.eat('if')) {
parser.error({
code: 'invalid-elseif',
message: `'elseif' should be 'else if'`
});
}
parser.allowWhitespace();
// :else if
if (parser.eat('if')) {
const block = parser.current(); const block = parser.current();
if (block.type !== 'IfBlock') if (block.type !== 'IfBlock')
parser.error({ parser.error({
@ -118,7 +129,10 @@ export default function mustache(parser: Parser) {
}; };
parser.stack.push(block.else.children[0]); parser.stack.push(block.else.children[0]);
} else if (parser.eat(':else')) { }
// :else
else {
const block = parser.current(); const block = parser.current();
if (block.type !== 'IfBlock' && block.type !== 'EachBlock') { if (block.type !== 'IfBlock' && block.type !== 'EachBlock') {
parser.error({ parser.error({
@ -138,6 +152,7 @@ export default function mustache(parser: Parser) {
}; };
parser.stack.push(block.else); parser.stack.push(block.else);
}
} else if (parser.eat(':then')) { } else if (parser.eat(':then')) {
// TODO DRY out this and the next section // TODO DRY out this and the next section
const pendingBlock = parser.current(); const pendingBlock = parser.current();

@ -1,4 +1,4 @@
import { run_all, noop } from './internal'; import { run_all, noop, get_store_value } from './internal';
export function readable(start, value) { export function readable(start, value) {
const subscribers = []; const subscribers = [];
@ -103,3 +103,5 @@ export function derive(stores, fn) {
}; };
}); });
} }
export { get_store_value as get };

@ -1,84 +0,0 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const glob = require('tiny-glob/sync.js');
const shell = require("shelljs");
const cli = path.resolve(__dirname, "../../cli/index.js");
function normalize(str) {
return str
.replace(/^\s+$/gm, '')
.replace(
/\/\*(.*?)generated by Svelte v[.\d]+/,
(_, path) => `/*${path.replace(/\\/g, '/')}generated by Svelte vx.y.z`
)
.trim();
}
const cwd = process.cwd();
// TODO figure out what to do with the CLI
describe.skip('cli', function() {
this.timeout(10000);
afterEach(() => {
process.chdir(cwd);
});
fs.readdirSync('test/cli/samples').forEach(dir => {
if (dir[0] === '.') return;
// append .solo to test dir to only run that test
const solo = /\.solo$/.test(dir);
(solo ? it.only : it)(dir, done => {
process.chdir(`${__dirname}/samples/${dir}`);
const command = fs.readFileSync('command.sh', 'utf-8');
shell.mkdir("-p", "actual");
shell.rm("-rf", "actual/*");
const { commandErr } = shell.exec(
command.replace(/^svelte /, `node ${cli} `)
);
if (commandErr) {
done(commandErr);
return;
}
const actual = glob('**', { cwd: 'actual', filesOnly: true })
.map(file => {
return {
file,
contents: normalize(fs.readFileSync(`actual/${file}`, 'utf-8'))
};
});
const expected = glob('**', { cwd: 'expected', filesOnly: true })
.map(file => {
return {
file,
contents: normalize(
fs.readFileSync(`expected/${file}`, 'utf-8')
)
};
});
actual.forEach((a, i) => {
const e = expected[i];
assert.equal(a.file, e.file, 'File list mismatch');
if (/\.map$/.test(a.file)) {
assert.deepEqual(JSON.parse(a.contents), JSON.parse(e.contents));
} else {
assert.equal(a.contents, e.contents);
}
});
done();
});
});
});

@ -1 +0,0 @@
svelte compile src/Main.svelte > actual/Main.js

@ -1,191 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "Hello world!";
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Main(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Main;

@ -1 +0,0 @@
svelte compile src/Main.svelte --customElement > actual/Main.js

@ -1,212 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "Hello world!";
this.c = noop;
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
class Main extends HTMLElement {
constructor(options = {}) {
super();
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
assign(Main.prototype, {
_mount(target, anchor) {
target.insertBefore(this, anchor);
}
});
customElements.define("my-element", Main);
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function noop() {}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Main;

@ -1,3 +0,0 @@
<svelte:options tag="my-element"/>
<p>Hello world!</p>

@ -1 +0,0 @@
svelte compile src/Main.svelte -d > actual/Main.js

@ -1,227 +0,0 @@
/* src/Main.svelte generated by Svelte v2.13.4 */
const file = "src/Main.svelte";
function create_main_fragment(component, ctx) {
var p;
return {
c: function create() {
p = createElement("p");
p.textContent = "Hello world!";
addLoc(p, file, 0, 0, 0);
},
m: function mount(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d: function destroy(detach) {
if (detach) {
detachNode(p);
}
}
};
}
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._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._checkReadOnly = function _checkReadOnly(newState) {
};
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function addLoc(element, file, line, column, char) {
element.__svelte_meta = {
loc: { file, line, column, char }
};
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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;
this._fragment.d(detach !== false);
this._fragment = null;
this._state = {};
}
function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;
flush(this.root);
}
function flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Main;

@ -1 +0,0 @@
svelte compile src -m -o actual

@ -1,186 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
import Widget from './Widget.svelte';
function create_main_fragment(component, ctx) {
var widget = new Widget({
root: component.root,
store: component.store
});
return {
c() {
widget._fragment.c();
},
m(target, anchor) {
widget._mount(target, anchor);
},
p: noop,
d(detach) {
widget.destroy(detach);
}
};
}
function Main(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
this._fragment = create_main_fragment(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
flush(this);
}
}
assign(Main.prototype, {
destroy: destroy,
get: get,
fire: fire,
on: on,
set: set,
_set: _set,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function noop() {}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
function assign(tar, src) {
for (var k in src) tar[k] = src[k];
return tar;
}
function flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
this.set = noop;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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.svelte"],"sourcesContent":["<Widget/>\n\n<script>\n\timport Widget from './Widget.svelte';\n\n\texport default {\n\t\tcomponents: {\n\t\t\tWidget\n\t\t}\n\t};\n</script>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

@ -1,192 +0,0 @@
/* src/Widget.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "widget";
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Widget(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Widget.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
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.svelte"],"sourcesContent":["<p>widget</p>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

@ -1,5 +0,0 @@
<script>
import Widget from './Widget.svelte';
</script>
<Widget/>

@ -1 +0,0 @@
svelte compile src -o actual

@ -1,185 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
import Widget from './widget/Widget.svelte';
function create_main_fragment(component, ctx) {
var widget = new Widget({
root: component.root,
store: component.store
});
return {
c() {
widget._fragment.c();
},
m(target, anchor) {
widget._mount(target, anchor);
},
p: noop,
d(detach) {
widget.destroy(detach);
}
};
}
function Main(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
this._fragment = create_main_fragment(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
flush(this);
}
}
assign(Main.prototype, {
destroy: destroy,
get: get,
fire: fire,
on: on,
set: set,
_set: _set,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function noop() {}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
function assign(tar, src) {
for (var k in src) tar[k] = src[k];
return tar;
}
function flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
this.set = noop;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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,191 +0,0 @@
/* src/widget/Widget.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "widget";
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Widget(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Widget.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Widget;

@ -1,5 +0,0 @@
<script>
import Widget from './widget/Widget.svelte';
</script>
<Widget/>

@ -1 +0,0 @@
svelte compile src -o actual

@ -1,185 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
import Widget from './Widget.svelte';
function create_main_fragment(component, ctx) {
var widget = new Widget({
root: component.root,
store: component.store
});
return {
c() {
widget._fragment.c();
},
m(target, anchor) {
widget._mount(target, anchor);
},
p: noop,
d(detach) {
widget.destroy(detach);
}
};
}
function Main(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
this._fragment = create_main_fragment(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
flush(this);
}
}
assign(Main.prototype, {
destroy: destroy,
get: get,
fire: fire,
on: on,
set: set,
_set: _set,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function noop() {}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
function assign(tar, src) {
for (var k in src) tar[k] = src[k];
return tar;
}
function flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
this.set = noop;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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,191 +0,0 @@
/* src/Widget.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "widget";
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Widget(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Widget.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Widget;

@ -1,5 +0,0 @@
<script>
import Widget from './Widget.svelte';
</script>
<Widget/>

@ -1 +0,0 @@
svelte compile src/Main.svelte -f iife -g the-answer:theAnswer > actual/Main.js

@ -1,219 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
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, text0, text1;
return {
c() {
p = createElement("p");
text0 = createText("The answer is ");
text1 = createText(ctx.answer);
},
m(target, anchor) {
insert(target, p, anchor);
append(p, text0);
append(p, text1);
},
p(changed, ctx) {
if (changed.answer) {
setData(text1, ctx.answer);
}
},
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Main(options) {
init(this, options);
this._state = assign(data(), options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function createText(data) {
return document.createTextNode(data);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function append(target, node) {
target.appendChild(node);
}
function setData(text, data) {
text.data = '' + data;
}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
function _differs(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function noop() {}
function blankObject() {
return Object.create(null);
}
function flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
return Main;
}(theAnswer));

@ -1,5 +0,0 @@
<script>
import answer from 'the-answer';
</script>
<p>The answer is {answer}</p>

@ -1 +0,0 @@
svelte compile src/Main.svelte -m inline -o actual/Main.js

@ -1,192 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "Hello world!";
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Main(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Main;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=

@ -1,9 +0,0 @@
<script>
import { onMount } from 'svelte';
onMount(() => {
console.log('here');
});
</script>
<p>Hello world!</p>

@ -1 +0,0 @@
svelte compile src/Main.svelte -m -o actual/Main.js

@ -1,192 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var p;
return {
c() {
p = createElement("p");
p.textContent = "Hello world!";
},
m(target, anchor) {
insert(target, p, anchor);
},
p: noop,
d(detach) {
if (detach) {
detachNode(p);
}
}
};
}
function Main(options) {
init(this, options);
this._state = assign({}, options.data);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function noop() {}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
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 flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
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.svelte"],"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,9 +0,0 @@
<script>
import { onMount } from 'svelte';
onMount(() => {
console.log('here');
});
</script>
<p>Hello world!</p>

@ -1 +0,0 @@
svelte compile --generate ssr src/Main.svelte > actual/Main.js

@ -1,48 +0,0 @@
"use strict";
var Main = {};
Main.filename = "src/Main.svelte";
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 +0,0 @@
svelte compile src/Main.svelte --store > actual/Main.js

@ -1,217 +0,0 @@
/* src/Main.svelte generated by Svelte vx.y.z */
function create_main_fragment(component, ctx) {
var h1, text0, text1;
return {
c() {
h1 = createElement("h1");
text0 = createText("Hello ");
text1 = createText(ctx.$name);
},
m(target, anchor) {
insert(target, h1, anchor);
append(h1, text0);
append(h1, text1);
},
p(changed, ctx) {
if (changed.$name) {
setData(text1, ctx.$name);
}
},
d(detach) {
if (detach) {
detachNode(h1);
}
}
};
}
function Main(options) {
init(this, options);
this._state = assign(this.store._init(["name"]), options.data);
this.store._add(this, ["name"]);
this._intro = true;
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,
_stage: _stage,
_mount: _mount,
_differs: _differs
});
Main.prototype._recompute = noop;
function createElement(name) {
return document.createElement(name);
}
function createText(data) {
return document.createTextNode(data);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor);
}
function append(target, node) {
target.appendChild(node);
}
function setData(text, data) {
text.data = '' + data;
}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function init(component, options) {
component._handlers = blankObject();
component._slots = blankObject();
component._bind = options._bind;
component._staged = {};
component.options = options;
component.root = options.root || component;
component.store = options.store || component.root.store;
if (!options.root) {
component._beforecreate = [];
component._oncreate = [];
component._aftercreate = [];
}
}
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;
this._fragment.d(detach !== false);
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) {
try {
handler.__calling = true;
handler.call(this, data);
} finally {
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;
flush(this.root);
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
newState = assign(this._staged, newState);
this._staged = {};
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 _stage(newState) {
assign(this._staged, newState);
}
function _mount(target, anchor) {
this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null);
}
function _differs(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function noop() {}
function blankObject() {
return Object.create(null);
}
function flush(component) {
component._lock = true;
callAll(component._beforecreate);
callAll(component._oncreate);
callAll(component._aftercreate);
component._lock = false;
}
function callAll(fns) {
while (fns && fns.length) fns.shift()();
}
export default Main;

@ -1 +0,0 @@
<h1>Hello {$name}</h1>

@ -1,20 +0,0 @@
const sander = require('sander');
const glob = require('tiny-glob/sync');
process.chdir(__dirname);
sander.readdirSync('samples').forEach(dir => {
if (dir[0] === '.') return;
sander.rimrafSync(`samples/${dir}/expected`);
const files = glob(`**`, { cwd: `samples/${dir}/actual`, filesOnly: true });
files.forEach(file => {
const source = sander.readFileSync(`samples/${dir}/actual/${file}`, { encoding: 'utf-8' });
sander.writeFileSync(
`samples/${dir}/expected/${file}`,
source.replace(/generated by Svelte v(\d+\.\d+\.\d+)/, 'generated by Svelte vx.y.z')
);
});
});

@ -1,12 +1,12 @@
{ {
"html": { "html": {
"start": 0, "start": 0,
"end": 88, "end": 89,
"type": "Fragment", "type": "Fragment",
"children": [ "children": [
{ {
"start": 0, "start": 0,
"end": 88, "end": 89,
"type": "IfBlock", "type": "IfBlock",
"expression": { "expression": {
"type": "BinaryExpression", "type": "BinaryExpression",
@ -45,45 +45,45 @@
} }
], ],
"else": { "else": {
"start": 57, "start": 58,
"end": 83, "end": 84,
"type": "ElseBlock", "type": "ElseBlock",
"children": [ "children": [
{ {
"start": 57, "start": 58,
"end": 88, "end": 89,
"type": "IfBlock", "type": "IfBlock",
"elseif": true, "elseif": true,
"expression": { "expression": {
"type": "BinaryExpression", "type": "BinaryExpression",
"start": 51, "start": 52,
"end": 56, "end": 57,
"left": { "left": {
"type": "Identifier", "type": "Identifier",
"start": 51, "start": 52,
"end": 52, "end": 53,
"name": "x" "name": "x"
}, },
"operator": "<", "operator": "<",
"right": { "right": {
"type": "Literal", "type": "Literal",
"start": 55, "start": 56,
"end": 56, "end": 57,
"value": 5, "value": 5,
"raw": "5" "raw": "5"
} }
}, },
"children": [ "children": [
{ {
"start": 59, "start": 60,
"end": 82, "end": 83,
"type": "Element", "type": "Element",
"name": "p", "name": "p",
"attributes": [], "attributes": [],
"children": [ "children": [
{ {
"start": 62, "start": 63,
"end": 78, "end": 79,
"type": "Text", "type": "Text",
"data": "x is less than 5" "data": "x is less than 5"
} }
@ -95,8 +95,5 @@
} }
} }
] ]
}, }
"css": null,
"instance": null,
"module": null
} }

@ -0,0 +1,15 @@
export default {
html: `
<button>clicked: false</button>
`,
async test({ assert, component, target, window }) {
const button = target.querySelector('button');
const event = new window.MouseEvent('click');
await button.dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<button>clicked: true</button>
`);
}
};

@ -0,0 +1,16 @@
<script>
function get_handlers() {
return {
handle_click: () => {
clicked = true;
}
};
}
let clicked = false;
const { handle_click } = get_handlers();
</script>
<button on:click={handle_click}>
clicked: {clicked}
</button>

@ -0,0 +1,11 @@
import { writable } from '../../../../store.js';
export default {
props: {
b: writable(42)
},
html: `
42
`
};

@ -0,0 +1,7 @@
<script>
export let a;
export let b;
export let c;
</script>
{$b}

@ -1,5 +1,5 @@
import * as assert from 'assert'; import * as assert from 'assert';
import { readable, writable, derive } from '../../store.js'; import { readable, writable, derive, get } from '../../store.js';
describe('store', () => { describe('store', () => {
describe('writable', () => { describe('writable', () => {
@ -172,4 +172,11 @@ describe('store', () => {
unsubscribe(); unsubscribe();
}); });
}); });
describe('get', () => {
it('gets the current value of a store', () => {
const store = readable(() => {}, 42);
assert.equal(get(store), 42);
});
});
}); });

@ -14,7 +14,8 @@ describe('vars', () => {
throw new Error('Forgot to remove `solo: true` from test'); throw new Error('Forgot to remove `solo: true` from test');
} }
(solo ? it.only : skip ? it.skip : it)(dir, () => { for (const generate of ['dom', 'ssr', false]) {
(solo ? it.only : skip ? it.skip : it)(`${dir}, generate: ${generate}`, () => {
const config = loadConfig(`./vars/samples/${dir}/_config.js`); const config = loadConfig(`./vars/samples/${dir}/_config.js`);
const filename = `test/vars/samples/${dir}/input.svelte`; const filename = `test/vars/samples/${dir}/input.svelte`;
const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, ''); const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, '');
@ -27,7 +28,7 @@ describe('vars', () => {
let error; let error;
try { try {
result = svelte.compile(input, config.options); result = svelte.compile(input, { ...config.options, generate });
config.test(assert, result.vars); config.test(assert, result.vars);
} catch (e) { } catch (e) {
error = e; error = e;
@ -48,13 +49,6 @@ describe('vars', () => {
assert.equal(error.pos, expectedError.pos); assert.equal(error.pos, expectedError.pos);
} }
}); });
}); }
it('returns a vars object when options.generate is false', () => {
const { vars } = svelte.compile('', {
generate: false
});
assert.ok(Array.isArray(vars));
}); });
}); });

@ -0,0 +1,16 @@
export default {
test(assert, vars) {
assert.deepEqual(vars, [
{
export_name: null,
injected: false,
module: false,
mutated: false,
name: 'foo',
reassigned: false,
referenced: true,
writable: true
}
]);
}
};

@ -0,0 +1,5 @@
<script>
let foo;
</script>
<div use:foo/>

@ -0,0 +1,16 @@
export default {
test(assert, vars) {
assert.deepEqual(vars, [
{
export_name: null,
injected: false,
module: false,
mutated: false,
name: 'foo',
reassigned: false,
referenced: true,
writable: true
}
]);
}
};

@ -0,0 +1,7 @@
<script>
let foo;
</script>
{#each [] as x (x)}
<div animate:foo/>
{/each}

@ -0,0 +1,36 @@
export default {
test(assert, vars) {
assert.deepEqual(vars, [
{
export_name: null,
injected: false,
module: false,
mutated: false,
name: 'foo',
reassigned: false,
referenced: true,
writable: true
},
{
export_name: null,
injected: false,
module: false,
mutated: false,
name: 'bar',
reassigned: false,
referenced: true,
writable: true
},
{
export_name: null,
injected: false,
module: false,
mutated: false,
name: 'baz',
reassigned: false,
referenced: true,
writable: true
}
]);
}
};

@ -0,0 +1,9 @@
<script>
let foo;
let bar;
let baz;
</script>
<div in:foo/>
<div out:bar/>
<div transition:baz/>
Loading…
Cancel
Save