diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..35195c5
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,1518 @@
+{
+ "name": "svelte-cli",
+ "version": "1.3.6",
+ "lockfileVersion": 1,
+ "dependencies": {
+ "acorn": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.0.tgz",
+ "integrity": "sha512-WXZ0VTJT8EE25BmZjc+wr0qIwG7QaEna9csPKHS6WQp8gDo4V376wUWi222LXRiuAF6CAS4Ejv736DdRwuPK9g==",
+ "dev": true
+ },
+ "acorn-jsx": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz",
+ "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=",
+ "dev": true,
+ "dependencies": {
+ "acorn": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
+ "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=",
+ "dev": true
+ }
+ }
+ },
+ "ajv": {
+ "version": "4.11.8",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz",
+ "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=",
+ "dev": true
+ },
+ "ajv-keywords": {
+ "version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz",
+ "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=",
+ "dev": true
+ },
+ "ansi-escapes": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz",
+ "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=",
+ "dev": true
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
+ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
+ "dev": true
+ },
+ "argparse": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz",
+ "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=",
+ "dev": true
+ },
+ "arr-diff": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
+ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
+ "dev": true
+ },
+ "arr-flatten": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.3.tgz",
+ "integrity": "sha1-onTthawIhJtr14R8RYB0XcUa37E=",
+ "dev": true
+ },
+ "array-union": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz",
+ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=",
+ "dev": true
+ },
+ "array-uniq": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
+ "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=",
+ "dev": true
+ },
+ "array-unique": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
+ "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=",
+ "dev": true
+ },
+ "arrify": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
+ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
+ "dev": true
+ },
+ "babel-code-frame": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz",
+ "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=",
+ "dev": true
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "1.1.8",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
+ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
+ "dev": true
+ },
+ "braces": {
+ "version": "1.8.5",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz",
+ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
+ "dev": true
+ },
+ "browser-resolve": {
+ "version": "1.11.2",
+ "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz",
+ "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=",
+ "dev": true,
+ "dependencies": {
+ "resolve": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
+ "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
+ "dev": true
+ }
+ }
+ },
+ "browser-stdout": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz",
+ "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=",
+ "dev": true
+ },
+ "builtin-modules": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
+ "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
+ "dev": true
+ },
+ "caller-path": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz",
+ "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=",
+ "dev": true
+ },
+ "callsites": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz",
+ "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=",
+ "dev": true
+ },
+ "chalk": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
+ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
+ "dev": true
+ },
+ "circular-json": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.1.tgz",
+ "integrity": "sha1-vos2rvzN6LPKeqLWr8B6NyQsDS0=",
+ "dev": true
+ },
+ "cli-cursor": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz",
+ "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=",
+ "dev": true
+ },
+ "cli-width": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz",
+ "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=",
+ "dev": true
+ },
+ "co": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
+ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
+ "dev": true
+ },
+ "code-point-at": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
+ "dev": true
+ },
+ "commander": {
+ "version": "2.9.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
+ "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
+ "dev": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "concat-stream": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
+ "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=",
+ "dev": true
+ },
+ "contains-path": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz",
+ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=",
+ "dev": true
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
+ "dev": true
+ },
+ "d": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
+ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
+ "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "dev": true
+ },
+ "deep-is": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
+ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
+ "dev": true
+ },
+ "del": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz",
+ "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=",
+ "dev": true
+ },
+ "diff": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz",
+ "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=",
+ "dev": true
+ },
+ "doctrine": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz",
+ "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=",
+ "dev": true
+ },
+ "error-ex": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
+ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
+ "dev": true
+ },
+ "es5-ext": {
+ "version": "0.10.23",
+ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.23.tgz",
+ "integrity": "sha1-dXi1G+l0IHpUh4IbVlOMIk5Oezg=",
+ "dev": true
+ },
+ "es6-iterator": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz",
+ "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=",
+ "dev": true
+ },
+ "es6-map": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz",
+ "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=",
+ "dev": true
+ },
+ "es6-set": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
+ "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=",
+ "dev": true
+ },
+ "es6-symbol": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz",
+ "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=",
+ "dev": true
+ },
+ "es6-weak-map": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz",
+ "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=",
+ "dev": true
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
+ "dev": true
+ },
+ "escope": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz",
+ "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=",
+ "dev": true
+ },
+ "eslint": {
+ "version": "3.19.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz",
+ "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=",
+ "dev": true
+ },
+ "eslint-import-resolver-node": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz",
+ "integrity": "sha512-yUtXS15gIcij68NmXmP9Ni77AQuCN0itXbCc/jWd8C6/yKZaSNXicpC8cgvjnxVdmfsosIXrjpzFq7GcDryb6A==",
+ "dev": true
+ },
+ "eslint-module-utils": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz",
+ "integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==",
+ "dev": true
+ },
+ "eslint-plugin-import": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.6.1.tgz",
+ "integrity": "sha512-aAMb32eHCQaQmgdb1MOG1hfu/rPiNgGur2IF71VJeDfTXdLpPiKALKWlzxMdcxQOZZ2CmYVKabAxCvjACxH1uQ==",
+ "dev": true,
+ "dependencies": {
+ "doctrine": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
+ "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
+ "dev": true
+ }
+ }
+ },
+ "espree": {
+ "version": "3.4.3",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz",
+ "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=",
+ "dev": true
+ },
+ "esprima": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz",
+ "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=",
+ "dev": true
+ },
+ "esquery": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz",
+ "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=",
+ "dev": true
+ },
+ "esrecurse": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz",
+ "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=",
+ "dev": true
+ },
+ "estraverse": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
+ "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=",
+ "dev": true
+ },
+ "estree-walker": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.3.1.tgz",
+ "integrity": "sha1-5rGlHPcpJSTnI3wxLl/mZgwc4ao=",
+ "dev": true
+ },
+ "esutils": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
+ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
+ "dev": true
+ },
+ "event-emitter": {
+ "version": "0.3.5",
+ "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
+ "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=",
+ "dev": true
+ },
+ "exit-hook": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz",
+ "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=",
+ "dev": true
+ },
+ "expand-brackets": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
+ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
+ "dev": true
+ },
+ "expand-range": {
+ "version": "1.8.2",
+ "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz",
+ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=",
+ "dev": true
+ },
+ "extglob": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz",
+ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
+ "dev": true
+ },
+ "fast-levenshtein": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
+ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
+ "dev": true
+ },
+ "figures": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz",
+ "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=",
+ "dev": true
+ },
+ "file-entry-cache": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz",
+ "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=",
+ "dev": true
+ },
+ "filename-regex": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
+ "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=",
+ "dev": true
+ },
+ "fill-range": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz",
+ "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=",
+ "dev": true
+ },
+ "find-up": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
+ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
+ "dev": true
+ },
+ "flat-cache": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz",
+ "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=",
+ "dev": true
+ },
+ "for-in": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
+ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
+ "dev": true
+ },
+ "for-own": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz",
+ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "function-bind": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz",
+ "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=",
+ "dev": true
+ },
+ "generate-function": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz",
+ "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=",
+ "dev": true
+ },
+ "generate-object-property": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
+ "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=",
+ "dev": true
+ },
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "dev": true
+ },
+ "glob-base": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz",
+ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=",
+ "dev": true
+ },
+ "glob-parent": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz",
+ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=",
+ "dev": true
+ },
+ "globals": {
+ "version": "9.18.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz",
+ "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==",
+ "dev": true
+ },
+ "globby": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
+ "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=",
+ "dev": true
+ },
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ },
+ "graceful-readlink": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
+ "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
+ "dev": true
+ },
+ "growl": {
+ "version": "1.9.2",
+ "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
+ "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
+ "dev": true
+ },
+ "has": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz",
+ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=",
+ "dev": true
+ },
+ "has-ansi": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
+ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
+ "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=",
+ "dev": true
+ },
+ "hosted-git-info": {
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz",
+ "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==",
+ "dev": true
+ },
+ "ignore": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz",
+ "integrity": "sha1-QyNS5XrM2HqzEQ6C0/6g5HgSFW0=",
+ "dev": true
+ },
+ "imurmurhash": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
+ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
+ "dev": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
+ "dev": true
+ },
+ "inquirer": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz",
+ "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=",
+ "dev": true
+ },
+ "interpret": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz",
+ "integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A=",
+ "dev": true
+ },
+ "is-arrayish": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
+ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=",
+ "dev": true
+ },
+ "is-buffer": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz",
+ "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=",
+ "dev": true
+ },
+ "is-builtin-module": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz",
+ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=",
+ "dev": true
+ },
+ "is-dotfile": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz",
+ "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=",
+ "dev": true
+ },
+ "is-equal-shallow": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz",
+ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=",
+ "dev": true
+ },
+ "is-extendable": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
+ "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=",
+ "dev": true
+ },
+ "is-extglob": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
+ "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
+ "dev": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
+ "dev": true
+ },
+ "is-glob": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
+ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
+ "dev": true
+ },
+ "is-module": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
+ "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=",
+ "dev": true
+ },
+ "is-my-json-valid": {
+ "version": "2.16.0",
+ "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz",
+ "integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=",
+ "dev": true
+ },
+ "is-number": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
+ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=",
+ "dev": true
+ },
+ "is-path-cwd": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
+ "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=",
+ "dev": true
+ },
+ "is-path-in-cwd": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz",
+ "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=",
+ "dev": true
+ },
+ "is-path-inside": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz",
+ "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=",
+ "dev": true
+ },
+ "is-posix-bracket": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz",
+ "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=",
+ "dev": true
+ },
+ "is-primitive": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz",
+ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=",
+ "dev": true
+ },
+ "is-property": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
+ "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=",
+ "dev": true
+ },
+ "is-resolvable": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz",
+ "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=",
+ "dev": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+ "dev": true
+ },
+ "isobject": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
+ "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
+ "dev": true
+ },
+ "js-tokens": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
+ "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
+ "dev": true
+ },
+ "js-yaml": {
+ "version": "3.8.4",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz",
+ "integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=",
+ "dev": true
+ },
+ "json-stable-stringify": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz",
+ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=",
+ "dev": true
+ },
+ "json3": {
+ "version": "3.3.2",
+ "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
+ "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=",
+ "dev": true
+ },
+ "jsonify": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
+ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
+ "dev": true
+ },
+ "jsonpointer": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz",
+ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=",
+ "dev": true
+ },
+ "kind-of": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
+ "dev": true
+ },
+ "levn": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
+ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=",
+ "dev": true
+ },
+ "load-json-file": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
+ "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
+ "dev": true
+ },
+ "locate-path": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
+ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
+ "dev": true,
+ "dependencies": {
+ "path-exists": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
+ "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
+ "dev": true
+ }
+ }
+ },
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "dev": true
+ },
+ "lodash._baseassign": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
+ "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=",
+ "dev": true
+ },
+ "lodash._basecopy": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
+ "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
+ "dev": true
+ },
+ "lodash._basecreate": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz",
+ "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=",
+ "dev": true
+ },
+ "lodash._getnative": {
+ "version": "3.9.1",
+ "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz",
+ "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=",
+ "dev": true
+ },
+ "lodash._isiterateecall": {
+ "version": "3.0.9",
+ "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz",
+ "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=",
+ "dev": true
+ },
+ "lodash.cond": {
+ "version": "4.5.2",
+ "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz",
+ "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=",
+ "dev": true
+ },
+ "lodash.create": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz",
+ "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=",
+ "dev": true
+ },
+ "lodash.isarguments": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
+ "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=",
+ "dev": true
+ },
+ "lodash.isarray": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz",
+ "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=",
+ "dev": true
+ },
+ "lodash.keys": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
+ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=",
+ "dev": true
+ },
+ "magic-string": {
+ "version": "0.19.1",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.19.1.tgz",
+ "integrity": "sha1-FNdoATyvLsj96hakmvgvw3fnUgE=",
+ "dev": true
+ },
+ "micromatch": {
+ "version": "2.3.11",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz",
+ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true
+ },
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "dependencies": {
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
+ "dev": true
+ }
+ }
+ },
+ "mocha": {
+ "version": "3.4.2",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.4.2.tgz",
+ "integrity": "sha1-0O9NMyEm2/GNDWQMmzgt1IvpdZQ=",
+ "dev": true,
+ "dependencies": {
+ "debug": {
+ "version": "2.6.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz",
+ "integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=",
+ "dev": true
+ },
+ "glob": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz",
+ "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=",
+ "dev": true
+ },
+ "ms": {
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz",
+ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz",
+ "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=",
+ "dev": true
+ }
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
+ "dev": true
+ },
+ "mute-stream": {
+ "version": "0.0.5",
+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz",
+ "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=",
+ "dev": true
+ },
+ "natural-compare": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
+ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
+ "dev": true
+ },
+ "normalize-package-data": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
+ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
+ "dev": true
+ },
+ "normalize-path": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
+ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
+ "dev": true
+ },
+ "number-is-nan": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
+ "dev": true
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+ "dev": true
+ },
+ "object.omit": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz",
+ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=",
+ "dev": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "dev": true
+ },
+ "onetime": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
+ "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=",
+ "dev": true
+ },
+ "optionator": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
+ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=",
+ "dev": true
+ },
+ "os-homedir": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
+ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
+ "dev": true
+ },
+ "p-limit": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz",
+ "integrity": "sha1-sH/y2aXYi+yAYDWJWiurZqJ5iLw=",
+ "dev": true
+ },
+ "p-locate": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
+ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
+ "dev": true
+ },
+ "parse-glob": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz",
+ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=",
+ "dev": true
+ },
+ "parse-json": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
+ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
+ "dev": true
+ },
+ "path-exists": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
+ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
+ "dev": true
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "path-is-inside": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz",
+ "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=",
+ "dev": true
+ },
+ "path-parse": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz",
+ "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=",
+ "dev": true
+ },
+ "path-type": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz",
+ "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=",
+ "dev": true
+ },
+ "pify": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
+ "dev": true
+ },
+ "pinkie": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
+ "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=",
+ "dev": true
+ },
+ "pinkie-promise": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
+ "dev": true
+ },
+ "pkg-dir": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz",
+ "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=",
+ "dev": true
+ },
+ "pluralize": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz",
+ "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=",
+ "dev": true
+ },
+ "prelude-ls": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
+ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
+ "dev": true
+ },
+ "preserve": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz",
+ "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
+ "dev": true
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+ "dev": true
+ },
+ "progress": {
+ "version": "1.1.8",
+ "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz",
+ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=",
+ "dev": true
+ },
+ "randomatic": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
+ "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==",
+ "dev": true,
+ "dependencies": {
+ "is-number": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
+ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=",
+ "dev": true,
+ "dependencies": {
+ "kind-of": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
+ "dev": true
+ }
+ }
+ },
+ "kind-of": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz",
+ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=",
+ "dev": true
+ }
+ }
+ },
+ "read-pkg": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
+ "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=",
+ "dev": true
+ },
+ "read-pkg-up": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
+ "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=",
+ "dev": true,
+ "dependencies": {
+ "find-up": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
+ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
+ "dev": true
+ }
+ }
+ },
+ "readable-stream": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
+ "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
+ "dev": true
+ },
+ "readline2": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz",
+ "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=",
+ "dev": true
+ },
+ "rechoir": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
+ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
+ "dev": true
+ },
+ "regex-cache": {
+ "version": "0.4.3",
+ "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz",
+ "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=",
+ "dev": true
+ },
+ "remove-trailing-separator": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz",
+ "integrity": "sha1-abBi2XhyetFNxrVrpKt3L9jXBRE=",
+ "dev": true
+ },
+ "repeat-element": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz",
+ "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=",
+ "dev": true
+ },
+ "repeat-string": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
+ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
+ "dev": true
+ },
+ "require-uncached": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz",
+ "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=",
+ "dev": true
+ },
+ "resolve": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz",
+ "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=",
+ "dev": true
+ },
+ "resolve-from": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz",
+ "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=",
+ "dev": true
+ },
+ "restore-cursor": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz",
+ "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
+ "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "dev": true
+ },
+ "rollup": {
+ "version": "0.41.6",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.41.6.tgz",
+ "integrity": "sha1-4NBUl4d6OYwQTYFtJzOnGKepTio=",
+ "dev": true
+ },
+ "rollup-plugin-commonjs": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.0.2.tgz",
+ "integrity": "sha1-mLFYm/4ypsD2d5C2DAtJmXKv7Yk=",
+ "dev": true,
+ "dependencies": {
+ "acorn": {
+ "version": "4.0.13",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz",
+ "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=",
+ "dev": true
+ }
+ }
+ },
+ "rollup-plugin-json": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-json/-/rollup-plugin-json-2.3.0.tgz",
+ "integrity": "sha512-W45nZH7lmXgkSR/DkeyF4ks0YWFrMysdjUT049gTuAg+lwUEDBKI2+PztqW8UDSMlXCAeEONsLzpDDyBy9m+9A==",
+ "dev": true
+ },
+ "rollup-plugin-node-resolve": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.0.tgz",
+ "integrity": "sha1-i4l8TDAw1QASd7BRSyXSygloPuA=",
+ "dev": true
+ },
+ "rollup-plugin-string": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-string/-/rollup-plugin-string-2.0.2.tgz",
+ "integrity": "sha1-9TI6Is/XOLRQy+piq2WTcF6sdEs=",
+ "dev": true,
+ "dependencies": {
+ "estree-walker": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.2.1.tgz",
+ "integrity": "sha1-va/oCVOD2EFNXcLs9MkXO225QS4=",
+ "dev": true
+ },
+ "rollup-pluginutils": {
+ "version": "1.5.2",
+ "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz",
+ "integrity": "sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=",
+ "dev": true
+ }
+ }
+ },
+ "rollup-pluginutils": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz",
+ "integrity": "sha1-fslbNXP2VDpGpkYb2afFRFJdD8A=",
+ "dev": true
+ },
+ "run-async": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz",
+ "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=",
+ "dev": true
+ },
+ "rx-lite": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz",
+ "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=",
+ "dev": true
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
+ "dev": true
+ },
+ "semver": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
+ "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
+ "dev": true
+ },
+ "shelljs": {
+ "version": "0.7.8",
+ "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz",
+ "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=",
+ "dev": true
+ },
+ "slice-ansi": {
+ "version": "0.0.4",
+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz",
+ "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=",
+ "dev": true
+ },
+ "source-map": {
+ "version": "0.5.6",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
+ "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=",
+ "dev": true
+ },
+ "source-map-support": {
+ "version": "0.4.15",
+ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz",
+ "integrity": "sha1-AyAt9lwG0r2MfsI2KhkwVv7407E=",
+ "dev": true
+ },
+ "spdx-correct": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz",
+ "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=",
+ "dev": true
+ },
+ "spdx-expression-parse": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz",
+ "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=",
+ "dev": true
+ },
+ "spdx-license-ids": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz",
+ "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=",
+ "dev": true
+ },
+ "sprintf-js": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
+ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
+ "dev": true
+ },
+ "string_decoder": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+ "dev": true
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
+ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true
+ },
+ "strip-bom": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
+ "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=",
+ "dev": true
+ },
+ "strip-json-comments": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
+ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
+ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
+ "dev": true
+ },
+ "svelte": {
+ "version": "1.23.4",
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-1.23.4.tgz",
+ "integrity": "sha1-2dH2AUPA5nLksLJQCCAEWj3Qo4I="
+ },
+ "table": {
+ "version": "3.8.3",
+ "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz",
+ "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=",
+ "dev": true,
+ "dependencies": {
+ "ansi-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
+ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
+ "dev": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
+ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
+ "dev": true
+ },
+ "string-width": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.0.tgz",
+ "integrity": "sha1-AwZkVh/BRslCPsfZeP4kV0N/5tA=",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
+ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
+ "dev": true
+ }
+ }
+ },
+ "text-table": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
+ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
+ "dev": true
+ },
+ "through": {
+ "version": "2.3.8",
+ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
+ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
+ "dev": true
+ },
+ "tryit": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz",
+ "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=",
+ "dev": true
+ },
+ "type-check": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
+ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",
+ "dev": true
+ },
+ "typedarray": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
+ "dev": true
+ },
+ "user-home": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz",
+ "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=",
+ "dev": true
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
+ "dev": true
+ },
+ "validate-npm-package-license": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz",
+ "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=",
+ "dev": true
+ },
+ "vlq": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.2.tgz",
+ "integrity": "sha1-4xbVJXtAuGu0PLjV/qXX9U1rDKE=",
+ "dev": true
+ },
+ "wordwrap": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
+ "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
+ "dev": true
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+ "dev": true
+ },
+ "write": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz",
+ "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=",
+ "dev": true
+ },
+ "xtend": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
+ "dev": true
+ }
+ }
+}
diff --git a/src/tasks/compile/index.js b/src/tasks/compile/index.js
index 2d9296a..d86adf5 100644
--- a/src/tasks/compile/index.js
+++ b/src/tasks/compile/index.js
@@ -83,7 +83,8 @@ function compileFile ( input, output, options ) {
const { sourceMap } = options;
const inline = sourceMap === "inline";
- const source = fs.readFileSync( input, 'utf-8' );
+ let source = fs.readFileSync( input, 'utf-8' );
+ if ( source[0] === 0xFEFF ) source = source.slice( 1 );
let compiled;
diff --git a/test/samples/basic/actual/Main.js b/test/samples/basic/actual/Main.js
index c50ab9c..e13bd85 100644
--- a/test/samples/basic/actual/Main.js
+++ b/test/samples/basic/actual/Main.js
@@ -1,183 +1,198 @@
-function render_main_fragment ( root, component ) {
- var p = createElement( 'p' );
-
- appendNode( createText( "Hello world!" ), p );
+function create_main_fragment ( state, component ) {
+ var p, text;
return {
+ create: function () {
+ p = createElement( 'p' );
+ text = createText( "Hello world!" );
+ },
+
mount: function ( target, anchor ) {
insertNode( p, target, anchor );
+ appendNode( text, p );
},
-
- update: noop,
-
- teardown: function ( detach ) {
- if ( detach ) {
- detachNode( p );
- }
- }
+
+ unmount: function () {
+ detachNode( p );
+ },
+
+ destroy: noop
};
}
function Main ( options ) {
options = options || {};
this._state = options.data || {};
-
+
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
-
+
this._handlers = Object.create( null );
-
- this._root = options._root;
+
+ this._root = options._root || this;
this._yield = options._yield;
-
+
this._torndown = false;
-
- this._fragment = render_main_fragment( this._state, this );
- if ( options.target ) this._fragment.mount( options.target, null );
+
+ this._fragment = create_main_fragment( this._state, this );
+
+ if ( options.target ) {
+ this._fragment.create();
+ this._fragment.mount( options.target, null );
+ }
}
assign( Main.prototype, {
- get: get,
- fire: fire,
- observe: observe,
- on: on,
- set: set,
- _flush: _flush
-});
+ get: get,
+ fire: fire,
+ observe: observe,
+ on: on,
+ set: set,
+ _flush: _flush
+ });
Main.prototype._set = function _set ( newState ) {
var oldState = this._state;
this._state = assign( {}, oldState, newState );
-
dispatchObservers( this, this._observers.pre, newState, oldState );
- if ( this._fragment ) this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState );
};
Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
- this._fragment.teardown( detach !== false );
+ if ( detach !== false ) this._fragment.unmount();
+ this._fragment.destroy();
this._fragment = null;
this._state = {};
this._torndown = true;
};
-function createElement( name ) {
- return document.createElement( name );
+function createElement(name) {
+ return document.createElement(name);
}
-function detachNode( node ) {
- node.parentNode.removeChild( node );
+function insertNode(node, target, anchor) {
+ target.insertBefore(node, anchor);
}
-function insertNode( node, target, anchor ) {
- target.insertBefore( node, anchor );
+function detachNode(node) {
+ node.parentNode.removeChild(node);
}
-function createText( data ) {
- return document.createTextNode( data );
+function createText(data) {
+ return document.createTextNode(data);
}
-function appendNode( node, target ) {
- target.appendChild( node );
+function appendNode(node, target) {
+ target.appendChild(node);
}
-function noop() {}
-
-function assign( target ) {
- for ( var i = 1; i < arguments.length; i += 1 ) {
- var source = arguments[i];
- for ( var k in source ) target[k] = source[k];
+function assign(target) {
+ var k,
+ source,
+ i = 1,
+ len = arguments.length;
+ for (; i < len; i++) {
+ source = arguments[i];
+ for (k in source) target[k] = source[k];
}
return target;
}
-function dispatchObservers( component, group, newState, oldState ) {
- for ( var key in group ) {
- if ( !( key in newState ) ) continue;
-
- var newValue = newState[ key ];
- var oldValue = oldState[ key ];
+function dispatchObservers(component, group, newState, oldState) {
+ for (var key in group) {
+ if (!(key in newState)) continue;
- if ( newValue === oldValue && typeof newValue !== 'object' ) continue;
+ var newValue = newState[key];
+ var oldValue = oldState[key];
- var callbacks = group[ key ];
- if ( !callbacks ) continue;
+ if (differs(newValue, oldValue)) {
+ var callbacks = group[key];
+ if (!callbacks) continue;
- for ( var i = 0; i < callbacks.length; i += 1 ) {
- var callback = callbacks[i];
- if ( callback.__calling ) continue;
+ for (var i = 0; i < callbacks.length; i += 1) {
+ var callback = callbacks[i];
+ if (callback.__calling) continue;
- callback.__calling = true;
- callback.call( component, newValue, oldValue );
- callback.__calling = false;
+ callback.__calling = true;
+ callback.call(component, newValue, oldValue);
+ callback.__calling = false;
+ }
}
}
}
-function get( key ) {
- return key ? this._state[ key ] : this._state;
+function noop() {}
+
+function get(key) {
+ return key ? this._state[key] : this._state;
}
-function fire( eventName, data ) {
- var handlers = eventName in this._handlers && this._handlers[ eventName ].slice();
- if ( !handlers ) return;
+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 ) {
- handlers[i].call( this, data );
+ for (var i = 0; i < handlers.length; i += 1) {
+ handlers[i].call(this, data);
}
}
-function observe( key, callback, options ) {
- var group = ( options && options.defer ) ? this._observers.pre : this._observers.post;
+function observe(key, callback, options) {
+ var group = options && options.defer
+ ? this._observers.post
+ : this._observers.pre;
- ( group[ key ] || ( group[ key ] = [] ) ).push( callback );
+ (group[key] || (group[key] = [])).push(callback);
- if ( !options || options.init !== false ) {
+ if (!options || options.init !== false) {
callback.__calling = true;
- callback.call( this, this._state[ key ] );
+ callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
- cancel: function () {
- var index = group[ key ].indexOf( callback );
- if ( ~index ) group[ key ].splice( index, 1 );
+ cancel: function() {
+ var index = group[key].indexOf(callback);
+ if (~index) group[key].splice(index, 1);
}
};
}
-function on( eventName, handler ) {
- if ( eventName === 'teardown' ) return this.on( 'destroy', handler );
+function on(eventName, handler) {
+ if (eventName === 'teardown') return this.on('destroy', handler);
- var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] );
- handlers.push( 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 );
+ cancel: function() {
+ var index = handlers.indexOf(handler);
+ if (~index) handlers.splice(index, 1);
}
};
}
-function set( newState ) {
- this._set( newState );
- ( this._root || this )._flush();
+function set(newState) {
+ this._set(assign({}, newState));
+ this._root._flush();
}
function _flush() {
- if ( !this._renderHooks ) return;
+ if (!this._renderHooks) return;
- while ( this._renderHooks.length ) {
- var hook = this._renderHooks.pop();
- hook.fn.call( hook.context );
+ while (this._renderHooks.length) {
+ this._renderHooks.pop()();
}
}
+function differs(a, b) {
+ return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
+}
+
export default Main;
\ No newline at end of file
diff --git a/test/samples/basic/expected/Main.js b/test/samples/basic/expected/Main.js
index 07b5b85..e13bd85 100644
--- a/test/samples/basic/expected/Main.js
+++ b/test/samples/basic/expected/Main.js
@@ -1,20 +1,22 @@
-function render_main_fragment ( root, component ) {
- var p = createElement( 'p' );
-
- appendNode( createText( "Hello world!" ), p );
+function create_main_fragment ( state, component ) {
+ var p, text;
return {
+ create: function () {
+ p = createElement( 'p' );
+ text = createText( "Hello world!" );
+ },
+
mount: function ( target, anchor ) {
insertNode( p, target, anchor );
+ appendNode( text, p );
},
- update: noop,
+ unmount: function () {
+ detachNode( p );
+ },
- teardown: function ( detach ) {
- if ( detach ) {
- detachNode( p );
- }
- }
+ destroy: noop
};
}
@@ -29,155 +31,168 @@ function Main ( options ) {
this._handlers = Object.create( null );
- this._root = options._root;
+ this._root = options._root || this;
this._yield = options._yield;
this._torndown = false;
- this._fragment = render_main_fragment( this._state, this );
- if ( options.target ) this._fragment.mount( options.target, null );
+ this._fragment = create_main_fragment( this._state, this );
+
+ if ( options.target ) {
+ this._fragment.create();
+ this._fragment.mount( options.target, null );
+ }
}
assign( Main.prototype, {
- get: get,
- fire: fire,
- observe: observe,
- on: on,
- set: set,
- _flush: _flush
-});
+ get: get,
+ fire: fire,
+ observe: observe,
+ on: on,
+ set: set,
+ _flush: _flush
+ });
Main.prototype._set = function _set ( newState ) {
var oldState = this._state;
this._state = assign( {}, oldState, newState );
-
dispatchObservers( this, this._observers.pre, newState, oldState );
- if ( this._fragment ) this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState );
};
Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
- this._fragment.teardown( detach !== false );
+ if ( detach !== false ) this._fragment.unmount();
+ this._fragment.destroy();
this._fragment = null;
this._state = {};
this._torndown = true;
};
-function createElement( name ) {
- return document.createElement( name );
+function createElement(name) {
+ return document.createElement(name);
}
-function detachNode( node ) {
- node.parentNode.removeChild( node );
+function insertNode(node, target, anchor) {
+ target.insertBefore(node, anchor);
}
-function insertNode( node, target, anchor ) {
- target.insertBefore( node, anchor );
+function detachNode(node) {
+ node.parentNode.removeChild(node);
}
-function createText( data ) {
- return document.createTextNode( data );
+function createText(data) {
+ return document.createTextNode(data);
}
-function appendNode( node, target ) {
- target.appendChild( node );
+function appendNode(node, target) {
+ target.appendChild(node);
}
-function noop() {}
-
-function assign( target ) {
- for ( var i = 1; i < arguments.length; i += 1 ) {
- var source = arguments[i];
- for ( var k in source ) target[k] = source[k];
+function assign(target) {
+ var k,
+ source,
+ i = 1,
+ len = arguments.length;
+ for (; i < len; i++) {
+ source = arguments[i];
+ for (k in source) target[k] = source[k];
}
return target;
}
-function dispatchObservers( component, group, newState, oldState ) {
- for ( var key in group ) {
- if ( !( key in newState ) ) continue;
+function dispatchObservers(component, group, newState, oldState) {
+ for (var key in group) {
+ if (!(key in newState)) continue;
- var newValue = newState[ key ];
- var oldValue = oldState[ key ];
+ var newValue = newState[key];
+ var oldValue = oldState[key];
- if ( newValue === oldValue && typeof newValue !== 'object' ) continue;
+ if (differs(newValue, oldValue)) {
+ var callbacks = group[key];
+ if (!callbacks) continue;
- var callbacks = group[ key ];
- if ( !callbacks ) continue;
+ for (var i = 0; i < callbacks.length; i += 1) {
+ var callback = callbacks[i];
+ if (callback.__calling) continue;
- for ( var i = 0; i < callbacks.length; i += 1 ) {
- var callback = callbacks[i];
- if ( callback.__calling ) continue;
-
- callback.__calling = true;
- callback.call( component, newValue, oldValue );
- callback.__calling = false;
+ callback.__calling = true;
+ callback.call(component, newValue, oldValue);
+ callback.__calling = false;
+ }
}
}
}
-function get( key ) {
- return key ? this._state[ key ] : this._state;
+function noop() {}
+
+function get(key) {
+ return key ? this._state[key] : this._state;
}
-function fire( eventName, data ) {
- var handlers = eventName in this._handlers && this._handlers[ eventName ].slice();
- if ( !handlers ) return;
+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 ) {
- handlers[i].call( this, data );
+ for (var i = 0; i < handlers.length; i += 1) {
+ handlers[i].call(this, data);
}
}
-function observe( key, callback, options ) {
- var group = ( options && options.defer ) ? this._observers.pre : this._observers.post;
+function observe(key, callback, options) {
+ var group = options && options.defer
+ ? this._observers.post
+ : this._observers.pre;
- ( group[ key ] || ( group[ key ] = [] ) ).push( callback );
+ (group[key] || (group[key] = [])).push(callback);
- if ( !options || options.init !== false ) {
+ if (!options || options.init !== false) {
callback.__calling = true;
- callback.call( this, this._state[ key ] );
+ callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
- cancel: function () {
- var index = group[ key ].indexOf( callback );
- if ( ~index ) group[ key ].splice( index, 1 );
+ cancel: function() {
+ var index = group[key].indexOf(callback);
+ if (~index) group[key].splice(index, 1);
}
};
}
-function on( eventName, handler ) {
- if ( eventName === 'teardown' ) return this.on( 'destroy', handler );
+function on(eventName, handler) {
+ if (eventName === 'teardown') return this.on('destroy', handler);
- var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] );
- handlers.push( 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 );
+ cancel: function() {
+ var index = handlers.indexOf(handler);
+ if (~index) handlers.splice(index, 1);
}
};
}
-function set( newState ) {
- this._set( newState );
- ( this._root || this )._flush();
+function set(newState) {
+ this._set(assign({}, newState));
+ this._root._flush();
}
function _flush() {
- if ( !this._renderHooks ) return;
+ if (!this._renderHooks) return;
- while ( this._renderHooks.length ) {
- var hook = this._renderHooks.pop();
- hook.fn.call( hook.context );
+ while (this._renderHooks.length) {
+ this._renderHooks.pop()();
}
}
+function differs(a, b) {
+ return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
+}
+
export default Main;
\ No newline at end of file
diff --git a/test/samples/dev/actual/Main.js b/test/samples/dev/actual/Main.js
index 81c59ec..a4f48d9 100644
--- a/test/samples/dev/actual/Main.js
+++ b/test/samples/dev/actual/Main.js
@@ -1,200 +1,228 @@
-function render_main_fragment ( root, component ) {
- var p = createElement( 'p' );
-
- appendNode( createText( "Hello world!" ), p );
+function create_main_fragment ( state, component ) {
+ var p, text;
return {
+ create: function () {
+ p = createElement( 'p' );
+ text = createText( "Hello world!" );
+ },
+
mount: function ( target, anchor ) {
insertNode( p, target, anchor );
+ appendNode( text, p );
},
-
- update: noop,
-
- teardown: function ( detach ) {
- if ( detach ) {
- detachNode( p );
- }
- }
+
+ unmount: function () {
+ detachNode( p );
+ },
+
+ destroy: noop
};
}
function Main ( options ) {
options = options || {};
- this._state = options.data || {};
-
if ( !options.target && !options._root ) throw new Error( "'target' is a required option" );
-
+ this._state = options.data || {};
+
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
-
+
this._handlers = Object.create( null );
-
- this._root = options._root;
+
+ this._root = options._root || this;
this._yield = options._yield;
-
+
this._torndown = false;
-
- this._fragment = render_main_fragment( this._state, this );
- if ( options.target ) this._fragment.mount( options.target, null );
+
+ this._fragment = create_main_fragment( this._state, this );
+
+ if ( options.target ) {
+ this._fragment.create();
+ this._fragment.mount( options.target, null );
+ }
}
assign( Main.prototype, {
- get: get,
- fire: fire,
- observe: observeDev,
- on: onDev,
- set: set,
- _flush: _flush
-});
+ get: get,
+ fire: fire,
+ observe: observeDev,
+ on: onDev,
+ set: set,
+ _flush: _flush
+ });
Main.prototype._set = function _set ( newState ) {
if ( typeof newState !== 'object' ) {
throw new Error( 'Component .set was called without an object of data key-values to update.' );
}
-
+
var oldState = this._state;
this._state = assign( {}, oldState, newState );
-
dispatchObservers( this, this._observers.pre, newState, oldState );
- if ( this._fragment ) this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState );
};
Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
- this._fragment.teardown( detach !== false );
+ if ( detach !== false ) this._fragment.unmount();
+ this._fragment.destroy();
this._fragment = null;
this._state = {};
this._torndown = true;
};
-function createElement( name ) {
- return document.createElement( name );
+function createElement(name) {
+ return document.createElement(name);
}
-function detachNode( node ) {
- node.parentNode.removeChild( node );
+function insertNode(node, target, anchor) {
+ target.insertBefore(node, anchor);
}
-function insertNode( node, target, anchor ) {
- target.insertBefore( node, anchor );
+function detachNode(node) {
+ node.parentNode.removeChild(node);
}
-function createText( data ) {
- return document.createTextNode( data );
+function createText(data) {
+ return document.createTextNode(data);
}
-function appendNode( node, target ) {
- target.appendChild( node );
+function appendNode(node, target) {
+ target.appendChild(node);
}
-function noop() {}
-
-function assign( target ) {
- for ( var i = 1; i < arguments.length; i += 1 ) {
- var source = arguments[i];
- for ( var k in source ) target[k] = source[k];
+function assign(target) {
+ var k,
+ source,
+ i = 1,
+ len = arguments.length;
+ for (; i < len; i++) {
+ source = arguments[i];
+ for (k in source) target[k] = source[k];
}
return target;
}
-function dispatchObservers( component, group, newState, oldState ) {
- for ( var key in group ) {
- if ( !( key in newState ) ) continue;
-
- var newValue = newState[ key ];
- var oldValue = oldState[ key ];
+function dispatchObservers(component, group, newState, oldState) {
+ for (var key in group) {
+ if (!(key in newState)) continue;
- if ( newValue === oldValue && typeof newValue !== 'object' ) continue;
+ var newValue = newState[key];
+ var oldValue = oldState[key];
- var callbacks = group[ key ];
- if ( !callbacks ) continue;
+ if (differs(newValue, oldValue)) {
+ var callbacks = group[key];
+ if (!callbacks) continue;
- for ( var i = 0; i < callbacks.length; i += 1 ) {
- var callback = callbacks[i];
- if ( callback.__calling ) continue;
+ for (var i = 0; i < callbacks.length; i += 1) {
+ var callback = callbacks[i];
+ if (callback.__calling) continue;
- callback.__calling = true;
- callback.call( component, newValue, oldValue );
- callback.__calling = false;
+ callback.__calling = true;
+ callback.call(component, newValue, oldValue);
+ callback.__calling = false;
+ }
}
}
}
-function get( key ) {
- return key ? this._state[ key ] : this._state;
+function noop() {}
+
+function get(key) {
+ return key ? this._state[key] : 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) {
+ handlers[i].call(this, data);
+ }
}
-function fire( eventName, data ) {
- var handlers = eventName in this._handlers && this._handlers[ eventName ].slice();
- if ( !handlers ) return;
+function observeDev(key, callback, options) {
+ var c = (key = '' + key).search(/[^\w]/);
+ if (c > -1) {
+ var message =
+ 'The first argument to component.observe(...) must be the name of a top-level property';
+ if (c > 0)
+ message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'";
+
+ throw new Error(message);
+ }
+
+ return observe.call(this, key, callback, options);
+}
- for ( var i = 0; i < handlers.length; i += 1 ) {
- handlers[i].call( this, data );
+function onDev(eventName, handler) {
+ if (eventName === 'teardown') {
+ console.warn(
+ "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2"
+ );
+ return this.on('destroy', handler);
}
+
+ return on.call(this, eventName, handler);
}
-function observeDev( key, callback, options ) {
- var c = ( key = '' + key ).search( /[^\w]/ );
- if ( c > -1 ) {
- var message = "The first argument to component.observe(...) must be the name of a top-level property";
- if ( c > 0 ) message += ", i.e. '" + key.slice( 0, c ) + "' rather than '" + key + "'";
+function set(newState) {
+ this._set(assign({}, newState));
+ this._root._flush();
+}
+
+function _flush() {
+ if (!this._renderHooks) return;
- throw new Error( message );
+ while (this._renderHooks.length) {
+ this._renderHooks.pop()();
}
+}
+
+function differs(a, b) {
+ return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
+}
- var group = ( options && options.defer ) ? this._observers.pre : this._observers.post;
+function observe(key, callback, options) {
+ var group = options && options.defer
+ ? this._observers.post
+ : this._observers.pre;
- ( group[ key ] || ( group[ key ] = [] ) ).push( callback );
+ (group[key] || (group[key] = [])).push(callback);
- if ( !options || options.init !== false ) {
+ if (!options || options.init !== false) {
callback.__calling = true;
- callback.call( this, this._state[ key ] );
+ callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
- cancel: function () {
- var index = group[ key ].indexOf( callback );
- if ( ~index ) group[ key ].splice( index, 1 );
+ cancel: function() {
+ var index = group[key].indexOf(callback);
+ if (~index) group[key].splice(index, 1);
}
};
}
-function onDev( eventName, handler ) {
- if ( eventName === 'teardown' ) {
- console.warn( "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" );
- return this.on( 'destroy', handler );
- }
+function on(eventName, handler) {
+ if (eventName === 'teardown') return this.on('destroy', handler);
- var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] );
- handlers.push( 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 );
+ cancel: function() {
+ var index = handlers.indexOf(handler);
+ if (~index) handlers.splice(index, 1);
}
};
}
-function set( newState ) {
- this._set( newState );
- ( this._root || this )._flush();
-}
-
-function _flush() {
- if ( !this._renderHooks ) return;
-
- while ( this._renderHooks.length ) {
- var hook = this._renderHooks.pop();
- hook.fn.call( hook.context );
- }
-}
-
export default Main;
\ No newline at end of file
diff --git a/test/samples/dev/expected/Main.js b/test/samples/dev/expected/Main.js
index fd05318..a4f48d9 100644
--- a/test/samples/dev/expected/Main.js
+++ b/test/samples/dev/expected/Main.js
@@ -1,28 +1,29 @@
-function render_main_fragment ( root, component ) {
- var p = createElement( 'p' );
-
- appendNode( createText( "Hello world!" ), p );
+function create_main_fragment ( state, component ) {
+ var p, text;
return {
+ create: function () {
+ p = createElement( 'p' );
+ text = createText( "Hello world!" );
+ },
+
mount: function ( target, anchor ) {
insertNode( p, target, anchor );
+ appendNode( text, p );
},
- update: noop,
+ unmount: function () {
+ detachNode( p );
+ },
- teardown: function ( detach ) {
- if ( detach ) {
- detachNode( p );
- }
- }
+ destroy: noop
};
}
function Main ( options ) {
options = options || {};
- this._state = options.data || {};
-
if ( !options.target && !options._root ) throw new Error( "'target' is a required option" );
+ this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
@@ -31,23 +32,27 @@ function Main ( options ) {
this._handlers = Object.create( null );
- this._root = options._root;
+ this._root = options._root || this;
this._yield = options._yield;
this._torndown = false;
- this._fragment = render_main_fragment( this._state, this );
- if ( options.target ) this._fragment.mount( options.target, null );
+ this._fragment = create_main_fragment( this._state, this );
+
+ if ( options.target ) {
+ this._fragment.create();
+ this._fragment.mount( options.target, null );
+ }
}
assign( Main.prototype, {
- get: get,
- fire: fire,
- observe: observeDev,
- on: onDev,
- set: set,
- _flush: _flush
-});
+ get: get,
+ fire: fire,
+ observe: observeDev,
+ on: onDev,
+ set: set,
+ _flush: _flush
+ });
Main.prototype._set = function _set ( newState ) {
if ( typeof newState !== 'object' ) {
@@ -56,145 +61,168 @@ Main.prototype._set = function _set ( newState ) {
var oldState = this._state;
this._state = assign( {}, oldState, newState );
-
dispatchObservers( this, this._observers.pre, newState, oldState );
- if ( this._fragment ) this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState );
};
Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
- this._fragment.teardown( detach !== false );
+ if ( detach !== false ) this._fragment.unmount();
+ this._fragment.destroy();
this._fragment = null;
this._state = {};
this._torndown = true;
};
-function createElement( name ) {
- return document.createElement( name );
+function createElement(name) {
+ return document.createElement(name);
}
-function detachNode( node ) {
- node.parentNode.removeChild( node );
+function insertNode(node, target, anchor) {
+ target.insertBefore(node, anchor);
}
-function insertNode( node, target, anchor ) {
- target.insertBefore( node, anchor );
+function detachNode(node) {
+ node.parentNode.removeChild(node);
}
-function createText( data ) {
- return document.createTextNode( data );
+function createText(data) {
+ return document.createTextNode(data);
}
-function appendNode( node, target ) {
- target.appendChild( node );
+function appendNode(node, target) {
+ target.appendChild(node);
}
-function noop() {}
-
-function assign( target ) {
- for ( var i = 1; i < arguments.length; i += 1 ) {
- var source = arguments[i];
- for ( var k in source ) target[k] = source[k];
+function assign(target) {
+ var k,
+ source,
+ i = 1,
+ len = arguments.length;
+ for (; i < len; i++) {
+ source = arguments[i];
+ for (k in source) target[k] = source[k];
}
return target;
}
-function dispatchObservers( component, group, newState, oldState ) {
- for ( var key in group ) {
- if ( !( key in newState ) ) continue;
+function dispatchObservers(component, group, newState, oldState) {
+ for (var key in group) {
+ if (!(key in newState)) continue;
- var newValue = newState[ key ];
- var oldValue = oldState[ key ];
+ var newValue = newState[key];
+ var oldValue = oldState[key];
- if ( newValue === oldValue && typeof newValue !== 'object' ) continue;
+ if (differs(newValue, oldValue)) {
+ var callbacks = group[key];
+ if (!callbacks) continue;
- var callbacks = group[ key ];
- if ( !callbacks ) continue;
+ for (var i = 0; i < callbacks.length; i += 1) {
+ var callback = callbacks[i];
+ if (callback.__calling) continue;
- for ( var i = 0; i < callbacks.length; i += 1 ) {
- var callback = callbacks[i];
- if ( callback.__calling ) continue;
-
- callback.__calling = true;
- callback.call( component, newValue, oldValue );
- callback.__calling = false;
+ callback.__calling = true;
+ callback.call(component, newValue, oldValue);
+ callback.__calling = false;
+ }
}
}
}
-function get( key ) {
- return key ? this._state[ key ] : this._state;
+function noop() {}
+
+function get(key) {
+ return key ? this._state[key] : this._state;
}
-function fire( eventName, data ) {
- var handlers = eventName in this._handlers && this._handlers[ eventName ].slice();
- if ( !handlers ) return;
+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 ) {
- handlers[i].call( this, data );
+ for (var i = 0; i < handlers.length; i += 1) {
+ handlers[i].call(this, data);
}
}
-function observeDev( key, callback, options ) {
- var c = ( key = '' + key ).search( /[^\w]/ );
- if ( c > -1 ) {
- var message = "The first argument to component.observe(...) must be the name of a top-level property";
- if ( c > 0 ) message += ", i.e. '" + key.slice( 0, c ) + "' rather than '" + key + "'";
+function observeDev(key, callback, options) {
+ var c = (key = '' + key).search(/[^\w]/);
+ if (c > -1) {
+ var message =
+ 'The first argument to component.observe(...) must be the name of a top-level property';
+ if (c > 0)
+ message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'";
- throw new Error( message );
+ throw new Error(message);
}
- var group = ( options && options.defer ) ? this._observers.pre : this._observers.post;
+ return observe.call(this, key, callback, options);
+}
- ( group[ key ] || ( group[ key ] = [] ) ).push( callback );
+function onDev(eventName, handler) {
+ if (eventName === 'teardown') {
+ console.warn(
+ "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2"
+ );
+ return this.on('destroy', handler);
+ }
- if ( !options || options.init !== false ) {
+ return on.call(this, eventName, handler);
+}
+
+function set(newState) {
+ this._set(assign({}, newState));
+ this._root._flush();
+}
+
+function _flush() {
+ if (!this._renderHooks) return;
+
+ while (this._renderHooks.length) {
+ this._renderHooks.pop()();
+ }
+}
+
+function differs(a, b) {
+ return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
+}
+
+function observe(key, callback, options) {
+ var group = options && options.defer
+ ? this._observers.post
+ : this._observers.pre;
+
+ (group[key] || (group[key] = [])).push(callback);
+
+ if (!options || options.init !== false) {
callback.__calling = true;
- callback.call( this, this._state[ key ] );
+ callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
- cancel: function () {
- var index = group[ key ].indexOf( callback );
- if ( ~index ) group[ key ].splice( index, 1 );
+ cancel: function() {
+ var index = group[key].indexOf(callback);
+ if (~index) group[key].splice(index, 1);
}
};
}
-function onDev( eventName, handler ) {
- if ( eventName === 'teardown' ) {
- console.warn( "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" );
- return this.on( 'destroy', handler );
- }
+function on(eventName, handler) {
+ if (eventName === 'teardown') return this.on('destroy', handler);
- var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] );
- handlers.push( 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 );
+ cancel: function() {
+ var index = handlers.indexOf(handler);
+ if (~index) handlers.splice(index, 1);
}
};
}
-function set( newState ) {
- this._set( newState );
- ( this._root || this )._flush();
-}
-
-function _flush() {
- if ( !this._renderHooks ) return;
-
- while ( this._renderHooks.length ) {
- var hook = this._renderHooks.pop();
- hook.fn.call( hook.context );
- }
-}
-
export default Main;
\ No newline at end of file
diff --git a/test/samples/dir-sourcemap/actual/Main.js b/test/samples/dir-sourcemap/actual/Main.js
index 1a70a58..ba64b84 100644
--- a/test/samples/dir-sourcemap/actual/Main.js
+++ b/test/samples/dir-sourcemap/actual/Main.js
@@ -1,20 +1,26 @@
import Widget from './Widget.html';
-function render_main_fragment ( root, component ) {
+function create_main_fragment ( state, component ) {
+
var widget = new Widget({
- target: null,
- _root: component._root || component
+ _root: component._root
});
return {
+ create: function () {
+ widget._fragment.create();
+ },
+
mount: function ( target, anchor ) {
widget._fragment.mount( target, anchor );
},
-
- update: noop,
-
- teardown: function ( detach ) {
- widget.destroy( detach );
+
+ unmount: function () {
+ widget._fragment.unmount();
+ },
+
+ destroy: function () {
+ widget.destroy( false );
}
};
}
@@ -22,149 +28,158 @@ function render_main_fragment ( root, component ) {
function Main ( options ) {
options = options || {};
this._state = options.data || {};
-
+
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
-
+
this._handlers = Object.create( null );
-
- this._root = options._root;
+
+ this._root = options._root || this;
this._yield = options._yield;
-
+
this._torndown = false;
this._renderHooks = [];
-
- this._fragment = render_main_fragment( this._state, this );
- if ( options.target ) this._fragment.mount( options.target, null );
-
+
+ this._fragment = create_main_fragment( this._state, this );
+
+ if ( options.target ) {
+ this._fragment.create();
+ this._fragment.mount( options.target, null );
+ }
this._flush();
}
assign( Main.prototype, {
- get: get,
- fire: fire,
- observe: observe,
- on: on,
- set: set,
- _flush: _flush
-});
+ get: get,
+ fire: fire,
+ observe: observe,
+ on: on,
+ set: set,
+ _flush: _flush
+ });
Main.prototype._set = function _set ( newState ) {
var oldState = this._state;
this._state = assign( {}, oldState, newState );
-
dispatchObservers( this, this._observers.pre, newState, oldState );
- if ( this._fragment ) this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState );
-
this._flush();
};
Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
- this._fragment.teardown( detach !== false );
+ if ( detach !== false ) this._fragment.unmount();
+ this._fragment.destroy();
this._fragment = null;
this._state = {};
this._torndown = true;
};
-function noop() {}
-
-function assign( target ) {
- for ( var i = 1; i < arguments.length; i += 1 ) {
- var source = arguments[i];
- for ( var k in source ) target[k] = source[k];
+function assign(target) {
+ var k,
+ source,
+ i = 1,
+ len = arguments.length;
+ for (; i < len; i++) {
+ source = arguments[i];
+ for (k in source) target[k] = source[k];
}
return target;
}
-function dispatchObservers( component, group, newState, oldState ) {
- for ( var key in group ) {
- if ( !( key in newState ) ) continue;
-
- var newValue = newState[ key ];
- var oldValue = oldState[ key ];
+function dispatchObservers(component, group, newState, oldState) {
+ for (var key in group) {
+ if (!(key in newState)) continue;
- if ( newValue === oldValue && typeof newValue !== 'object' ) continue;
+ var newValue = newState[key];
+ var oldValue = oldState[key];
- var callbacks = group[ key ];
- if ( !callbacks ) continue;
+ if (differs(newValue, oldValue)) {
+ var callbacks = group[key];
+ if (!callbacks) continue;
- for ( var i = 0; i < callbacks.length; i += 1 ) {
- var callback = callbacks[i];
- if ( callback.__calling ) continue;
+ for (var i = 0; i < callbacks.length; i += 1) {
+ var callback = callbacks[i];
+ if (callback.__calling) continue;
- callback.__calling = true;
- callback.call( component, newValue, oldValue );
- callback.__calling = false;
+ callback.__calling = true;
+ callback.call(component, newValue, oldValue);
+ callback.__calling = false;
+ }
}
}
}
-function get( key ) {
- return key ? this._state[ key ] : this._state;
+function get(key) {
+ return key ? this._state[key] : this._state;
}
-function fire( eventName, data ) {
- var handlers = eventName in this._handlers && this._handlers[ eventName ].slice();
- if ( !handlers ) return;
+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 ) {
- handlers[i].call( this, data );
+ for (var i = 0; i < handlers.length; i += 1) {
+ handlers[i].call(this, data);
}
}
-function observe( key, callback, options ) {
- var group = ( options && options.defer ) ? this._observers.pre : this._observers.post;
+function observe(key, callback, options) {
+ var group = options && options.defer
+ ? this._observers.post
+ : this._observers.pre;
- ( group[ key ] || ( group[ key ] = [] ) ).push( callback );
+ (group[key] || (group[key] = [])).push(callback);
- if ( !options || options.init !== false ) {
+ if (!options || options.init !== false) {
callback.__calling = true;
- callback.call( this, this._state[ key ] );
+ callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
- cancel: function () {
- var index = group[ key ].indexOf( callback );
- if ( ~index ) group[ key ].splice( index, 1 );
+ cancel: function() {
+ var index = group[key].indexOf(callback);
+ if (~index) group[key].splice(index, 1);
}
};
}
-function on( eventName, handler ) {
- if ( eventName === 'teardown' ) return this.on( 'destroy', handler );
+function on(eventName, handler) {
+ if (eventName === 'teardown') return this.on('destroy', handler);
- var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] );
- handlers.push( 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 );
+ cancel: function() {
+ var index = handlers.indexOf(handler);
+ if (~index) handlers.splice(index, 1);
}
};
}
-function set( newState ) {
- this._set( newState );
- ( this._root || this )._flush();
+function set(newState) {
+ this._set(assign({}, newState));
+ this._root._flush();
}
function _flush() {
- if ( !this._renderHooks ) return;
+ if (!this._renderHooks) return;
- while ( this._renderHooks.length ) {
- var hook = this._renderHooks.pop();
- hook.fn.call( hook.context );
+ while (this._renderHooks.length) {
+ this._renderHooks.pop()();
}
}
+function differs(a, b) {
+ return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
+}
+
export default Main;
//# sourceMappingURL=Main.js.map
diff --git a/test/samples/dir-sourcemap/actual/Main.js.map b/test/samples/dir-sourcemap/actual/Main.js.map
index 8d47d27..b355625 100644
--- a/test/samples/dir-sourcemap/actual/Main.js.map
+++ b/test/samples/dir-sourcemap/actual/Main.js.map
@@ -1 +1 @@
-{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["
widget
"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["widget
"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/samples/dir-sourcemap/expected/Main.js b/test/samples/dir-sourcemap/expected/Main.js index 1a70a58..ba64b84 100644 --- a/test/samples/dir-sourcemap/expected/Main.js +++ b/test/samples/dir-sourcemap/expected/Main.js @@ -1,20 +1,26 @@ import Widget from './Widget.html'; -function render_main_fragment ( root, component ) { +function create_main_fragment ( state, component ) { + var widget = new Widget({ - target: null, - _root: component._root || component + _root: component._root }); return { + create: function () { + widget._fragment.create(); + }, + mount: function ( target, anchor ) { widget._fragment.mount( target, anchor ); }, - - update: noop, - - teardown: function ( detach ) { - widget.destroy( detach ); + + unmount: function () { + widget._fragment.unmount(); + }, + + destroy: function () { + widget.destroy( false ); } }; } @@ -22,149 +28,158 @@ function render_main_fragment ( root, component ) { function Main ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; this._renderHooks = []; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); - + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } this._flush(); } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); - this._flush(); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; //# sourceMappingURL=Main.js.map diff --git a/test/samples/dir-sourcemap/expected/Main.js.map b/test/samples/dir-sourcemap/expected/Main.js.map index 8d47d27..b355625 100644 --- a/test/samples/dir-sourcemap/expected/Main.js.map +++ b/test/samples/dir-sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["widget
"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["widget
"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/samples/dir/actual/Main.js b/test/samples/dir/actual/Main.js index b83747a..550fc3f 100644 --- a/test/samples/dir/actual/Main.js +++ b/test/samples/dir/actual/Main.js @@ -1,20 +1,26 @@ import Widget from './Widget.html'; -function render_main_fragment ( root, component ) { +function create_main_fragment ( state, component ) { + var widget = new Widget({ - target: null, - _root: component._root || component + _root: component._root }); return { + create: function () { + widget._fragment.create(); + }, + mount: function ( target, anchor ) { widget._fragment.mount( target, anchor ); }, - - update: noop, - - teardown: function ( detach ) { - widget.destroy( detach ); + + unmount: function () { + widget._fragment.unmount(); + }, + + destroy: function () { + widget.destroy( false ); } }; } @@ -22,148 +28,157 @@ function render_main_fragment ( root, component ) { function Main ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; this._renderHooks = []; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); - + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } this._flush(); } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); - this._flush(); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; \ No newline at end of file diff --git a/test/samples/dir/actual/Widget.js b/test/samples/dir/actual/Widget.js index 821e63a..563e9bb 100644 --- a/test/samples/dir/actual/Widget.js +++ b/test/samples/dir/actual/Widget.js @@ -1,183 +1,198 @@ -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "widget" ), p ); +function create_main_fragment ( state, component ) { + var p, text; return { + create: function () { + p = createElement( 'p' ); + text = createText( "widget" ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); }, - - update: noop, - - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } function Widget ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } } assign( Widget.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Widget.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Widget.prototype.teardown = Widget.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Widget; \ No newline at end of file diff --git a/test/samples/dir/expected/Main.js b/test/samples/dir/expected/Main.js index 9723d90..550fc3f 100644 --- a/test/samples/dir/expected/Main.js +++ b/test/samples/dir/expected/Main.js @@ -1,20 +1,26 @@ import Widget from './Widget.html'; -function render_main_fragment ( root, component ) { +function create_main_fragment ( state, component ) { + var widget = new Widget({ - target: null, - _root: component._root || component + _root: component._root }); return { + create: function () { + widget._fragment.create(); + }, + mount: function ( target, anchor ) { widget._fragment.mount( target, anchor ); }, - update: noop, + unmount: function () { + widget._fragment.unmount(); + }, - teardown: function ( detach ) { - widget.destroy( detach ); + destroy: function () { + widget.destroy( false ); } }; } @@ -30,140 +36,149 @@ function Main ( options ) { this._handlers = Object.create( null ); - this._root = options._root; + this._root = options._root || this; this._yield = options._yield; this._torndown = false; this._renderHooks = []; - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); + this._fragment = create_main_fragment( this._state, this ); + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } this._flush(); } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); - this._flush(); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; \ No newline at end of file diff --git a/test/samples/dir/expected/Widget.js b/test/samples/dir/expected/Widget.js index ff4c770..563e9bb 100644 --- a/test/samples/dir/expected/Widget.js +++ b/test/samples/dir/expected/Widget.js @@ -1,20 +1,22 @@ -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "widget" ), p ); +function create_main_fragment ( state, component ) { + var p, text; return { + create: function () { + p = createElement( 'p' ); + text = createText( "widget" ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); }, - update: noop, + unmount: function () { + detachNode( p ); + }, - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + destroy: noop }; } @@ -29,155 +31,168 @@ function Widget ( options ) { this._handlers = Object.create( null ); - this._root = options._root; + this._root = options._root || this; this._yield = options._yield; this._torndown = false; - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } } assign( Widget.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Widget.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Widget.prototype.teardown = Widget.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; + var newValue = newState[key]; + var oldValue = oldState[key]; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; - - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Widget; \ No newline at end of file diff --git a/test/samples/globals/actual/Main.js b/test/samples/globals/actual/Main.js index 79b8b9e..4aa7117 100644 --- a/test/samples/globals/actual/Main.js +++ b/test/samples/globals/actual/Main.js @@ -12,195 +12,212 @@ var template = (function () { }; }()); -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "The answer is " ), p ); - var last_text_1 = root.answer; - var text_1 = createText( last_text_1 ); - appendNode( text_1, p ); +function create_main_fragment ( state, component ) { + var p, text, text_1_value, text_1; return { + create: function () { + p = createElement( 'p' ); + text = createText( "The answer is " ); + text_1 = createText( text_1_value = state.answer ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); + appendNode( text_1, p ); }, - - update: function ( changed, root ) { - var tmp; - - if ( ( tmp = root.answer ) !== last_text_1 ) { - text_1.data = last_text_1 = tmp; + + update: function ( changed, state ) { + if ( text_1_value !== ( text_1_value = state.answer ) ) { + text_1.data = text_1_value; } }, - - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } function Main ( options ) { options = options || {}; this._state = assign( template.data(), options.data ); - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; + var newValue = newState[key]; + var oldValue = oldState[key]; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; - - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + return Main; }(theAnswer)); \ No newline at end of file diff --git a/test/samples/globals/expected/Main.js b/test/samples/globals/expected/Main.js index 9a46619..4aa7117 100644 --- a/test/samples/globals/expected/Main.js +++ b/test/samples/globals/expected/Main.js @@ -12,32 +12,33 @@ var template = (function () { }; }()); -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "The answer is " ), p ); - var last_text_1 = root.answer; - var text_1 = createText( last_text_1 ); - appendNode( text_1, p ); +function create_main_fragment ( state, component ) { + var p, text, text_1_value, text_1; return { + create: function () { + p = createElement( 'p' ); + text = createText( "The answer is " ); + text_1 = createText( text_1_value = state.answer ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); + appendNode( text_1, p ); }, - update: function ( changed, root ) { - var tmp; - - if ( ( tmp = root.answer ) !== last_text_1 ) { - text_1.data = last_text_1 = tmp; + update: function ( changed, state ) { + if ( text_1_value !== ( text_1_value = state.answer ) ) { + text_1.data = text_1_value; } }, - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -52,155 +53,171 @@ function Main ( options ) { this._handlers = Object.create( null ); - this._root = options._root; + this._root = options._root || this; this._yield = options._yield; this._torndown = false; - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + return Main; }(theAnswer)); \ No newline at end of file diff --git a/test/samples/sourcemap-inline/actual/Main.js b/test/samples/sourcemap-inline/actual/Main.js index 031cf75..996c338 100644 --- a/test/samples/sourcemap-inline/actual/Main.js +++ b/test/samples/sourcemap-inline/actual/Main.js @@ -6,193 +6,208 @@ var template = (function () { }; }()); -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "Hello world!" ), p ); +function create_main_fragment ( state, component ) { + var p, text; return { + create: function () { + p = createElement( 'p' ); + text = createText( "Hello world!" ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); }, - - update: noop, - - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } function Main ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); - + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } + if ( options._root ) { - options._root._renderHooks.push({ fn: template.oncreate, context: this }); + options._root._renderHooks.push( template.oncreate.bind( this ) ); } else { template.oncreate.call( this ); } } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI2QkFFUTtDQUNQLE9BQWU7RUFDZCxRQUFRLENBQUMsR0FBRztHQUNYLE9BQU8sQ0FBQyxHQUFHLEVBQUUsTUFBTSxFQUFFLENBQUM7R0FDdEI7RUFDRCxDQUFDO0FBQ0g7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI2QkFFUTtDQUNQLE9BQWU7RUFDZCxRQUFRLENBQUMsR0FBRztHQUNYLE9BQU8sQ0FBQyxHQUFHLEVBQUUsTUFBTSxFQUFFLENBQUM7R0FDdEI7RUFDRCxDQUFDO0FBQ0g7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= diff --git a/test/samples/sourcemap-inline/expected/Main.js b/test/samples/sourcemap-inline/expected/Main.js index 031cf75..996c338 100644 --- a/test/samples/sourcemap-inline/expected/Main.js +++ b/test/samples/sourcemap-inline/expected/Main.js @@ -6,193 +6,208 @@ var template = (function () { }; }()); -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "Hello world!" ), p ); +function create_main_fragment ( state, component ) { + var p, text; return { + create: function () { + p = createElement( 'p' ); + text = createText( "Hello world!" ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); }, - - update: noop, - - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } function Main ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); - + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } + if ( options._root ) { - options._root._renderHooks.push({ fn: template.oncreate, context: this }); + options._root._renderHooks.push( template.oncreate.bind( this ) ); } else { template.oncreate.call( this ); } } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI2QkFFUTtDQUNQLE9BQWU7RUFDZCxRQUFRLENBQUMsR0FBRztHQUNYLE9BQU8sQ0FBQyxHQUFHLEVBQUUsTUFBTSxFQUFFLENBQUM7R0FDdEI7RUFDRCxDQUFDO0FBQ0g7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI2QkFFUTtDQUNQLE9BQWU7RUFDZCxRQUFRLENBQUMsR0FBRztHQUNYLE9BQU8sQ0FBQyxHQUFHLEVBQUUsTUFBTSxFQUFFLENBQUM7R0FDdEI7RUFDRCxDQUFDO0FBQ0g7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= diff --git a/test/samples/sourcemap/actual/Main.js b/test/samples/sourcemap/actual/Main.js index e7dfc41..f403c8e 100644 --- a/test/samples/sourcemap/actual/Main.js +++ b/test/samples/sourcemap/actual/Main.js @@ -6,193 +6,208 @@ var template = (function () { }; }()); -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "Hello world!" ), p ); +function create_main_fragment ( state, component ) { + var p, text; return { + create: function () { + p = createElement( 'p' ); + text = createText( "Hello world!" ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); }, - - update: noop, - - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } function Main ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); - + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } + if ( options._root ) { - options._root._renderHooks.push({ fn: template.oncreate, context: this }); + options._root._renderHooks.push( template.oncreate.bind( this ) ); } else { template.oncreate.call( this ); } } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; //# sourceMappingURL=Main.js.map diff --git a/test/samples/sourcemap/actual/Main.js.map b/test/samples/sourcemap/actual/Main.js.map index 38ae85e..2071d68 100644 --- a/test/samples/sourcemap/actual/Main.js.map +++ b/test/samples/sourcemap/actual/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["Hello world!
\n\n"],"names":[],"mappings":"6BAEQ;CACP,OAAe;EACd,QAAQ,CAAC,GAAG;GACX,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;GACtB;EACD,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["Hello world!
\n\n"],"names":[],"mappings":"6BAEQ;CACP,OAAe;EACd,QAAQ,CAAC,GAAG;GACX,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;GACtB;EACD,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/samples/sourcemap/expected/Main.js b/test/samples/sourcemap/expected/Main.js index e7dfc41..f403c8e 100644 --- a/test/samples/sourcemap/expected/Main.js +++ b/test/samples/sourcemap/expected/Main.js @@ -6,193 +6,208 @@ var template = (function () { }; }()); -function render_main_fragment ( root, component ) { - var p = createElement( 'p' ); - - appendNode( createText( "Hello world!" ), p ); +function create_main_fragment ( state, component ) { + var p, text; return { + create: function () { + p = createElement( 'p' ); + text = createText( "Hello world!" ); + }, + mount: function ( target, anchor ) { insertNode( p, target, anchor ); + appendNode( text, p ); }, - - update: noop, - - teardown: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } function Main ( options ) { options = options || {}; this._state = options.data || {}; - + this._observers = { pre: Object.create( null ), post: Object.create( null ) }; - + this._handlers = Object.create( null ); - - this._root = options._root; + + this._root = options._root || this; this._yield = options._yield; - + this._torndown = false; - - this._fragment = render_main_fragment( this._state, this ); - if ( options.target ) this._fragment.mount( options.target, null ); - + + this._fragment = create_main_fragment( this._state, this ); + + if ( options.target ) { + this._fragment.create(); + this._fragment.mount( options.target, null ); + } + if ( options._root ) { - options._root._renderHooks.push({ fn: template.oncreate, context: this }); + options._root._renderHooks.push( template.oncreate.bind( this ) ); } else { template.oncreate.call( this ); } } assign( Main.prototype, { - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - _flush: _flush -}); + get: get, + fire: fire, + observe: observe, + on: on, + set: set, + _flush: _flush + }); Main.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); - dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; Main.prototype.teardown = Main.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.teardown( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy(); this._fragment = null; this._state = {}; this._torndown = true; }; -function createElement( name ) { - return document.createElement( name ); +function createElement(name) { + return document.createElement(name); } -function detachNode( node ) { - node.parentNode.removeChild( node ); +function insertNode(node, target, anchor) { + target.insertBefore(node, anchor); } -function insertNode( node, target, anchor ) { - target.insertBefore( node, anchor ); +function detachNode(node) { + node.parentNode.removeChild(node); } -function createText( data ) { - return document.createTextNode( data ); +function createText(data) { + return document.createTextNode(data); } -function appendNode( node, target ) { - target.appendChild( node ); +function appendNode(node, target) { + target.appendChild(node); } -function noop() {} - -function assign( target ) { - for ( var i = 1; i < arguments.length; i += 1 ) { - var source = arguments[i]; - for ( var k in source ) target[k] = source[k]; +function assign(target) { + var k, + source, + i = 1, + len = arguments.length; + for (; i < len; i++) { + source = arguments[i]; + for (k in source) target[k] = source[k]; } return target; } -function dispatchObservers( component, group, newState, oldState ) { - for ( var key in group ) { - if ( !( key in newState ) ) continue; - - var newValue = newState[ key ]; - var oldValue = oldState[ key ]; +function dispatchObservers(component, group, newState, oldState) { + for (var key in group) { + if (!(key in newState)) continue; - if ( newValue === oldValue && typeof newValue !== 'object' ) continue; + var newValue = newState[key]; + var oldValue = oldState[key]; - var callbacks = group[ key ]; - if ( !callbacks ) continue; + if (differs(newValue, oldValue)) { + var callbacks = group[key]; + if (!callbacks) continue; - for ( var i = 0; i < callbacks.length; i += 1 ) { - var callback = callbacks[i]; - if ( callback.__calling ) continue; + for (var i = 0; i < callbacks.length; i += 1) { + var callback = callbacks[i]; + if (callback.__calling) continue; - callback.__calling = true; - callback.call( component, newValue, oldValue ); - callback.__calling = false; + callback.__calling = true; + callback.call(component, newValue, oldValue); + callback.__calling = false; + } } } } -function get( key ) { - return key ? this._state[ key ] : this._state; +function noop() {} + +function get(key) { + return key ? this._state[key] : this._state; } -function fire( eventName, data ) { - var handlers = eventName in this._handlers && this._handlers[ eventName ].slice(); - if ( !handlers ) return; +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 ) { - handlers[i].call( this, data ); + for (var i = 0; i < handlers.length; i += 1) { + handlers[i].call(this, data); } } -function observe( key, callback, options ) { - var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; +function observe(key, callback, options) { + var group = options && options.defer + ? this._observers.post + : this._observers.pre; - ( group[ key ] || ( group[ key ] = [] ) ).push( callback ); + (group[key] || (group[key] = [])).push(callback); - if ( !options || options.init !== false ) { + if (!options || options.init !== false) { callback.__calling = true; - callback.call( this, this._state[ key ] ); + callback.call(this, this._state[key]); callback.__calling = false; } return { - cancel: function () { - var index = group[ key ].indexOf( callback ); - if ( ~index ) group[ key ].splice( index, 1 ); + cancel: function() { + var index = group[key].indexOf(callback); + if (~index) group[key].splice(index, 1); } }; } -function on( eventName, handler ) { - if ( eventName === 'teardown' ) return this.on( 'destroy', handler ); +function on(eventName, handler) { + if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] ); - handlers.push( 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 ); + cancel: function() { + var index = handlers.indexOf(handler); + if (~index) handlers.splice(index, 1); } }; } -function set( newState ) { - this._set( newState ); - ( this._root || this )._flush(); +function set(newState) { + this._set(assign({}, newState)); + this._root._flush(); } function _flush() { - if ( !this._renderHooks ) return; + if (!this._renderHooks) return; - while ( this._renderHooks.length ) { - var hook = this._renderHooks.pop(); - hook.fn.call( hook.context ); + while (this._renderHooks.length) { + this._renderHooks.pop()(); } } +function differs(a, b) { + return a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + export default Main; //# sourceMappingURL=Main.js.map diff --git a/test/samples/sourcemap/expected/Main.js.map b/test/samples/sourcemap/expected/Main.js.map index 38ae85e..2071d68 100644 --- a/test/samples/sourcemap/expected/Main.js.map +++ b/test/samples/sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["Hello world!
\n\n"],"names":[],"mappings":"6BAEQ;CACP,OAAe;EACd,QAAQ,CAAC,GAAG;GACX,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;GACtB;EACD,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["Hello world!
\n\n"],"names":[],"mappings":"6BAEQ;CACP,OAAe;EACd,QAAQ,CAAC,GAAG;GACX,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;GACtB;EACD,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/test.js b/test/test.js index 4d27e15..bc85e7a 100644 --- a/test/test.js +++ b/test/test.js @@ -26,6 +26,7 @@ describe( 'svelte-cli', () => { child_process.exec( ` alias svelte=${bin} + chmod u+x ${bin} mkdir -p actual rm -rf actual/* ${command}