diff --git a/.gitignore b/.gitignore index 3a7d2ce532..a78b294346 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ node_modules *.map /src/compile/internal-exports.ts -/cli/ /compiler.js /index.js /internal.* @@ -14,7 +13,6 @@ node_modules /scratch/ /coverage/ /coverage.lcov/ -/test/cli/samples/*/actual /test/sourcemaps/samples/*/output.js /test/sourcemaps/samples/*/output.js.map /test/sourcemaps/samples/*/output.css diff --git a/package-lock.json b/package-lock.json index 9e5722c351..034a9b0259 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { "version": "2.0.0", "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": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -2831,33 +2819,6 @@ "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", "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": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -3374,15 +3335,6 @@ "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": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", @@ -3951,15 +3903,6 @@ "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": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -3981,17 +3924,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "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": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.6.tgz", @@ -4051,17 +3983,6 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "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": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", diff --git a/package.json b/package.json index 114fe051c9..b0b53d1e46 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,7 @@ "description": "The magical disappearing UI framework", "module": "index.mjs", "main": "index", - "bin": { - "svelte": "svelte" - }, "files": [ - "cli", "compiler.js", "register.js", "index.*", @@ -72,7 +68,6 @@ "magic-string": "^0.25.2", "mocha": "^5.2.0", "nightmare": "^3.0.1", - "node-resolve": "^1.3.3", "rollup": "^1.1.2", "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-json": "^3.0.0", @@ -81,9 +76,6 @@ "rollup-plugin-sucrase": "^2.1.0", "rollup-plugin-typescript": "^1.0.0", "rollup-plugin-virtual": "^1.0.1", - "sade": "^1.4.0", - "sander": "^0.6.0", - "shelljs": "^0.8.2", "source-map": "0.6", "source-map-support": "^0.5.4", "tiny-glob": "^0.2.1", diff --git a/rollup.config.js b/rollup.config.js index ad58d25f22..c523cb004d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -69,27 +69,6 @@ export default [ : 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 */ { input: `src/motion/index.js`, diff --git a/src/cli/compile.ts b/src/cli/compile.ts deleted file mode 100644 index f8928c29cf..0000000000 --- a/src/cli/compile.ts +++ /dev/null @@ -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'); -} diff --git a/src/cli/error.ts b/src/cli/error.ts deleted file mode 100644 index 2413ab9ee5..0000000000 --- a/src/cli/error.ts +++ /dev/null @@ -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); -} diff --git a/src/cli/index.ts b/src/cli/index.ts deleted file mode 100644 index 309d23acda..0000000000 --- a/src/cli/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import sade from 'sade'; -import * as pkg from '../../package.json'; - -const prog = sade('svelte').version(pkg.version); - -prog - .command('compile ') - - .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); \ No newline at end of file diff --git a/test/cli/index.js b/test/cli/index.js deleted file mode 100644 index f1779b1ea1..0000000000 --- a/test/cli/index.js +++ /dev/null @@ -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(); - }); - }); -}); diff --git a/test/cli/samples/basic/command.sh b/test/cli/samples/basic/command.sh deleted file mode 100644 index 9e272a7d5b..0000000000 --- a/test/cli/samples/basic/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte > actual/Main.js diff --git a/test/cli/samples/basic/expected/Main.js b/test/cli/samples/basic/expected/Main.js deleted file mode 100644 index ecc2beb83c..0000000000 --- a/test/cli/samples/basic/expected/Main.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/basic/src/Main.svelte b/test/cli/samples/basic/src/Main.svelte deleted file mode 100644 index aa994ea13e..0000000000 --- a/test/cli/samples/basic/src/Main.svelte +++ /dev/null @@ -1 +0,0 @@ -

Hello world!

\ No newline at end of file diff --git a/test/cli/samples/custom-element/command.sh b/test/cli/samples/custom-element/command.sh deleted file mode 100644 index ee9f854e9b..0000000000 --- a/test/cli/samples/custom-element/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte --customElement > actual/Main.js diff --git a/test/cli/samples/custom-element/expected/Main.js b/test/cli/samples/custom-element/expected/Main.js deleted file mode 100644 index f6befc4e3b..0000000000 --- a/test/cli/samples/custom-element/expected/Main.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/custom-element/src/Main.svelte b/test/cli/samples/custom-element/src/Main.svelte deleted file mode 100644 index 6323e9e8d1..0000000000 --- a/test/cli/samples/custom-element/src/Main.svelte +++ /dev/null @@ -1,3 +0,0 @@ - - -

Hello world!

diff --git a/test/cli/samples/dev/command.sh b/test/cli/samples/dev/command.sh deleted file mode 100644 index b9dc99e7d1..0000000000 --- a/test/cli/samples/dev/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte -d > actual/Main.js \ No newline at end of file diff --git a/test/cli/samples/dev/expected/Main.js b/test/cli/samples/dev/expected/Main.js deleted file mode 100644 index db75c4a5c1..0000000000 --- a/test/cli/samples/dev/expected/Main.js +++ /dev/null @@ -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 = '
'; - 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; \ No newline at end of file diff --git a/test/cli/samples/dev/src/Main.svelte b/test/cli/samples/dev/src/Main.svelte deleted file mode 100644 index aa994ea13e..0000000000 --- a/test/cli/samples/dev/src/Main.svelte +++ /dev/null @@ -1 +0,0 @@ -

Hello world!

\ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/command.sh b/test/cli/samples/dir-sourcemap/command.sh deleted file mode 100644 index 37089f3f44..0000000000 --- a/test/cli/samples/dir-sourcemap/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src -m -o actual \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js b/test/cli/samples/dir-sourcemap/expected/Main.js deleted file mode 100644 index e164569e1c..0000000000 --- a/test/cli/samples/dir-sourcemap/expected/Main.js +++ /dev/null @@ -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 diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js.map b/test/cli/samples/dir-sourcemap/expected/Main.js.map deleted file mode 100644 index a0f4cf48c7..0000000000 --- a/test/cli/samples/dir-sourcemap/expected/Main.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.svelte"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js b/test/cli/samples/dir-sourcemap/expected/Widget.js deleted file mode 100644 index d55dcbda4c..0000000000 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js +++ /dev/null @@ -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 diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js.map b/test/cli/samples/dir-sourcemap/expected/Widget.js.map deleted file mode 100644 index 37247333ed..0000000000 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Widget.js","sources":["../src/Widget.svelte"],"sourcesContent":["

widget

"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/src/Main.svelte b/test/cli/samples/dir-sourcemap/src/Main.svelte deleted file mode 100644 index 0a9d5bba87..0000000000 --- a/test/cli/samples/dir-sourcemap/src/Main.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/src/Widget.svelte b/test/cli/samples/dir-sourcemap/src/Widget.svelte deleted file mode 100644 index 963b8f1a2a..0000000000 --- a/test/cli/samples/dir-sourcemap/src/Widget.svelte +++ /dev/null @@ -1 +0,0 @@ -

widget

\ No newline at end of file diff --git a/test/cli/samples/dir-subdir/command.sh b/test/cli/samples/dir-subdir/command.sh deleted file mode 100644 index 10067cb1f9..0000000000 --- a/test/cli/samples/dir-subdir/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src -o actual \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/expected/Main.js b/test/cli/samples/dir-subdir/expected/Main.js deleted file mode 100644 index 3026a122e2..0000000000 --- a/test/cli/samples/dir-subdir/expected/Main.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/expected/widget/Widget.js b/test/cli/samples/dir-subdir/expected/widget/Widget.js deleted file mode 100644 index e63ac2dad7..0000000000 --- a/test/cli/samples/dir-subdir/expected/widget/Widget.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/src/Main.svelte b/test/cli/samples/dir-subdir/src/Main.svelte deleted file mode 100644 index ac663b4338..0000000000 --- a/test/cli/samples/dir-subdir/src/Main.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/src/widget/Widget.svelte b/test/cli/samples/dir-subdir/src/widget/Widget.svelte deleted file mode 100644 index 963b8f1a2a..0000000000 --- a/test/cli/samples/dir-subdir/src/widget/Widget.svelte +++ /dev/null @@ -1 +0,0 @@ -

widget

\ No newline at end of file diff --git a/test/cli/samples/dir/command.sh b/test/cli/samples/dir/command.sh deleted file mode 100644 index 10067cb1f9..0000000000 --- a/test/cli/samples/dir/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src -o actual \ No newline at end of file diff --git a/test/cli/samples/dir/expected/Main.js b/test/cli/samples/dir/expected/Main.js deleted file mode 100644 index d87ac37939..0000000000 --- a/test/cli/samples/dir/expected/Main.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/dir/expected/Widget.js b/test/cli/samples/dir/expected/Widget.js deleted file mode 100644 index eeb37e3cfa..0000000000 --- a/test/cli/samples/dir/expected/Widget.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/dir/src/Main.svelte b/test/cli/samples/dir/src/Main.svelte deleted file mode 100644 index 0a9d5bba87..0000000000 --- a/test/cli/samples/dir/src/Main.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/test/cli/samples/dir/src/Widget.svelte b/test/cli/samples/dir/src/Widget.svelte deleted file mode 100644 index 963b8f1a2a..0000000000 --- a/test/cli/samples/dir/src/Widget.svelte +++ /dev/null @@ -1 +0,0 @@ -

widget

\ No newline at end of file diff --git a/test/cli/samples/globals/command.sh b/test/cli/samples/globals/command.sh deleted file mode 100644 index 9e1a2de74a..0000000000 --- a/test/cli/samples/globals/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte -f iife -g the-answer:theAnswer > actual/Main.js \ No newline at end of file diff --git a/test/cli/samples/globals/expected/Main.js b/test/cli/samples/globals/expected/Main.js deleted file mode 100644 index 8e526b08bf..0000000000 --- a/test/cli/samples/globals/expected/Main.js +++ /dev/null @@ -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)); \ No newline at end of file diff --git a/test/cli/samples/globals/src/Main.svelte b/test/cli/samples/globals/src/Main.svelte deleted file mode 100644 index 2fc0383a67..0000000000 --- a/test/cli/samples/globals/src/Main.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - -

The answer is {answer}

\ No newline at end of file diff --git a/test/cli/samples/sourcemap-inline/command.sh b/test/cli/samples/sourcemap-inline/command.sh deleted file mode 100644 index 073fa7d259..0000000000 --- a/test/cli/samples/sourcemap-inline/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte -m inline -o actual/Main.js \ No newline at end of file diff --git a/test/cli/samples/sourcemap-inline/expected/Main.js b/test/cli/samples/sourcemap-inline/expected/Main.js deleted file mode 100644 index 534c6734f2..0000000000 --- a/test/cli/samples/sourcemap-inline/expected/Main.js +++ /dev/null @@ -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= diff --git a/test/cli/samples/sourcemap-inline/src/Main.svelte b/test/cli/samples/sourcemap-inline/src/Main.svelte deleted file mode 100644 index 6f3f80bbff..0000000000 --- a/test/cli/samples/sourcemap-inline/src/Main.svelte +++ /dev/null @@ -1,9 +0,0 @@ - - -

Hello world!

\ No newline at end of file diff --git a/test/cli/samples/sourcemap/command.sh b/test/cli/samples/sourcemap/command.sh deleted file mode 100644 index 9164b1760c..0000000000 --- a/test/cli/samples/sourcemap/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte -m -o actual/Main.js \ No newline at end of file diff --git a/test/cli/samples/sourcemap/expected/Main.js b/test/cli/samples/sourcemap/expected/Main.js deleted file mode 100644 index 59059aadcb..0000000000 --- a/test/cli/samples/sourcemap/expected/Main.js +++ /dev/null @@ -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 diff --git a/test/cli/samples/sourcemap/expected/Main.js.map b/test/cli/samples/sourcemap/expected/Main.js.map deleted file mode 100644 index a31dec16ab..0000000000 --- a/test/cli/samples/sourcemap/expected/Main.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.svelte"],"sourcesContent":["

Hello world!

\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/sourcemap/src/Main.svelte b/test/cli/samples/sourcemap/src/Main.svelte deleted file mode 100644 index 6f3f80bbff..0000000000 --- a/test/cli/samples/sourcemap/src/Main.svelte +++ /dev/null @@ -1,9 +0,0 @@ - - -

Hello world!

\ No newline at end of file diff --git a/test/cli/samples/ssr/command.sh b/test/cli/samples/ssr/command.sh deleted file mode 100644 index 878f6038ab..0000000000 --- a/test/cli/samples/ssr/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile --generate ssr src/Main.svelte > actual/Main.js diff --git a/test/cli/samples/ssr/expected/Main.js b/test/cli/samples/ssr/expected/Main.js deleted file mode 100644 index b7a4f4addf..0000000000 --- a/test/cli/samples/ssr/expected/Main.js +++ /dev/null @@ -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 `

Hello world!

`; -}; - -Main.css = { - code: '', - map: null -}; - -var warned = false; - -module.exports = Main; \ No newline at end of file diff --git a/test/cli/samples/ssr/src/Main.svelte b/test/cli/samples/ssr/src/Main.svelte deleted file mode 100644 index aa994ea13e..0000000000 --- a/test/cli/samples/ssr/src/Main.svelte +++ /dev/null @@ -1 +0,0 @@ -

Hello world!

\ No newline at end of file diff --git a/test/cli/samples/store/command.sh b/test/cli/samples/store/command.sh deleted file mode 100644 index dedeae05ef..0000000000 --- a/test/cli/samples/store/command.sh +++ /dev/null @@ -1 +0,0 @@ -svelte compile src/Main.svelte --store > actual/Main.js diff --git a/test/cli/samples/store/expected/Main.js b/test/cli/samples/store/expected/Main.js deleted file mode 100644 index 28bc62b786..0000000000 --- a/test/cli/samples/store/expected/Main.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/test/cli/samples/store/src/Main.svelte b/test/cli/samples/store/src/Main.svelte deleted file mode 100644 index 3010a856fb..0000000000 --- a/test/cli/samples/store/src/Main.svelte +++ /dev/null @@ -1 +0,0 @@ -

Hello {$name}

\ No newline at end of file diff --git a/test/cli/update.js b/test/cli/update.js deleted file mode 100644 index 468fe51f15..0000000000 --- a/test/cli/update.js +++ /dev/null @@ -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') - ); - }); -}); \ No newline at end of file