diff --git a/.gitignore b/.gitignore index 3a7d2ce532..a78b294346 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ node_modules *.map /src/compile/internal-exports.ts -/cli/ /compiler.js /index.js /internal.* @@ -14,7 +13,6 @@ node_modules /scratch/ /coverage/ /coverage.lcov/ -/test/cli/samples/*/actual /test/sourcemaps/samples/*/output.js /test/sourcemaps/samples/*/output.js.map /test/sourcemaps/samples/*/output.css diff --git a/package-lock.json b/package-lock.json index 9e5722c351..9771d83536 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.0.0-beta.7", + "version": "3.0.0-beta.15", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -116,6 +116,15 @@ } } }, + "agent-base": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "dev": true, + "requires": { + "es6-promisify": "^5.0.0" + } + }, "ajv": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.7.0.tgz", @@ -194,12 +203,6 @@ "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", "dev": true }, - "array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true - }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -485,22 +488,6 @@ "integrity": "sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw==", "dev": true }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true - }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "requires": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" - } - }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -585,12 +572,6 @@ "wrap-ansi": "^2.0.0" } }, - "clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", - "dev": true - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -676,7 +657,7 @@ "dependencies": { "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -691,7 +672,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -764,15 +745,6 @@ "cssom": "0.3.x" } }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "dev": true, - "requires": { - "array-find-index": "^1.0.1" - } - }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -814,36 +786,12 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "deep-defaults": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/deep-defaults/-/deep-defaults-1.0.5.tgz", - "integrity": "sha512-5ev/sNkiHTmeTqbDJEDgdQa/Ub0eOMQNix9l+dLLGbwOos7/in5HdvHXI014wqxsET4YeJG9Eq4qj0PJRL8rSw==", - "dev": true, - "requires": { - "lodash": "^4.17.5" - } - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "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 }, - "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "dev": true, - "requires": { - "clone": "^1.0.2" - } - }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -980,74 +928,6 @@ "safer-buffer": "^2.1.0" } }, - "electron": { - "version": "1.8.8", - "resolved": "https://registry.npmjs.org/electron/-/electron-1.8.8.tgz", - "integrity": "sha512-1f9zJehcTTGjrkb06o6ds+gsRq6SYhZJyxOk6zIWjRH8hVy03y/RzUDELzNas71f5vcvXmfGVvyjeEsadDI8tg==", - "dev": true, - "requires": { - "@types/node": "^8.0.24", - "electron-download": "^3.0.1", - "extract-zip": "^1.0.3" - }, - "dependencies": { - "@types/node": { - "version": "8.10.39", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.39.tgz", - "integrity": "sha512-rE7fktr02J8ybFf6eysife+WF+L4sAHWzw09DgdCebEu+qDwMvv4zl6Bc+825ttGZP73kCKxa3dhJOoGJ8+5mA==", - "dev": true - } - } - }, - "electron-download": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-3.3.0.tgz", - "integrity": "sha1-LP1U1pZsAZxNSa1l++Zcyc3vaMg=", - "dev": true, - "requires": { - "debug": "^2.2.0", - "fs-extra": "^0.30.0", - "home-path": "^1.0.1", - "minimist": "^1.2.0", - "nugget": "^2.0.0", - "path-exists": "^2.1.0", - "rc": "^1.1.2", - "semver": "^5.3.0", - "sumchecker": "^1.2.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "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, - "requires": { - "pinkie-promise": "^2.0.0" - } - } - } - }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", @@ -1057,23 +937,6 @@ "once": "^1.4.0" } }, - "enqueue": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/enqueue/-/enqueue-1.0.2.tgz", - "integrity": "sha1-kBTpvOVw7pPKlubI5jrVTBkra8g=", - "dev": true, - "requires": { - "sliced": "0.0.5" - }, - "dependencies": { - "sliced": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", - "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8=", - "dev": true - } - } - }, "entities": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", @@ -1090,11 +953,20 @@ } }, "es6-promise": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", - "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", + "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==", "dev": true }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "dev": true, + "requires": { + "es6-promise": "^4.0.3" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -1559,19 +1431,6 @@ "map-cache": "^0.2.2" } }, - "fs-extra": { - "version": "0.30.0", - "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", - "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0", - "path-is-absolute": "^1.0.0", - "rimraf": "^2.2.8" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1584,12 +1443,6 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "function-source": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/function-source/-/function-source-0.1.0.tgz", - "integrity": "sha1-2RBL8+RniLVUaMAr8bL6vPj8Ga8=", - "dev": true - }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -1612,12 +1465,6 @@ "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true - }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -1795,12 +1642,6 @@ "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", "dev": true }, - "home-path": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/home-path/-/home-path-1.0.6.tgz", - "integrity": "sha512-wo+yjrdAtoXt43Vy92a+0IPCYViiyLAHyp0QVS4xL/tfvVz5sXIW1ubLZk3nhVkD92fQpUMKX+fzMjr5F489vw==", - "dev": true - }, "hosted-git-info": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", @@ -1841,6 +1682,27 @@ "sshpk": "^1.7.0" } }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", + "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "dev": true, + "requires": { + "agent-base": "^4.1.0", + "debug": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -1881,15 +1743,6 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1906,12 +1759,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true - }, "inquirer": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.1.tgz", @@ -1950,12 +1797,6 @@ } } }, - "interpret": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", - "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", - "dev": true - }, "invert-kv": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", @@ -2026,15 +1867,6 @@ "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", "dev": true }, - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, "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", @@ -2091,12 +1923,6 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -2202,12 +2028,6 @@ "xml-name-validator": "^3.0.0" } }, - "jsesc": { - "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true - }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -2238,15 +2058,6 @@ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "jsonfile": { - "version": "2.4.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -2259,12 +2070,6 @@ "verror": "1.10.0" } }, - "keypress": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz", - "integrity": "sha1-SjGI1CkbZrT2XtuZ+AaqmuKTWSo=", - "dev": true - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -2274,15 +2079,6 @@ "is-buffer": "^1.1.5" } }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - }, "kleur": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.1.tgz", @@ -2354,16 +2150,6 @@ "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "dev": true }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" - } - }, "lru-cache": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", @@ -2421,12 +2207,6 @@ "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", @@ -2453,104 +2233,11 @@ "p-is-promise": "^1.1.0" } }, - "meow": { - "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "requires": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" - }, - "dependencies": { - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "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, - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - } - } + "mime": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", + "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", + "dev": true }, "mime-db": { "version": "1.37.0", @@ -2588,26 +2275,6 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, - "minstache": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minstache/-/minstache-1.2.0.tgz", - "integrity": "sha1-/xzEA6woRPaNvxjGYhKb5+sO/EE=", - "dev": true, - "requires": { - "commander": "1.0.4" - }, - "dependencies": { - "commander": { - "version": "1.0.4", - "resolved": "http://registry.npmjs.org/commander/-/commander-1.0.4.tgz", - "integrity": "sha1-Xt6xruI8T7VBprcNaSq+8ZZpotM=", - "dev": true, - "requires": { - "keypress": "0.1.x" - } - } - } - }, "mixin-deep": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", @@ -2697,27 +2364,12 @@ } } }, - "mri": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz", - "integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==", - "dev": true - }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true }, - "multiline": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/multiline/-/multiline-1.0.2.tgz", - "integrity": "sha1-abHyX/B00oKJBPJE3dBrfZbvbJM=", - "dev": true, - "requires": { - "strip-indent": "^1.0.0" - } - }, "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -2786,78 +2438,12 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, - "nightmare": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/nightmare/-/nightmare-3.0.1.tgz", - "integrity": "sha512-WptvyPfp5mHRRYHzt6+4xazaR9cc437BuLJI6cLFnqwwgxgdtsFImfBVDeTUCPAeLrkp5VryX5jlw7Wwg+UnFQ==", - "dev": true, - "requires": { - "debug": "^2.2.0", - "deep-defaults": "^1.0.3", - "defaults": "^1.0.2", - "electron": "^1.8.4", - "enqueue": "^1.0.2", - "function-source": "^0.1.0", - "jsesc": "^0.5.0", - "minstache": "^1.2.0", - "mkdirp": "^0.5.1", - "multiline": "^1.0.2", - "once": "^1.3.3", - "rimraf": "^2.4.3", - "sliced": "1.0.1", - "split2": "^2.0.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "node-modules-regexp": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", "dev": true }, - "node-resolve": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/node-resolve/-/node-resolve-1.3.4.tgz", - "integrity": "sha512-yQ8Qn3GGR4cyunvggEHg7fb37V/6atft1K/xU6b2OEfJDbi8zbRSNIKxClzJszAV6tjtYyZt1vHlBgdORMcPXg==", - "dev": true, - "requires": { - "is-builtin-module": "^3.0.0", - "lodash": "^4.13.1" - }, - "dependencies": { - "builtin-modules": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.0.0.tgz", - "integrity": "sha512-hMIeU4K2ilbXV6Uv93ZZ0Avg/M91RaKXucQ+4me2Do1txxBDyDZWCBa5bJSLqoNTRpXTLwEzIk1KmloenDDjhg==", - "dev": true - }, - "is-builtin-module": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.0.0.tgz", - "integrity": "sha512-/93sDihsAD652hrMEbJGbMAVBf1qc96kyThHQ0CAOONHaE3aROLpTjDe4WQ5aoC5ITHFxEq1z8XqSU7km+8amw==", - "dev": true, - "requires": { - "builtin-modules": "^3.0.0" - } - } - } - }, "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -2879,44 +2465,6 @@ "path-key": "^2.0.0" } }, - "nugget": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/nugget/-/nugget-2.0.1.tgz", - "integrity": "sha1-IBCVpIfhrTYIGzQy+jytpPjQcbA=", - "dev": true, - "requires": { - "debug": "^2.1.3", - "minimist": "^1.1.0", - "pretty-bytes": "^1.0.2", - "progress-stream": "^1.1.0", - "request": "^2.45.0", - "single-line-log": "^1.1.2", - "throttleit": "0.0.2" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", @@ -2963,12 +2511,6 @@ } } }, - "object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true - }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -3199,21 +2741,6 @@ "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, - "requires": { - "pinkie": "^2.0.0" - } - }, "pirates": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.0.tgz", @@ -3256,16 +2783,6 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, - "pretty-bytes": { - "version": "1.0.4", - "resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", - "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", - "dev": true, - "requires": { - "get-stdin": "^4.0.1", - "meow": "^3.1.0" - } - }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", @@ -3278,15 +2795,11 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, - "progress-stream": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/progress-stream/-/progress-stream-1.2.0.tgz", - "integrity": "sha1-LNPP6jO6OonJwSHsM0er6asSX3c=", - "dev": true, - "requires": { - "speedometer": "~0.1.2", - "through2": "~0.2.3" - } + "proxy-from-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", + "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", + "dev": true }, "pseudomap": { "version": "1.0.2", @@ -3316,32 +2829,28 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "puppeteer": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.13.0.tgz", + "integrity": "sha512-LUXgvhjfB/P6IOUDAKxOcbCz9ISwBLL9UpKghYrcBDwrOGx1m60y0iN2M64mdAUbT4+7oZM5DTxOW7equa2fxQ==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "extract-zip": "^1.6.6", + "https-proxy-agent": "^2.2.1", + "mime": "^2.0.3", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^2.6.1", + "ws": "^6.1.0" + } + }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dev": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -3374,25 +2883,6 @@ "util-deprecate": "^1.0.1" } }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "^1.1.6" - } - }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "dev": true, - "requires": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" - } - }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -3421,15 +2911,6 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, - "requires": { - "is-finite": "^1.0.0" - } - }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -3951,15 +3432,6 @@ "tslib": "^1.9.0" } }, - "sade": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/sade/-/sade-1.4.2.tgz", - "integrity": "sha512-MTrQm+Nhl4m1mbssYDgAculC/HbShjj08QtHnA2GTpzivfU5aUp8EoHlECmrIHEaa8hZRZSp2Gygv8VMlpXEBw==", - "dev": true, - "requires": { - "mri": "^1.1.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -3981,17 +3453,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "sander": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/sander/-/sander-0.6.0.tgz", - "integrity": "sha1-rxYkzX+2362Y6+9WUxn5IAeNqSU=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.3", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.2" - } - }, "saxes": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.6.tgz", @@ -4051,69 +3512,12 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, - "shelljs": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz", - "integrity": "sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==", - "dev": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - } - }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "single-line-log": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-1.1.2.tgz", - "integrity": "sha1-wvg/Jzo+GhbtsJlWYdoO1e8DM2Q=", - "dev": true, - "requires": { - "string-width": "^1.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "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, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, "slice-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.0.0.tgz", @@ -4125,12 +3529,6 @@ "is-fullwidth-code-point": "^2.0.0" } }, - "sliced": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", - "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=", - "dev": true - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -4333,12 +3731,6 @@ "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", "dev": true }, - "speedometer": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/speedometer/-/speedometer-0.1.4.tgz", - "integrity": "sha1-mHbb0qFp0xFUAtSObqYynIgWpQ0=", - "dev": true - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -4348,57 +3740,6 @@ "extend-shallow": "^3.0.0" } }, - "split2": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", - "dev": true, - "requires": { - "through2": "^2.0.2" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -4489,15 +3830,6 @@ "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, - "strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "requires": { - "get-stdin": "^4.0.1" - } - }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -4524,33 +3856,6 @@ } } }, - "sumchecker": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-1.3.1.tgz", - "integrity": "sha1-ebs7RFbdBPGOvbwNcDodHa7FEF0=", - "dev": true, - "requires": { - "debug": "^2.2.0", - "es6-promise": "^4.0.5" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -4717,54 +4022,12 @@ "thenify": ">= 3.1.0 < 4" } }, - "throttleit": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", - "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=", - "dev": true - }, "through": { "version": "2.3.8", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "through2": { - "version": "0.2.3", - "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", - "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", - "dev": true, - "requires": { - "readable-stream": "~1.1.9", - "xtend": "~2.1.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, "tiny-glob": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.6.tgz", @@ -4853,12 +4116,6 @@ "punycode": "^2.1.0" } }, - "trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true - }, "ts-node": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.0.2.tgz", @@ -5226,15 +4483,6 @@ "integrity": "sha512-tGkGJkN8XqCod7OT+EvGYK5Z4SfDQGD30zAa58OcnAa0RRWgzUEK72tkXhsX1FZd+rgnhRxFtmO+ihkp8LHSkw==", "dev": true }, - "xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", - "dev": true, - "requires": { - "object-keys": "~0.4.0" - } - }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", diff --git a/package.json b/package.json index 114fe051c9..4b85fdfdb9 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,10 @@ { "name": "svelte", - "version": "3.0.0-beta.7", + "version": "3.0.0-beta.15", "description": "The magical disappearing UI framework", "module": "index.mjs", "main": "index", - "bin": { - "svelte": "svelte" - }, "files": [ - "cli", "compiler.js", "register.js", "index.*", @@ -71,8 +67,7 @@ "locate-character": "^2.0.5", "magic-string": "^0.25.2", "mocha": "^5.2.0", - "nightmare": "^3.0.1", - "node-resolve": "^1.3.3", + "puppeteer": "^1.13.0", "rollup": "^1.1.2", "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-json": "^3.0.0", @@ -81,9 +76,6 @@ "rollup-plugin-sucrase": "^2.1.0", "rollup-plugin-typescript": "^1.0.0", "rollup-plugin-virtual": "^1.0.1", - "sade": "^1.4.0", - "sander": "^0.6.0", - "shelljs": "^0.8.2", "source-map": "0.6", "source-map-support": "^0.5.4", "tiny-glob": "^0.2.1", diff --git a/rollup.config.js b/rollup.config.js index ad58d25f22..c523cb004d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -69,27 +69,6 @@ export default [ : id => id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree') }, - /* cli/*.js */ - { - input: ['src/cli/index.ts'], - output: { - dir: 'cli', - format: 'cjs', - paths: { - svelte: '../compiler.js' - } - }, - external: ['fs', 'path', 'os', 'svelte'], - plugins: [ - json(), - commonjs(), - resolve(), - typescript({ - typescript: require('typescript') - }) - ] - }, - /* motion.mjs */ { input: `src/motion/index.js`, diff --git a/site/.eslintrc.json b/site/.eslintrc.json index 0032aca092..98a3b0889c 100644 --- a/site/.eslintrc.json +++ b/site/.eslintrc.json @@ -39,7 +39,6 @@ "sourceType": "module" }, "settings": { - "import/core-modules": ["svelte"], - "svelte3/extensions": [".html"] + "import/core-modules": ["svelte"] } } diff --git a/site/content/blog/2017-12-31-sapper-towards-the-ideal-web-app-framework.md b/site/content/blog/2017-12-31-sapper-towards-the-ideal-web-app-framework.md index 0f6266a4d1..614f266136 100644 --- a/site/content/blog/2017-12-31-sapper-towards-the-ideal-web-app-framework.md +++ b/site/content/blog/2017-12-31-sapper-towards-the-ideal-web-app-framework.md @@ -48,7 +48,7 @@ What happens if we use the new model as a starting point? ## Introducing Sapper - + [Sapper](https://sapper.svelte.technology) is the answer to that question. **Sapper is a Next.js-style framework that aims to meet the eleven criteria at the top of this article while dramatically reducing the amount of code that gets sent to the browser.** It's implemented as Express-compatible middleware, meaning it's easy to understand and customise. @@ -67,7 +67,7 @@ But size is only part of the story. Svelte apps are also extremely performant an The biggest drawback for many developers evaluating Sapper would be 'but I like React, and I already know how to use it', which is fair. -If you're in that camp, I'd invite you to at least try alternative frameworks. You might be pleasantly surprised! The [Sapper RealWorld](https://github.com/sveltejs/realworld) implementation totals 1,201 lines of source code, compared to 2,377 for the reference implementation, because you're able to express concepts very concisely using Svelte's template syntax (which [takes all of five minutes to master](https://svelte.technology/guide#template-syntax)). You get [scoped CSS](the-zen-of-just-writing-css), with unused style removal and minification built-in, and you can use preprocessors like LESS if you want. You no longer need to use Babel. SSR is ridiculously fast, because it's just string concatenation. And we recently introduced [svelte/store](https://svelte.technology/guide#state-management), a tiny global store that synchronises state across your component hierarchy with zero boilerplate. The worst that can happen is that you'll end up feeling vindicated! +If you're in that camp, I'd invite you to at least try alternative frameworks. You might be pleasantly surprised! The [Sapper RealWorld](https://github.com/sveltejs/realworld) implementation totals 1,201 lines of source code, compared to 2,377 for the reference implementation, because you're able to express concepts very concisely using Svelte's template syntax (which [takes all of five minutes to master](https://svelte.technology/docs#template-syntax)). You get [scoped CSS](the-zen-of-just-writing-css), with unused style removal and minification built-in, and you can use preprocessors like LESS if you want. You no longer need to use Babel. SSR is ridiculously fast, because it's just string concatenation. And we recently introduced [svelte/store](https://svelte.technology/docs#state-management), a tiny global store that synchronises state across your component hierarchy with zero boilerplate. The worst that can happen is that you'll end up feeling vindicated! But there are trade-offs nonetheless. Some people have a pathological aversion to any form of 'template language', and maybe that applies to you. JSX proponents will clobber you with the 'it's just JavaScript' mantra, and therein lies React's greatest strength, which is that it is infinitely flexible. That flexibility comes with its own set of trade-offs, but we're not here to discuss those. diff --git a/site/content/blog/2018-04-18-version-2.md b/site/content/blog/2018-04-18-version-2.md index 3204fa1035..295efbbd11 100644 --- a/site/content/blog/2018-04-18-version-2.md +++ b/site/content/blog/2018-04-18-version-2.md @@ -86,7 +86,7 @@ If you need to support IE11 and friends, you will need to use a transpiler like ## New lifecycle hooks -In addition to `oncreate` and `ondestroy`, Svelte v2 adds two more [lifecycle hooks](guide#lifecycle-hooks) for responding to state changes: +In addition to `oncreate` and `ondestroy`, Svelte v2 adds two more [lifecycle hooks](docs#lifecycle-hooks) for responding to state changes: ```js export default { @@ -169,7 +169,7 @@ This change might seem annoying initially, but it's the right move: among other ## event_handler.destroy -If your app has [custom event handlers](guide#custom-event-handlers), they must return an object with a `destroy` method, *not* a `teardown` method (this aligns event handlers with the component API). +If your app has [custom event handlers](docs#custom-event-handlers), they must return an object with a `destroy` method, *not* a `teardown` method (this aligns event handlers with the component API). ## No more type coercion diff --git a/site/content/examples/00-introduction/00-hello-world/App.svelte b/site/content/examples/00-introduction/00-hello-world/App.svelte new file mode 100644 index 0000000000..22b3c84db0 --- /dev/null +++ b/site/content/examples/00-introduction/00-hello-world/App.svelte @@ -0,0 +1,5 @@ + + +

Hello {name}!

\ No newline at end of file diff --git a/site/content/examples/00-introduction/00-hello-world/meta.json b/site/content/examples/00-introduction/00-hello-world/meta.json new file mode 100644 index 0000000000..2f47184710 --- /dev/null +++ b/site/content/examples/00-introduction/00-hello-world/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Adding data" +} \ No newline at end of file diff --git a/site/content/examples/00-introduction/01-dynamic-attributes/App.svelte b/site/content/examples/00-introduction/01-dynamic-attributes/App.svelte new file mode 100644 index 0000000000..6a76b43dde --- /dev/null +++ b/site/content/examples/00-introduction/01-dynamic-attributes/App.svelte @@ -0,0 +1,7 @@ + + + +{name} dancing \ No newline at end of file diff --git a/site/content/examples/00-introduction/01-dynamic-attributes/meta.json b/site/content/examples/00-introduction/01-dynamic-attributes/meta.json new file mode 100644 index 0000000000..89614e0aa6 --- /dev/null +++ b/site/content/examples/00-introduction/01-dynamic-attributes/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Dynamic attributes" +} \ No newline at end of file diff --git a/site/content/examples/00-introduction/02-styling/App.svelte b/site/content/examples/00-introduction/02-styling/App.svelte new file mode 100644 index 0000000000..cacaf8ccba --- /dev/null +++ b/site/content/examples/00-introduction/02-styling/App.svelte @@ -0,0 +1,9 @@ + + +

Styled!

\ No newline at end of file diff --git a/site/content/examples/00-introduction/02-styling/meta.json b/site/content/examples/00-introduction/02-styling/meta.json new file mode 100644 index 0000000000..dcdf2bff01 --- /dev/null +++ b/site/content/examples/00-introduction/02-styling/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Styling" +} \ No newline at end of file diff --git a/site/content/examples/00-introduction/03-nested-components/App.svelte b/site/content/examples/00-introduction/03-nested-components/App.svelte new file mode 100644 index 0000000000..e0a2e5fe17 --- /dev/null +++ b/site/content/examples/00-introduction/03-nested-components/App.svelte @@ -0,0 +1,14 @@ + + + + +

These styles...

+ \ No newline at end of file diff --git a/site/content/examples/00-introduction/03-nested-components/Nested.svelte b/site/content/examples/00-introduction/03-nested-components/Nested.svelte new file mode 100644 index 0000000000..17685233a5 --- /dev/null +++ b/site/content/examples/00-introduction/03-nested-components/Nested.svelte @@ -0,0 +1 @@ +

...don't affect this element

\ No newline at end of file diff --git a/site/content/examples/00-introduction/03-nested-components/meta.json b/site/content/examples/00-introduction/03-nested-components/meta.json new file mode 100644 index 0000000000..5848360a40 --- /dev/null +++ b/site/content/examples/00-introduction/03-nested-components/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Nested components" +} \ No newline at end of file diff --git a/site/content/examples/00-introduction/04-html-tags/App.svelte b/site/content/examples/00-introduction/04-html-tags/App.svelte new file mode 100644 index 0000000000..4029f076e2 --- /dev/null +++ b/site/content/examples/00-introduction/04-html-tags/App.svelte @@ -0,0 +1,5 @@ + + +

{@html string}

\ No newline at end of file diff --git a/site/content/examples/00-introduction/04-html-tags/meta.json b/site/content/examples/00-introduction/04-html-tags/meta.json new file mode 100644 index 0000000000..01af59ac84 --- /dev/null +++ b/site/content/examples/00-introduction/04-html-tags/meta.json @@ -0,0 +1,3 @@ +{ + "title": "HTML tags" +} \ No newline at end of file diff --git a/site/content/examples/00-introduction/meta.json b/site/content/examples/00-introduction/meta.json new file mode 100644 index 0000000000..5c8f7bc10b --- /dev/null +++ b/site/content/examples/00-introduction/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Introduction" +} \ No newline at end of file diff --git a/site/content/examples/01-reactivity/00-reactive-assignments/App.svelte b/site/content/examples/01-reactivity/00-reactive-assignments/App.svelte new file mode 100644 index 0000000000..bc50d74cfc --- /dev/null +++ b/site/content/examples/01-reactivity/00-reactive-assignments/App.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/examples/01-reactivity/00-reactive-assignments/meta.json b/site/content/examples/01-reactivity/00-reactive-assignments/meta.json new file mode 100644 index 0000000000..feb3e8f338 --- /dev/null +++ b/site/content/examples/01-reactivity/00-reactive-assignments/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Reactive assignments" +} \ No newline at end of file diff --git a/site/content/examples/01-reactivity/01-reactive-declarations/App.svelte b/site/content/examples/01-reactivity/01-reactive-declarations/App.svelte new file mode 100644 index 0000000000..f7aca3bd80 --- /dev/null +++ b/site/content/examples/01-reactivity/01-reactive-declarations/App.svelte @@ -0,0 +1,18 @@ + + + + +

{count} * 2 = {doubled}

+

{doubled} * 2 = {quadrupled}

\ No newline at end of file diff --git a/site/content/examples/01-reactivity/01-reactive-declarations/meta.json b/site/content/examples/01-reactivity/01-reactive-declarations/meta.json new file mode 100644 index 0000000000..d824d83669 --- /dev/null +++ b/site/content/examples/01-reactivity/01-reactive-declarations/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Reactive declarations" +} \ No newline at end of file diff --git a/site/content/examples/01-reactivity/02-reactive-statements/App.svelte b/site/content/examples/01-reactivity/02-reactive-statements/App.svelte new file mode 100644 index 0000000000..f757be6f51 --- /dev/null +++ b/site/content/examples/01-reactivity/02-reactive-statements/App.svelte @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/site/content/examples/01-reactivity/02-reactive-statements/meta.json b/site/content/examples/01-reactivity/02-reactive-statements/meta.json new file mode 100644 index 0000000000..1ef62c8830 --- /dev/null +++ b/site/content/examples/01-reactivity/02-reactive-statements/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Reactive statements" +} \ No newline at end of file diff --git a/site/content/examples/01-reactivity/meta.json b/site/content/examples/01-reactivity/meta.json new file mode 100644 index 0000000000..c908815e04 --- /dev/null +++ b/site/content/examples/01-reactivity/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Reactivity" +} \ No newline at end of file diff --git a/site/content/examples/nested-components/App.svelte b/site/content/examples/02-props/00-declaring-props/App.svelte similarity index 56% rename from site/content/examples/nested-components/App.svelte rename to site/content/examples/02-props/00-declaring-props/App.svelte index 83cc0c6eb5..79d7e6b789 100644 --- a/site/content/examples/nested-components/App.svelte +++ b/site/content/examples/02-props/00-declaring-props/App.svelte @@ -2,5 +2,4 @@ import Nested from './Nested.svelte'; -

This is a top-level element.

- \ No newline at end of file + \ No newline at end of file diff --git a/site/content/examples/02-props/00-declaring-props/Nested.svelte b/site/content/examples/02-props/00-declaring-props/Nested.svelte new file mode 100644 index 0000000000..ecd3cb6254 --- /dev/null +++ b/site/content/examples/02-props/00-declaring-props/Nested.svelte @@ -0,0 +1,5 @@ + + +

The answer is {answer}

\ No newline at end of file diff --git a/site/content/examples/02-props/00-declaring-props/meta.json b/site/content/examples/02-props/00-declaring-props/meta.json new file mode 100644 index 0000000000..485c2708bd --- /dev/null +++ b/site/content/examples/02-props/00-declaring-props/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Declaring props" +} \ No newline at end of file diff --git a/site/content/examples/02-props/01-default-values/App.svelte b/site/content/examples/02-props/01-default-values/App.svelte new file mode 100644 index 0000000000..f9d63b30d6 --- /dev/null +++ b/site/content/examples/02-props/01-default-values/App.svelte @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/site/content/examples/02-props/01-default-values/Nested.svelte b/site/content/examples/02-props/01-default-values/Nested.svelte new file mode 100644 index 0000000000..35ee5c9f88 --- /dev/null +++ b/site/content/examples/02-props/01-default-values/Nested.svelte @@ -0,0 +1,5 @@ + + +

The answer is {answer}

\ No newline at end of file diff --git a/site/content/examples/02-props/01-default-values/meta.json b/site/content/examples/02-props/01-default-values/meta.json new file mode 100644 index 0000000000..f690d64349 --- /dev/null +++ b/site/content/examples/02-props/01-default-values/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Default values" +} \ No newline at end of file diff --git a/site/content/examples/02-props/02-spread-props/App.svelte b/site/content/examples/02-props/02-spread-props/App.svelte new file mode 100644 index 0000000000..f40d3b89c8 --- /dev/null +++ b/site/content/examples/02-props/02-spread-props/App.svelte @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/site/content/examples/02-props/02-spread-props/Info.svelte b/site/content/examples/02-props/02-spread-props/Info.svelte new file mode 100644 index 0000000000..7412398244 --- /dev/null +++ b/site/content/examples/02-props/02-spread-props/Info.svelte @@ -0,0 +1,12 @@ + + +

+ The {name} package is {speed} fast. + Download version {version} from npm + and learn more here +

\ No newline at end of file diff --git a/site/content/examples/02-props/02-spread-props/meta.json b/site/content/examples/02-props/02-spread-props/meta.json new file mode 100644 index 0000000000..3f4b5128bf --- /dev/null +++ b/site/content/examples/02-props/02-spread-props/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Spread props" +} \ No newline at end of file diff --git a/site/content/examples/02-props/meta.json b/site/content/examples/02-props/meta.json new file mode 100644 index 0000000000..7b9e0a2783 --- /dev/null +++ b/site/content/examples/02-props/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Props" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/00-if-blocks/App.svelte b/site/content/examples/03-logic/00-if-blocks/App.svelte new file mode 100644 index 0000000000..01b8867ade --- /dev/null +++ b/site/content/examples/03-logic/00-if-blocks/App.svelte @@ -0,0 +1,19 @@ + + +{#if user.loggedIn} + +{/if} + +{#if !user.loggedIn} + +{/if} \ No newline at end of file diff --git a/site/content/examples/03-logic/00-if-blocks/meta.json b/site/content/examples/03-logic/00-if-blocks/meta.json new file mode 100644 index 0000000000..21598b878e --- /dev/null +++ b/site/content/examples/03-logic/00-if-blocks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "If blocks" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/01-else-blocks/App.svelte b/site/content/examples/03-logic/01-else-blocks/App.svelte new file mode 100644 index 0000000000..c82565c2f7 --- /dev/null +++ b/site/content/examples/03-logic/01-else-blocks/App.svelte @@ -0,0 +1,17 @@ + + +{#if user.loggedIn} + +{:else} + +{/if} \ No newline at end of file diff --git a/site/content/examples/03-logic/01-else-blocks/meta.json b/site/content/examples/03-logic/01-else-blocks/meta.json new file mode 100644 index 0000000000..5703b7ea92 --- /dev/null +++ b/site/content/examples/03-logic/01-else-blocks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Else blocks" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/02-else-if-blocks/App.svelte b/site/content/examples/03-logic/02-else-if-blocks/App.svelte new file mode 100644 index 0000000000..9102618ff4 --- /dev/null +++ b/site/content/examples/03-logic/02-else-if-blocks/App.svelte @@ -0,0 +1,11 @@ + + +{#if x > 10} +

{x} is greater than 10

+{:else if 5 > x} +

{x} is less than 5

+{:else} +

{x} is between 5 and 10

+{/if} \ No newline at end of file diff --git a/site/content/examples/03-logic/02-else-if-blocks/meta.json b/site/content/examples/03-logic/02-else-if-blocks/meta.json new file mode 100644 index 0000000000..c778d9f48b --- /dev/null +++ b/site/content/examples/03-logic/02-else-if-blocks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Else-if blocks" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/03-each-blocks/App.svelte b/site/content/examples/03-logic/03-each-blocks/App.svelte new file mode 100644 index 0000000000..6ea5097be2 --- /dev/null +++ b/site/content/examples/03-logic/03-each-blocks/App.svelte @@ -0,0 +1,17 @@ + + +

The Famous Cats of YouTube

+ + \ No newline at end of file diff --git a/site/content/examples/03-logic/03-each-blocks/meta.json b/site/content/examples/03-logic/03-each-blocks/meta.json new file mode 100644 index 0000000000..d829b3cc53 --- /dev/null +++ b/site/content/examples/03-logic/03-each-blocks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Each blocks" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/04-keyed-each-blocks/App.svelte b/site/content/examples/03-logic/04-keyed-each-blocks/App.svelte new file mode 100644 index 0000000000..73a2dcc609 --- /dev/null +++ b/site/content/examples/03-logic/04-keyed-each-blocks/App.svelte @@ -0,0 +1,23 @@ + + + + +{#each things as thing (thing.id)} + +{/each} \ No newline at end of file diff --git a/site/content/examples/03-logic/04-keyed-each-blocks/Thing.svelte b/site/content/examples/03-logic/04-keyed-each-blocks/Thing.svelte new file mode 100644 index 0000000000..4e86d32109 --- /dev/null +++ b/site/content/examples/03-logic/04-keyed-each-blocks/Thing.svelte @@ -0,0 +1,9 @@ + + +

{valueAtStart} / {value}

\ No newline at end of file diff --git a/site/content/examples/03-logic/04-keyed-each-blocks/meta.json b/site/content/examples/03-logic/04-keyed-each-blocks/meta.json new file mode 100644 index 0000000000..faee8bff8d --- /dev/null +++ b/site/content/examples/03-logic/04-keyed-each-blocks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Keyed each blocks" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/05-await-blocks/App.svelte b/site/content/examples/03-logic/05-await-blocks/App.svelte new file mode 100644 index 0000000000..8c8036c0f1 --- /dev/null +++ b/site/content/examples/03-logic/05-await-blocks/App.svelte @@ -0,0 +1,30 @@ + + + + +{#await promise} +

...waiting

+{:then number} +

The number is {number}

+{:catch error} +

{error.message}

+{/await} \ No newline at end of file diff --git a/site/content/examples/03-logic/05-await-blocks/meta.json b/site/content/examples/03-logic/05-await-blocks/meta.json new file mode 100644 index 0000000000..c7a809f5ed --- /dev/null +++ b/site/content/examples/03-logic/05-await-blocks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Await blocks" +} \ No newline at end of file diff --git a/site/content/examples/03-logic/meta.json b/site/content/examples/03-logic/meta.json new file mode 100644 index 0000000000..3ecf1ccee2 --- /dev/null +++ b/site/content/examples/03-logic/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Logic" +} \ No newline at end of file diff --git a/site/content/examples/04-events/00-dom-events/App.svelte b/site/content/examples/04-events/00-dom-events/App.svelte new file mode 100644 index 0000000000..f26112f06c --- /dev/null +++ b/site/content/examples/04-events/00-dom-events/App.svelte @@ -0,0 +1,16 @@ + + + + +
+ The mouse position is {m.x} x {m.y} +
\ No newline at end of file diff --git a/site/content/examples/04-events/00-dom-events/meta.json b/site/content/examples/04-events/00-dom-events/meta.json new file mode 100644 index 0000000000..5b3e37e41f --- /dev/null +++ b/site/content/examples/04-events/00-dom-events/meta.json @@ -0,0 +1,3 @@ +{ + "title": "DOM events" +} \ No newline at end of file diff --git a/site/content/examples/04-events/01-inline-handlers/App.svelte b/site/content/examples/04-events/01-inline-handlers/App.svelte new file mode 100644 index 0000000000..f0fd6ff17a --- /dev/null +++ b/site/content/examples/04-events/01-inline-handlers/App.svelte @@ -0,0 +1,11 @@ + + + + +
+ The mouse position is {m.x} x {m.y} +
\ No newline at end of file diff --git a/site/content/examples/04-events/01-inline-handlers/meta.json b/site/content/examples/04-events/01-inline-handlers/meta.json new file mode 100644 index 0000000000..575b9ab2b6 --- /dev/null +++ b/site/content/examples/04-events/01-inline-handlers/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Inline handlers" +} \ No newline at end of file diff --git a/site/content/examples/04-events/02-event-modifiers/App.svelte b/site/content/examples/04-events/02-event-modifiers/App.svelte new file mode 100644 index 0000000000..94df49cb2d --- /dev/null +++ b/site/content/examples/04-events/02-event-modifiers/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/02-event-modifiers/meta.json b/site/content/examples/04-events/02-event-modifiers/meta.json new file mode 100644 index 0000000000..322bb5ba5e --- /dev/null +++ b/site/content/examples/04-events/02-event-modifiers/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Event modifiers" +} \ No newline at end of file diff --git a/site/content/examples/04-events/03-component-events/App.svelte b/site/content/examples/04-events/03-component-events/App.svelte new file mode 100644 index 0000000000..a8d14a368a --- /dev/null +++ b/site/content/examples/04-events/03-component-events/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/03-component-events/Inner.svelte b/site/content/examples/04-events/03-component-events/Inner.svelte new file mode 100644 index 0000000000..6ac8301f24 --- /dev/null +++ b/site/content/examples/04-events/03-component-events/Inner.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/03-component-events/meta.json b/site/content/examples/04-events/03-component-events/meta.json new file mode 100644 index 0000000000..2a777d4d00 --- /dev/null +++ b/site/content/examples/04-events/03-component-events/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Component events" +} \ No newline at end of file diff --git a/site/content/examples/04-events/04-event-forwarding/App.svelte b/site/content/examples/04-events/04-event-forwarding/App.svelte new file mode 100644 index 0000000000..973df50f0a --- /dev/null +++ b/site/content/examples/04-events/04-event-forwarding/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/04-event-forwarding/Inner.svelte b/site/content/examples/04-events/04-event-forwarding/Inner.svelte new file mode 100644 index 0000000000..6ac8301f24 --- /dev/null +++ b/site/content/examples/04-events/04-event-forwarding/Inner.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/04-event-forwarding/Outer.svelte b/site/content/examples/04-events/04-event-forwarding/Outer.svelte new file mode 100644 index 0000000000..10c28f298a --- /dev/null +++ b/site/content/examples/04-events/04-event-forwarding/Outer.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/04-event-forwarding/meta.json b/site/content/examples/04-events/04-event-forwarding/meta.json new file mode 100644 index 0000000000..3a8aa674b7 --- /dev/null +++ b/site/content/examples/04-events/04-event-forwarding/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Event forwarding" +} \ No newline at end of file diff --git a/site/content/examples/04-events/05-dom-event-forwarding/App.svelte b/site/content/examples/04-events/05-dom-event-forwarding/App.svelte new file mode 100644 index 0000000000..1429cae207 --- /dev/null +++ b/site/content/examples/04-events/05-dom-event-forwarding/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/05-dom-event-forwarding/FancyButton.svelte b/site/content/examples/04-events/05-dom-event-forwarding/FancyButton.svelte new file mode 100644 index 0000000000..75630ea99c --- /dev/null +++ b/site/content/examples/04-events/05-dom-event-forwarding/FancyButton.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/examples/04-events/05-dom-event-forwarding/meta.json b/site/content/examples/04-events/05-dom-event-forwarding/meta.json new file mode 100644 index 0000000000..9aa593808f --- /dev/null +++ b/site/content/examples/04-events/05-dom-event-forwarding/meta.json @@ -0,0 +1,3 @@ +{ + "title": "DOM event forwarding" +} \ No newline at end of file diff --git a/site/content/examples/04-events/meta.json b/site/content/examples/04-events/meta.json new file mode 100644 index 0000000000..c5f088e208 --- /dev/null +++ b/site/content/examples/04-events/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Events" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/00-text-inputs/App.svelte b/site/content/examples/05-bindings/00-text-inputs/App.svelte new file mode 100644 index 0000000000..5eab79764a --- /dev/null +++ b/site/content/examples/05-bindings/00-text-inputs/App.svelte @@ -0,0 +1,6 @@ + + + +

Hello {name || 'stranger'}!

\ No newline at end of file diff --git a/site/content/examples/05-bindings/00-text-inputs/meta.json b/site/content/examples/05-bindings/00-text-inputs/meta.json new file mode 100644 index 0000000000..45577af5be --- /dev/null +++ b/site/content/examples/05-bindings/00-text-inputs/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Text inputs" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/01-numeric-inputs/App.svelte b/site/content/examples/05-bindings/01-numeric-inputs/App.svelte new file mode 100644 index 0000000000..798d57e021 --- /dev/null +++ b/site/content/examples/05-bindings/01-numeric-inputs/App.svelte @@ -0,0 +1,16 @@ + + + + + + +

{a} + {b} = {a + b}

\ No newline at end of file diff --git a/site/content/examples/05-bindings/01-numeric-inputs/meta.json b/site/content/examples/05-bindings/01-numeric-inputs/meta.json new file mode 100644 index 0000000000..72f8579704 --- /dev/null +++ b/site/content/examples/05-bindings/01-numeric-inputs/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Numeric inputs" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/02-checkbox-inputs/App.svelte b/site/content/examples/05-bindings/02-checkbox-inputs/App.svelte new file mode 100644 index 0000000000..b82d31e783 --- /dev/null +++ b/site/content/examples/05-bindings/02-checkbox-inputs/App.svelte @@ -0,0 +1,18 @@ + + + + +{#if yes} +

Thank you. We will bombard your inbox and sell your personal details.

+{:else} +

You must opt in to continue. If you're not paying, you're the product.

+{/if} + + \ No newline at end of file diff --git a/site/content/examples/05-bindings/02-checkbox-inputs/meta.json b/site/content/examples/05-bindings/02-checkbox-inputs/meta.json new file mode 100644 index 0000000000..723312a3d9 --- /dev/null +++ b/site/content/examples/05-bindings/02-checkbox-inputs/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Checkbox inputs" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/03-group-inputs/App.svelte b/site/content/examples/05-bindings/03-group-inputs/App.svelte new file mode 100644 index 0000000000..a46c61c7e7 --- /dev/null +++ b/site/content/examples/05-bindings/03-group-inputs/App.svelte @@ -0,0 +1,52 @@ + + +

Size

+ + + + + + + +

Flavours

+ +{#each menu as flavour} + +{/each} + +{#if flavours.length === 0} +

Please select at least one flavour

+{:else if flavours.length > scoops} +

Can't order more flavours than scoops!

+{:else} +

+ You ordered {scoops} {scoops === 1 ? 'scoop' : 'scoops'} + of {join(flavours)} +

+{/if} diff --git a/site/content/examples/05-bindings/03-group-inputs/meta.json b/site/content/examples/05-bindings/03-group-inputs/meta.json new file mode 100644 index 0000000000..2203d6e6fa --- /dev/null +++ b/site/content/examples/05-bindings/03-group-inputs/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Group inputs" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/04-textarea-inputs/App.svelte b/site/content/examples/05-bindings/04-textarea-inputs/App.svelte new file mode 100644 index 0000000000..be338bf47f --- /dev/null +++ b/site/content/examples/05-bindings/04-textarea-inputs/App.svelte @@ -0,0 +1,12 @@ + + + + + + +{@html marked(value)} \ No newline at end of file diff --git a/site/content/examples/05-bindings/04-textarea-inputs/meta.json b/site/content/examples/05-bindings/04-textarea-inputs/meta.json new file mode 100644 index 0000000000..01adf6b5cf --- /dev/null +++ b/site/content/examples/05-bindings/04-textarea-inputs/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Textarea inputs" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/05-select-bindings/App.svelte b/site/content/examples/05-bindings/05-select-bindings/App.svelte new file mode 100644 index 0000000000..3f1e7fa7e1 --- /dev/null +++ b/site/content/examples/05-bindings/05-select-bindings/App.svelte @@ -0,0 +1,39 @@ + + + + +

Insecurity questions

+ +
+ + + + + +
+ +

selected question {selected ? selected.id : '[waiting...]'}

\ No newline at end of file diff --git a/site/content/examples/05-bindings/05-select-bindings/meta.json b/site/content/examples/05-bindings/05-select-bindings/meta.json new file mode 100644 index 0000000000..fe170eb0fc --- /dev/null +++ b/site/content/examples/05-bindings/05-select-bindings/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Select bindings" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/06-multiple-select-bindings/App.svelte b/site/content/examples/05-bindings/06-multiple-select-bindings/App.svelte new file mode 100644 index 0000000000..d808850158 --- /dev/null +++ b/site/content/examples/05-bindings/06-multiple-select-bindings/App.svelte @@ -0,0 +1,53 @@ + + +

Size

+ + + + + + + +

Flavours

+ + + +{#if flavours.length === 0} +

Please select at least one flavour

+{:else if flavours.length > scoops} +

Can't order more flavours than scoops!

+{:else} +

+ You ordered {scoops} {scoops === 1 ? 'scoop' : 'scoops'} + of {join(flavours)} +

+{/if} diff --git a/site/content/examples/05-bindings/06-multiple-select-bindings/meta.json b/site/content/examples/05-bindings/06-multiple-select-bindings/meta.json new file mode 100644 index 0000000000..abf7635407 --- /dev/null +++ b/site/content/examples/05-bindings/06-multiple-select-bindings/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Select multiple" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/07-each-block-bindings/App.svelte b/site/content/examples/05-bindings/07-each-block-bindings/App.svelte new file mode 100644 index 0000000000..92bdc7754f --- /dev/null +++ b/site/content/examples/05-bindings/07-each-block-bindings/App.svelte @@ -0,0 +1,39 @@ + + +

Todos

+ +{#each todos as todo} +
+ + + +
+{/each} + + + + diff --git a/site/content/examples/05-bindings/07-each-block-bindings/meta.json b/site/content/examples/05-bindings/07-each-block-bindings/meta.json new file mode 100644 index 0000000000..2d27051b49 --- /dev/null +++ b/site/content/examples/05-bindings/07-each-block-bindings/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Each block bindings" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/08-media-elements/App.svelte b/site/content/examples/05-bindings/08-media-elements/App.svelte new file mode 100644 index 0000000000..2cf819fca0 --- /dev/null +++ b/site/content/examples/05-bindings/08-media-elements/App.svelte @@ -0,0 +1,130 @@ + + + + +

Caminandes: Llamigos

+

From Blender Open Projects. CC-BY

+ +
+ + +
+ + +
+ {format(time)} + click anywhere to {paused ? 'play' : 'pause'} / drag to seek + {format(duration)} +
+
+
\ No newline at end of file diff --git a/site/content/examples/05-bindings/08-media-elements/meta.json b/site/content/examples/05-bindings/08-media-elements/meta.json new file mode 100644 index 0000000000..4e40a6acee --- /dev/null +++ b/site/content/examples/05-bindings/08-media-elements/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Media elements" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/09-dimensions/App.svelte b/site/content/examples/05-bindings/09-dimensions/App.svelte new file mode 100644 index 0000000000..ca992599c1 --- /dev/null +++ b/site/content/examples/05-bindings/09-dimensions/App.svelte @@ -0,0 +1,20 @@ + + + + + + + +

size: {w}px x {h}px

+ +
+ {text} +
\ No newline at end of file diff --git a/site/content/examples/05-bindings/09-dimensions/meta.json b/site/content/examples/05-bindings/09-dimensions/meta.json new file mode 100644 index 0000000000..9f8b6602c7 --- /dev/null +++ b/site/content/examples/05-bindings/09-dimensions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Dimensions" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/10-bind-this/App.svelte b/site/content/examples/05-bindings/10-bind-this/App.svelte new file mode 100644 index 0000000000..eacd203629 --- /dev/null +++ b/site/content/examples/05-bindings/10-bind-this/App.svelte @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/site/content/examples/05-bindings/10-bind-this/meta.json b/site/content/examples/05-bindings/10-bind-this/meta.json new file mode 100644 index 0000000000..da5ce399ab --- /dev/null +++ b/site/content/examples/05-bindings/10-bind-this/meta.json @@ -0,0 +1,3 @@ +{ + "title": "bind:this={canvas}" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/11-component-bindings/App.svelte b/site/content/examples/05-bindings/11-component-bindings/App.svelte new file mode 100644 index 0000000000..67fec4a5ad --- /dev/null +++ b/site/content/examples/05-bindings/11-component-bindings/App.svelte @@ -0,0 +1,14 @@ + + +

{view}

+ + \ No newline at end of file diff --git a/site/content/examples/05-bindings/11-component-bindings/Keypad.svelte b/site/content/examples/05-bindings/11-component-bindings/Keypad.svelte new file mode 100644 index 0000000000..c457a15cb5 --- /dev/null +++ b/site/content/examples/05-bindings/11-component-bindings/Keypad.svelte @@ -0,0 +1,40 @@ + + + + +
+ + + + + + + + + + + + + +
\ No newline at end of file diff --git a/site/content/examples/05-bindings/11-component-bindings/meta.json b/site/content/examples/05-bindings/11-component-bindings/meta.json new file mode 100644 index 0000000000..4c921d0e8a --- /dev/null +++ b/site/content/examples/05-bindings/11-component-bindings/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Component bindings" +} \ No newline at end of file diff --git a/site/content/examples/05-bindings/meta.json b/site/content/examples/05-bindings/meta.json new file mode 100644 index 0000000000..8bb0142ecc --- /dev/null +++ b/site/content/examples/05-bindings/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Bindings" +} \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/00-onmount/App.svelte b/site/content/examples/06-lifecycle/00-onmount/App.svelte new file mode 100644 index 0000000000..1b83727627 --- /dev/null +++ b/site/content/examples/06-lifecycle/00-onmount/App.svelte @@ -0,0 +1,38 @@ + + + + +

Photo album

+ +
+ {#each photos as photo} +
+ {photo.title} +
{photo.title}
+
+ {:else} + +

loading...

+ {/each} +
\ No newline at end of file diff --git a/site/content/examples/06-lifecycle/00-onmount/meta.json b/site/content/examples/06-lifecycle/00-onmount/meta.json new file mode 100644 index 0000000000..3b2799c5bc --- /dev/null +++ b/site/content/examples/06-lifecycle/00-onmount/meta.json @@ -0,0 +1,3 @@ +{ + "title": "onMount" +} \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/01-ondestroy/App.svelte b/site/content/examples/06-lifecycle/01-ondestroy/App.svelte new file mode 100644 index 0000000000..93a721ef44 --- /dev/null +++ b/site/content/examples/06-lifecycle/01-ondestroy/App.svelte @@ -0,0 +1,11 @@ + + +

+ The page has been open for + {seconds} {seconds === 1 ? 'second' : 'seconds'} +

\ No newline at end of file diff --git a/site/content/examples/06-lifecycle/01-ondestroy/meta.json b/site/content/examples/06-lifecycle/01-ondestroy/meta.json new file mode 100644 index 0000000000..d87febd1a5 --- /dev/null +++ b/site/content/examples/06-lifecycle/01-ondestroy/meta.json @@ -0,0 +1,3 @@ +{ + "title": "onDestroy" +} \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/01-ondestroy/utils.js b/site/content/examples/06-lifecycle/01-ondestroy/utils.js new file mode 100644 index 0000000000..0f75f29e2a --- /dev/null +++ b/site/content/examples/06-lifecycle/01-ondestroy/utils.js @@ -0,0 +1,9 @@ +import { onDestroy } from 'svelte'; + +export function onInterval(callback, milliseconds) { + const interval = setInterval(callback, milliseconds); + + onDestroy(() => { + clearInterval(interval); + }); +} \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/02-update/App.svelte b/site/content/examples/06-lifecycle/02-update/App.svelte new file mode 100644 index 0000000000..373b6dcb6a --- /dev/null +++ b/site/content/examples/06-lifecycle/02-update/App.svelte @@ -0,0 +1,106 @@ + + + + +
+

Eliza

+ +
+ {#each comments as comment} +
+ {comment.text} +
+ {/each} +
+ + +
\ No newline at end of file diff --git a/site/content/examples/06-lifecycle/02-update/meta.json b/site/content/examples/06-lifecycle/02-update/meta.json new file mode 100644 index 0000000000..c92a6db8dc --- /dev/null +++ b/site/content/examples/06-lifecycle/02-update/meta.json @@ -0,0 +1,3 @@ +{ + "title": "beforeUpdate and afterUpdate" +} \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/03-tick/App.svelte b/site/content/examples/06-lifecycle/03-tick/App.svelte new file mode 100644 index 0000000000..c9cb6de420 --- /dev/null +++ b/site/content/examples/06-lifecycle/03-tick/App.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/03-tick/meta.json b/site/content/examples/06-lifecycle/03-tick/meta.json new file mode 100644 index 0000000000..0a406e13aa --- /dev/null +++ b/site/content/examples/06-lifecycle/03-tick/meta.json @@ -0,0 +1,3 @@ +{ + "title": "tick" +} \ No newline at end of file diff --git a/site/content/examples/06-lifecycle/meta.json b/site/content/examples/06-lifecycle/meta.json new file mode 100644 index 0000000000..2f833e2a4a --- /dev/null +++ b/site/content/examples/06-lifecycle/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Lifecycle" +} \ No newline at end of file diff --git a/site/content/examples/07-stores/00-writable-stores/App.svelte b/site/content/examples/07-stores/00-writable-stores/App.svelte new file mode 100644 index 0000000000..ee542f789d --- /dev/null +++ b/site/content/examples/07-stores/00-writable-stores/App.svelte @@ -0,0 +1,18 @@ + + +

The count is {count_value}

+ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte b/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte new file mode 100644 index 0000000000..043b795047 --- /dev/null +++ b/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/examples/homepage-demo-reactivity/App.svelte b/site/content/examples/07-stores/00-writable-stores/Incrementer.svelte similarity index 50% rename from site/content/examples/homepage-demo-reactivity/App.svelte rename to site/content/examples/07-stores/00-writable-stores/Incrementer.svelte index 9d1b2757c0..2b5763012b 100644 --- a/site/content/examples/homepage-demo-reactivity/App.svelte +++ b/site/content/examples/07-stores/00-writable-stores/Incrementer.svelte @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/site/content/examples/07-stores/00-writable-stores/Resetter.svelte b/site/content/examples/07-stores/00-writable-stores/Resetter.svelte new file mode 100644 index 0000000000..4183421e51 --- /dev/null +++ b/site/content/examples/07-stores/00-writable-stores/Resetter.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/00-writable-stores/meta.json b/site/content/examples/07-stores/00-writable-stores/meta.json new file mode 100644 index 0000000000..e0b2a6809d --- /dev/null +++ b/site/content/examples/07-stores/00-writable-stores/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Writable stores" +} \ No newline at end of file diff --git a/site/content/examples/07-stores/00-writable-stores/stores.js b/site/content/examples/07-stores/00-writable-stores/stores.js new file mode 100644 index 0000000000..143e0c99f0 --- /dev/null +++ b/site/content/examples/07-stores/00-writable-stores/stores.js @@ -0,0 +1,3 @@ +import { writable } from 'svelte/store'; + +export const count = writable(0); \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/App.svelte b/site/content/examples/07-stores/01-auto-subscriptions/App.svelte new file mode 100644 index 0000000000..10ebfb65bb --- /dev/null +++ b/site/content/examples/07-stores/01-auto-subscriptions/App.svelte @@ -0,0 +1,12 @@ + + +

The count is {$count}

+ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte b/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte new file mode 100644 index 0000000000..043b795047 --- /dev/null +++ b/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte b/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte new file mode 100644 index 0000000000..2b5763012b --- /dev/null +++ b/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte b/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte new file mode 100644 index 0000000000..4183421e51 --- /dev/null +++ b/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/meta.json b/site/content/examples/07-stores/01-auto-subscriptions/meta.json new file mode 100644 index 0000000000..a7e4c5fefc --- /dev/null +++ b/site/content/examples/07-stores/01-auto-subscriptions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Auto-subscriptions" +} \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/stores.js b/site/content/examples/07-stores/01-auto-subscriptions/stores.js new file mode 100644 index 0000000000..143e0c99f0 --- /dev/null +++ b/site/content/examples/07-stores/01-auto-subscriptions/stores.js @@ -0,0 +1,3 @@ +import { writable } from 'svelte/store'; + +export const count = writable(0); \ No newline at end of file diff --git a/site/content/examples/07-stores/02-readable-stores/App.svelte b/site/content/examples/07-stores/02-readable-stores/App.svelte new file mode 100644 index 0000000000..3ff0b0362f --- /dev/null +++ b/site/content/examples/07-stores/02-readable-stores/App.svelte @@ -0,0 +1,12 @@ + + +

The time is {formatter.format($time)}

\ No newline at end of file diff --git a/site/content/examples/07-stores/02-readable-stores/meta.json b/site/content/examples/07-stores/02-readable-stores/meta.json new file mode 100644 index 0000000000..3f420cafd8 --- /dev/null +++ b/site/content/examples/07-stores/02-readable-stores/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Readable stores" +} \ No newline at end of file diff --git a/site/content/examples/07-stores/02-readable-stores/stores.js b/site/content/examples/07-stores/02-readable-stores/stores.js new file mode 100644 index 0000000000..015de5ad45 --- /dev/null +++ b/site/content/examples/07-stores/02-readable-stores/stores.js @@ -0,0 +1,11 @@ +import { readable } from 'svelte/store'; + +export const time = readable(function start(set) { + const interval = setInterval(() => { + set(new Date()); + }, 1000); + + return function stop() { + clearInterval(interval); + }; +}, new Date()); \ No newline at end of file diff --git a/site/content/examples/07-stores/03-derived-stores/App.svelte b/site/content/examples/07-stores/03-derived-stores/App.svelte new file mode 100644 index 0000000000..8182ecd671 --- /dev/null +++ b/site/content/examples/07-stores/03-derived-stores/App.svelte @@ -0,0 +1,17 @@ + + +

The time is {formatter.format($time)}

+ +

+ This page has been open for + {$elapsed} {$elapsed === 1 ? 'second' : 'seconds'} +

\ No newline at end of file diff --git a/site/content/examples/07-stores/03-derived-stores/meta.json b/site/content/examples/07-stores/03-derived-stores/meta.json new file mode 100644 index 0000000000..23105b0bfa --- /dev/null +++ b/site/content/examples/07-stores/03-derived-stores/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Derived stores" +} \ No newline at end of file diff --git a/site/content/examples/07-stores/03-derived-stores/stores.js b/site/content/examples/07-stores/03-derived-stores/stores.js new file mode 100644 index 0000000000..2f3af1247a --- /dev/null +++ b/site/content/examples/07-stores/03-derived-stores/stores.js @@ -0,0 +1,18 @@ +import { readable, derive } from 'svelte/store'; + +export const time = readable(function start(set) { + const interval = setInterval(() => { + set(new Date()); + }, 1000); + + return function stop() { + clearInterval(interval); + }; +}, new Date()); + +const start = new Date(); + +export const elapsed = derive( + time, + $time => Math.round(($time - start) / 1000) +); \ No newline at end of file diff --git a/site/content/examples/07-stores/04-custom-stores/App.svelte b/site/content/examples/07-stores/04-custom-stores/App.svelte new file mode 100644 index 0000000000..a320cc052f --- /dev/null +++ b/site/content/examples/07-stores/04-custom-stores/App.svelte @@ -0,0 +1,9 @@ + + +

The count is {$count}

+ + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/04-custom-stores/meta.json b/site/content/examples/07-stores/04-custom-stores/meta.json new file mode 100644 index 0000000000..7394c55f28 --- /dev/null +++ b/site/content/examples/07-stores/04-custom-stores/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Custom stores" +} \ No newline at end of file diff --git a/site/content/examples/07-stores/04-custom-stores/stores.js b/site/content/examples/07-stores/04-custom-stores/stores.js new file mode 100644 index 0000000000..5a26025b03 --- /dev/null +++ b/site/content/examples/07-stores/04-custom-stores/stores.js @@ -0,0 +1,14 @@ +import { writable } from 'svelte/store'; + +function createCount() { + const { subscribe, set, update } = writable(0); + + return { + subscribe, + increment: () => update(n => n + 1), + decrement: () => update(n => n - 1), + reset: () => set(0) + }; +} + +export const count = createCount(); \ No newline at end of file diff --git a/site/content/examples/07-stores/meta.json b/site/content/examples/07-stores/meta.json new file mode 100644 index 0000000000..ad974de0d9 --- /dev/null +++ b/site/content/examples/07-stores/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Stores" +} \ No newline at end of file diff --git a/site/content/examples/08-motion/00-tweened/App.svelte b/site/content/examples/08-motion/00-tweened/App.svelte new file mode 100644 index 0000000000..83f3b50a04 --- /dev/null +++ b/site/content/examples/08-motion/00-tweened/App.svelte @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/site/content/examples/08-motion/00-tweened/meta.json b/site/content/examples/08-motion/00-tweened/meta.json new file mode 100644 index 0000000000..39d3af7f38 --- /dev/null +++ b/site/content/examples/08-motion/00-tweened/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Tweened" +} \ No newline at end of file diff --git a/site/content/examples/motion-spring/App.svelte b/site/content/examples/08-motion/01-spring/App.svelte similarity index 53% rename from site/content/examples/motion-spring/App.svelte rename to site/content/examples/08-motion/01-spring/App.svelte index ae90d7cc8d..2cb0fd1eb7 100644 --- a/site/content/examples/motion-spring/App.svelte +++ b/site/content/examples/08-motion/01-spring/App.svelte @@ -1,43 +1,20 @@ - - - - - + -
+
- \ No newline at end of file + + + \ No newline at end of file diff --git a/site/content/examples/08-motion/01-spring/meta.json b/site/content/examples/08-motion/01-spring/meta.json new file mode 100644 index 0000000000..f871fea53e --- /dev/null +++ b/site/content/examples/08-motion/01-spring/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Spring" +} \ No newline at end of file diff --git a/site/content/examples/08-motion/meta.json b/site/content/examples/08-motion/meta.json new file mode 100644 index 0000000000..e6fa83cd7f --- /dev/null +++ b/site/content/examples/08-motion/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Motion" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/00-transition/App.svelte b/site/content/examples/09-transitions/00-transition/App.svelte new file mode 100644 index 0000000000..b7909fb86e --- /dev/null +++ b/site/content/examples/09-transitions/00-transition/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Fades in and out +

+{/if} \ No newline at end of file diff --git a/site/content/examples/09-transitions/00-transition/meta.json b/site/content/examples/09-transitions/00-transition/meta.json new file mode 100644 index 0000000000..e07975554f --- /dev/null +++ b/site/content/examples/09-transitions/00-transition/meta.json @@ -0,0 +1,3 @@ +{ + "title": "The transition directive" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/01-adding-parameters-to-transitions/App.svelte b/site/content/examples/09-transitions/01-adding-parameters-to-transitions/App.svelte new file mode 100644 index 0000000000..01047f5e37 --- /dev/null +++ b/site/content/examples/09-transitions/01-adding-parameters-to-transitions/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Flies in and out +

+{/if} \ No newline at end of file diff --git a/site/content/examples/09-transitions/01-adding-parameters-to-transitions/meta.json b/site/content/examples/09-transitions/01-adding-parameters-to-transitions/meta.json new file mode 100644 index 0000000000..517bc54c3c --- /dev/null +++ b/site/content/examples/09-transitions/01-adding-parameters-to-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Adding parameters" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/02-in-and-out/App.svelte b/site/content/examples/09-transitions/02-in-and-out/App.svelte new file mode 100644 index 0000000000..36d36664e6 --- /dev/null +++ b/site/content/examples/09-transitions/02-in-and-out/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Flies in, fades out +

+{/if} \ No newline at end of file diff --git a/site/content/examples/09-transitions/02-in-and-out/meta.json b/site/content/examples/09-transitions/02-in-and-out/meta.json new file mode 100644 index 0000000000..627f409fa4 --- /dev/null +++ b/site/content/examples/09-transitions/02-in-and-out/meta.json @@ -0,0 +1,3 @@ +{ + "title": "In and out" +} \ No newline at end of file diff --git a/site/content/examples/transitions-custom/App.svelte b/site/content/examples/09-transitions/03-custom-css-transitions/App.svelte similarity index 62% rename from site/content/examples/transitions-custom/App.svelte rename to site/content/examples/09-transitions/03-custom-css-transitions/App.svelte index bee159e4c5..6e8dfcaf08 100644 --- a/site/content/examples/transitions-custom/App.svelte +++ b/site/content/examples/09-transitions/03-custom-css-transitions/App.svelte @@ -1,14 +1,14 @@ - visible - -{#if visible} -
- wheeee!!!!! -
-{/if} - + + + +{#if visible} +
+ transitions! +
+{/if} \ No newline at end of file diff --git a/site/content/examples/09-transitions/03-custom-css-transitions/meta.json b/site/content/examples/09-transitions/03-custom-css-transitions/meta.json new file mode 100644 index 0000000000..8b70464ca8 --- /dev/null +++ b/site/content/examples/09-transitions/03-custom-css-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Custom CSS transitions" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte b/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte new file mode 100644 index 0000000000..3b3fb94d1c --- /dev/null +++ b/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte @@ -0,0 +1,36 @@ + + + + +{#if visible} +

+ The quick brown fox jumps over the lazy dog +

+{/if} \ No newline at end of file diff --git a/site/content/examples/09-transitions/04-custom-js-transitions/meta.json b/site/content/examples/09-transitions/04-custom-js-transitions/meta.json new file mode 100644 index 0000000000..1ec11d90f9 --- /dev/null +++ b/site/content/examples/09-transitions/04-custom-js-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Custom JS transitions" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/05-transition-events/App.svelte b/site/content/examples/09-transitions/05-transition-events/App.svelte new file mode 100644 index 0000000000..da79897365 --- /dev/null +++ b/site/content/examples/09-transitions/05-transition-events/App.svelte @@ -0,0 +1,25 @@ + + +

status: {status}

+ + + +{#if visible} +

+ Flies in and out +

+{/if} \ No newline at end of file diff --git a/site/content/examples/09-transitions/05-transition-events/meta.json b/site/content/examples/09-transitions/05-transition-events/meta.json new file mode 100644 index 0000000000..b46e28feed --- /dev/null +++ b/site/content/examples/09-transitions/05-transition-events/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Transition events" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/06-deferred-transitions/App.svelte b/site/content/examples/09-transitions/06-deferred-transitions/App.svelte new file mode 100644 index 0000000000..c46096c204 --- /dev/null +++ b/site/content/examples/09-transitions/06-deferred-transitions/App.svelte @@ -0,0 +1,146 @@ + + + + +
+ + +
+

todo

+ {#each todos.filter(t => !t.done) as todo (todo.id)} + + {/each} +
+ +
+

done

+ {#each todos.filter(t => t.done) as todo (todo.id)} + + {/each} +
+
\ No newline at end of file diff --git a/site/content/examples/09-transitions/06-deferred-transitions/crossfade.js b/site/content/examples/09-transitions/06-deferred-transitions/crossfade.js new file mode 100644 index 0000000000..e11e18b60e --- /dev/null +++ b/site/content/examples/09-transitions/06-deferred-transitions/crossfade.js @@ -0,0 +1,65 @@ +import { quintOut } from 'svelte/easing'; + +export default function crossfade({ send, receive, fallback }) { + let requested = new Map(); + let provided = new Map(); + + function crossfade(from, node) { + const to = node.getBoundingClientRect(); + const dx = from.left - to.left; + const dy = from.top - to.top; + + const style = getComputedStyle(node); + const transform = style.transform === 'none' ? '' : style.transform; + + return { + duration: 400, + easing: quintOut, + css: (t, u) => ` + opacity: ${t}; + transform: ${transform} translate(${u * dx}px,${u * dy}px); + ` + }; + } + + return { + send(node, params) { + provided.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (requested.has(params.key)) { + const { rect } = requested.get(params.key); + requested.delete(params.key); + + return crossfade(rect, node); + } + + // if the node is disappearing altogether + // (i.e. wasn't claimed by the other list) + // then we need to supply an outro + provided.delete(params.key); + return fallback(node, params); + }; + }, + + receive(node, params) { + requested.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (provided.has(params.key)) { + const { rect } = provided.get(params.key); + provided.delete(params.key); + + return crossfade(rect, node); + } + + requested.delete(params.key); + return fallback(node, params); + }; + } + }; +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/06-deferred-transitions/meta.json b/site/content/examples/09-transitions/06-deferred-transitions/meta.json new file mode 100644 index 0000000000..b9fc7da898 --- /dev/null +++ b/site/content/examples/09-transitions/06-deferred-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Deferred transitions" +} \ No newline at end of file diff --git a/site/content/examples/09-transitions/meta.json b/site/content/examples/09-transitions/meta.json new file mode 100644 index 0000000000..cb9291d73f --- /dev/null +++ b/site/content/examples/09-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Transitions" +} \ No newline at end of file diff --git a/site/content/examples/10-animations/00-animate/App.svelte b/site/content/examples/10-animations/00-animate/App.svelte new file mode 100644 index 0000000000..c46096c204 --- /dev/null +++ b/site/content/examples/10-animations/00-animate/App.svelte @@ -0,0 +1,146 @@ + + + + +
+ + +
+

todo

+ {#each todos.filter(t => !t.done) as todo (todo.id)} + + {/each} +
+ +
+

done

+ {#each todos.filter(t => t.done) as todo (todo.id)} + + {/each} +
+
\ No newline at end of file diff --git a/site/content/examples/10-animations/00-animate/crossfade.js b/site/content/examples/10-animations/00-animate/crossfade.js new file mode 100644 index 0000000000..e11e18b60e --- /dev/null +++ b/site/content/examples/10-animations/00-animate/crossfade.js @@ -0,0 +1,65 @@ +import { quintOut } from 'svelte/easing'; + +export default function crossfade({ send, receive, fallback }) { + let requested = new Map(); + let provided = new Map(); + + function crossfade(from, node) { + const to = node.getBoundingClientRect(); + const dx = from.left - to.left; + const dy = from.top - to.top; + + const style = getComputedStyle(node); + const transform = style.transform === 'none' ? '' : style.transform; + + return { + duration: 400, + easing: quintOut, + css: (t, u) => ` + opacity: ${t}; + transform: ${transform} translate(${u * dx}px,${u * dy}px); + ` + }; + } + + return { + send(node, params) { + provided.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (requested.has(params.key)) { + const { rect } = requested.get(params.key); + requested.delete(params.key); + + return crossfade(rect, node); + } + + // if the node is disappearing altogether + // (i.e. wasn't claimed by the other list) + // then we need to supply an outro + provided.delete(params.key); + return fallback(node, params); + }; + }, + + receive(node, params) { + requested.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (provided.has(params.key)) { + const { rect } = provided.get(params.key); + provided.delete(params.key); + + return crossfade(rect, node); + } + + requested.delete(params.key); + return fallback(node, params); + }; + } + }; +} \ No newline at end of file diff --git a/site/content/examples/10-animations/00-animate/meta.json b/site/content/examples/10-animations/00-animate/meta.json new file mode 100644 index 0000000000..dd7e345443 --- /dev/null +++ b/site/content/examples/10-animations/00-animate/meta.json @@ -0,0 +1,3 @@ +{ + "title": "The animate directive" +} \ No newline at end of file diff --git a/site/content/examples/10-animations/meta.json b/site/content/examples/10-animations/meta.json new file mode 100644 index 0000000000..c71301495e --- /dev/null +++ b/site/content/examples/10-animations/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Animations" +} \ No newline at end of file diff --git a/site/content/examples/svg-clock/App.svelte b/site/content/examples/11-svg/01-clock/App.svelte similarity index 85% rename from site/content/examples/svg-clock/App.svelte rename to site/content/examples/11-svg/01-clock/App.svelte index 3e406b5d65..49d3a7f809 100644 --- a/site/content/examples/svg-clock/App.svelte +++ b/site/content/examples/11-svg/01-clock/App.svelte @@ -1,16 +1,13 @@ + + @@ -66,35 +101,4 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/site/content/examples/11-svg/01-clock/meta.json b/site/content/examples/11-svg/01-clock/meta.json new file mode 100644 index 0000000000..ec7137feb6 --- /dev/null +++ b/site/content/examples/11-svg/01-clock/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Clock" +} \ No newline at end of file diff --git a/site/content/examples/bar-chart/App.svelte b/site/content/examples/11-svg/02-bar-chart/App.svelte similarity index 84% rename from site/content/examples/bar-chart/App.svelte rename to site/content/examples/11-svg/02-bar-chart/App.svelte index 82af1834a8..e0f27586c3 100644 --- a/site/content/examples/bar-chart/App.svelte +++ b/site/content/examples/11-svg/02-bar-chart/App.svelte @@ -1,7 +1,14 @@
-

US birthrate by year {width}/{height}

+

US birthrate by year

diff --git a/site/content/examples/11-svg/02-bar-chart/meta.json b/site/content/examples/11-svg/02-bar-chart/meta.json new file mode 100644 index 0000000000..97ae2b671b --- /dev/null +++ b/site/content/examples/11-svg/02-bar-chart/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Bar chart" +} \ No newline at end of file diff --git a/site/content/examples/line-chart/App.svelte b/site/content/examples/11-svg/03-area-chart/App.svelte similarity index 96% rename from site/content/examples/line-chart/App.svelte rename to site/content/examples/11-svg/03-area-chart/App.svelte index efa933b5f5..c41801e036 100644 --- a/site/content/examples/line-chart/App.svelte +++ b/site/content/examples/11-svg/03-area-chart/App.svelte @@ -1,8 +1,7 @@
-

Anscombe's quartet

- - - - - -
- \ No newline at end of file + + +
+

Anscombe's quartet

+ + + + + +
\ No newline at end of file diff --git a/site/content/examples/scatterplot/Scatterplot.svelte b/site/content/examples/11-svg/04-scatterplot/Scatterplot.svelte similarity index 97% rename from site/content/examples/scatterplot/Scatterplot.svelte rename to site/content/examples/11-svg/04-scatterplot/Scatterplot.svelte index b1ee52a149..f7a46899fa 100644 --- a/site/content/examples/scatterplot/Scatterplot.svelte +++ b/site/content/examples/11-svg/04-scatterplot/Scatterplot.svelte @@ -4,31 +4,30 @@ export let points; + let svg; + let width = 500; + let height = 200; + const padding = { top: 20, right: 40, bottom: 40, left: 25 }; - let xScale; $: xScale = scaleLinear() .domain([0, 20]) .range([padding.left, width - padding.right]); - let yScale; + $: yScale = scaleLinear() .domain([0, 12]) .range([height - padding.bottom, padding.top]); - let width = 500; - let height = 200; - let xTicks; $: xTicks = width > 180 ? [0, 4, 8, 12, 16, 20] : [0, 10, 20]; - let yTicks; + $: yTicks = height > 180 ? [0, 2, 4, 6, 8, 10, 12] : [0, 4, 8, 12]; onMount(resize); - let svg; function resize() { ({ width, height } = svg.getBoundingClientRect()); } diff --git a/site/content/examples/11-svg/04-scatterplot/data.js b/site/content/examples/11-svg/04-scatterplot/data.js new file mode 100644 index 0000000000..0faeb976d9 --- /dev/null +++ b/site/content/examples/11-svg/04-scatterplot/data.js @@ -0,0 +1,54 @@ +export default { + a: [ + { x: 10, y: 8.04 }, + { x: 8, y: 6.95 }, + { x: 13, y: 7.58 }, + { x: 9, y: 8.81 }, + { x: 11, y: 8.33 }, + { x: 14, y: 9.96 }, + { x: 6, y: 7.24 }, + { x: 4, y: 4.26 }, + { x: 12, y: 10.84 }, + { x: 7, y: 4.82 }, + { x: 5, y: 5.68 } + ], + b: [ + { x: 10, y: 9.14 }, + { x: 8, y: 8.14 }, + { x: 13, y: 8.74 }, + { x: 9, y: 8.77 }, + { x: 11, y: 9.26 }, + { x: 14, y: 8.1 }, + { x: 6, y: 6.13 }, + { x: 4, y: 3.1 }, + { x: 12, y: 9.13 }, + { x: 7, y: 7.26 }, + { x: 5, y: 4.74 } + ], + c: [ + { x: 10, y: 7.46 }, + { x: 8, y: 6.77 }, + { x: 13, y: 12.74 }, + { x: 9, y: 7.11 }, + { x: 11, y: 7.81 }, + { x: 14, y: 8.84 }, + { x: 6, y: 6.08 }, + { x: 4, y: 5.39 }, + { x: 12, y: 8.15 }, + { x: 7, y: 6.42 }, + { x: 5, y: 5.73 } + ], + d: [ + { x: 8, y: 6.58 }, + { x: 8, y: 5.76 }, + { x: 8, y: 7.71 }, + { x: 8, y: 8.84 }, + { x: 8, y: 8.47 }, + { x: 8, y: 7.04 }, + { x: 8, y: 5.25 }, + { x: 19, y: 12.5 }, + { x: 8, y: 5.56 }, + { x: 8, y: 7.91 }, + { x: 8, y: 6.89 } + ] +}; \ No newline at end of file diff --git a/site/content/examples/11-svg/04-scatterplot/meta.json b/site/content/examples/11-svg/04-scatterplot/meta.json new file mode 100644 index 0000000000..52a4c119bc --- /dev/null +++ b/site/content/examples/11-svg/04-scatterplot/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Scatterplot" +} \ No newline at end of file diff --git a/site/content/examples/homepage-demo-transitions/App.svelte b/site/content/examples/11-svg/05-svg-transitions/App.svelte similarity index 100% rename from site/content/examples/homepage-demo-transitions/App.svelte rename to site/content/examples/11-svg/05-svg-transitions/App.svelte diff --git a/site/content/examples/homepage-demo-transitions/custom-transitions.js b/site/content/examples/11-svg/05-svg-transitions/custom-transitions.js similarity index 100% rename from site/content/examples/homepage-demo-transitions/custom-transitions.js rename to site/content/examples/11-svg/05-svg-transitions/custom-transitions.js diff --git a/site/content/examples/11-svg/05-svg-transitions/meta.json b/site/content/examples/11-svg/05-svg-transitions/meta.json new file mode 100644 index 0000000000..aa14d1a3d4 --- /dev/null +++ b/site/content/examples/11-svg/05-svg-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "SVG transitions" +} \ No newline at end of file diff --git a/site/content/examples/homepage-demo-transitions/shape.js b/site/content/examples/11-svg/05-svg-transitions/shape.js similarity index 86% rename from site/content/examples/homepage-demo-transitions/shape.js rename to site/content/examples/11-svg/05-svg-transitions/shape.js index 032a58bf24..9ed2128ebe 100644 --- a/site/content/examples/homepage-demo-transitions/shape.js +++ b/site/content/examples/11-svg/05-svg-transitions/shape.js @@ -1,5 +1,2 @@ export const inner = `M45.41,108.86A21.81,21.81,0,0,1,22,100.18,20.2,20.2,0,0,1,18.53,84.9a19,19,0,0,1,.65-2.57l.52-1.58,1.41,1a35.32,35.32,0,0,0,10.75,5.37l1,.31-.1,1a6.2,6.2,0,0,0,1.11,4.08A6.57,6.57,0,0,0,41,95.19a6,6,0,0,0,1.68-.74L70.11,76.94a5.76,5.76,0,0,0,2.59-3.83,6.09,6.09,0,0,0-1-4.6,6.58,6.58,0,0,0-7.06-2.62,6.21,6.21,0,0,0-1.69.74L52.43,73.31a19.88,19.88,0,0,1-5.58,2.45,21.82,21.82,0,0,1-23.43-8.68A20.2,20.2,0,0,1,20,51.8a19,19,0,0,1,8.56-12.7L56,21.59a19.88,19.88,0,0,1,5.58-2.45A21.81,21.81,0,0,1,85,27.82,20.2,20.2,0,0,1,88.47,43.1a19,19,0,0,1-.65,2.57l-.52,1.58-1.41-1a35.32,35.32,0,0,0-10.75-5.37l-1-.31.1-1a6.2,6.2,0,0,0-1.11-4.08,6.57,6.57,0,0,0-7.06-2.62,6,6,0,0,0-1.68.74L36.89,51.06a5.71,5.71,0,0,0-2.58,3.83,6,6,0,0,0,1,4.6,6.58,6.58,0,0,0,7.06,2.62,6.21,6.21,0,0,0,1.69-.74l10.48-6.68a19.88,19.88,0,0,1,5.58-2.45,21.82,21.82,0,0,1,23.43,8.68A20.2,20.2,0,0,1,87,76.2a19,19,0,0,1-8.56,12.7L51,106.41a19.88,19.88,0,0,1-5.58,2.45`; - -export const outer = ` - M65,34 L37,52 A1 1 0 0 0 44 60 L70.5,44.5 A1 1 0 0 0 65,34Z - M64,67 L36,85 A1 1 0 0 0 42 94 L68,77.5 A1 1 0 0 0 64,67Z`; \ No newline at end of file +export const outer = `M65,34 L37,52 A1 1 0 0 0 44 60 L70.5,44.5 A1 1 0 0 0 65,34Z M64,67 L36,85 A1 1 0 0 0 42 94 L68,77.5 A1 1 0 0 0 64,67Z`; \ No newline at end of file diff --git a/site/content/examples/11-svg/meta.json b/site/content/examples/11-svg/meta.json new file mode 100644 index 0000000000..a26780dfc8 --- /dev/null +++ b/site/content/examples/11-svg/meta.json @@ -0,0 +1,3 @@ +{ + "title": "SVG" +} \ No newline at end of file diff --git a/site/content/examples/12-actions/00-actions/App.svelte b/site/content/examples/12-actions/00-actions/App.svelte new file mode 100644 index 0000000000..1324277bac --- /dev/null +++ b/site/content/examples/12-actions/00-actions/App.svelte @@ -0,0 +1,49 @@ + + + + +
\ No newline at end of file diff --git a/site/content/examples/12-actions/00-actions/meta.json b/site/content/examples/12-actions/00-actions/meta.json new file mode 100644 index 0000000000..463fc963af --- /dev/null +++ b/site/content/examples/12-actions/00-actions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "The use directive" +} \ No newline at end of file diff --git a/site/content/examples/12-actions/00-actions/pannable.js b/site/content/examples/12-actions/00-actions/pannable.js new file mode 100644 index 0000000000..f7d15328be --- /dev/null +++ b/site/content/examples/12-actions/00-actions/pannable.js @@ -0,0 +1,47 @@ +export function pannable(node) { + let x; + let y; + + function handleMousedown(event) { + x = event.clientX; + y = event.clientY; + + node.dispatchEvent(new CustomEvent('panstart', { + detail: { x, y } + })); + + window.addEventListener('mousemove', handleMousemove); + window.addEventListener('mouseup', handleMouseup); + } + + function handleMousemove(event) { + const dx = event.clientX - x; + const dy = event.clientY - y; + x = event.clientX; + y = event.clientY; + + node.dispatchEvent(new CustomEvent('panmove', { + detail: { x, y, dx, dy } + })); + } + + function handleMouseup(event) { + x = event.clientX; + y = event.clientY; + + node.dispatchEvent(new CustomEvent('panend', { + detail: { x, y } + })); + + window.removeEventListener('mousemove', handleMousemove); + window.removeEventListener('mouseup', handleMouseup); + } + + node.addEventListener('mousedown', handleMousedown); + + return { + destroy() { + node.removeEventListener('mousedown', handleMousedown); + } + }; +} \ No newline at end of file diff --git a/site/content/examples/12-actions/01-adding-parameters-to-actions/App.svelte b/site/content/examples/12-actions/01-adding-parameters-to-actions/App.svelte new file mode 100644 index 0000000000..0bd9d56113 --- /dev/null +++ b/site/content/examples/12-actions/01-adding-parameters-to-actions/App.svelte @@ -0,0 +1,70 @@ + + + \ No newline at end of file diff --git a/site/content/examples/12-actions/01-adding-parameters-to-actions/meta.json b/site/content/examples/12-actions/01-adding-parameters-to-actions/meta.json new file mode 100644 index 0000000000..517bc54c3c --- /dev/null +++ b/site/content/examples/12-actions/01-adding-parameters-to-actions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Adding parameters" +} \ No newline at end of file diff --git a/site/content/examples/12-actions/meta.json b/site/content/examples/12-actions/meta.json new file mode 100644 index 0000000000..a154610283 --- /dev/null +++ b/site/content/examples/12-actions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Actions" +} \ No newline at end of file diff --git a/site/content/examples/13-classes/00-classes/App.svelte b/site/content/examples/13-classes/00-classes/App.svelte new file mode 100644 index 0000000000..4da386991d --- /dev/null +++ b/site/content/examples/13-classes/00-classes/App.svelte @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/site/content/examples/13-classes/00-classes/meta.json b/site/content/examples/13-classes/00-classes/meta.json new file mode 100644 index 0000000000..7641cc6a5a --- /dev/null +++ b/site/content/examples/13-classes/00-classes/meta.json @@ -0,0 +1,3 @@ +{ + "title": "The class directive" +} \ No newline at end of file diff --git a/site/content/examples/13-classes/01-class-shorthand/App.svelte b/site/content/examples/13-classes/01-class-shorthand/App.svelte new file mode 100644 index 0000000000..0f4e0d9f24 --- /dev/null +++ b/site/content/examples/13-classes/01-class-shorthand/App.svelte @@ -0,0 +1,18 @@ + + + + + + +
+ some {big ? 'big' : 'small'} text +
\ No newline at end of file diff --git a/site/content/examples/13-classes/01-class-shorthand/meta.json b/site/content/examples/13-classes/01-class-shorthand/meta.json new file mode 100644 index 0000000000..72c51bd387 --- /dev/null +++ b/site/content/examples/13-classes/01-class-shorthand/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Shorthand class directive" +} \ No newline at end of file diff --git a/site/content/examples/13-classes/meta.json b/site/content/examples/13-classes/meta.json new file mode 100644 index 0000000000..9c2b8a41f6 --- /dev/null +++ b/site/content/examples/13-classes/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Classes" +} \ No newline at end of file diff --git a/site/content/examples/14-composition/00-slots/App.svelte b/site/content/examples/14-composition/00-slots/App.svelte new file mode 100644 index 0000000000..cd0ebde935 --- /dev/null +++ b/site/content/examples/14-composition/00-slots/App.svelte @@ -0,0 +1,8 @@ + + + +

Hello!

+

This is a box. It can contain anything.

+
\ No newline at end of file diff --git a/site/content/examples/14-composition/00-slots/Box.svelte b/site/content/examples/14-composition/00-slots/Box.svelte new file mode 100644 index 0000000000..7ed13f386f --- /dev/null +++ b/site/content/examples/14-composition/00-slots/Box.svelte @@ -0,0 +1,14 @@ + + +
+ +
\ No newline at end of file diff --git a/site/content/examples/14-composition/00-slots/meta.json b/site/content/examples/14-composition/00-slots/meta.json new file mode 100644 index 0000000000..bd30c8935a --- /dev/null +++ b/site/content/examples/14-composition/00-slots/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Slots" +} \ No newline at end of file diff --git a/site/content/examples/14-composition/01-slot-fallbacks/App.svelte b/site/content/examples/14-composition/01-slot-fallbacks/App.svelte new file mode 100644 index 0000000000..e30be6d1fc --- /dev/null +++ b/site/content/examples/14-composition/01-slot-fallbacks/App.svelte @@ -0,0 +1,10 @@ + + + +

Hello!

+

This is a box. It can contain anything.

+
+ + \ No newline at end of file diff --git a/site/content/examples/14-composition/01-slot-fallbacks/Box.svelte b/site/content/examples/14-composition/01-slot-fallbacks/Box.svelte new file mode 100644 index 0000000000..66c580632c --- /dev/null +++ b/site/content/examples/14-composition/01-slot-fallbacks/Box.svelte @@ -0,0 +1,16 @@ + + +
+ + no content was provided + +
\ No newline at end of file diff --git a/site/content/examples/14-composition/01-slot-fallbacks/meta.json b/site/content/examples/14-composition/01-slot-fallbacks/meta.json new file mode 100644 index 0000000000..26e7fcfb92 --- /dev/null +++ b/site/content/examples/14-composition/01-slot-fallbacks/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Slot fallbacks" +} \ No newline at end of file diff --git a/site/content/examples/14-composition/02-named-slots/App.svelte b/site/content/examples/14-composition/02-named-slots/App.svelte new file mode 100644 index 0000000000..8047809359 --- /dev/null +++ b/site/content/examples/14-composition/02-named-slots/App.svelte @@ -0,0 +1,14 @@ + + + + + P. Sherman + + + + 42 Wallaby Way
+ Sydney +
+
\ No newline at end of file diff --git a/site/content/examples/14-composition/02-named-slots/ContactCard.svelte b/site/content/examples/14-composition/02-named-slots/ContactCard.svelte new file mode 100644 index 0000000000..1acf290943 --- /dev/null +++ b/site/content/examples/14-composition/02-named-slots/ContactCard.svelte @@ -0,0 +1,47 @@ + + +
+

+ + Unknown name + +

+ +
+ + Unknown address + +
+ + +
\ No newline at end of file diff --git a/site/content/examples/14-composition/02-named-slots/meta.json b/site/content/examples/14-composition/02-named-slots/meta.json new file mode 100644 index 0000000000..60b82e991c --- /dev/null +++ b/site/content/examples/14-composition/02-named-slots/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Named slots" +} \ No newline at end of file diff --git a/site/content/examples/14-composition/03-slot-props/App.svelte b/site/content/examples/14-composition/03-slot-props/App.svelte new file mode 100644 index 0000000000..36772a5077 --- /dev/null +++ b/site/content/examples/14-composition/03-slot-props/App.svelte @@ -0,0 +1,46 @@ + + + + + +
+ {#if active} +

I am being hovered upon.

+ {:else} +

Hover over me!

+ {/if} +
+
+ + +
+ {#if active} +

I am being hovered upon.

+ {:else} +

Hover over me!

+ {/if} +
+
+ + +
+ {#if active} +

I am being hovered upon.

+ {:else} +

Hover over me!

+ {/if} +
+
\ No newline at end of file diff --git a/site/content/examples/14-composition/03-slot-props/Hoverable.svelte b/site/content/examples/14-composition/03-slot-props/Hoverable.svelte new file mode 100644 index 0000000000..69f2fc8ef6 --- /dev/null +++ b/site/content/examples/14-composition/03-slot-props/Hoverable.svelte @@ -0,0 +1,15 @@ + + +
+ +
\ No newline at end of file diff --git a/site/content/examples/14-composition/03-slot-props/meta.json b/site/content/examples/14-composition/03-slot-props/meta.json new file mode 100644 index 0000000000..74e2ff197c --- /dev/null +++ b/site/content/examples/14-composition/03-slot-props/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Slot props" +} \ No newline at end of file diff --git a/site/content/examples/modal-with-slot/App.svelte b/site/content/examples/14-composition/04-modal/App.svelte similarity index 96% rename from site/content/examples/modal-with-slot/App.svelte rename to site/content/examples/14-composition/04-modal/App.svelte index 665a89554e..ac9d441f52 100644 --- a/site/content/examples/modal-with-slot/App.svelte +++ b/site/content/examples/14-composition/04-modal/App.svelte @@ -1,7 +1,7 @@ {#if showModal} diff --git a/site/content/examples/modal-with-slot/Modal.svelte b/site/content/examples/14-composition/04-modal/Modal.svelte similarity index 100% rename from site/content/examples/modal-with-slot/Modal.svelte rename to site/content/examples/14-composition/04-modal/Modal.svelte index 87f1b02299..5ffa5989a4 100644 --- a/site/content/examples/modal-with-slot/Modal.svelte +++ b/site/content/examples/14-composition/04-modal/Modal.svelte @@ -4,17 +4,6 @@ const dispatch = createEventDispatcher(); - - - - + + + + diff --git a/site/content/examples/14-composition/04-modal/meta.json b/site/content/examples/14-composition/04-modal/meta.json new file mode 100644 index 0000000000..c39791fcf6 --- /dev/null +++ b/site/content/examples/14-composition/04-modal/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Modal" +} \ No newline at end of file diff --git a/site/content/examples/14-composition/meta.json b/site/content/examples/14-composition/meta.json new file mode 100644 index 0000000000..54cf2db82d --- /dev/null +++ b/site/content/examples/14-composition/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Component composition" +} \ No newline at end of file diff --git a/site/content/examples/15-context/00-context-api/App.svelte b/site/content/examples/15-context/00-context-api/App.svelte new file mode 100644 index 0000000000..ea1ba4c7ae --- /dev/null +++ b/site/content/examples/15-context/00-context-api/App.svelte @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/site/content/examples/15-context/00-context-api/Map.svelte b/site/content/examples/15-context/00-context-api/Map.svelte new file mode 100644 index 0000000000..0282cbc311 --- /dev/null +++ b/site/content/examples/15-context/00-context-api/Map.svelte @@ -0,0 +1,50 @@ + + + + +
+ {#if map} + + {/if} +
\ No newline at end of file diff --git a/site/content/examples/15-context/00-context-api/MapMarker.svelte b/site/content/examples/15-context/00-context-api/MapMarker.svelte new file mode 100644 index 0000000000..c936652507 --- /dev/null +++ b/site/content/examples/15-context/00-context-api/MapMarker.svelte @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/site/content/examples/15-context/00-context-api/mapbox.js b/site/content/examples/15-context/00-context-api/mapbox.js new file mode 100644 index 0000000000..55b4200038 --- /dev/null +++ b/site/content/examples/15-context/00-context-api/mapbox.js @@ -0,0 +1,8 @@ +import mapbox from 'mapbox-gl'; + +// https://docs.mapbox.com/help/glossary/access-token/ +mapbox.accessToken = MAPBOX_ACCESS_TOKEN; + +const key = {}; + +export { mapbox, key }; \ No newline at end of file diff --git a/site/content/examples/15-context/00-context-api/meta.json b/site/content/examples/15-context/00-context-api/meta.json new file mode 100644 index 0000000000..2601c87cae --- /dev/null +++ b/site/content/examples/15-context/00-context-api/meta.json @@ -0,0 +1,3 @@ +{ + "title": "setContext and getContext" +} \ No newline at end of file diff --git a/site/content/examples/15-context/meta.json b/site/content/examples/15-context/meta.json new file mode 100644 index 0000000000..d3bd862676 --- /dev/null +++ b/site/content/examples/15-context/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Context API" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/00-svelte-self/App.svelte b/site/content/examples/16-special-elements/00-svelte-self/App.svelte new file mode 100644 index 0000000000..ff02fa6a42 --- /dev/null +++ b/site/content/examples/16-special-elements/00-svelte-self/App.svelte @@ -0,0 +1,41 @@ + + + \ No newline at end of file diff --git a/site/content/examples/16-special-elements/00-svelte-self/File.svelte b/site/content/examples/16-special-elements/00-svelte-self/File.svelte new file mode 100644 index 0000000000..e34686101a --- /dev/null +++ b/site/content/examples/16-special-elements/00-svelte-self/File.svelte @@ -0,0 +1,14 @@ + + + + +{name} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/00-svelte-self/Folder.svelte b/site/content/examples/16-special-elements/00-svelte-self/Folder.svelte new file mode 100644 index 0000000000..c25bb2a93d --- /dev/null +++ b/site/content/examples/16-special-elements/00-svelte-self/Folder.svelte @@ -0,0 +1,52 @@ + + + + +{name} + +{#if expanded} +
    + {#each files as file} +
  • + {#if file.type === 'folder'} + + {:else} + + {/if} +
  • + {/each} +
+{/if} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/00-svelte-self/meta.json b/site/content/examples/16-special-elements/00-svelte-self/meta.json new file mode 100644 index 0000000000..14485d7cee --- /dev/null +++ b/site/content/examples/16-special-elements/00-svelte-self/meta.json @@ -0,0 +1,3 @@ +{ + "title": "" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/01-svelte-component/App.svelte b/site/content/examples/16-special-elements/01-svelte-component/App.svelte new file mode 100644 index 0000000000..a510fa8ad8 --- /dev/null +++ b/site/content/examples/16-special-elements/01-svelte-component/App.svelte @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/site/content/examples/16-special-elements/01-svelte-component/BlueThing.svelte b/site/content/examples/16-special-elements/01-svelte-component/BlueThing.svelte new file mode 100644 index 0000000000..f9130d9d65 --- /dev/null +++ b/site/content/examples/16-special-elements/01-svelte-component/BlueThing.svelte @@ -0,0 +1,5 @@ + + +blue thing \ No newline at end of file diff --git a/site/content/examples/16-special-elements/01-svelte-component/GreenThing.svelte b/site/content/examples/16-special-elements/01-svelte-component/GreenThing.svelte new file mode 100644 index 0000000000..9cbee235d3 --- /dev/null +++ b/site/content/examples/16-special-elements/01-svelte-component/GreenThing.svelte @@ -0,0 +1,5 @@ + + +green thing \ No newline at end of file diff --git a/site/content/examples/16-special-elements/01-svelte-component/RedThing.svelte b/site/content/examples/16-special-elements/01-svelte-component/RedThing.svelte new file mode 100644 index 0000000000..42f5e4c672 --- /dev/null +++ b/site/content/examples/16-special-elements/01-svelte-component/RedThing.svelte @@ -0,0 +1,5 @@ + + +red thing \ No newline at end of file diff --git a/site/content/examples/16-special-elements/01-svelte-component/meta.json b/site/content/examples/16-special-elements/01-svelte-component/meta.json new file mode 100644 index 0000000000..bb3675d5e5 --- /dev/null +++ b/site/content/examples/16-special-elements/01-svelte-component/meta.json @@ -0,0 +1,3 @@ +{ + "title": "" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/02-svelte-window/App.svelte b/site/content/examples/16-special-elements/02-svelte-window/App.svelte new file mode 100644 index 0000000000..845d666dff --- /dev/null +++ b/site/content/examples/16-special-elements/02-svelte-window/App.svelte @@ -0,0 +1,42 @@ + + + + + + +
+ {#if key} + {key === ' ' ? 'Space' : key} +

{keyCode}

+ {:else} +

Focus this window and press any key

+ {/if} +
\ No newline at end of file diff --git a/site/content/examples/16-special-elements/02-svelte-window/meta.json b/site/content/examples/16-special-elements/02-svelte-window/meta.json new file mode 100644 index 0000000000..18357e9ef9 --- /dev/null +++ b/site/content/examples/16-special-elements/02-svelte-window/meta.json @@ -0,0 +1,3 @@ +{ + "title": "" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/03-svelte-window-bindings/App.svelte b/site/content/examples/16-special-elements/03-svelte-window-bindings/App.svelte new file mode 100644 index 0000000000..3dbfd43f21 --- /dev/null +++ b/site/content/examples/16-special-elements/03-svelte-window-bindings/App.svelte @@ -0,0 +1,88 @@ + + + + + + {#each [0, 1, 2, 3, 4, 5, 6, 7, 8] as layer} + parallax layer {layer} + {/each} + + +
+ + scroll down + + +
+ You have scrolled {y} pixels +
+
+ + diff --git a/site/content/examples/16-special-elements/03-svelte-window-bindings/meta.json b/site/content/examples/16-special-elements/03-svelte-window-bindings/meta.json new file mode 100644 index 0000000000..9903a804bb --- /dev/null +++ b/site/content/examples/16-special-elements/03-svelte-window-bindings/meta.json @@ -0,0 +1,3 @@ +{ + "title": " bindings" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/04-svelte-body/App.svelte b/site/content/examples/16-special-elements/04-svelte-body/App.svelte new file mode 100644 index 0000000000..ac946962eb --- /dev/null +++ b/site/content/examples/16-special-elements/04-svelte-body/App.svelte @@ -0,0 +1,37 @@ + + + + + + + +Kitten wants to know what's going on \ No newline at end of file diff --git a/site/content/examples/16-special-elements/04-svelte-body/meta.json b/site/content/examples/16-special-elements/04-svelte-body/meta.json new file mode 100644 index 0000000000..a140d2c168 --- /dev/null +++ b/site/content/examples/16-special-elements/04-svelte-body/meta.json @@ -0,0 +1,3 @@ +{ + "title": "" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/05-svelte-head/App.svelte b/site/content/examples/16-special-elements/05-svelte-head/App.svelte new file mode 100644 index 0000000000..38089c9fdd --- /dev/null +++ b/site/content/examples/16-special-elements/05-svelte-head/App.svelte @@ -0,0 +1,5 @@ + + + + +

Hello world!

\ No newline at end of file diff --git a/site/content/examples/16-special-elements/05-svelte-head/meta.json b/site/content/examples/16-special-elements/05-svelte-head/meta.json new file mode 100644 index 0000000000..d35a752d15 --- /dev/null +++ b/site/content/examples/16-special-elements/05-svelte-head/meta.json @@ -0,0 +1,3 @@ +{ + "title": "" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/06-svelte-options/App.svelte b/site/content/examples/16-special-elements/06-svelte-options/App.svelte new file mode 100644 index 0000000000..e0051449ee --- /dev/null +++ b/site/content/examples/16-special-elements/06-svelte-options/App.svelte @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/site/content/examples/16-special-elements/06-svelte-options/Square.svelte b/site/content/examples/16-special-elements/06-svelte-options/Square.svelte new file mode 100644 index 0000000000..38f26d1dba --- /dev/null +++ b/site/content/examples/16-special-elements/06-svelte-options/Square.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/site/content/examples/16-special-elements/06-svelte-options/meta.json b/site/content/examples/16-special-elements/06-svelte-options/meta.json new file mode 100644 index 0000000000..242c006850 --- /dev/null +++ b/site/content/examples/16-special-elements/06-svelte-options/meta.json @@ -0,0 +1,3 @@ +{ + "title": "" +} \ No newline at end of file diff --git a/site/content/examples/16-special-elements/meta.json b/site/content/examples/16-special-elements/meta.json new file mode 100644 index 0000000000..2718c14b59 --- /dev/null +++ b/site/content/examples/16-special-elements/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Special elements" +} \ No newline at end of file diff --git a/site/content/examples/17-module-context/00-sharing-code/App.svelte b/site/content/examples/17-module-context/00-sharing-code/App.svelte new file mode 100644 index 0000000000..3c0133350a --- /dev/null +++ b/site/content/examples/17-module-context/00-sharing-code/App.svelte @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + diff --git a/site/content/examples/17-module-context/00-sharing-code/AudioPlayer.svelte b/site/content/examples/17-module-context/00-sharing-code/AudioPlayer.svelte new file mode 100644 index 0000000000..27dbe1993b --- /dev/null +++ b/site/content/examples/17-module-context/00-sharing-code/AudioPlayer.svelte @@ -0,0 +1,46 @@ + + + + + + +
+

{title}

+

{composer} / performed by {performer}

+ + +
\ No newline at end of file diff --git a/site/content/examples/17-module-context/00-sharing-code/meta.json b/site/content/examples/17-module-context/00-sharing-code/meta.json new file mode 100644 index 0000000000..15c3725377 --- /dev/null +++ b/site/content/examples/17-module-context/00-sharing-code/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Sharing code" +} \ No newline at end of file diff --git a/site/content/examples/17-module-context/01-module-exports/App.svelte b/site/content/examples/17-module-context/01-module-exports/App.svelte new file mode 100644 index 0000000000..cd5ab44b21 --- /dev/null +++ b/site/content/examples/17-module-context/01-module-exports/App.svelte @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + diff --git a/site/content/examples/17-module-context/01-module-exports/AudioPlayer.svelte b/site/content/examples/17-module-context/01-module-exports/AudioPlayer.svelte new file mode 100644 index 0000000000..4e3d191dbf --- /dev/null +++ b/site/content/examples/17-module-context/01-module-exports/AudioPlayer.svelte @@ -0,0 +1,52 @@ + + + + + + +
+

{title}

+

{composer} / performed by {performer}

+ + +
\ No newline at end of file diff --git a/site/content/examples/17-module-context/01-module-exports/meta.json b/site/content/examples/17-module-context/01-module-exports/meta.json new file mode 100644 index 0000000000..82be49d1c7 --- /dev/null +++ b/site/content/examples/17-module-context/01-module-exports/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Exports" +} \ No newline at end of file diff --git a/site/content/examples/17-module-context/meta.json b/site/content/examples/17-module-context/meta.json new file mode 100644 index 0000000000..1a8720e2ce --- /dev/null +++ b/site/content/examples/17-module-context/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Module context" +} \ No newline at end of file diff --git a/site/content/examples/18-debugging/00-debug/App.svelte b/site/content/examples/18-debugging/00-debug/App.svelte new file mode 100644 index 0000000000..1b91ac740b --- /dev/null +++ b/site/content/examples/18-debugging/00-debug/App.svelte @@ -0,0 +1,13 @@ + + + + + +{@debug user} + +

Hello {user.firstname}!

\ No newline at end of file diff --git a/site/content/examples/18-debugging/00-debug/meta.json b/site/content/examples/18-debugging/00-debug/meta.json new file mode 100644 index 0000000000..44ad769024 --- /dev/null +++ b/site/content/examples/18-debugging/00-debug/meta.json @@ -0,0 +1,3 @@ +{ + "title": "The @debug tag" +} \ No newline at end of file diff --git a/site/content/examples/18-debugging/meta.json b/site/content/examples/18-debugging/meta.json new file mode 100644 index 0000000000..5eeed281d3 --- /dev/null +++ b/site/content/examples/18-debugging/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Debugging" +} \ No newline at end of file diff --git a/site/content/examples/7guis-counter/App.svelte b/site/content/examples/19-7guis/01-7guis-counter/App.svelte similarity index 52% rename from site/content/examples/7guis-counter/App.svelte rename to site/content/examples/19-7guis/01-7guis-counter/App.svelte index 385a3c9749..11c5993901 100644 --- a/site/content/examples/7guis-counter/App.svelte +++ b/site/content/examples/19-7guis/01-7guis-counter/App.svelte @@ -1,3 +1,7 @@ + + \ No newline at end of file diff --git a/site/content/examples/19-7guis/01-7guis-counter/meta.json b/site/content/examples/19-7guis/01-7guis-counter/meta.json new file mode 100644 index 0000000000..a3c3ba33c2 --- /dev/null +++ b/site/content/examples/19-7guis/01-7guis-counter/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Counter" +} \ No newline at end of file diff --git a/site/content/examples/7guis-temperature/App.svelte b/site/content/examples/19-7guis/02-7guis-temperature/App.svelte similarity index 100% rename from site/content/examples/7guis-temperature/App.svelte rename to site/content/examples/19-7guis/02-7guis-temperature/App.svelte diff --git a/site/content/examples/19-7guis/02-7guis-temperature/meta.json b/site/content/examples/19-7guis/02-7guis-temperature/meta.json new file mode 100644 index 0000000000..3a578f3887 --- /dev/null +++ b/site/content/examples/19-7guis/02-7guis-temperature/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Temperature Converter" +} \ No newline at end of file diff --git a/site/content/examples/7guis-flight-booker/App.svelte b/site/content/examples/19-7guis/03-7guis-flight-booker/App.svelte similarity index 100% rename from site/content/examples/7guis-flight-booker/App.svelte rename to site/content/examples/19-7guis/03-7guis-flight-booker/App.svelte diff --git a/site/content/examples/19-7guis/03-7guis-flight-booker/meta.json b/site/content/examples/19-7guis/03-7guis-flight-booker/meta.json new file mode 100644 index 0000000000..8f546a740c --- /dev/null +++ b/site/content/examples/19-7guis/03-7guis-flight-booker/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Flight booker" +} \ No newline at end of file diff --git a/site/content/examples/7guis-timer/App.svelte b/site/content/examples/19-7guis/04-7guis-timer/App.svelte similarity index 100% rename from site/content/examples/7guis-timer/App.svelte rename to site/content/examples/19-7guis/04-7guis-timer/App.svelte diff --git a/site/content/examples/19-7guis/04-7guis-timer/meta.json b/site/content/examples/19-7guis/04-7guis-timer/meta.json new file mode 100644 index 0000000000..516b8bc3c2 --- /dev/null +++ b/site/content/examples/19-7guis/04-7guis-timer/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Timer" +} \ No newline at end of file diff --git a/site/content/examples/7guis-crud/App.svelte b/site/content/examples/19-7guis/05-7guis-crud/App.svelte similarity index 91% rename from site/content/examples/7guis-crud/App.svelte rename to site/content/examples/19-7guis/05-7guis-crud/App.svelte index 388a2f4ea3..ed53430eff 100644 --- a/site/content/examples/7guis-crud/App.svelte +++ b/site/content/examples/19-7guis/05-7guis-crud/App.svelte @@ -1,7 +1,20 @@ - - - -{#if promise} - {#await promise} -

wait for it...

- {:then answer} -

the answer is {answer}!

- {:catch error} -

well that's odd

- {/await} -{/if} diff --git a/site/content/examples/await-block/data.json5 b/site/content/examples/await-block/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/await-block/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/bar-chart/data.json5 b/site/content/examples/bar-chart/data.json5 deleted file mode 100644 index 389c90a7d1..0000000000 --- a/site/content/examples/bar-chart/data.json5 +++ /dev/null @@ -1,28 +0,0 @@ -{ - "points": [ - { - "year": 1990, - "birthrate": 16.7 - }, - { - "year": 1995, - "birthrate": 14.6 - }, - { - "year": 2000, - "birthrate": 14.4 - }, - { - "year": 2005, - "birthrate": 14 - }, - { - "year": 2010, - "birthrate": 13 - }, - { - "year": 2015, - "birthrate": 12.4 - } - ] -} \ No newline at end of file diff --git a/site/content/examples/binding-input-checkbox-group/App.svelte b/site/content/examples/binding-input-checkbox-group/App.svelte deleted file mode 100644 index 617e71e17d..0000000000 --- a/site/content/examples/binding-input-checkbox-group/App.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - -

{selected.join(', ') || 'nothing'} selected

\ No newline at end of file diff --git a/site/content/examples/binding-input-checkbox-group/data.json5 b/site/content/examples/binding-input-checkbox-group/data.json5 deleted file mode 100644 index 2285e3abfa..0000000000 --- a/site/content/examples/binding-input-checkbox-group/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "selected": ["blue"] -} \ No newline at end of file diff --git a/site/content/examples/binding-input-checkbox/App.svelte b/site/content/examples/binding-input-checkbox/App.svelte deleted file mode 100644 index b8facdd53b..0000000000 --- a/site/content/examples/binding-input-checkbox/App.svelte +++ /dev/null @@ -1,17 +0,0 @@ -{#each todos as todo} -
- - -
-{/each} - - \ No newline at end of file diff --git a/site/content/examples/binding-input-checkbox/data.json5 b/site/content/examples/binding-input-checkbox/data.json5 deleted file mode 100644 index 4afee559a5..0000000000 --- a/site/content/examples/binding-input-checkbox/data.json5 +++ /dev/null @@ -1,16 +0,0 @@ -{ - "todos": [ - { - "description": "Buy some milk", - "done": true - }, - { - "description": "Do the laundry", - "done": true - }, - { - "description": "Find life's true purpose", - "done": false - } - ] -} \ No newline at end of file diff --git a/site/content/examples/binding-input-numeric/App.svelte b/site/content/examples/binding-input-numeric/App.svelte deleted file mode 100644 index 566c16006c..0000000000 --- a/site/content/examples/binding-input-numeric/App.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - - -

{a} * {b} = {a * b}

- - \ No newline at end of file diff --git a/site/content/examples/binding-input-numeric/data.json5 b/site/content/examples/binding-input-numeric/data.json5 deleted file mode 100644 index 1aa99a76cd..0000000000 --- a/site/content/examples/binding-input-numeric/data.json5 +++ /dev/null @@ -1,4 +0,0 @@ -{ - "a": 5, - "b": 5 -} \ No newline at end of file diff --git a/site/content/examples/binding-input-radio/App.svelte b/site/content/examples/binding-input-radio/App.svelte deleted file mode 100644 index f83813754f..0000000000 --- a/site/content/examples/binding-input-radio/App.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - -

selected {selected}

\ No newline at end of file diff --git a/site/content/examples/binding-input-radio/data.json5 b/site/content/examples/binding-input-radio/data.json5 deleted file mode 100644 index 961184190e..0000000000 --- a/site/content/examples/binding-input-radio/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "selected": "blue" -} \ No newline at end of file diff --git a/site/content/examples/binding-input-text/App.svelte b/site/content/examples/binding-input-text/App.svelte deleted file mode 100644 index 5d81d1e564..0000000000 --- a/site/content/examples/binding-input-text/App.svelte +++ /dev/null @@ -1,2 +0,0 @@ - -

Hello {name || 'stranger'}!

\ No newline at end of file diff --git a/site/content/examples/binding-input-text/data.json5 b/site/content/examples/binding-input-text/data.json5 deleted file mode 100644 index 393554903d..0000000000 --- a/site/content/examples/binding-input-text/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "" -} \ No newline at end of file diff --git a/site/content/examples/binding-media-elements/App.svelte b/site/content/examples/binding-media-elements/App.svelte deleted file mode 100644 index ef25a3dd0d..0000000000 --- a/site/content/examples/binding-media-elements/App.svelte +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - -

THX Deep Note

-
- play/pause button - {format(t)} - {format(d)} -
- -
-

THX Deep Note

-
- play/pause button - {format(t)} - {format(d)} -
-
- - diff --git a/site/content/examples/binding-media-elements/data.json5 b/site/content/examples/binding-media-elements/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/binding-media-elements/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/binding-textarea/App.svelte b/site/content/examples/binding-textarea/App.svelte deleted file mode 100644 index 4fd46f2625..0000000000 --- a/site/content/examples/binding-textarea/App.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - - -
{@html marked(markdown)}
- - \ No newline at end of file diff --git a/site/content/examples/binding-textarea/data.json5 b/site/content/examples/binding-textarea/data.json5 deleted file mode 100644 index 12268060fb..0000000000 --- a/site/content/examples/binding-textarea/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "markdown": "# Markdown editor\n\nTODOs:\n\n* make a Svelte app\n* think of a third item for this list" -} \ No newline at end of file diff --git a/site/content/examples/each-blocks/App.svelte b/site/content/examples/each-blocks/App.svelte deleted file mode 100644 index b8ba07a5e9..0000000000 --- a/site/content/examples/each-blocks/App.svelte +++ /dev/null @@ -1,7 +0,0 @@ -

Cats of YouTube

- - \ No newline at end of file diff --git a/site/content/examples/each-blocks/data.json5 b/site/content/examples/each-blocks/data.json5 deleted file mode 100644 index 41eff03354..0000000000 --- a/site/content/examples/each-blocks/data.json5 +++ /dev/null @@ -1,16 +0,0 @@ -{ - "cats": [ - { - "name": "Keyboard Cat", - "video": "https://www.youtube.com/watch?v=J---aiyznGQ" - }, - { - "name": "Maru", - "video": "https://www.youtube.com/watch?v=z_AbfPXTKms" - }, - { - "name": "Henri The Existential Cat", - "video": "https://www.youtube.com/watch?v=OUtn3pvWmpg" - } - ] -} \ No newline at end of file diff --git a/site/content/examples/hacker-news/data.json5 b/site/content/examples/hacker-news/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/hacker-news/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/hello-world/App.svelte b/site/content/examples/hello-world/App.svelte deleted file mode 100644 index 70a9a95503..0000000000 --- a/site/content/examples/hello-world/App.svelte +++ /dev/null @@ -1,14 +0,0 @@ -

Hello {name}!

- - \ No newline at end of file diff --git a/site/content/examples/hello-world/data.json5 b/site/content/examples/hello-world/data.json5 deleted file mode 100644 index 3949aecc6a..0000000000 --- a/site/content/examples/hello-world/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "world" -} \ No newline at end of file diff --git a/site/content/examples/homepage-demo-hello-world/App.svelte b/site/content/examples/homepage-demo-hello-world/App.svelte deleted file mode 100644 index 543c6059c4..0000000000 --- a/site/content/examples/homepage-demo-hello-world/App.svelte +++ /dev/null @@ -1 +0,0 @@ -

Hello {name}!

\ No newline at end of file diff --git a/site/content/examples/homepage-demo-hello-world/data.json5 b/site/content/examples/homepage-demo-hello-world/data.json5 deleted file mode 100644 index 3949aecc6a..0000000000 --- a/site/content/examples/homepage-demo-hello-world/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "world" -} \ No newline at end of file diff --git a/site/content/examples/homepage-demo-reactivity/data.json5 b/site/content/examples/homepage-demo-reactivity/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/homepage-demo-reactivity/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/homepage-demo-scoped-styles/App.svelte b/site/content/examples/homepage-demo-scoped-styles/App.svelte deleted file mode 100644 index b1fe0495a9..0000000000 --- a/site/content/examples/homepage-demo-scoped-styles/App.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - - -

this <p> is bold but not red

- \ No newline at end of file diff --git a/site/content/examples/homepage-demo-scoped-styles/Foo.svelte b/site/content/examples/homepage-demo-scoped-styles/Foo.svelte deleted file mode 100644 index eb1dd82f7f..0000000000 --- a/site/content/examples/homepage-demo-scoped-styles/Foo.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - -

this <p> is red but not bold

\ No newline at end of file diff --git a/site/content/examples/homepage-demo-scoped-styles/data.json5 b/site/content/examples/homepage-demo-scoped-styles/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/homepage-demo-scoped-styles/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/homepage-demo-transitions/data.json5 b/site/content/examples/homepage-demo-transitions/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/homepage-demo-transitions/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/if-blocks/App.svelte b/site/content/examples/if-blocks/App.svelte deleted file mode 100644 index 57de219159..0000000000 --- a/site/content/examples/if-blocks/App.svelte +++ /dev/null @@ -1,5 +0,0 @@ -{#if foo} -

foo!

-{:else} -

not foo!

-{/if} \ No newline at end of file diff --git a/site/content/examples/if-blocks/data.json5 b/site/content/examples/if-blocks/data.json5 deleted file mode 100644 index c803db4749..0000000000 --- a/site/content/examples/if-blocks/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "foo": true -} \ No newline at end of file diff --git a/site/content/examples/immutable/data.json5 b/site/content/examples/immutable/data.json5 deleted file mode 100644 index a0ed59d82b..0000000000 --- a/site/content/examples/immutable/data.json5 +++ /dev/null @@ -1,7 +0,0 @@ -{ - todos: [ - { id: 1, done: true, text: "wash the car" }, - { id: 2, done: false, text: "take the dog for a walk" }, - { id: 3, done: false, text: "mow the lawn" } - ] -} diff --git a/site/content/examples/line-chart/data.json5 b/site/content/examples/line-chart/data.json5 deleted file mode 100644 index 88e7f02f35..0000000000 --- a/site/content/examples/line-chart/data.json5 +++ /dev/null @@ -1,156 +0,0 @@ -{ - "points": [ - { - "x": 1979, - "y": 7.19 - }, - { - "x": 1980, - "y": 7.83 - }, - { - "x": 1981, - "y": 7.24 - }, - { - "x": 1982, - "y": 7.44 - }, - { - "x": 1983, - "y": 7.51 - }, - { - "x": 1984, - "y": 7.1 - }, - { - "x": 1985, - "y": 6.91 - }, - { - "x": 1986, - "y": 7.53 - }, - { - "x": 1987, - "y": 7.47 - }, - { - "x": 1988, - "y": 7.48 - }, - { - "x": 1989, - "y": 7.03 - }, - { - "x": 1990, - "y": 6.23 - }, - { - "x": 1991, - "y": 6.54 - }, - { - "x": 1992, - "y": 7.54 - }, - { - "x": 1993, - "y": 6.5 - }, - { - "x": 1994, - "y": 7.18 - }, - { - "x": 1995, - "y": 6.12 - }, - { - "x": 1996, - "y": 7.87 - }, - { - "x": 1997, - "y": 6.73 - }, - { - "x": 1998, - "y": 6.55 - }, - { - "x": 1999, - "y": 6.23 - }, - { - "x": 2000, - "y": 6.31 - }, - { - "x": 2001, - "y": 6.74 - }, - { - "x": 2002, - "y": 5.95 - }, - { - "x": 2003, - "y": 6.13 - }, - { - "x": 2004, - "y": 6.04 - }, - { - "x": 2005, - "y": 5.56 - }, - { - "x": 2006, - "y": 5.91 - }, - { - "x": 2007, - "y": 4.29 - }, - { - "x": 2008, - "y": 4.72 - }, - { - "x": 2009, - "y": 5.38 - }, - { - "x": 2010, - "y": 4.92 - }, - { - "x": 2011, - "y": 4.61 - }, - { - "x": 2012, - "y": 3.62 - }, - { - "x": 2013, - "y": 5.35 - }, - { - "x": 2014, - "y": 5.28 - }, - { - "x": 2015, - "y": 4.63 - }, - { - "x": 2016, - "y": 4.72 - } - ] -} \ No newline at end of file diff --git a/site/content/examples/manifest.json b/site/content/examples/manifest.json deleted file mode 100644 index cc7b2f887b..0000000000 --- a/site/content/examples/manifest.json +++ /dev/null @@ -1,184 +0,0 @@ -[ - { - "name": "Basics", - "examples": [ - { - "slug": "hello-world", - "title": "Hello World!" - }, - { - "slug": "if-blocks", - "title": "If blocks" - }, - { - "slug": "each-blocks", - "title": "Each blocks" - }, - { - "slug": "scoped-styles", - "title": "Scoped styles" - } - ] - }, - { - "name": "Two-way bindings", - "examples": [ - { - "slug": "binding-input-text", - "title": "Text input" - }, - { - "slug": "binding-input-numeric", - "title": "Numeric input" - }, - { - "slug": "binding-textarea", - "title": "Textarea" - }, - { - "slug": "binding-input-checkbox", - "title": "Checkbox input" - }, - { - "slug": "binding-input-checkbox-group", - "title": "Checkbox input (grouped)" - }, - { - "slug": "binding-input-radio", - "title": "Radio input" - }, - { - "slug": "binding-media-elements", - "title": "Media elements" - } - ] - }, - { - "name": "Nested components", - "examples": [ - { - "slug": "nested-components", - "title": "Nested components" - }, - { - "slug": "modal-with-slot", - "title": "Modal with " - }, - { - "slug": "self-references", - "title": "Self-references" - } - ] - }, - { - "name": "SVG and dataviz", - "examples": [ - { - "slug": "svg-clock", - "title": "SVG Clock" - }, - { - "slug": "line-chart", - "title": "Line/area chart" - }, - { - "slug": "bar-chart", - "title": "Bar chart" - }, - { - "slug": "scatterplot", - "title": "Scatterplot" - } - ] - }, - { - "name": "Transitions", - "examples": [ - { - "slug": "transitions-fade", - "title": "Simple fade" - }, - { - "slug": "transitions-fly", - "title": "Parameterised" - }, - { - "slug": "transitions-in-out", - "title": "In and out" - }, - { - "slug": "transitions-custom", - "title": "Custom CSS" - } - ] - }, - { - "name": "Motion", - "examples": [ - { - "slug": "motion-spring", - "title": "Spring physics" - } - ] - }, - { - "name": "Async data", - "examples": [ - { - "slug": "await-block", - "title": "Await block" - } - ] - }, - { - "name": "7guis", - "examples": [ - { - "slug": "7guis-counter", - "title": "Counter" - }, - { - "slug": "7guis-temperature", - "title": "Temperature converter" - }, - { - "slug": "7guis-flight-booker", - "title": "Flight booker" - }, - { - "slug": "7guis-timer", - "title": "Timer" - }, - { - "slug": "7guis-crud", - "title": "CRUD" - }, - { - "slug": "7guis-circles", - "title": "Circles" - } - ] - }, - { - "name": "<:Window>", - "examples": [ - { - "slug": "parallax", - "title": "Parallax" - } - ] - }, - { - "name": "Miscellaneous", - "examples": [ - { - "slug": "hacker-news", - "title": "Hacker News" - }, - { - "slug": "immutable", - "title": "Immutable data" - } - ] - } -] diff --git a/site/content/examples/modal-with-slot/data.json5 b/site/content/examples/modal-with-slot/data.json5 deleted file mode 100644 index 18cc32884c..0000000000 --- a/site/content/examples/modal-with-slot/data.json5 +++ /dev/null @@ -1,3 +0,0 @@ -{ - "showModal": true -} \ No newline at end of file diff --git a/site/content/examples/nested-components/Nested.svelte b/site/content/examples/nested-components/Nested.svelte deleted file mode 100644 index 74ee56a5ed..0000000000 --- a/site/content/examples/nested-components/Nested.svelte +++ /dev/null @@ -1 +0,0 @@ -

And this is a nested component.

\ No newline at end of file diff --git a/site/content/examples/nested-components/data.json5 b/site/content/examples/nested-components/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/nested-components/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/parallax/App.svelte b/site/content/examples/parallax/App.svelte deleted file mode 100644 index 38ffd716b5..0000000000 --- a/site/content/examples/parallax/App.svelte +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - -
- - - - - -
- -
- (scroll down) - parallax has never been this easy -
- - diff --git a/site/content/examples/parallax/data.json5 b/site/content/examples/parallax/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/parallax/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/scatterplot/data.json5 b/site/content/examples/scatterplot/data.json5 deleted file mode 100644 index 8d879e1edd..0000000000 --- a/site/content/examples/scatterplot/data.json5 +++ /dev/null @@ -1,186 +0,0 @@ -{ - "a": [ - { - "x": 10, - "y": 8.04 - }, - { - "x": 8, - "y": 6.95 - }, - { - "x": 13, - "y": 7.58 - }, - { - "x": 9, - "y": 8.81 - }, - { - "x": 11, - "y": 8.33 - }, - { - "x": 14, - "y": 9.96 - }, - { - "x": 6, - "y": 7.24 - }, - { - "x": 4, - "y": 4.26 - }, - { - "x": 12, - "y": 10.84 - }, - { - "x": 7, - "y": 4.82 - }, - { - "x": 5, - "y": 5.68 - } - ], - "b": [ - { - "x": 10, - "y": 9.14 - }, - { - "x": 8, - "y": 8.14 - }, - { - "x": 13, - "y": 8.74 - }, - { - "x": 9, - "y": 8.77 - }, - { - "x": 11, - "y": 9.26 - }, - { - "x": 14, - "y": 8.1 - }, - { - "x": 6, - "y": 6.13 - }, - { - "x": 4, - "y": 3.1 - }, - { - "x": 12, - "y": 9.13 - }, - { - "x": 7, - "y": 7.26 - }, - { - "x": 5, - "y": 4.74 - } - ], - "c": [ - { - "x": 10, - "y": 7.46 - }, - { - "x": 8, - "y": 6.77 - }, - { - "x": 13, - "y": 12.74 - }, - { - "x": 9, - "y": 7.11 - }, - { - "x": 11, - "y": 7.81 - }, - { - "x": 14, - "y": 8.84 - }, - { - "x": 6, - "y": 6.08 - }, - { - "x": 4, - "y": 5.39 - }, - { - "x": 12, - "y": 8.15 - }, - { - "x": 7, - "y": 6.42 - }, - { - "x": 5, - "y": 5.73 - } - ], - "d": [ - { - "x": 8, - "y": 6.58 - }, - { - "x": 8, - "y": 5.76 - }, - { - "x": 8, - "y": 7.71 - }, - { - "x": 8, - "y": 8.84 - }, - { - "x": 8, - "y": 8.47 - }, - { - "x": 8, - "y": 7.04 - }, - { - "x": 8, - "y": 5.25 - }, - { - "x": 19, - "y": 12.5 - }, - { - "x": 8, - "y": 5.56 - }, - { - "x": 8, - "y": 7.91 - }, - { - "x": 8, - "y": 6.89 - } - ] -} \ No newline at end of file diff --git a/site/content/examples/scoped-styles/App.svelte b/site/content/examples/scoped-styles/App.svelte deleted file mode 100644 index c4d73176f0..0000000000 --- a/site/content/examples/scoped-styles/App.svelte +++ /dev/null @@ -1,11 +0,0 @@ -
- Big red Comic Sans -
- - \ No newline at end of file diff --git a/site/content/examples/scoped-styles/data.json5 b/site/content/examples/scoped-styles/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/scoped-styles/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/self-references/App.svelte b/site/content/examples/self-references/App.svelte deleted file mode 100644 index bd4475e206..0000000000 --- a/site/content/examples/self-references/App.svelte +++ /dev/null @@ -1,9 +0,0 @@ -
    -
  • {node.name} - {#if node.children} - {#each node.children as child} - - {/each} - {/if} -
  • -
\ No newline at end of file diff --git a/site/content/examples/self-references/data.json5 b/site/content/examples/self-references/data.json5 deleted file mode 100644 index de0cfbd194..0000000000 --- a/site/content/examples/self-references/data.json5 +++ /dev/null @@ -1,32 +0,0 @@ -{ - "node": { - "name": "Fruit", - "children": [ - { - "name": "Red", - "children": [ - { - "name": "Cherry" - }, - { - "name": "Strawberry" - } - ] - }, - { - "name": "Green", - "children": [ - { - "name": "Apple" - }, - { - "name": "Pear" - }, - { - "name": "Lime" - } - ] - } - ] - } -} \ No newline at end of file diff --git a/site/content/examples/svg-clock/data.json5 b/site/content/examples/svg-clock/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/svg-clock/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/transitions-custom/data.json5 b/site/content/examples/transitions-custom/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/transitions-custom/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/transitions-fade/App.svelte b/site/content/examples/transitions-fade/App.svelte deleted file mode 100644 index 528d495361..0000000000 --- a/site/content/examples/transitions-fade/App.svelte +++ /dev/null @@ -1,11 +0,0 @@ - - - visible - -{#if visible} -

fades in and out

-{/if} diff --git a/site/content/examples/transitions-fade/data.json5 b/site/content/examples/transitions-fade/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/transitions-fade/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/transitions-fly/App.svelte b/site/content/examples/transitions-fly/App.svelte deleted file mode 100644 index 43e4a1dd2d..0000000000 --- a/site/content/examples/transitions-fly/App.svelte +++ /dev/null @@ -1,11 +0,0 @@ - - - visible - -{#if visible} -

flies 200 pixels up, slowly

-{/if} diff --git a/site/content/examples/transitions-fly/data.json5 b/site/content/examples/transitions-fly/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/transitions-fly/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/examples/transitions-in-out/App.svelte b/site/content/examples/transitions-in-out/App.svelte deleted file mode 100644 index 7b995bc04d..0000000000 --- a/site/content/examples/transitions-in-out/App.svelte +++ /dev/null @@ -1,11 +0,0 @@ - - - visible - -{#if visible} -

flies up, fades out

-{/if} diff --git a/site/content/examples/transitions-in-out/data.json5 b/site/content/examples/transitions-in-out/data.json5 deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/site/content/examples/transitions-in-out/data.json5 +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/site/content/guide/02-template-syntax.md b/site/content/guide/02-template-syntax.md index 41418c474e..d915a8e37f 100644 --- a/site/content/guide/02-template-syntax.md +++ b/site/content/guide/02-template-syntax.md @@ -87,13 +87,13 @@ You can combine the two blocks above with `{:else}`: {/if} ``` -You can also use `{:elseif ...}`: +You can also use `{:else if ...}`: ```html - + {#if x > 10}

{x} is greater than 10

-{:elseif 5 > x} +{:else if 5 > x}

{x} is less than 5

{:else}

{x} is between 5 and 10

@@ -176,7 +176,7 @@ You can access the index of the current element with *expression* as *name*, *in } ``` -> By default, if the list `a, b, c` becomes `a, c`, Svelte will *remove* the third block and *change* the second from `b` to `c`, rather than removing `b`. If that's not what you want, use a [keyed each block](guide#keyed-each-blocks). +> By default, if the list `a, b, c` becomes `a, c`, Svelte will *remove* the third block and *change* the second from `b` to `c`, rather than removing `b`. If that's not what you want, use a [keyed each block](docs#keyed-each-blocks). You can use destructuring patterns on the elements of the array: @@ -237,7 +237,7 @@ If the expression in `{#await expression}` *isn't* a promise, Svelte skips ahead ### Directives -Directives allow you to add special instructions for adding [event handlers](guide#event-handlers), [bindings](guide#bindings), [transitions](guide#transitions) and so on. We'll cover each of those in later stages of this guide – for now, all you need to know is that directives can be identified by the `:` character: +Directives allow you to add special instructions for adding [event handlers](docs#event-handlers), [bindings](docs#bindings), [transitions](docs#transitions) and so on. We'll cover each of those in later stages of this guide – for now, all you need to know is that directives can be identified by the `:` character: ```html diff --git a/site/content/guide/03-scoped-styles.md b/site/content/guide/03-scoped-styles.md index 9a96da84db..b9ba69b981 100644 --- a/site/content/guide/03-scoped-styles.md +++ b/site/content/guide/03-scoped-styles.md @@ -30,7 +30,7 @@ Open the example above in the REPL and inspect the element to see what has happe This is vastly simpler than achieving the same effect via [Shadow DOM](http://caniuse.com/#search=shadow%20dom) and works everywhere without polyfills. -> Svelte will add a ` + +

This is a paragraph.

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/04-styling/app-b/App.svelte b/site/content/tutorial/01-introduction/04-styling/app-b/App.svelte new file mode 100644 index 0000000000..ab87af83d8 --- /dev/null +++ b/site/content/tutorial/01-introduction/04-styling/app-b/App.svelte @@ -0,0 +1,9 @@ + + +

This is a paragraph.

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/04-styling/text.md b/site/content/tutorial/01-introduction/04-styling/text.md new file mode 100644 index 0000000000..9f285d2f51 --- /dev/null +++ b/site/content/tutorial/01-introduction/04-styling/text.md @@ -0,0 +1,19 @@ +--- +title: Styling +--- + +Just like in HTML, you can add a ` + +

This is a paragraph.

+``` + +Importantly, these rules are *scoped to the component*. You won't accidentally change the style of `

` elements elsewhere in your app, as we'll see in the next step. \ No newline at end of file diff --git a/site/content/tutorial/01-introduction/05-nested-components/app-a/App.svelte b/site/content/tutorial/01-introduction/05-nested-components/app-a/App.svelte new file mode 100644 index 0000000000..ab87af83d8 --- /dev/null +++ b/site/content/tutorial/01-introduction/05-nested-components/app-a/App.svelte @@ -0,0 +1,9 @@ + + +

This is a paragraph.

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/05-nested-components/app-a/Nested.svelte b/site/content/tutorial/01-introduction/05-nested-components/app-a/Nested.svelte new file mode 100644 index 0000000000..5297ab1044 --- /dev/null +++ b/site/content/tutorial/01-introduction/05-nested-components/app-a/Nested.svelte @@ -0,0 +1 @@ +

This is another paragraph.

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/05-nested-components/app-b/App.svelte b/site/content/tutorial/01-introduction/05-nested-components/app-b/App.svelte new file mode 100644 index 0000000000..9ba76665bf --- /dev/null +++ b/site/content/tutorial/01-introduction/05-nested-components/app-b/App.svelte @@ -0,0 +1,14 @@ + + + + +

This is a paragraph.

+ \ No newline at end of file diff --git a/site/content/tutorial/01-introduction/05-nested-components/app-b/Nested.svelte b/site/content/tutorial/01-introduction/05-nested-components/app-b/Nested.svelte new file mode 100644 index 0000000000..5297ab1044 --- /dev/null +++ b/site/content/tutorial/01-introduction/05-nested-components/app-b/Nested.svelte @@ -0,0 +1 @@ +

This is another paragraph.

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/05-nested-components/text.md b/site/content/tutorial/01-introduction/05-nested-components/text.md new file mode 100644 index 0000000000..f1406f93db --- /dev/null +++ b/site/content/tutorial/01-introduction/05-nested-components/text.md @@ -0,0 +1,22 @@ +--- +title: Nested components +--- + +It would be impractical to put your entire app in a single component. Instead, we can import components from other files and include them as though we were including elements. + +Add a ` +``` + +...then add it to the markup: + +```html +

This is a paragraph.

+ +``` + +Notice that even though `Nested.svelte` has a `

` element, the styles from `App.svelte` don't leak in. \ No newline at end of file diff --git a/site/content/tutorial/01-introduction/06-html-tags/app-a/App.svelte b/site/content/tutorial/01-introduction/06-html-tags/app-a/App.svelte new file mode 100644 index 0000000000..e366d78865 --- /dev/null +++ b/site/content/tutorial/01-introduction/06-html-tags/app-a/App.svelte @@ -0,0 +1,5 @@ + + +

{string}

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/06-html-tags/app-b/App.svelte b/site/content/tutorial/01-introduction/06-html-tags/app-b/App.svelte new file mode 100644 index 0000000000..527e9a4830 --- /dev/null +++ b/site/content/tutorial/01-introduction/06-html-tags/app-b/App.svelte @@ -0,0 +1,5 @@ + + +

{@html string}

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/06-html-tags/text.md b/site/content/tutorial/01-introduction/06-html-tags/text.md new file mode 100644 index 0000000000..fdc8a576ff --- /dev/null +++ b/site/content/tutorial/01-introduction/06-html-tags/text.md @@ -0,0 +1,15 @@ +--- +title: HTML tags +--- + +Ordinarily, strings are inserted as plain text, meaning that characters like `<` and `>` have no special meaning. + +But sometimes you need to render HTML directly into a component. For example, the words you're reading right now exist in a markdown file that gets included on this page as a blob of HTML. + +In Svelte, you do this with the special `{@html ...}` tag: + +```html +

{@html string}

+``` + +> Svelte doesn't perform any sanitization of the data before it gets inserted into the DOM. In other words, it's critical that you manually escape HTML that comes from sources you don't trust, otherwise you risk exposing your users to XSS attacks. \ No newline at end of file diff --git a/site/content/tutorial/01-introduction/07-making-an-app/app-a/App.svelte b/site/content/tutorial/01-introduction/07-making-an-app/app-a/App.svelte new file mode 100644 index 0000000000..c4de2848c2 --- /dev/null +++ b/site/content/tutorial/01-introduction/07-making-an-app/app-a/App.svelte @@ -0,0 +1 @@ +

What now?

\ No newline at end of file diff --git a/site/content/tutorial/01-introduction/07-making-an-app/text.md b/site/content/tutorial/01-introduction/07-making-an-app/text.md new file mode 100644 index 0000000000..136c6b5f07 --- /dev/null +++ b/site/content/tutorial/01-introduction/07-making-an-app/text.md @@ -0,0 +1,31 @@ +--- +title: Making an app +--- + +This tutorial is designed to get you familiar with the process of writing components. But at some point, you'll want to start writing components in the comfort of your own text editor. + +First, you'll need to integrate Svelte with a build tool. Popular choices are: + +* [Rollup](https://rollupjs.org) / [rollup-plugin-svelte](https://github.com/rollup/rollup-plugin-svelte) +* [webpack](https://webpack.js.org/) / [svelte-loader](https://github.com/sveltejs/svelte-loader) +* [Parcel](https://parceljs.org/) / [parcel-plugin-svelte](https://github.com/DeMoorJasper/parcel-plugin-svelte) + +Don't worry if you're relatively new to web development and haven't used these tools before. We've prepared a simple step-by-step guide, [Svelte for new developers](blog/svelte-for-new-developers), which walks you through the process. + +You'll also want to configure your text editor to treat `.svelte` files the same as `.html` for the sake of syntax highlighting. [Read this guide to learn how](blog/setting-up-your-editor). + +Then, once you've got your project set up, using Svelte components is easy. The compiler turns each component into a regular JavaScript class — just import it and instantiate with `new`: + +```js +import App from './App.svelte'; + +const app = new App({ + target: document.body, + props: { + // we'll learn about props later + answer: 42 + } +}); +``` + +You can then interact with `app` using the [component API](docs/component-api) if you need to. diff --git a/site/content/tutorial/01-introduction/meta.json b/site/content/tutorial/01-introduction/meta.json new file mode 100644 index 0000000000..5c8f7bc10b --- /dev/null +++ b/site/content/tutorial/01-introduction/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Introduction" +} \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte b/site/content/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte new file mode 100644 index 0000000000..a3b89cc128 --- /dev/null +++ b/site/content/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte b/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte new file mode 100644 index 0000000000..bc50d74cfc --- /dev/null +++ b/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md b/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md new file mode 100644 index 0000000000..b0909f1feb --- /dev/null +++ b/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md @@ -0,0 +1,21 @@ +--- +title: Assignments +--- + +At the heart of Svelte is a powerful system of *reactivity* for keeping the DOM in sync with your application state — for example, in response to an event. + +To demonstrate it, we first need to wire up an event handler. Replace line 9 with this: + +```html + \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/02-reactive-declarations/app-b/App.svelte b/site/content/tutorial/02-reactivity/02-reactive-declarations/app-b/App.svelte new file mode 100644 index 0000000000..a9fc207851 --- /dev/null +++ b/site/content/tutorial/02-reactivity/02-reactive-declarations/app-b/App.svelte @@ -0,0 +1,14 @@ + + + + +

{count} doubled is {doubled}

\ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/02-reactive-declarations/text.md b/site/content/tutorial/02-reactivity/02-reactive-declarations/text.md new file mode 100644 index 0000000000..365908cf22 --- /dev/null +++ b/site/content/tutorial/02-reactivity/02-reactive-declarations/text.md @@ -0,0 +1,22 @@ +--- +title: Declarations +--- + +Svelte automatically updates the DOM when your component's state changes. Often, some parts of a component's state need to be computed from *other* parts (such as a `fullname` derived from a `firstname` and a `lastname`), and recomputed whenever they change. + +For these, we have *reactive declarations*. They look like this: + +```js +let count = 0; +$: doubled = count * 2; +``` + +> Don't worry if this looks a little alien. It's valid (if unconventional) JavaScript, which Svelte interprets to mean 're-run this code whenever any of the referenced values change'. Once you get used to it, there's no going back. + +Let's use `doubled` in our markup: + +```html +

{count} doubled is {doubled}

+``` + +Of course, you could just write `{count * 2}` in the markup instead — you don't have to use reactive values. Reactive values become particularly valuable when you need to reference them multiple times, or you have values that depend on *other* reactive values. \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/03-reactive-statements/app-a/App.svelte b/site/content/tutorial/02-reactivity/03-reactive-statements/app-a/App.svelte new file mode 100644 index 0000000000..bc50d74cfc --- /dev/null +++ b/site/content/tutorial/02-reactivity/03-reactive-statements/app-a/App.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/03-reactive-statements/app-b/App.svelte b/site/content/tutorial/02-reactivity/03-reactive-statements/app-b/App.svelte new file mode 100644 index 0000000000..f757be6f51 --- /dev/null +++ b/site/content/tutorial/02-reactivity/03-reactive-statements/app-b/App.svelte @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/03-reactive-statements/text.md b/site/content/tutorial/02-reactivity/03-reactive-statements/text.md new file mode 100644 index 0000000000..1b0e90b7d5 --- /dev/null +++ b/site/content/tutorial/02-reactivity/03-reactive-statements/text.md @@ -0,0 +1,27 @@ +--- +title: Statements +--- + +We're not limited to declaring reactive *values* — we can also run arbitrary *statements* reactively. For example, we can log the value of `count` whenever it changes: + +```js +$: console.log(`the count is ${count}`); +``` + +You can easily group statements together with a block: + +```js +$: { + console.log(`the count is ${count}`); + alert(`I SAID THE COUNT IS ${count}`); +} +``` + +You can even put the `$:` in front of things like `if` blocks: + +```js +$: if (count >= 10) { + alert(`count is dangerously high!`); + count = 9; +} +``` \ No newline at end of file diff --git a/site/content/tutorial/02-reactivity/meta.json b/site/content/tutorial/02-reactivity/meta.json new file mode 100644 index 0000000000..c908815e04 --- /dev/null +++ b/site/content/tutorial/02-reactivity/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Reactivity" +} \ No newline at end of file diff --git a/site/content/tutorial/03-props/01-declaring-props/app-a/App.svelte b/site/content/tutorial/03-props/01-declaring-props/app-a/App.svelte new file mode 100644 index 0000000000..79d7e6b789 --- /dev/null +++ b/site/content/tutorial/03-props/01-declaring-props/app-a/App.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/03-props/01-declaring-props/app-a/Nested.svelte b/site/content/tutorial/03-props/01-declaring-props/app-a/Nested.svelte new file mode 100644 index 0000000000..da9270c7a2 --- /dev/null +++ b/site/content/tutorial/03-props/01-declaring-props/app-a/Nested.svelte @@ -0,0 +1,5 @@ + + +

The answer is {answer}

\ No newline at end of file diff --git a/site/content/tutorial/03-props/01-declaring-props/app-b/App.svelte b/site/content/tutorial/03-props/01-declaring-props/app-b/App.svelte new file mode 100644 index 0000000000..79d7e6b789 --- /dev/null +++ b/site/content/tutorial/03-props/01-declaring-props/app-b/App.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/03-props/01-declaring-props/app-b/Nested.svelte b/site/content/tutorial/03-props/01-declaring-props/app-b/Nested.svelte new file mode 100644 index 0000000000..ecd3cb6254 --- /dev/null +++ b/site/content/tutorial/03-props/01-declaring-props/app-b/Nested.svelte @@ -0,0 +1,5 @@ + + +

The answer is {answer}

\ No newline at end of file diff --git a/site/content/tutorial/03-props/01-declaring-props/text.md b/site/content/tutorial/03-props/01-declaring-props/text.md new file mode 100644 index 0000000000..26e6762106 --- /dev/null +++ b/site/content/tutorial/03-props/01-declaring-props/text.md @@ -0,0 +1,15 @@ +--- +title: Declaring props +--- + +So far, we've dealt exclusively with internal state — that is to say, the values are only accessible within a given component. + +In any real application, you'll need to pass data from one component down to its children. To do that, we need to declare *properties*, generally shortened to 'props'. In Svelte, we do that with the `export` keyword. Edit the `Nested.svelte` component: + +```html + +``` + +> Just like `$:`, this may feel a little weird at first. That's not how `export` normally works in JavaScript modules! Just roll with it for now — it'll soon become second nature. \ No newline at end of file diff --git a/site/content/tutorial/03-props/02-default-values/app-a/App.svelte b/site/content/tutorial/03-props/02-default-values/app-a/App.svelte new file mode 100644 index 0000000000..79d7e6b789 --- /dev/null +++ b/site/content/tutorial/03-props/02-default-values/app-a/App.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/03-props/02-default-values/app-a/Nested.svelte b/site/content/tutorial/03-props/02-default-values/app-a/Nested.svelte new file mode 100644 index 0000000000..ecd3cb6254 --- /dev/null +++ b/site/content/tutorial/03-props/02-default-values/app-a/Nested.svelte @@ -0,0 +1,5 @@ + + +

The answer is {answer}

\ No newline at end of file diff --git a/site/content/tutorial/03-props/02-default-values/app-b/App.svelte b/site/content/tutorial/03-props/02-default-values/app-b/App.svelte new file mode 100644 index 0000000000..f9d63b30d6 --- /dev/null +++ b/site/content/tutorial/03-props/02-default-values/app-b/App.svelte @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/site/content/tutorial/03-props/02-default-values/app-b/Nested.svelte b/site/content/tutorial/03-props/02-default-values/app-b/Nested.svelte new file mode 100644 index 0000000000..35ee5c9f88 --- /dev/null +++ b/site/content/tutorial/03-props/02-default-values/app-b/Nested.svelte @@ -0,0 +1,5 @@ + + +

The answer is {answer}

\ No newline at end of file diff --git a/site/content/tutorial/03-props/02-default-values/text.md b/site/content/tutorial/03-props/02-default-values/text.md new file mode 100644 index 0000000000..dda6a370fe --- /dev/null +++ b/site/content/tutorial/03-props/02-default-values/text.md @@ -0,0 +1,18 @@ +--- +title: Default values +--- + +We can easily specify default values for props: + +```html + +``` + +If we now instantiate the component without an `answer` prop, it will fall back to the default: + +```html + + +``` \ No newline at end of file diff --git a/site/content/tutorial/03-props/03-spread-props/app-a/App.svelte b/site/content/tutorial/03-props/03-spread-props/app-a/App.svelte new file mode 100644 index 0000000000..640e853c57 --- /dev/null +++ b/site/content/tutorial/03-props/03-spread-props/app-a/App.svelte @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/03-props/03-spread-props/app-a/Info.svelte b/site/content/tutorial/03-props/03-spread-props/app-a/Info.svelte new file mode 100644 index 0000000000..7412398244 --- /dev/null +++ b/site/content/tutorial/03-props/03-spread-props/app-a/Info.svelte @@ -0,0 +1,12 @@ + + +

+ The {name} package is {speed} fast. + Download version {version} from npm + and learn more here +

\ No newline at end of file diff --git a/site/content/tutorial/03-props/03-spread-props/app-b/App.svelte b/site/content/tutorial/03-props/03-spread-props/app-b/App.svelte new file mode 100644 index 0000000000..f40d3b89c8 --- /dev/null +++ b/site/content/tutorial/03-props/03-spread-props/app-b/App.svelte @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/03-props/03-spread-props/app-b/Info.svelte b/site/content/tutorial/03-props/03-spread-props/app-b/Info.svelte new file mode 100644 index 0000000000..7412398244 --- /dev/null +++ b/site/content/tutorial/03-props/03-spread-props/app-b/Info.svelte @@ -0,0 +1,12 @@ + + +

+ The {name} package is {speed} fast. + Download version {version} from npm + and learn more here +

\ No newline at end of file diff --git a/site/content/tutorial/03-props/03-spread-props/text.md b/site/content/tutorial/03-props/03-spread-props/text.md new file mode 100644 index 0000000000..aa7d4dc831 --- /dev/null +++ b/site/content/tutorial/03-props/03-spread-props/text.md @@ -0,0 +1,11 @@ +--- +title: Spread props +--- + +If you have an object of properties, you can 'spread' them on to a component instead of specifying each one: + +```html + +``` + +> Conversely, if you need to reference all the props that were passed into a component, including ones that weren't declared with `export`, you can do so by accessing `$$props` directly. It's not generally recommended, as it's difficult for Svelte to optimise, but it's useful in rare cases. \ No newline at end of file diff --git a/site/content/tutorial/03-props/meta.json b/site/content/tutorial/03-props/meta.json new file mode 100644 index 0000000000..7b9e0a2783 --- /dev/null +++ b/site/content/tutorial/03-props/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Props" +} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/01-if-blocks/app-a/App.svelte b/site/content/tutorial/04-logic/01-if-blocks/app-a/App.svelte new file mode 100644 index 0000000000..38efdc9ddd --- /dev/null +++ b/site/content/tutorial/04-logic/01-if-blocks/app-a/App.svelte @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/site/content/tutorial/04-logic/01-if-blocks/app-b/App.svelte b/site/content/tutorial/04-logic/01-if-blocks/app-b/App.svelte new file mode 100644 index 0000000000..01b8867ade --- /dev/null +++ b/site/content/tutorial/04-logic/01-if-blocks/app-b/App.svelte @@ -0,0 +1,19 @@ + + +{#if user.loggedIn} + +{/if} + +{#if !user.loggedIn} + +{/if} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/01-if-blocks/text.md b/site/content/tutorial/04-logic/01-if-blocks/text.md new file mode 100644 index 0000000000..33915070cb --- /dev/null +++ b/site/content/tutorial/04-logic/01-if-blocks/text.md @@ -0,0 +1,23 @@ +--- +title: If blocks +--- + +HTML doesn't have a way of expressing *logic*, like conditionals and loops. Svelte does. + +To conditionally render some markup, we wrap it in an `if` block: + +```html +{#if user.loggedIn} + +{/if} + +{#if !user.loggedIn} + +{/if} +``` + +Try it — update the component, and click on the buttons. \ No newline at end of file diff --git a/site/content/tutorial/04-logic/02-else-blocks/app-a/App.svelte b/site/content/tutorial/04-logic/02-else-blocks/app-a/App.svelte new file mode 100644 index 0000000000..01b8867ade --- /dev/null +++ b/site/content/tutorial/04-logic/02-else-blocks/app-a/App.svelte @@ -0,0 +1,19 @@ + + +{#if user.loggedIn} + +{/if} + +{#if !user.loggedIn} + +{/if} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/02-else-blocks/app-b/App.svelte b/site/content/tutorial/04-logic/02-else-blocks/app-b/App.svelte new file mode 100644 index 0000000000..c82565c2f7 --- /dev/null +++ b/site/content/tutorial/04-logic/02-else-blocks/app-b/App.svelte @@ -0,0 +1,17 @@ + + +{#if user.loggedIn} + +{:else} + +{/if} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/02-else-blocks/text.md b/site/content/tutorial/04-logic/02-else-blocks/text.md new file mode 100644 index 0000000000..d25a7d3897 --- /dev/null +++ b/site/content/tutorial/04-logic/02-else-blocks/text.md @@ -0,0 +1,19 @@ +--- +title: Else blocks +--- + +Since the two conditions — `if user.loggedIn` and `if !user.loggedIn` — are mutually exclusive, we can simplify this component slightly by using an `else` block: + +```html +{#if user.loggedIn} + +{:else} + +{/if} +``` + +> A `#` character always indicates a *block opening* tag. A `/` character always indicates a *block closing* tag. A `:` character, as in `{:else}`, indicates a *block continuation* tag. Don't worry — you've already learned almost all the syntax Svelte adds to HTML. \ No newline at end of file diff --git a/site/content/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte b/site/content/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte new file mode 100644 index 0000000000..efffa9af2b --- /dev/null +++ b/site/content/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte @@ -0,0 +1,13 @@ + + +{#if x > 10} +

{x} is greater than 10

+{:else} + {#if 5 > x} +

{x} is less than 5

+ {:else} +

{x} is between 5 and 10

+ {/if} +{/if} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/03-else-if-blocks/app-b/App.svelte b/site/content/tutorial/04-logic/03-else-if-blocks/app-b/App.svelte new file mode 100644 index 0000000000..9102618ff4 --- /dev/null +++ b/site/content/tutorial/04-logic/03-else-if-blocks/app-b/App.svelte @@ -0,0 +1,11 @@ + + +{#if x > 10} +

{x} is greater than 10

+{:else if 5 > x} +

{x} is less than 5

+{:else} +

{x} is between 5 and 10

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/03-else-if-blocks/text.md b/site/content/tutorial/04-logic/03-else-if-blocks/text.md new file mode 100644 index 0000000000..18faeacfe6 --- /dev/null +++ b/site/content/tutorial/04-logic/03-else-if-blocks/text.md @@ -0,0 +1,15 @@ +--- +title: Else-if blocks +--- + +Multiple conditions can be 'chained' together with `else if`: + +```html +{#if x > 10} +

{x} is greater than 10

+{:else if 5 > x} +

{x} is less than 5

+{:else} +

{x} is between 5 and 10

+{/if} +``` \ No newline at end of file diff --git a/site/content/tutorial/04-logic/04-each-blocks/app-a/App.svelte b/site/content/tutorial/04-logic/04-each-blocks/app-a/App.svelte new file mode 100644 index 0000000000..34fb2cebfc --- /dev/null +++ b/site/content/tutorial/04-logic/04-each-blocks/app-a/App.svelte @@ -0,0 +1,17 @@ + + +

The Famous Cats of YouTube

+ + \ No newline at end of file diff --git a/site/content/tutorial/04-logic/04-each-blocks/app-b/App.svelte b/site/content/tutorial/04-logic/04-each-blocks/app-b/App.svelte new file mode 100644 index 0000000000..6ea5097be2 --- /dev/null +++ b/site/content/tutorial/04-logic/04-each-blocks/app-b/App.svelte @@ -0,0 +1,17 @@ + + +

The Famous Cats of YouTube

+ + \ No newline at end of file diff --git a/site/content/tutorial/04-logic/04-each-blocks/text.md b/site/content/tutorial/04-logic/04-each-blocks/text.md new file mode 100644 index 0000000000..886990f5a0 --- /dev/null +++ b/site/content/tutorial/04-logic/04-each-blocks/text.md @@ -0,0 +1,29 @@ +--- +title: Each blocks +--- + +If you need to loop over lists of data, use an `each` block: + +```html + +``` + +> The expression (`cats`, in this case) can be any array or array-like object (i.e. it has a `length` property). You can loop over generic iterables with `each [...iterable]`. + +You can get the current *index* as a second argument, like so: + +```html +{#each cats as cat, i} +
  • + {i + 1}: {cat.name} +
  • +{/each} +``` + +If you prefer, you can use destructuring — `each cats as { id, name }` — and replace `cat.id` and `cat.name` with `id` and `name`. \ No newline at end of file diff --git a/site/content/tutorial/04-logic/05-keyed-each-blocks/app-a/App.svelte b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-a/App.svelte new file mode 100644 index 0000000000..3d4a2c801d --- /dev/null +++ b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-a/App.svelte @@ -0,0 +1,23 @@ + + + + +{#each things as thing} + +{/each} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte new file mode 100644 index 0000000000..4e86d32109 --- /dev/null +++ b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte @@ -0,0 +1,9 @@ + + +

    {valueAtStart} / {value}

    \ No newline at end of file diff --git a/site/content/tutorial/04-logic/05-keyed-each-blocks/app-b/App.svelte b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-b/App.svelte new file mode 100644 index 0000000000..73a2dcc609 --- /dev/null +++ b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-b/App.svelte @@ -0,0 +1,23 @@ + + + + +{#each things as thing (thing.id)} + +{/each} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte new file mode 100644 index 0000000000..4e86d32109 --- /dev/null +++ b/site/content/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte @@ -0,0 +1,9 @@ + + +

    {valueAtStart} / {value}

    \ No newline at end of file diff --git a/site/content/tutorial/04-logic/05-keyed-each-blocks/text.md b/site/content/tutorial/04-logic/05-keyed-each-blocks/text.md new file mode 100644 index 0000000000..d0dec628b6 --- /dev/null +++ b/site/content/tutorial/04-logic/05-keyed-each-blocks/text.md @@ -0,0 +1,17 @@ +--- +title: Keyed each blocks +--- + +By default, when you modify the value of an `each` block, it will add and remove items at the *end* of the block, and update any values that have changed. That might not be what you want. + +It's easier to show why than to explain. Click the 'Remove first item' button a few times, and notice that it's removing `` components from the end and updating the `value` for those that remain. Instead, we'd like to remove the first `` component and leave the rest unaffected. + +To do that, we specify a unique identifier for the `each` block: + +```html +{#each things as thing (thing.id)} + +{/each} +``` + +The `(thing.id)` tells Svelte how to figure out what changed. \ No newline at end of file diff --git a/site/content/tutorial/04-logic/06-await-blocks/app-a/App.svelte b/site/content/tutorial/04-logic/06-await-blocks/app-a/App.svelte new file mode 100644 index 0000000000..7ac5ca3c9e --- /dev/null +++ b/site/content/tutorial/04-logic/06-await-blocks/app-a/App.svelte @@ -0,0 +1,25 @@ + + + + + +

    {promise}

    \ No newline at end of file diff --git a/site/content/tutorial/04-logic/06-await-blocks/app-b/App.svelte b/site/content/tutorial/04-logic/06-await-blocks/app-b/App.svelte new file mode 100644 index 0000000000..8c8036c0f1 --- /dev/null +++ b/site/content/tutorial/04-logic/06-await-blocks/app-b/App.svelte @@ -0,0 +1,30 @@ + + + + +{#await promise} +

    ...waiting

    +{:then number} +

    The number is {number}

    +{:catch error} +

    {error.message}

    +{/await} \ No newline at end of file diff --git a/site/content/tutorial/04-logic/06-await-blocks/text.md b/site/content/tutorial/04-logic/06-await-blocks/text.md new file mode 100644 index 0000000000..0d47dcde95 --- /dev/null +++ b/site/content/tutorial/04-logic/06-await-blocks/text.md @@ -0,0 +1,25 @@ +--- +title: Await blocks +--- + +Most web applications have to deal with asynchronous data at some point. Svelte makes it easy to *await* the value of [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) directly in your markup: + +```html +{#await promise} +

    ...waiting

    +{:then number} +

    The number is {number}

    +{:catch error} +

    {error.message}

    +{/await} +``` + +> Only the most recent `promise` is considered, meaning you don't need to worry about race conditions. + +If you know that your promise can't reject, you can omit the `catch` block. You can also omit the first block if you don't want to show anything until the promise resolves: + +```html +{#await promise then value} +

    the value is {value}

    +{/await} +``` \ No newline at end of file diff --git a/site/content/tutorial/04-logic/meta.json b/site/content/tutorial/04-logic/meta.json new file mode 100644 index 0000000000..3ecf1ccee2 --- /dev/null +++ b/site/content/tutorial/04-logic/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Logic" +} \ No newline at end of file diff --git a/site/content/tutorial/05-events/01-dom-events/app-a/App.svelte b/site/content/tutorial/05-events/01-dom-events/app-a/App.svelte new file mode 100644 index 0000000000..dce67f6368 --- /dev/null +++ b/site/content/tutorial/05-events/01-dom-events/app-a/App.svelte @@ -0,0 +1,16 @@ + + + + +
    + The mouse position is {m.x} x {m.y} +
    \ No newline at end of file diff --git a/site/content/tutorial/05-events/01-dom-events/app-b/App.svelte b/site/content/tutorial/05-events/01-dom-events/app-b/App.svelte new file mode 100644 index 0000000000..f26112f06c --- /dev/null +++ b/site/content/tutorial/05-events/01-dom-events/app-b/App.svelte @@ -0,0 +1,16 @@ + + + + +
    + The mouse position is {m.x} x {m.y} +
    \ No newline at end of file diff --git a/site/content/tutorial/05-events/01-dom-events/text.md b/site/content/tutorial/05-events/01-dom-events/text.md new file mode 100644 index 0000000000..1c08c9159a --- /dev/null +++ b/site/content/tutorial/05-events/01-dom-events/text.md @@ -0,0 +1,11 @@ +--- +title: DOM events +--- + +As we've briefly seen already, you can listen to any event on an element with the `on:` directive: + +```html +
    + The mouse position is {m.x} x {m.y} +
    +``` \ No newline at end of file diff --git a/site/content/tutorial/05-events/02-inline-handlers/app-a/App.svelte b/site/content/tutorial/05-events/02-inline-handlers/app-a/App.svelte new file mode 100644 index 0000000000..f26112f06c --- /dev/null +++ b/site/content/tutorial/05-events/02-inline-handlers/app-a/App.svelte @@ -0,0 +1,16 @@ + + + + +
    + The mouse position is {m.x} x {m.y} +
    \ No newline at end of file diff --git a/site/content/tutorial/05-events/02-inline-handlers/app-b/App.svelte b/site/content/tutorial/05-events/02-inline-handlers/app-b/App.svelte new file mode 100644 index 0000000000..f0fd6ff17a --- /dev/null +++ b/site/content/tutorial/05-events/02-inline-handlers/app-b/App.svelte @@ -0,0 +1,11 @@ + + + + +
    + The mouse position is {m.x} x {m.y} +
    \ No newline at end of file diff --git a/site/content/tutorial/05-events/02-inline-handlers/text.md b/site/content/tutorial/05-events/02-inline-handlers/text.md new file mode 100644 index 0000000000..0ec177cb44 --- /dev/null +++ b/site/content/tutorial/05-events/02-inline-handlers/text.md @@ -0,0 +1,15 @@ +--- +title: Inline handlers +--- + +You can also declare event handlers inline: + +```html +
    + The mouse position is {m.x} x {m.y} +
    +``` + +The quote marks are optional, but they're helpful for syntax highlighting in some environments. + +> In some frameworks you may see recommendations to avoid inline event handlers for performance reasons, particularly inside loops. That advice doesn't apply to Svelte — the compiler will always do the right thing, whichever form you choose. \ No newline at end of file diff --git a/site/content/tutorial/05-events/03-event-modifiers/app-a/App.svelte b/site/content/tutorial/05-events/03-event-modifiers/app-a/App.svelte new file mode 100644 index 0000000000..e49115d4f1 --- /dev/null +++ b/site/content/tutorial/05-events/03-event-modifiers/app-a/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/03-event-modifiers/app-b/App.svelte b/site/content/tutorial/05-events/03-event-modifiers/app-b/App.svelte new file mode 100644 index 0000000000..94df49cb2d --- /dev/null +++ b/site/content/tutorial/05-events/03-event-modifiers/app-b/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/03-event-modifiers/text.md b/site/content/tutorial/05-events/03-event-modifiers/text.md new file mode 100644 index 0000000000..8927344656 --- /dev/null +++ b/site/content/tutorial/05-events/03-event-modifiers/text.md @@ -0,0 +1,27 @@ +--- +title: Event modifiers +--- + +DOM event handlers can have *modifiers* that alter their behaviour. For example, a handler with a `once` modifier will only run a single time: + +```html + + + +``` + +The full list of modifiers: + +* `preventDefault` — calls `event.preventDefault()` before running the handler. Useful for e.g. client-side form handling +* `stopPropagation` — calls `event.stopPropagation()`, preventing the event reaching the next element +* `passive` — improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so) +* `capture` — fires the handler during the *capture* phase instead of the *bubbling* phase +* `once` — remove the handler after the first time it runs + +You can chain modifiers together, e.g. `on:click|once|capture={...}`. \ No newline at end of file diff --git a/site/content/tutorial/05-events/04-component-events/app-a/App.svelte b/site/content/tutorial/05-events/04-component-events/app-a/App.svelte new file mode 100644 index 0000000000..a8d14a368a --- /dev/null +++ b/site/content/tutorial/05-events/04-component-events/app-a/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/04-component-events/app-a/Inner.svelte b/site/content/tutorial/05-events/04-component-events/app-a/Inner.svelte new file mode 100644 index 0000000000..0a7980c45c --- /dev/null +++ b/site/content/tutorial/05-events/04-component-events/app-a/Inner.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/04-component-events/app-b/App.svelte b/site/content/tutorial/05-events/04-component-events/app-b/App.svelte new file mode 100644 index 0000000000..a8d14a368a --- /dev/null +++ b/site/content/tutorial/05-events/04-component-events/app-b/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/04-component-events/app-b/Inner.svelte b/site/content/tutorial/05-events/04-component-events/app-b/Inner.svelte new file mode 100644 index 0000000000..6ac8301f24 --- /dev/null +++ b/site/content/tutorial/05-events/04-component-events/app-b/Inner.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/04-component-events/text.md b/site/content/tutorial/05-events/04-component-events/text.md new file mode 100644 index 0000000000..222a292b5f --- /dev/null +++ b/site/content/tutorial/05-events/04-component-events/text.md @@ -0,0 +1,21 @@ +--- +title: Component events +--- + +Components can also dispatch events. To do so, they must create an event dispatcher. Update `Inner.svelte`: + +```html + +``` + +> `createEventDispatcher` must be called when the component is first instantiated — you can't do it later inside e.g. a `setTimeout` callback. This links `dispatch` to the component instance. \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/app-a/App.svelte b/site/content/tutorial/05-events/05-event-forwarding/app-a/App.svelte new file mode 100644 index 0000000000..973df50f0a --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/app-a/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/app-a/Inner.svelte b/site/content/tutorial/05-events/05-event-forwarding/app-a/Inner.svelte new file mode 100644 index 0000000000..6ac8301f24 --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/app-a/Inner.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/app-a/Outer.svelte b/site/content/tutorial/05-events/05-event-forwarding/app-a/Outer.svelte new file mode 100644 index 0000000000..6c13070e79 --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/app-a/Outer.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/app-b/App.svelte b/site/content/tutorial/05-events/05-event-forwarding/app-b/App.svelte new file mode 100644 index 0000000000..973df50f0a --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/app-b/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/app-b/Inner.svelte b/site/content/tutorial/05-events/05-event-forwarding/app-b/Inner.svelte new file mode 100644 index 0000000000..6ac8301f24 --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/app-b/Inner.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/app-b/Outer.svelte b/site/content/tutorial/05-events/05-event-forwarding/app-b/Outer.svelte new file mode 100644 index 0000000000..10c28f298a --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/app-b/Outer.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/05-event-forwarding/text.md b/site/content/tutorial/05-events/05-event-forwarding/text.md new file mode 100644 index 0000000000..b65a028f27 --- /dev/null +++ b/site/content/tutorial/05-events/05-event-forwarding/text.md @@ -0,0 +1,34 @@ +--- +title: Event forwarding +--- + +Unlike DOM events, component events don't *bubble*. If you want to listen to an event on some deeply nested component, the intermediate components must *forward* the event. + +In this case, we have the same `App.svelte` and `Inner.svelte` as in the [previous chapter](tutorial/component-events), but there's now an `Outer.svelte` component that contains ``. + +One way we could solve the problem is adding `createEventDispatcher` to `Outer.svelte`, listening for the `message` event, and creating a handler for it: + +```html + + + +``` + +But that's a lot of code to write, so Svelte gives us an equivalent shorthand — an `on:message` event directive without a value means 'forward all `message` events'. + +```html + + + +``` \ No newline at end of file diff --git a/site/content/tutorial/05-events/06-dom-event-forwarding/app-a/App.svelte b/site/content/tutorial/05-events/06-dom-event-forwarding/app-a/App.svelte new file mode 100644 index 0000000000..1429cae207 --- /dev/null +++ b/site/content/tutorial/05-events/06-dom-event-forwarding/app-a/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/06-dom-event-forwarding/app-a/FancyButton.svelte b/site/content/tutorial/05-events/06-dom-event-forwarding/app-a/FancyButton.svelte new file mode 100644 index 0000000000..9c3ae75809 --- /dev/null +++ b/site/content/tutorial/05-events/06-dom-event-forwarding/app-a/FancyButton.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/06-dom-event-forwarding/app-b/App.svelte b/site/content/tutorial/05-events/06-dom-event-forwarding/app-b/App.svelte new file mode 100644 index 0000000000..1429cae207 --- /dev/null +++ b/site/content/tutorial/05-events/06-dom-event-forwarding/app-b/App.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/06-dom-event-forwarding/app-b/FancyButton.svelte b/site/content/tutorial/05-events/06-dom-event-forwarding/app-b/FancyButton.svelte new file mode 100644 index 0000000000..75630ea99c --- /dev/null +++ b/site/content/tutorial/05-events/06-dom-event-forwarding/app-b/FancyButton.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/05-events/06-dom-event-forwarding/text.md b/site/content/tutorial/05-events/06-dom-event-forwarding/text.md new file mode 100644 index 0000000000..0959e1d98b --- /dev/null +++ b/site/content/tutorial/05-events/06-dom-event-forwarding/text.md @@ -0,0 +1,13 @@ +--- +title: DOM event forwarding +--- + +Event forwarding works for DOM events too. + +We want to get notified of clicks on our `` — to do that, we just need to forward `click` events on the ` +``` \ No newline at end of file diff --git a/site/content/tutorial/05-events/meta.json b/site/content/tutorial/05-events/meta.json new file mode 100644 index 0000000000..c5f088e208 --- /dev/null +++ b/site/content/tutorial/05-events/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Events" +} \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/01-text-inputs/app-a/App.svelte b/site/content/tutorial/06-bindings/01-text-inputs/app-a/App.svelte new file mode 100644 index 0000000000..f1c03071ed --- /dev/null +++ b/site/content/tutorial/06-bindings/01-text-inputs/app-a/App.svelte @@ -0,0 +1,7 @@ + + + + +

    Hello {name}!

    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/01-text-inputs/app-b/App.svelte b/site/content/tutorial/06-bindings/01-text-inputs/app-b/App.svelte new file mode 100644 index 0000000000..89dd54a709 --- /dev/null +++ b/site/content/tutorial/06-bindings/01-text-inputs/app-b/App.svelte @@ -0,0 +1,7 @@ + + + + +

    Hello {name}!

    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/01-text-inputs/text.md b/site/content/tutorial/06-bindings/01-text-inputs/text.md new file mode 100644 index 0000000000..0082586133 --- /dev/null +++ b/site/content/tutorial/06-bindings/01-text-inputs/text.md @@ -0,0 +1,15 @@ +--- +title: Text inputs +--- + +As a general rule, data flow in Svelte is *top down* — a parent component can set props on a child component, and a component can set attributes on an element, but not the other way around. + +Sometimes it's useful to break that rule. Take the case of the `` element in this component — we *could* add an `on:input` event handler that set the value of `name` to `event.target.value`, but it's a bit... boilerplatey. It gets even worse with other kinds of form element, as we'll see. + +Instead, we can use the `bind:value` directive: + +```html + +``` + +This means that not only will changes to the value of `name` update the input value, but changes to the input value will update `name`. \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte b/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte new file mode 100644 index 0000000000..ac4fadf012 --- /dev/null +++ b/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte @@ -0,0 +1,16 @@ + + + + + + +

    {a} + {b} = {a + b}

    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte b/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte new file mode 100644 index 0000000000..798d57e021 --- /dev/null +++ b/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte @@ -0,0 +1,16 @@ + + + + + + +

    {a} + {b} = {a + b}

    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/02-numeric-inputs/text.md b/site/content/tutorial/06-bindings/02-numeric-inputs/text.md new file mode 100644 index 0000000000..1ede244301 --- /dev/null +++ b/site/content/tutorial/06-bindings/02-numeric-inputs/text.md @@ -0,0 +1,12 @@ +--- +title: Numeric inputs +--- + +In the DOM, everything is a string. That's unhelpful when you're dealing with numeric inputs — `type="number"` and `type="range"` — as it means you have to remember to coerce `input.value` before using it. + +With `bind:value`, Svelte takes care of it for you: + +```html + + +``` \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/03-checkbox-inputs/app-a/App.svelte b/site/content/tutorial/06-bindings/03-checkbox-inputs/app-a/App.svelte new file mode 100644 index 0000000000..2847dad485 --- /dev/null +++ b/site/content/tutorial/06-bindings/03-checkbox-inputs/app-a/App.svelte @@ -0,0 +1,18 @@ + + + + +{#if yes} +

    Thank you. We will bombard your inbox and sell your personal details.

    +{:else} +

    You must opt in to continue. If you're not paying, you're the product.

    +{/if} + + \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/03-checkbox-inputs/app-b/App.svelte b/site/content/tutorial/06-bindings/03-checkbox-inputs/app-b/App.svelte new file mode 100644 index 0000000000..b82d31e783 --- /dev/null +++ b/site/content/tutorial/06-bindings/03-checkbox-inputs/app-b/App.svelte @@ -0,0 +1,18 @@ + + + + +{#if yes} +

    Thank you. We will bombard your inbox and sell your personal details.

    +{:else} +

    You must opt in to continue. If you're not paying, you're the product.

    +{/if} + + \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/03-checkbox-inputs/text.md b/site/content/tutorial/06-bindings/03-checkbox-inputs/text.md new file mode 100644 index 0000000000..621d9fbb7b --- /dev/null +++ b/site/content/tutorial/06-bindings/03-checkbox-inputs/text.md @@ -0,0 +1,9 @@ +--- +title: Checkbox inputs +--- + +Checkboxes are used for toggling between states. Instead of binding to `input.value`, we bind to `input.checked`: + +```html + +``` \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/04-group-inputs/app-a/App.svelte b/site/content/tutorial/06-bindings/04-group-inputs/app-a/App.svelte new file mode 100644 index 0000000000..5ea04f4e95 --- /dev/null +++ b/site/content/tutorial/06-bindings/04-group-inputs/app-a/App.svelte @@ -0,0 +1,54 @@ + + +

    Size

    + + + + + + + +

    Flavours

    + + + + + + + +{#if flavours.length === 0} +

    Please select at least one flavour

    +{:else if flavours.length > scoops} +

    Can't order more flavours than scoops!

    +{:else} +

    + You ordered {scoops} {scoops === 1 ? 'scoop' : 'scoops'} + of {join(flavours)} +

    +{/if} diff --git a/site/content/tutorial/06-bindings/04-group-inputs/app-b/App.svelte b/site/content/tutorial/06-bindings/04-group-inputs/app-b/App.svelte new file mode 100644 index 0000000000..a46c61c7e7 --- /dev/null +++ b/site/content/tutorial/06-bindings/04-group-inputs/app-b/App.svelte @@ -0,0 +1,52 @@ + + +

    Size

    + + + + + + + +

    Flavours

    + +{#each menu as flavour} + +{/each} + +{#if flavours.length === 0} +

    Please select at least one flavour

    +{:else if flavours.length > scoops} +

    Can't order more flavours than scoops!

    +{:else} +

    + You ordered {scoops} {scoops === 1 ? 'scoop' : 'scoops'} + of {join(flavours)} +

    +{/if} diff --git a/site/content/tutorial/06-bindings/04-group-inputs/text.md b/site/content/tutorial/06-bindings/04-group-inputs/text.md new file mode 100644 index 0000000000..97edb8db76 --- /dev/null +++ b/site/content/tutorial/06-bindings/04-group-inputs/text.md @@ -0,0 +1,36 @@ +--- +title: Group inputs +--- + +If you have multiple inputs relating to the same value, you can use `bind:group` along with the `value` attribute. Radio inputs in the same group are mutually exclusive; checkbox inputs in the same group form an array of selected values. + +Add `bind:group` to each input: + +```html + +``` + +In this case, we could make the code simpler by moving the checkbox inputs into an `each` block. First, add a `menu` variable to the ` + + + + + +{@html marked(value)} \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/05-textarea-inputs/app-b/App.svelte b/site/content/tutorial/06-bindings/05-textarea-inputs/app-b/App.svelte new file mode 100644 index 0000000000..be338bf47f --- /dev/null +++ b/site/content/tutorial/06-bindings/05-textarea-inputs/app-b/App.svelte @@ -0,0 +1,12 @@ + + + + + + +{@html marked(value)} \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/05-textarea-inputs/text.md b/site/content/tutorial/06-bindings/05-textarea-inputs/text.md new file mode 100644 index 0000000000..42763200c7 --- /dev/null +++ b/site/content/tutorial/06-bindings/05-textarea-inputs/text.md @@ -0,0 +1,17 @@ +--- +title: Textarea inputs +--- + +The ` +``` + +In cases like these, where the names match, we can also use a shorthand form: + +```html + +``` + +This applies to all bindings, not just textareas. \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/06-select-bindings/app-a/App.svelte b/site/content/tutorial/06-bindings/06-select-bindings/app-a/App.svelte new file mode 100644 index 0000000000..b6f50b935e --- /dev/null +++ b/site/content/tutorial/06-bindings/06-select-bindings/app-a/App.svelte @@ -0,0 +1,39 @@ + + + + +

    Insecurity questions

    + +
    + + + + + +
    + +

    selected question {selected ? selected.id : '[waiting...]'}

    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/06-select-bindings/app-b/App.svelte b/site/content/tutorial/06-bindings/06-select-bindings/app-b/App.svelte new file mode 100644 index 0000000000..3f1e7fa7e1 --- /dev/null +++ b/site/content/tutorial/06-bindings/06-select-bindings/app-b/App.svelte @@ -0,0 +1,39 @@ + + + + +

    Insecurity questions

    + +
    + + + + + +
    + +

    selected question {selected ? selected.id : '[waiting...]'}

    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/06-select-bindings/text.md b/site/content/tutorial/06-bindings/06-select-bindings/text.md new file mode 100644 index 0000000000..f4972557ab --- /dev/null +++ b/site/content/tutorial/06-bindings/06-select-bindings/text.md @@ -0,0 +1,13 @@ +--- +title: Select bindings +--- + +We can also use `bind:value` with ` +``` + +Note that the ` + {/each} + +``` \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/08-each-block-bindings/app-a/App.svelte b/site/content/tutorial/06-bindings/08-each-block-bindings/app-a/App.svelte new file mode 100644 index 0000000000..6a92e03cca --- /dev/null +++ b/site/content/tutorial/06-bindings/08-each-block-bindings/app-a/App.svelte @@ -0,0 +1,39 @@ + + +

    Todos

    + +{#each todos as todo} +
    + + + +
    +{/each} + + + + diff --git a/site/content/tutorial/06-bindings/08-each-block-bindings/app-b/App.svelte b/site/content/tutorial/06-bindings/08-each-block-bindings/app-b/App.svelte new file mode 100644 index 0000000000..92bdc7754f --- /dev/null +++ b/site/content/tutorial/06-bindings/08-each-block-bindings/app-b/App.svelte @@ -0,0 +1,39 @@ + + +

    Todos

    + +{#each todos as todo} +
    + + + +
    +{/each} + + + + diff --git a/site/content/tutorial/06-bindings/08-each-block-bindings/text.md b/site/content/tutorial/06-bindings/08-each-block-bindings/text.md new file mode 100644 index 0000000000..7e50966c32 --- /dev/null +++ b/site/content/tutorial/06-bindings/08-each-block-bindings/text.md @@ -0,0 +1,19 @@ +--- +title: Each block bindings +--- + +You can even bind to properties inside an `each` block. + +```html + + + +``` + +> Note that interacting with these `` elements will mutate the array. If you prefer to work with immutable data, you should avoid these bindings and use event handlers instead. \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/09-media-elements/app-a/App.svelte b/site/content/tutorial/06-bindings/09-media-elements/app-a/App.svelte new file mode 100644 index 0000000000..a80588d398 --- /dev/null +++ b/site/content/tutorial/06-bindings/09-media-elements/app-a/App.svelte @@ -0,0 +1,127 @@ + + + + +

    Caminandes: Llamigos

    +

    From Blender Open Projects. CC-BY

    + +
    + + +
    + + +
    + {format(time)} + click anywhere to {paused ? 'play' : 'pause'} / drag to seek + {format(duration)} +
    +
    +
    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/09-media-elements/app-b/App.svelte b/site/content/tutorial/06-bindings/09-media-elements/app-b/App.svelte new file mode 100644 index 0000000000..2cf819fca0 --- /dev/null +++ b/site/content/tutorial/06-bindings/09-media-elements/app-b/App.svelte @@ -0,0 +1,130 @@ + + + + +

    Caminandes: Llamigos

    +

    From Blender Open Projects. CC-BY

    + +
    + + +
    + + +
    + {format(time)} + click anywhere to {paused ? 'play' : 'pause'} / drag to seek + {format(duration)} +
    +
    +
    \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/09-media-elements/text.md b/site/content/tutorial/06-bindings/09-media-elements/text.md new file mode 100644 index 0000000000..df8beec05c --- /dev/null +++ b/site/content/tutorial/06-bindings/09-media-elements/text.md @@ -0,0 +1,38 @@ +--- +title: Media elements +--- + +The `
    \ No newline at end of file diff --git a/site/src/components/Repl/Input/ComponentSelector.svelte b/site/src/components/Repl/Input/ComponentSelector.svelte new file mode 100644 index 0000000000..7933306b0a --- /dev/null +++ b/site/src/components/Repl/Input/ComponentSelector.svelte @@ -0,0 +1,231 @@ + + + + +
    + {#if $components.length} +
    + {#each $components as component} +
    + {#if component.name == 'App'} +
    + App.svelte +
    + {:else} + {#if component === editing} + {editing.name + (/\./.test(editing.name) ? '' : `.${editing.type}`)} + + + {:else} +
    + {component.name}.{component.type} +
    + + + + + + {/if} + {/if} +
    + {/each} + + +
    + {/if} +
    diff --git a/site/src/components/Repl/Input/ModuleEditor.svelte b/site/src/components/Repl/Input/ModuleEditor.svelte new file mode 100644 index 0000000000..bf1716e373 --- /dev/null +++ b/site/src/components/Repl/Input/ModuleEditor.svelte @@ -0,0 +1,63 @@ + + + + +
    +
    + +
    + +
    + {#if $bundle} + {#if $bundle.error} + + {:else if $bundle.warnings.length > 0} + {#each $bundle.warnings as warning} + + {/each} + {/if} + {/if} +
    +
    \ No newline at end of file diff --git a/site/src/routes/repl/_components/InputOutputToggle.svelte b/site/src/components/Repl/InputOutputToggle.svelte similarity index 100% rename from site/src/routes/repl/_components/InputOutputToggle.svelte rename to site/src/components/Repl/InputOutputToggle.svelte diff --git a/site/src/components/Repl/Message.svelte b/site/src/components/Repl/Message.svelte new file mode 100644 index 0000000000..6a9183dfb3 --- /dev/null +++ b/site/src/components/Repl/Message.svelte @@ -0,0 +1,80 @@ + + + + +
    + {#if details} +

    {message(details)}

    + {:else} + + {/if} +
    \ No newline at end of file diff --git a/site/src/components/Repl/Output/Compiler.js b/site/src/components/Repl/Output/Compiler.js new file mode 100644 index 0000000000..b6d13e53bd --- /dev/null +++ b/site/src/components/Repl/Output/Compiler.js @@ -0,0 +1,38 @@ +export default class Compiler { + constructor(version) { + this.worker = new Worker('/workers/compiler.js'); + this.worker.postMessage({ type: 'init', version }); + + this.uid = 1; + this.handlers = new Map(); + + this.worker.onmessage = event => { + const handler = this.handlers.get(event.data.id); + handler(event.data.result); + this.handlers.delete(event.data.id); + }; + } + + compile(component, options) { + return new Promise(fulfil => { + const id = this.uid++; + + this.handlers.set(id, fulfil); + + this.worker.postMessage({ + id, + type: 'compile', + source: component.source, + options: Object.assign({ + name: component.name, + filename: `${component.name}.svelte` + }, options), + entry: component.name === 'App' + }); + }); + } + + destroy() { + this.worker.terminate(); + } +} \ No newline at end of file diff --git a/site/src/routes/repl/_components/Output/CompilerOptions.svelte b/site/src/components/Repl/Output/CompilerOptions.svelte similarity index 100% rename from site/src/routes/repl/_components/Output/CompilerOptions.svelte rename to site/src/components/Repl/Output/CompilerOptions.svelte diff --git a/site/src/components/Repl/Output/ReplProxy.js b/site/src/components/Repl/Output/ReplProxy.js new file mode 100644 index 0000000000..7ae56e35b7 --- /dev/null +++ b/site/src/components/Repl/Output/ReplProxy.js @@ -0,0 +1,76 @@ +export default class ReplProxy { + constructor(iframe, handlers) { + this.iframe = iframe; + this.handlers = handlers; + + this.cmdId = 1; + this.pendingCmds = new Map(); + + this.handle_event = e => this.handleReplMessage(e); + window.addEventListener('message', this.handle_event, false); + } + + destroy() { + window.removeEventListener('message', this.handle_event); + } + + iframeCommand(command, args) { + return new Promise( (resolve, reject) => { + this.cmdId += 1; + this.pendingCmds.set(this.cmdId, { resolve, reject }); + + this.iframe.contentWindow.postMessage({ + action: command, + cmdId: this.cmdId, + args + }, '*') + }); + } + + handleCommandMessage(cmdData) { + let action = cmdData.action; + let id = cmdData.cmdId; + let handler = this.pendingCmds.get(id); + + if (handler) { + this.pendingCmds.delete(id); + if (action === 'cmdError') { + let { message, stack } = cmdData; + let e = new Error(message); + e.stack = stack; + console.log('repl cmd fail'); + handler.reject(e) + } + + if (action === 'cmdOk') { + handler.resolve(cmdData.args) + } + } else { + console.error('command not found', id, cmdData, [...this.pendingCmds.keys()]); + } + } + + handleReplMessage(event) { + const { action, args } = event.data; + + if (action === 'cmdError' || action === 'cmdOk') { + this.handleCommandMessage(event.data); + } + + if (action === 'fetch_progress') { + this.handlers.onFetchProgress(args.remaining) + } + } + + eval(script) { + return this.iframeCommand('eval', { script }); + } + + handleLinks() { + return this.iframeCommand('catch_clicks', {}); + } + + fetchImports(imports, import_map) { + return this.iframeCommand('fetch_imports', { imports, import_map }) + } +} \ No newline at end of file diff --git a/site/src/components/Repl/Output/Viewer.svelte b/site/src/components/Repl/Output/Viewer.svelte new file mode 100644 index 0000000000..f5fcb0295e --- /dev/null +++ b/site/src/components/Repl/Output/Viewer.svelte @@ -0,0 +1,155 @@ + + + + +
    + + +
    + {#if error} + + {:else if !$bundle} + loading Svelte compiler... + {:else if pending_imports} + loading {pending_imports} {pending_imports === 1 ? 'dependency' : 'dependencies'} from + https://bundle.run + {/if} +
    +
    \ No newline at end of file diff --git a/site/src/routes/repl/_utils/getLocationFromStack.js b/site/src/components/Repl/Output/getLocationFromStack.js similarity index 100% rename from site/src/routes/repl/_utils/getLocationFromStack.js rename to site/src/components/Repl/Output/getLocationFromStack.js diff --git a/site/src/components/Repl/Output/index.svelte b/site/src/components/Repl/Output/index.svelte new file mode 100644 index 0000000000..ae648cde9d --- /dev/null +++ b/site/src/components/Repl/Output/index.svelte @@ -0,0 +1,177 @@ + + + + +
    + + + + + +
    + + +
    + +
    + + +
    + {#if embedded} + + {:else} + +
    + +
    + +
    +

    Compiler options

    + + +
    +
    + {/if} +
    + + +
    + +
    \ No newline at end of file diff --git a/site/src/routes/repl/_components/SplitPane.svelte b/site/src/components/Repl/SplitPane.svelte similarity index 99% rename from site/src/routes/repl/_components/SplitPane.svelte rename to site/src/components/Repl/SplitPane.svelte index a79ef8b775..d7106553f3 100644 --- a/site/src/routes/repl/_components/SplitPane.svelte +++ b/site/src/components/Repl/SplitPane.svelte @@ -71,6 +71,7 @@ } .pane { + position: relative; float: left; width: 100%; height: 100%; diff --git a/site/src/routes/repl/_components/_codemirror.js b/site/src/components/Repl/_codemirror.js similarity index 100% rename from site/src/routes/repl/_components/_codemirror.js rename to site/src/components/Repl/_codemirror.js diff --git a/site/src/routes/repl/_components/codemirror.css b/site/src/components/Repl/codemirror.css similarity index 100% rename from site/src/routes/repl/_components/codemirror.css rename to site/src/components/Repl/codemirror.css diff --git a/site/src/components/Repl/index.svelte b/site/src/components/Repl/index.svelte new file mode 100644 index 0000000000..aa9a9fed93 --- /dev/null +++ b/site/src/components/Repl/index.svelte @@ -0,0 +1,230 @@ + + + + +
    +
    + +
    + + +
    + +
    + +
    +
    +
    +
    + + diff --git a/site/src/components/TopNav.svelte b/site/src/components/TopNav.svelte index c9945b912b..d1e4db6d31 100644 --- a/site/src/components/TopNav.svelte +++ b/site/src/components/TopNav.svelte @@ -156,23 +156,6 @@ height: 2rem; } - .menu-link { - cursor: pointer; - -webkit-tap-highlight-color: transparent; - -webkit-touch-callout: none; - } - - .logo { - position: relative; - top: .3rem; - width: 18rem; - color: var(--second); - -webkit-tap-highlight-color: transparent; - -webkit-touch-callout: none; - z-index: 11; - padding: 0.5em 0; - } - .home { position: relative; top: 0; @@ -190,7 +173,7 @@ color: var(--prime) } - @media (min-width: 768px) { + @media (min-width: 840px) { ul { padding: 0; background: none; @@ -244,7 +227,9 @@ on:mouseleave="{() => open = false}" >
  • Home
  • -
  • Guide
  • +
  • Tutorial
  • +
  • API Docs
  • +
  • Examples
  • REPL
  • Blog
  • Sapper
  • diff --git a/site/src/routes/_layout.svelte b/site/src/routes/_layout.svelte index b9cc668e95..386c27ac39 100644 --- a/site/src/routes/_layout.svelte +++ b/site/src/routes/_layout.svelte @@ -1,18 +1,19 @@ -{#if path !== '/repl/embed'} -