diff --git a/package-lock.json b/package-lock.json index e1b29982dc..d6237d5d0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.0.0-beta.10", + "version": "3.0.0-beta.18", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -61,9 +61,9 @@ "dev": true }, "acorn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.5.tgz", - "integrity": "sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", "dev": true }, "acorn-dynamic-import": { @@ -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", @@ -2020,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", @@ -2085,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", @@ -2196,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", @@ -2232,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", @@ -2253,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", @@ -2268,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", @@ -2348,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", @@ -2415,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", @@ -2447,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", @@ -2582,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,15 +2370,6 @@ "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", @@ -2774,45 +2438,6 @@ "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", @@ -2840,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", @@ -2924,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", @@ -3160,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", @@ -3217,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", @@ -3239,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", @@ -3277,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", @@ -3335,16 +2883,6 @@ "util-deprecate": "^1.0.1" } }, - "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", @@ -3373,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", @@ -3989,52 +3518,6 @@ "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", @@ -4046,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", @@ -4254,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", @@ -4269,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", @@ -4410,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", @@ -4445,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", @@ -4638,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", @@ -4774,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", @@ -5147,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 cf021b6045..93d319b4ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.0.0-beta.10", + "version": "3.0.0-beta.18", "description": "The magical disappearing UI framework", "module": "index.mjs", "main": "index", @@ -51,7 +51,7 @@ "devDependencies": { "@types/mocha": "^5.2.0", "@types/node": "^10.5.5", - "acorn": "^6.0.5", + "acorn": "^6.1.1", "acorn-dynamic-import": "^4.0.0", "agadoo": "^1.0.1", "c8": "^3.4.0", @@ -67,7 +67,7 @@ "locate-character": "^2.0.5", "magic-string": "^0.25.2", "mocha": "^5.2.0", - "nightmare": "^3.0.1", + "puppeteer": "^1.13.0", "rollup": "^1.1.2", "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-json": "^3.0.0", 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/08-motion/01-spring/App.svelte b/site/content/examples/08-motion/01-spring/App.svelte new file mode 100644 index 0000000000..9918cf40e8 --- /dev/null +++ b/site/content/examples/08-motion/01-spring/App.svelte @@ -0,0 +1,35 @@ + + + + +
+ + + +
+ + + + \ 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 87% rename from site/content/examples/svg-clock/App.svelte rename to site/content/examples/11-svg/01-clock/App.svelte index 19b56d7335..49d3a7f809 100644 --- a/site/content/examples/svg-clock/App.svelte +++ b/site/content/examples/11-svg/01-clock/App.svelte @@ -2,15 +2,12 @@ import { onMount } from 'svelte'; let time = new Date(); - let hours, minutes, seconds; - - $: { - // this block runs reactively, whenever - // `time` changes - hours = time.getHours(); - minutes = time.getMinutes(); - seconds = time.getSeconds(); - } + + // these automatically update when `time` + // changes, because of the `$:` prefix + $: hours = time.getHours(); + $: minutes = time.getMinutes(); + $: seconds = time.getSeconds(); onMount(() => { const interval = setInterval(() => { @@ -23,6 +20,44 @@ }); + + @@ -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..6c30c34eba --- /dev/null +++ b/site/src/components/Repl/Input/ComponentSelector.svelte @@ -0,0 +1,233 @@ + + + + +
    + {#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 69% rename from site/src/routes/repl/_components/Output/CompilerOptions.svelte rename to site/src/components/Repl/Output/CompilerOptions.svelte index 278f7aa275..75f7301aa7 100644 --- a/site/src/routes/repl/_components/Output/CompilerOptions.svelte +++ b/site/src/components/Repl/Output/CompilerOptions.svelte @@ -1,5 +1,7 @@ + +
    + + +
    + {#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..59d67b5fcf --- /dev/null +++ b/site/src/components/Repl/Output/index.svelte @@ -0,0 +1,169 @@ + + + + +
    + + + + + +
    + + +
    + +
    + + +
    + {#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..aa9e423932 --- /dev/null +++ b/site/src/components/Repl/index.svelte @@ -0,0 +1,250 @@ + + + + +
    +
    + +
    + + +
    + +
    + +
    +
    +
    +
    + + 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/api/blog/_posts.js b/site/src/routes/api/blog/_posts.js index 8b70483cd1..33c033b517 100644 --- a/site/src/routes/api/blog/_posts.js +++ b/site/src/routes/api/blog/_posts.js @@ -1,19 +1,10 @@ import fs from 'fs'; import path from 'path'; -import process_markdown from '../../../utils/_process_markdown.js'; +import { extract_frontmatter, langs } from '../../../utils/markdown.js'; import marked from 'marked'; - import PrismJS from 'prismjs'; import 'prismjs/components/prism-bash'; -// map lang to prism-language-attr -const prismLang = { - bash: 'bash', - html: 'markup', - js: 'javascript', - css: 'css', -}; - export default function() { return fs .readdirSync('content/blog') @@ -22,7 +13,7 @@ export default function() { const markdown = fs.readFileSync(`content/blog/${file}`, 'utf-8'); - const { content, metadata } = process_markdown(markdown); + const { content, metadata } = extract_frontmatter(markdown); const date = new Date(`${metadata.pubdate} EDT`); // cheeky hack metadata.dateString = date.toDateString(); @@ -30,7 +21,7 @@ export default function() { const renderer = new marked.Renderer(); renderer.code = (source, lang) => { - const plang = prismLang[lang]; + const plang = langs[lang]; const highlighted = PrismJS.highlight( source, PrismJS.languages[plang], diff --git a/site/src/routes/api/examples/[slug].js b/site/src/routes/api/examples/[slug].js deleted file mode 100644 index 03bf723766..0000000000 --- a/site/src/routes/api/examples/[slug].js +++ /dev/null @@ -1,73 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import manifest from '../../../../content/examples/manifest.json'; - -const lookup = new Map(); -const titles = new Map(); -const slugs = new Set(); - -manifest.forEach(group => { - group.examples.forEach(example => { - titles.set(example.slug, example.title); - slugs.add(example.slug); - }); -}); - -function createExample(slug) { - const files = fs.readdirSync(`content/examples/${slug}`); - - const components = files - .map(file => { - const ext = path.extname(file); - if (ext !== '.svelte' && ext !== '.js') return null; - - const source = fs.readFileSync(`content/examples/${slug}/${file}`, 'utf-8'); - - return { - name: file.replace(ext, ''), - type: ext.slice(1), - source - }; - }) - .filter(Boolean) - .sort((a, b) => { - if (a.name === 'App' && a.type === 'svelte') return -1; - if (b.name === 'App' && b.type === 'svelte') return 1; - - if (a.type !== b.type) return a.type === 'svelte' ? -1 : 1; - - return a.name < b.name ? -1 : 1; - }); - - const json5 = fs.existsSync(`content/examples/${slug}/data.json5`) - ? fs.readFileSync(`content/examples/${slug}/data.json5`, 'utf-8') - : '{}'; - - return JSON.stringify({ - title: titles.get(slug), - components, - json5 - }); -} - -export function get(req, res) { - const { slug } = req.params; - - try { - if (!lookup.has(slug) || process.env.NODE_ENV !== 'production') { - lookup.set(slug, createExample(slug)); - } - - res.writeHead(200, { - 'Content-Type': 'application/json' - }); - - res.end(lookup.get(slug)); - } catch (err) { - res.writeHead(404, { - 'Content-Type': 'application/json' - }); - - res.end(JSON.stringify({ error: 'not found' })); - } -} \ No newline at end of file diff --git a/site/src/routes/guide/_GuideContents.svelte b/site/src/routes/docs/_GuideContents.svelte similarity index 97% rename from site/src/routes/guide/_GuideContents.svelte rename to site/src/routes/docs/_GuideContents.svelte index 4c703f6af1..6fc7c6c588 100644 --- a/site/src/routes/guide/_GuideContents.svelte +++ b/site/src/routes/docs/_GuideContents.svelte @@ -106,7 +106,7 @@ > {#each sections as section}
  • - + {section.metadata.title} {#if section.slug === active_section} @@ -116,7 +116,7 @@ {#each section.subsections as subsection} - + {subsection.title} {#if subsection.slug === active_section} diff --git a/site/src/routes/guide/_sections.js b/site/src/routes/docs/_sections.js similarity index 83% rename from site/src/routes/guide/_sections.js rename to site/src/routes/docs/_sections.js index 59818bc464..d4adeebd09 100644 --- a/site/src/routes/guide/_sections.js +++ b/site/src/routes/docs/_sections.js @@ -1,20 +1,10 @@ import fs from 'fs'; import path from 'path'; -import * as fleece from 'golden-fleece'; -import process_markdown from '../../utils/_process_markdown.js'; +import { extract_frontmatter, extract_metadata, langs } from '../../utils/markdown.js'; import marked from 'marked'; - import PrismJS from 'prismjs'; import 'prismjs/components/prism-bash'; -// map lang to prism-language-attr -const prismLang = { - bash: 'bash', - html: 'markup', - js: 'javascript', - css: 'css', -}; - const escaped = { '"': '"', "'": ''', @@ -45,24 +35,6 @@ const blockTypes = [ 'tablecell' ]; -function extractMeta(line, lang) { - try { - if (lang === 'html' && line.startsWith('')) { - return fleece.evaluate(line.slice(4, -3).trim()); - } - - if ( - lang === 'js' || - (lang === 'json' && line.startsWith('/*') && line.endsWith('*/')) - ) { - return fleece.evaluate(line.slice(2, -2).trim()); - } - } catch (err) { - // TODO report these errors, don't just squelch them - return null; - } -} - // https://github.com/darkskyapp/string-hash/blob/master/index.js function getHash(str) { let hash = 5381; @@ -81,7 +53,7 @@ export default function() { .map(file => { const markdown = fs.readFileSync(`content/guide/${file}`, 'utf-8'); - const { content, metadata } = process_markdown(markdown); + const { content, metadata } = extract_frontmatter(markdown); const subsections = []; const groups = []; @@ -97,7 +69,7 @@ export default function() { const lines = source.split('\n'); - const meta = extractMeta(lines[0], lang); + const meta = extract_metadata(lines[0], lang); let prefix = ''; let className = 'code-block'; @@ -124,7 +96,7 @@ export default function() { if (meta && meta.hidden) return ''; - const plang = prismLang[lang]; + const plang = langs[lang]; const highlighted = PrismJS.highlight( source, PrismJS.languages[plang], @@ -164,7 +136,7 @@ export default function() { return ` - + ${text} `; } diff --git a/site/src/routes/guide/demo/[hash].json.js b/site/src/routes/docs/demo/[hash].json.js similarity index 100% rename from site/src/routes/guide/demo/[hash].json.js rename to site/src/routes/docs/demo/[hash].json.js diff --git a/site/src/routes/guide/index.json.js b/site/src/routes/docs/index.json.js similarity index 100% rename from site/src/routes/guide/index.json.js rename to site/src/routes/docs/index.json.js diff --git a/site/src/routes/guide/index.svelte b/site/src/routes/docs/index.svelte similarity index 98% rename from site/src/routes/guide/index.svelte rename to site/src/routes/docs/index.svelte index 3f4731cc11..5a4962336a 100644 --- a/site/src/routes/guide/index.svelte +++ b/site/src/routes/docs/index.svelte @@ -1,6 +1,6 @@ diff --git a/site/src/routes/examples/[slug].json.js b/site/src/routes/examples/[slug].json.js new file mode 100644 index 0000000000..222da42bb1 --- /dev/null +++ b/site/src/routes/examples/[slug].json.js @@ -0,0 +1,25 @@ +import { get_example } from './_examples.js'; + +const cache = new Map(); + +export function get(req, res) { + const { slug } = req.params; + + try { + if (!cache.has(slug) || process.env.NODE_ENV !== 'production') { + cache.set(slug, JSON.stringify(get_example(slug))); + } + + res.writeHead(200, { + 'Content-Type': 'application/json' + }); + + res.end(cache.get(slug)); + } catch (err) { + res.writeHead(404, { + 'Content-Type': 'application/json' + }); + + res.end(JSON.stringify({ error: 'not found' })); + } +} \ No newline at end of file diff --git a/site/src/routes/examples/_examples.js b/site/src/routes/examples/_examples.js new file mode 100644 index 0000000000..75c0aab08f --- /dev/null +++ b/site/src/routes/examples/_examples.js @@ -0,0 +1,51 @@ +import fs from 'fs'; +import path from 'path'; + +let lookup; +const titles = new Map(); + +export function get_examples() { + lookup = new Map(); + + return fs.readdirSync(`content/examples`).map(group_dir => { + const metadata = JSON.parse(fs.readFileSync(`content/examples/${group_dir}/meta.json`, 'utf-8')); + + return { + title: metadata.title, + examples: fs.readdirSync(`content/examples/${group_dir}`).filter(file => file !== 'meta.json').map(example_dir => { + const slug = example_dir.replace(/^\d+-/, ''); + + if (lookup.has(slug)) throw new Error(`Duplicate example slug "${slug}"`); + lookup.set(slug, `${group_dir}/${example_dir}`); + + const metadata = JSON.parse(fs.readFileSync(`content/examples/${group_dir}/${example_dir}/meta.json`, 'utf-8')); + titles.set(slug, metadata.title); + + return { + slug, + title: metadata.title + }; + }) + }; + }); +} + +export function get_example(slug) { + if (!lookup || !lookup.has(slug)) get_examples(); + + const dir = lookup.get(slug); + const title = titles.get(slug); + + if (!dir || !title) throw { status: 404, message: 'not found' }; + + const files = fs.readdirSync(`content/examples/${dir}`) + .filter(name => name[0] !== '.' && name !== 'meta.json') + .map(name => { + return { + name, + source: fs.readFileSync(`content/examples/${dir}/${name}`, 'utf-8') + }; + }); + + return { title, files }; +} \ No newline at end of file diff --git a/site/src/routes/examples/index.json.js b/site/src/routes/examples/index.json.js new file mode 100644 index 0000000000..4cb4d9c554 --- /dev/null +++ b/site/src/routes/examples/index.json.js @@ -0,0 +1,23 @@ +import { get_examples } from './_examples.js'; + +let cached; + +export function get(req, res) { + try { + if (!cached || process.env.NODE_ENV !== 'production') { + cached = JSON.stringify(get_examples()); + } + + res.writeHead(200, { + 'Content-Type': 'application/json' + }); + + res.end(cached); + } catch (e) { + res.writeHead(e.status || 500, { + 'Content-Type': 'application/json' + }); + + res.end(JSON.stringify({ message: e.message })); + } +} \ No newline at end of file diff --git a/site/src/routes/examples/index.svelte b/site/src/routes/examples/index.svelte new file mode 100644 index 0000000000..fa6ee35025 --- /dev/null +++ b/site/src/routes/examples/index.svelte @@ -0,0 +1,114 @@ + + + + + + +
    +

    Examples

    + + {#each groups as group} +
    +

    {group.title}

    + +
    + {#each group.examples as example} + +
    + {example.title} +
    + {/each} +
    +
    + {/each} +
    \ No newline at end of file diff --git a/site/src/routes/gist/create.js b/site/src/routes/gist/create.js index 601f21d466..1f55a51498 100644 --- a/site/src/routes/gist/create.js +++ b/site/src/routes/gist/create.js @@ -13,7 +13,7 @@ export async function post(req, res) { } try { - const { name, components, json5 } = await body(req); + const { name, components } = await body(req); const files = { 'meta.json': { @@ -33,10 +33,6 @@ export async function post(req, res) { files[file] = { content: component.source }; }); - if (json5) { - files['data.json5'] = { content: json5 }; - } - const r = await fetch(`https://api.github.com/gists`, { method: 'POST', headers: { diff --git a/site/src/routes/index.svelte b/site/src/routes/index.svelte index 75488610a6..edde4372c6 100644 --- a/site/src/routes/index.svelte +++ b/site/src/routes/index.svelte @@ -107,11 +107,6 @@ top: 0.6em; } - h6 { - max-width: 25em; - padding: 2.4rem; - } - .example { background: var(--second); color: white; @@ -238,7 +233,7 @@ npm run dev & open http://localhost:5000 @@ -250,7 +245,7 @@ npm run dev & open http://localhost:5000 @@ -262,7 +257,7 @@ npm run dev & open http://localhost:5000 @@ -274,7 +269,7 @@ npm run dev & open http://localhost:5000 diff --git a/site/src/routes/repl/_components/AppControls/index.svelte b/site/src/routes/repl/_components/AppControls/index.svelte index af4a0cf2e8..f02cdc8fd2 100644 --- a/site/src/routes/repl/_components/AppControls/index.svelte +++ b/site/src/routes/repl/_components/AppControls/index.svelte @@ -1,17 +1,15 @@ - - - -
    -
    - {#each $component_store as component} - - {/each} -
    - - -
    diff --git a/site/src/routes/repl/_components/Input/ModuleEditor.svelte b/site/src/routes/repl/_components/Input/ModuleEditor.svelte deleted file mode 100644 index 1b72f3aa31..0000000000 --- a/site/src/routes/repl/_components/Input/ModuleEditor.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - -
    - {#if component} - - {/if} -
    \ No newline at end of file diff --git a/site/src/routes/repl/_components/Input/index.svelte b/site/src/routes/repl/_components/Input/index.svelte deleted file mode 100644 index 0e824dd389..0000000000 --- a/site/src/routes/repl/_components/Input/index.svelte +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/site/src/routes/repl/_components/Output/PropEditor.svelte b/site/src/routes/repl/_components/Output/PropEditor.svelte deleted file mode 100644 index 4ea6ce5e7f..0000000000 --- a/site/src/routes/repl/_components/Output/PropEditor.svelte +++ /dev/null @@ -1,71 +0,0 @@ - - - - -
    - -
    \ No newline at end of file diff --git a/site/src/routes/repl/_components/Output/Viewer.svelte b/site/src/routes/repl/_components/Output/Viewer.svelte deleted file mode 100644 index e204b3c79d..0000000000 --- a/site/src/routes/repl/_components/Output/Viewer.svelte +++ /dev/null @@ -1,325 +0,0 @@ - - - - -
    - -
    - -
    - {#if error} -

    - {#if error.loc} - - {#if error.filename} - {error.filename} - {/if} - - ({error.loc.line}:{error.loc.column}) - - {/if} - - {error.message} -

    - {:elseif pending} -
    - -
    - {:elseif pendingImports} -

    loading {pendingImports} {pendingImports === 1 ? 'dependency' : 'dependencies'} from - https://bundle.run

    - {/if} -
    \ No newline at end of file diff --git a/site/src/routes/repl/_components/Output/index.svelte b/site/src/routes/repl/_components/Output/index.svelte deleted file mode 100644 index aea23e51d1..0000000000 --- a/site/src/routes/repl/_components/Output/index.svelte +++ /dev/null @@ -1,197 +0,0 @@ - - - - -
    - - - - - -
    - -{#if view === 'result'} - -
    - {#if bundle} - - {:else} - -

    loading Svelte compiler...

    - {/if} -
    - -
    -

    Props editor

    - - {#if props} - {#if props.length > 0} -
    - {#each props.sort() as prop (prop)} - {prop} - - - - {/each} -
    - {:else} -
    - - -

    This component has no props — declare props with the export keyword

    -
    - {/if} - {/if} -
    -
    -{:elseif embedded} - -{:else} - -
    - -
    - -
    -

    Compiler options

    - - -
    -
    -{/if} diff --git a/site/src/routes/repl/_components/Repl.svelte b/site/src/routes/repl/_components/Repl.svelte deleted file mode 100644 index 318ba0d5e8..0000000000 --- a/site/src/routes/repl/_components/Repl.svelte +++ /dev/null @@ -1,321 +0,0 @@ - - - - -
    -
    - -
    - -
    - -
    - -
    -
    -
    -
    - - diff --git a/site/src/routes/repl/_utils/process_example.js b/site/src/routes/repl/_utils/process_example.js new file mode 100644 index 0000000000..fc61d79ad3 --- /dev/null +++ b/site/src/routes/repl/_utils/process_example.js @@ -0,0 +1,16 @@ +export function process_example(files) { + return files + .map(file => { + const [name, type] = file.name.split('.'); + return { name, type, source: file.source }; + }) + .sort((a, b) => { + if (a.name === 'App' && a.type === 'svelte') return -1; + if (b.name === 'App' && b.type === 'svelte') return 1; + + if (a.type === b.type) return a.name < b.name ? -1 : 1; + + if (a.type === 'svelte') return -1; + if (b.type === 'svelte') return 1; + }); +} \ No newline at end of file diff --git a/site/src/routes/repl/_utils/replProxy.js b/site/src/routes/repl/_utils/replProxy.js deleted file mode 100644 index 4025dffe6b..0000000000 --- a/site/src/routes/repl/_utils/replProxy.js +++ /dev/null @@ -1,90 +0,0 @@ -export default class ReplProxy { - constructor(iframe) { - this.iframe = iframe; - this.cmdId = 1; - this.pendingCmds = new Map(); - this.onPropUpdate = null; - this.onFetchProgress = null; - this.handle_event = (ev) => this.handleReplMessage(ev); - window.addEventListener("message", this.handle_event, false); - } - - destroy() { - window.removeEventListener("message", this.handle_event); - } - - iframeCommand(command, args) { - return new Promise( (resolve, reject) => { - this.cmdId = this.cmdId + 1; - this.pendingCmds.set(this.cmdId, { resolve: resolve, reject: reject }); - this.iframe.contentWindow.postMessage({ - action: command, - cmdId: this.cmdId, - args: 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(ev) { - - let action = ev.data.action; - if ( action == "cmdError" || action == "cmdOk" ) { - this.handleCommandMessage(ev.data); - } - - if (action == "prop_update") { - let { prop, value } = ev.data.args; - if (this.onPropUpdate) - this.onPropUpdate(prop, value) - } - - if (action == "fetch_progress") { - if (this.onFetchProgress) - this.onFetchProgress(ev.data.args.remaining) - } - } - - eval(script) { - return this.iframeCommand("eval", { script: script }); - } - - setProp(prop, value) { - return this.iframeCommand("set_prop", {prop, value}) - } - - bindProps(props) { - return this.iframeCommand("bind_props", { props: props }) - } - - handleLinks() { - return this.iframeCommand("catch_clicks", {}); - } - - fetchImports(bundle) { - return this.iframeCommand("fetch_imports", { bundle }) - } - -} \ No newline at end of file diff --git a/site/src/routes/repl/embed.svelte b/site/src/routes/repl/embed.svelte index c9eb0a08ea..9cc680afb0 100644 --- a/site/src/routes/repl/embed.svelte +++ b/site/src/routes/repl/embed.svelte @@ -3,23 +3,19 @@ return { version: query.version || 'beta', gist: query.gist, - demo: query.demo + example: query.example }; } + + \ No newline at end of file diff --git a/site/src/routes/tutorial/[slug]/index.json.js b/site/src/routes/tutorial/[slug]/index.json.js new file mode 100644 index 0000000000..a44685530d --- /dev/null +++ b/site/src/routes/tutorial/[slug]/index.json.js @@ -0,0 +1,111 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import marked from 'marked'; +import PrismJS from 'prismjs'; +import { extract_frontmatter, extract_metadata, langs } from '../../../utils/markdown'; + +const cache = new Map(); + +function find_tutorial(slug) { + const sections = fs.readdirSync(`content/tutorial`); + + for (const section of sections) { + const chapters = fs.readdirSync(`content/tutorial/${section}`).filter(dir => /^\d+/.test(dir)); + for (const chapter of chapters) { + if (slug === chapter.replace(/^\d+-/, '')) { + return { section, chapter }; + } + } + } +} + +function get_tutorial(slug) { + const found = find_tutorial(slug); + if (!found) return found; + + const dir = `content/tutorial/${found.section}/${found.chapter}`; + + const markdown = fs.readFileSync(`${dir}/text.md`, 'utf-8'); + const app_a = fs.readdirSync(`${dir}/app-a`); + const app_b = fs.existsSync(`${dir}/app-b`) && fs.readdirSync(`${dir}/app-b`); + + const { content } = extract_frontmatter(markdown); + + const renderer = new marked.Renderer(); + + renderer.code = (source, lang) => { + source = source.replace(/^ +/gm, match => + match.split(' ').join('\t') + ); + + const lines = source.split('\n'); + + const meta = extract_metadata(lines[0], lang); + + let prefix = ''; + let className = 'code-block'; + + if (meta) { + source = lines.slice(1).join('\n'); + const filename = meta.filename || (lang === 'html' && 'App.svelte'); + if (filename) { + prefix = `${prefix} ${filename}`; + className += ' named'; + } + } + + const plang = langs[lang]; + const highlighted = PrismJS.highlight( + source, + PrismJS.languages[plang], + lang + ); + + return `
    ${prefix}
    ${highlighted}
    `; + }; + + let html = marked(content, { renderer }); + if (found.chapter.startsWith('01')) { + const meta = JSON.parse(fs.readFileSync(`content/tutorial/${found.section}/meta.json`)); + html = `

    ${meta.title}

    \n${html}`; + } + + function get_file(stage, file) { + const ext = path.extname(file); + const name = file.slice(0, -ext.length); + const type = ext.slice(1); + + return { + name, + type, + source: fs.readFileSync(`${dir}/${stage}/${file}`, 'utf-8') + }; + } + + return { + html, + app_a: app_a.map(file => get_file('app-a', file)), + app_b: app_b && app_b.map(file => get_file('app-b', file)) + }; +} + +export function get(req, res) { + const { slug } = req.params; + + if (!cache.has(slug) || process.env.NODE_ENV !== 'production') { + cache.set(slug, JSON.stringify(get_tutorial(slug))); + } + + const json = cache.get(slug); + + res.set({ + 'Content-Type': 'application/json' + }); + + if (json) { + res.end(json); + } else { + res.statusCode = 404; + res.end(JSON.stringify({ message: 'not found' })); + } +} \ No newline at end of file diff --git a/site/src/routes/tutorial/[slug]/index.svelte b/site/src/routes/tutorial/[slug]/index.svelte new file mode 100644 index 0000000000..eca5686270 --- /dev/null +++ b/site/src/routes/tutorial/[slug]/index.svelte @@ -0,0 +1,261 @@ + + + + + + + + {selected.section.title} / {selected.chapter.title} • Svelte Tutorial + + +
    +
    +
    + +
    + +
    + {@html chapter.html} + +
    + {#if chapter.app_b} + + + {/if} + + {#if selected.next} + + {/if} +
    + + +
    +
    + +
    + +
    +
    diff --git a/site/src/routes/tutorial/_layout.svelte b/site/src/routes/tutorial/_layout.svelte new file mode 100644 index 0000000000..c424fac2e6 --- /dev/null +++ b/site/src/routes/tutorial/_layout.svelte @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/site/src/routes/tutorial/index.json.js b/site/src/routes/tutorial/index.json.js new file mode 100644 index 0000000000..52b9e8aa33 --- /dev/null +++ b/site/src/routes/tutorial/index.json.js @@ -0,0 +1,70 @@ +import * as fs from 'fs'; +import { extract_frontmatter } from '../../utils/markdown'; + +let json; + +function get_sections() { + const slugs = new Set(); + + const sections = fs.readdirSync(`content/tutorial`) + .filter(dir => /^\d+/.test(dir)) + .map(dir => { + let meta; + + try { + meta = JSON.parse(fs.readFileSync(`content/tutorial/${dir}/meta.json`, 'utf-8')); + } catch (err) { + throw new Error(`Error reading metadata for ${dir}`); + } + + return { + title: meta.title, + chapters: fs.readdirSync(`content/tutorial/${dir}`) + .filter(dir => /^\d+/.test(dir)) + .map(tutorial => { + try { + const md = fs.readFileSync(`content/tutorial/${dir}/${tutorial}/text.md`, 'utf-8'); + const { metadata } = extract_frontmatter(md); + + const slug = tutorial.replace(/^\d+-/, ''); + + if (slugs.has(slug)) throw new Error(`Duplicate slug: ${slug}`); + slugs.add(slug); + + return { + slug, + title: metadata.title, + section_dir: dir, + chapter_dir: tutorial, + }; + } catch (err) { + throw new Error(`Error building tutorial ${dir}/${tutorial}: ${err.message}`); + } + }) + } + }); + + return sections; +} + +export function get(req, res) { + try { + if (!json || process.env.NODE_ENV !== 'production') { + json = JSON.stringify(get_sections()); + } + + res.set({ + 'Content-Type': 'application/json' + }); + + res.end(json); + } catch (err) { + res.writeHead(500, { + 'Content-Type': 'application/json' + }); + + res.end(JSON.stringify({ + message: err.message + })); + } +} diff --git a/site/src/routes/tutorial/index.svelte b/site/src/routes/tutorial/index.svelte new file mode 100644 index 0000000000..738a1b33e8 --- /dev/null +++ b/site/src/routes/tutorial/index.svelte @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/site/src/routes/tutorial/random-number.js b/site/src/routes/tutorial/random-number.js new file mode 100644 index 0000000000..f864dff946 --- /dev/null +++ b/site/src/routes/tutorial/random-number.js @@ -0,0 +1,20 @@ +export function get(req, res) { + let { min = '0', max = '100' } = req.query; + min = +min; + max = +max; + + res.setHeader('Access-Control-Allow-Origin', '*'); + + // simulate a long delay + setTimeout(() => { + // fail sometimes + if (Math.random() < 0.333) { + res.statusCode = 500; + res.end(`Failed to generate random number. Please try again`); + return; + } + + const num = min + Math.round(Math.random() * (max - min)); + res.end(String(num)); + }, 1000); +} \ No newline at end of file diff --git a/site/src/user.js b/site/src/user.js index 0ba4e7716f..9bbdcf2f76 100644 --- a/site/src/user.js +++ b/site/src/user.js @@ -5,6 +5,7 @@ export const user = writable(null); if (process.browser) { // TODO this is a workaround for the fact that there's currently // no way to pass session data from server to client + // TODO there is now! replace this with the session mechanism fetch('/auth/me.json', { credentials: 'include' }) .then(r => r.json()) .then(user.set); diff --git a/site/src/utils/_process_markdown.js b/site/src/utils/_process_markdown.js deleted file mode 100644 index f760018a3b..0000000000 --- a/site/src/utils/_process_markdown.js +++ /dev/null @@ -1,15 +0,0 @@ -export default function process_markdown(markdown) { - const match = /---\r?\n([\s\S]+?)\r?\n---/.exec(markdown); - const frontMatter = match[1]; - const content = markdown.slice(match[0].length); - - const metadata = {}; - frontMatter.split('\n').forEach(pair => { - const colonIndex = pair.indexOf(':'); - metadata[pair.slice(0, colonIndex).trim()] = pair - .slice(colonIndex + 1) - .trim(); - }); - - return { metadata, content }; -} \ No newline at end of file diff --git a/site/src/routes/repl/_components/events.js b/site/src/utils/events.js similarity index 100% rename from site/src/routes/repl/_components/events.js rename to site/src/utils/events.js diff --git a/site/src/utils/markdown.js b/site/src/utils/markdown.js new file mode 100644 index 0000000000..cbb4e3cbcc --- /dev/null +++ b/site/src/utils/markdown.js @@ -0,0 +1,43 @@ +import * as fleece from 'golden-fleece'; + +export function extract_frontmatter(markdown) { + const match = /---\r?\n([\s\S]+?)\r?\n---/.exec(markdown); + const frontMatter = match[1]; + const content = markdown.slice(match[0].length); + + const metadata = {}; + frontMatter.split('\n').forEach(pair => { + const colonIndex = pair.indexOf(':'); + metadata[pair.slice(0, colonIndex).trim()] = pair + .slice(colonIndex + 1) + .trim(); + }); + + return { metadata, content }; +} + +export function extract_metadata(line, lang) { + try { + if (lang === 'html' && line.startsWith('')) { + return fleece.evaluate(line.slice(4, -3).trim()); + } + + if ( + lang === 'js' || + (lang === 'json' && line.startsWith('/*') && line.endsWith('*/')) + ) { + return fleece.evaluate(line.slice(2, -2).trim()); + } + } catch (err) { + // TODO report these errors, don't just squelch them + return null; + } +} + +// map lang to prism-language-attr +export const langs = { + bash: 'bash', + html: 'markup', + js: 'javascript', + css: 'css', +}; \ No newline at end of file diff --git a/site/static/examples/thumbnails/7guis-circles.png b/site/static/examples/thumbnails/7guis-circles.png new file mode 100644 index 0000000000..653343a48c Binary files /dev/null and b/site/static/examples/thumbnails/7guis-circles.png differ diff --git a/site/static/examples/thumbnails/7guis-counter.png b/site/static/examples/thumbnails/7guis-counter.png new file mode 100644 index 0000000000..1b2c25182b Binary files /dev/null and b/site/static/examples/thumbnails/7guis-counter.png differ diff --git a/site/static/examples/thumbnails/7guis-crud.png b/site/static/examples/thumbnails/7guis-crud.png new file mode 100644 index 0000000000..6eaa8b25fd Binary files /dev/null and b/site/static/examples/thumbnails/7guis-crud.png differ diff --git a/site/static/examples/thumbnails/7guis-flight-booker.png b/site/static/examples/thumbnails/7guis-flight-booker.png new file mode 100644 index 0000000000..f2f5238841 Binary files /dev/null and b/site/static/examples/thumbnails/7guis-flight-booker.png differ diff --git a/site/static/examples/thumbnails/7guis-temperature.png b/site/static/examples/thumbnails/7guis-temperature.png new file mode 100644 index 0000000000..2d9a5f19b8 Binary files /dev/null and b/site/static/examples/thumbnails/7guis-temperature.png differ diff --git a/site/static/examples/thumbnails/7guis-timer.png b/site/static/examples/thumbnails/7guis-timer.png new file mode 100644 index 0000000000..c025f74398 Binary files /dev/null and b/site/static/examples/thumbnails/7guis-timer.png differ diff --git a/site/static/examples/thumbnails/actions.png b/site/static/examples/thumbnails/actions.png new file mode 100644 index 0000000000..0f5d239edb Binary files /dev/null and b/site/static/examples/thumbnails/actions.png differ diff --git a/site/static/examples/thumbnails/adding-parameters-to-actions.png b/site/static/examples/thumbnails/adding-parameters-to-actions.png new file mode 100644 index 0000000000..6c5b0822a5 Binary files /dev/null and b/site/static/examples/thumbnails/adding-parameters-to-actions.png differ diff --git a/site/static/examples/thumbnails/adding-parameters-to-transitions.png b/site/static/examples/thumbnails/adding-parameters-to-transitions.png new file mode 100644 index 0000000000..b32c6d3c9a Binary files /dev/null and b/site/static/examples/thumbnails/adding-parameters-to-transitions.png differ diff --git a/site/static/examples/thumbnails/animate.png b/site/static/examples/thumbnails/animate.png new file mode 100644 index 0000000000..8334d7ecb0 Binary files /dev/null and b/site/static/examples/thumbnails/animate.png differ diff --git a/site/static/examples/thumbnails/auto-subscriptions.png b/site/static/examples/thumbnails/auto-subscriptions.png new file mode 100644 index 0000000000..2f21706974 Binary files /dev/null and b/site/static/examples/thumbnails/auto-subscriptions.png differ diff --git a/site/static/examples/thumbnails/await-blocks.png b/site/static/examples/thumbnails/await-blocks.png new file mode 100644 index 0000000000..138f943af3 Binary files /dev/null and b/site/static/examples/thumbnails/await-blocks.png differ diff --git a/site/static/examples/thumbnails/bar-chart.png b/site/static/examples/thumbnails/bar-chart.png new file mode 100644 index 0000000000..178bf4d92c Binary files /dev/null and b/site/static/examples/thumbnails/bar-chart.png differ diff --git a/site/static/examples/thumbnails/bind-this.png b/site/static/examples/thumbnails/bind-this.png new file mode 100644 index 0000000000..29531b76a8 Binary files /dev/null and b/site/static/examples/thumbnails/bind-this.png differ diff --git a/site/static/examples/thumbnails/checkbox-inputs.png b/site/static/examples/thumbnails/checkbox-inputs.png new file mode 100644 index 0000000000..06342ff488 Binary files /dev/null and b/site/static/examples/thumbnails/checkbox-inputs.png differ diff --git a/site/static/examples/thumbnails/class-shorthand.png b/site/static/examples/thumbnails/class-shorthand.png new file mode 100644 index 0000000000..31f34e964f Binary files /dev/null and b/site/static/examples/thumbnails/class-shorthand.png differ diff --git a/site/static/examples/thumbnails/classes.png b/site/static/examples/thumbnails/classes.png new file mode 100644 index 0000000000..1eee71fa7a Binary files /dev/null and b/site/static/examples/thumbnails/classes.png differ diff --git a/site/static/examples/thumbnails/clock.png b/site/static/examples/thumbnails/clock.png new file mode 100644 index 0000000000..3f2b2b0d3e Binary files /dev/null and b/site/static/examples/thumbnails/clock.png differ diff --git a/site/static/examples/thumbnails/component-bindings.png b/site/static/examples/thumbnails/component-bindings.png new file mode 100644 index 0000000000..481e129b57 Binary files /dev/null and b/site/static/examples/thumbnails/component-bindings.png differ diff --git a/site/static/examples/thumbnails/component-events.png b/site/static/examples/thumbnails/component-events.png new file mode 100644 index 0000000000..960c7c7dbe Binary files /dev/null and b/site/static/examples/thumbnails/component-events.png differ diff --git a/site/static/examples/thumbnails/context-api.png b/site/static/examples/thumbnails/context-api.png new file mode 100644 index 0000000000..2a9c16e4c1 Binary files /dev/null and b/site/static/examples/thumbnails/context-api.png differ diff --git a/site/static/examples/thumbnails/custom-css-transitions.png b/site/static/examples/thumbnails/custom-css-transitions.png new file mode 100644 index 0000000000..05ae835701 Binary files /dev/null and b/site/static/examples/thumbnails/custom-css-transitions.png differ diff --git a/site/static/examples/thumbnails/custom-js-transitions.png b/site/static/examples/thumbnails/custom-js-transitions.png new file mode 100644 index 0000000000..470af19284 Binary files /dev/null and b/site/static/examples/thumbnails/custom-js-transitions.png differ diff --git a/site/static/examples/thumbnails/custom-stores.png b/site/static/examples/thumbnails/custom-stores.png new file mode 100644 index 0000000000..2f21706974 Binary files /dev/null and b/site/static/examples/thumbnails/custom-stores.png differ diff --git a/site/static/examples/thumbnails/debug.png b/site/static/examples/thumbnails/debug.png new file mode 100644 index 0000000000..c3155954bc Binary files /dev/null and b/site/static/examples/thumbnails/debug.png differ diff --git a/site/static/examples/thumbnails/declaring-props.png b/site/static/examples/thumbnails/declaring-props.png new file mode 100644 index 0000000000..6eda4ecaf5 Binary files /dev/null and b/site/static/examples/thumbnails/declaring-props.png differ diff --git a/site/static/examples/thumbnails/default-values.png b/site/static/examples/thumbnails/default-values.png new file mode 100644 index 0000000000..e8c26e7280 Binary files /dev/null and b/site/static/examples/thumbnails/default-values.png differ diff --git a/site/static/examples/thumbnails/deferred-transitions.png b/site/static/examples/thumbnails/deferred-transitions.png new file mode 100644 index 0000000000..8334d7ecb0 Binary files /dev/null and b/site/static/examples/thumbnails/deferred-transitions.png differ diff --git a/site/static/examples/thumbnails/derived-stores.png b/site/static/examples/thumbnails/derived-stores.png new file mode 100644 index 0000000000..b8d0f18027 Binary files /dev/null and b/site/static/examples/thumbnails/derived-stores.png differ diff --git a/site/static/examples/thumbnails/dimensions.png b/site/static/examples/thumbnails/dimensions.png new file mode 100644 index 0000000000..95796d6b12 Binary files /dev/null and b/site/static/examples/thumbnails/dimensions.png differ diff --git a/site/static/examples/thumbnails/dom-event-forwarding.png b/site/static/examples/thumbnails/dom-event-forwarding.png new file mode 100644 index 0000000000..89136fe37e Binary files /dev/null and b/site/static/examples/thumbnails/dom-event-forwarding.png differ diff --git a/site/static/examples/thumbnails/dom-events.png b/site/static/examples/thumbnails/dom-events.png new file mode 100644 index 0000000000..a219f75c48 Binary files /dev/null and b/site/static/examples/thumbnails/dom-events.png differ diff --git a/site/static/examples/thumbnails/dynamic-attributes.png b/site/static/examples/thumbnails/dynamic-attributes.png new file mode 100644 index 0000000000..f209e99590 Binary files /dev/null and b/site/static/examples/thumbnails/dynamic-attributes.png differ diff --git a/site/static/examples/thumbnails/each-block-bindings.png b/site/static/examples/thumbnails/each-block-bindings.png new file mode 100644 index 0000000000..4d1369be97 Binary files /dev/null and b/site/static/examples/thumbnails/each-block-bindings.png differ diff --git a/site/static/examples/thumbnails/each-blocks.png b/site/static/examples/thumbnails/each-blocks.png new file mode 100644 index 0000000000..3a0c646131 Binary files /dev/null and b/site/static/examples/thumbnails/each-blocks.png differ diff --git a/site/static/examples/thumbnails/else-blocks.png b/site/static/examples/thumbnails/else-blocks.png new file mode 100644 index 0000000000..dfd2585b18 Binary files /dev/null and b/site/static/examples/thumbnails/else-blocks.png differ diff --git a/site/static/examples/thumbnails/else-if-blocks.png b/site/static/examples/thumbnails/else-if-blocks.png new file mode 100644 index 0000000000..40abea3838 Binary files /dev/null and b/site/static/examples/thumbnails/else-if-blocks.png differ diff --git a/site/static/examples/thumbnails/event-forwarding.png b/site/static/examples/thumbnails/event-forwarding.png new file mode 100644 index 0000000000..960c7c7dbe Binary files /dev/null and b/site/static/examples/thumbnails/event-forwarding.png differ diff --git a/site/static/examples/thumbnails/event-modifiers.png b/site/static/examples/thumbnails/event-modifiers.png new file mode 100644 index 0000000000..f8a616690a Binary files /dev/null and b/site/static/examples/thumbnails/event-modifiers.png differ diff --git a/site/static/examples/thumbnails/group-inputs.png b/site/static/examples/thumbnails/group-inputs.png new file mode 100644 index 0000000000..e1c7ff791b Binary files /dev/null and b/site/static/examples/thumbnails/group-inputs.png differ diff --git a/site/static/examples/thumbnails/hacker-news.png b/site/static/examples/thumbnails/hacker-news.png new file mode 100644 index 0000000000..0f02ccf0a9 Binary files /dev/null and b/site/static/examples/thumbnails/hacker-news.png differ diff --git a/site/static/examples/thumbnails/hello-world.png b/site/static/examples/thumbnails/hello-world.png new file mode 100644 index 0000000000..b9acfca3b7 Binary files /dev/null and b/site/static/examples/thumbnails/hello-world.png differ diff --git a/site/static/examples/thumbnails/html-tags.png b/site/static/examples/thumbnails/html-tags.png new file mode 100644 index 0000000000..6d744e4eb3 Binary files /dev/null and b/site/static/examples/thumbnails/html-tags.png differ diff --git a/site/static/examples/thumbnails/if-blocks.png b/site/static/examples/thumbnails/if-blocks.png new file mode 100644 index 0000000000..dfd2585b18 Binary files /dev/null and b/site/static/examples/thumbnails/if-blocks.png differ diff --git a/site/static/examples/thumbnails/immutable-data.png b/site/static/examples/thumbnails/immutable-data.png new file mode 100644 index 0000000000..768486e86f Binary files /dev/null and b/site/static/examples/thumbnails/immutable-data.png differ diff --git a/site/static/examples/thumbnails/in-and-out.png b/site/static/examples/thumbnails/in-and-out.png new file mode 100644 index 0000000000..dca49b3f9d Binary files /dev/null and b/site/static/examples/thumbnails/in-and-out.png differ diff --git a/site/static/examples/thumbnails/inline-handlers.png b/site/static/examples/thumbnails/inline-handlers.png new file mode 100644 index 0000000000..a219f75c48 Binary files /dev/null and b/site/static/examples/thumbnails/inline-handlers.png differ diff --git a/site/static/examples/thumbnails/keyed-each-blocks.png b/site/static/examples/thumbnails/keyed-each-blocks.png new file mode 100644 index 0000000000..137a3cac74 Binary files /dev/null and b/site/static/examples/thumbnails/keyed-each-blocks.png differ diff --git a/site/static/examples/thumbnails/media-elements.png b/site/static/examples/thumbnails/media-elements.png new file mode 100644 index 0000000000..c233bce670 Binary files /dev/null and b/site/static/examples/thumbnails/media-elements.png differ diff --git a/site/static/examples/thumbnails/modal.png b/site/static/examples/thumbnails/modal.png new file mode 100644 index 0000000000..0fda9555cf Binary files /dev/null and b/site/static/examples/thumbnails/modal.png differ diff --git a/site/static/examples/thumbnails/module-exports.png b/site/static/examples/thumbnails/module-exports.png new file mode 100644 index 0000000000..4838fe704e Binary files /dev/null and b/site/static/examples/thumbnails/module-exports.png differ diff --git a/site/static/examples/thumbnails/multiple-select-bindings.png b/site/static/examples/thumbnails/multiple-select-bindings.png new file mode 100644 index 0000000000..7b90cb2280 Binary files /dev/null and b/site/static/examples/thumbnails/multiple-select-bindings.png differ diff --git a/site/static/examples/thumbnails/named-slots.png b/site/static/examples/thumbnails/named-slots.png new file mode 100644 index 0000000000..a5f586905f Binary files /dev/null and b/site/static/examples/thumbnails/named-slots.png differ diff --git a/site/static/examples/thumbnails/nested-components.png b/site/static/examples/thumbnails/nested-components.png new file mode 100644 index 0000000000..12700c9302 Binary files /dev/null and b/site/static/examples/thumbnails/nested-components.png differ diff --git a/site/static/examples/thumbnails/numeric-inputs.png b/site/static/examples/thumbnails/numeric-inputs.png new file mode 100644 index 0000000000..0db2df1450 Binary files /dev/null and b/site/static/examples/thumbnails/numeric-inputs.png differ diff --git a/site/static/examples/thumbnails/ondestroy.png b/site/static/examples/thumbnails/ondestroy.png new file mode 100644 index 0000000000..00dfd95496 Binary files /dev/null and b/site/static/examples/thumbnails/ondestroy.png differ diff --git a/site/static/examples/thumbnails/onmount.png b/site/static/examples/thumbnails/onmount.png new file mode 100644 index 0000000000..c488473d66 Binary files /dev/null and b/site/static/examples/thumbnails/onmount.png differ diff --git a/site/static/examples/thumbnails/reactive-assignments.png b/site/static/examples/thumbnails/reactive-assignments.png new file mode 100644 index 0000000000..4b8803caf1 Binary files /dev/null and b/site/static/examples/thumbnails/reactive-assignments.png differ diff --git a/site/static/examples/thumbnails/reactive-declarations.png b/site/static/examples/thumbnails/reactive-declarations.png new file mode 100644 index 0000000000..bb342db5b0 Binary files /dev/null and b/site/static/examples/thumbnails/reactive-declarations.png differ diff --git a/site/static/examples/thumbnails/reactive-statements.png b/site/static/examples/thumbnails/reactive-statements.png new file mode 100644 index 0000000000..4b8803caf1 Binary files /dev/null and b/site/static/examples/thumbnails/reactive-statements.png differ diff --git a/site/static/examples/thumbnails/readable-stores.png b/site/static/examples/thumbnails/readable-stores.png new file mode 100644 index 0000000000..16454533ae Binary files /dev/null and b/site/static/examples/thumbnails/readable-stores.png differ diff --git a/site/static/examples/thumbnails/scatterplot.png b/site/static/examples/thumbnails/scatterplot.png new file mode 100644 index 0000000000..b52b3a4d42 Binary files /dev/null and b/site/static/examples/thumbnails/scatterplot.png differ diff --git a/site/static/examples/thumbnails/select-bindings.png b/site/static/examples/thumbnails/select-bindings.png new file mode 100644 index 0000000000..3b1bd3ea7c Binary files /dev/null and b/site/static/examples/thumbnails/select-bindings.png differ diff --git a/site/static/examples/thumbnails/sharing-code.png b/site/static/examples/thumbnails/sharing-code.png new file mode 100644 index 0000000000..6fde40dcaf Binary files /dev/null and b/site/static/examples/thumbnails/sharing-code.png differ diff --git a/site/static/examples/thumbnails/slot-fallbacks.png b/site/static/examples/thumbnails/slot-fallbacks.png new file mode 100644 index 0000000000..debf43c24c Binary files /dev/null and b/site/static/examples/thumbnails/slot-fallbacks.png differ diff --git a/site/static/examples/thumbnails/slot-props.png b/site/static/examples/thumbnails/slot-props.png new file mode 100644 index 0000000000..6a1551ed4a Binary files /dev/null and b/site/static/examples/thumbnails/slot-props.png differ diff --git a/site/static/examples/thumbnails/slots.png b/site/static/examples/thumbnails/slots.png new file mode 100644 index 0000000000..3b755c39bd Binary files /dev/null and b/site/static/examples/thumbnails/slots.png differ diff --git a/site/static/examples/thumbnails/spread-props.png b/site/static/examples/thumbnails/spread-props.png new file mode 100644 index 0000000000..449a36ca05 Binary files /dev/null and b/site/static/examples/thumbnails/spread-props.png differ diff --git a/site/static/examples/thumbnails/spring.png b/site/static/examples/thumbnails/spring.png new file mode 100644 index 0000000000..0701a058db Binary files /dev/null and b/site/static/examples/thumbnails/spring.png differ diff --git a/site/static/examples/thumbnails/styling.png b/site/static/examples/thumbnails/styling.png new file mode 100644 index 0000000000..f8ad7e4a39 Binary files /dev/null and b/site/static/examples/thumbnails/styling.png differ diff --git a/site/static/examples/thumbnails/svelte-body.png b/site/static/examples/thumbnails/svelte-body.png new file mode 100644 index 0000000000..aae132bdc2 Binary files /dev/null and b/site/static/examples/thumbnails/svelte-body.png differ diff --git a/site/static/examples/thumbnails/svelte-component.png b/site/static/examples/thumbnails/svelte-component.png new file mode 100644 index 0000000000..eabcfc8be9 Binary files /dev/null and b/site/static/examples/thumbnails/svelte-component.png differ diff --git a/site/static/examples/thumbnails/svelte-head.png b/site/static/examples/thumbnails/svelte-head.png new file mode 100644 index 0000000000..944c473aa6 Binary files /dev/null and b/site/static/examples/thumbnails/svelte-head.png differ diff --git a/site/static/examples/thumbnails/svelte-options.png b/site/static/examples/thumbnails/svelte-options.png new file mode 100644 index 0000000000..c07cc884ca Binary files /dev/null and b/site/static/examples/thumbnails/svelte-options.png differ diff --git a/site/static/examples/thumbnails/svelte-self.png b/site/static/examples/thumbnails/svelte-self.png new file mode 100644 index 0000000000..ad44d6a25d Binary files /dev/null and b/site/static/examples/thumbnails/svelte-self.png differ diff --git a/site/static/examples/thumbnails/svelte-window.png b/site/static/examples/thumbnails/svelte-window.png new file mode 100644 index 0000000000..1184e46da2 Binary files /dev/null and b/site/static/examples/thumbnails/svelte-window.png differ diff --git a/site/static/examples/thumbnails/svg-transitions.png b/site/static/examples/thumbnails/svg-transitions.png new file mode 100644 index 0000000000..87e46e9df5 Binary files /dev/null and b/site/static/examples/thumbnails/svg-transitions.png differ diff --git a/site/static/examples/thumbnails/text-inputs.png b/site/static/examples/thumbnails/text-inputs.png new file mode 100644 index 0000000000..f644c73f80 Binary files /dev/null and b/site/static/examples/thumbnails/text-inputs.png differ diff --git a/site/static/examples/thumbnails/textarea-inputs.png b/site/static/examples/thumbnails/textarea-inputs.png new file mode 100644 index 0000000000..08d35db4da Binary files /dev/null and b/site/static/examples/thumbnails/textarea-inputs.png differ diff --git a/site/static/examples/thumbnails/tick.png b/site/static/examples/thumbnails/tick.png new file mode 100644 index 0000000000..f2de0ee11f Binary files /dev/null and b/site/static/examples/thumbnails/tick.png differ diff --git a/site/static/examples/thumbnails/transition-events.png b/site/static/examples/thumbnails/transition-events.png new file mode 100644 index 0000000000..52fee5f138 Binary files /dev/null and b/site/static/examples/thumbnails/transition-events.png differ diff --git a/site/static/examples/thumbnails/transition.png b/site/static/examples/thumbnails/transition.png new file mode 100644 index 0000000000..4d962a42c9 Binary files /dev/null and b/site/static/examples/thumbnails/transition.png differ diff --git a/site/static/examples/thumbnails/tweened.png b/site/static/examples/thumbnails/tweened.png new file mode 100644 index 0000000000..34af4dbca4 Binary files /dev/null and b/site/static/examples/thumbnails/tweened.png differ diff --git a/site/static/examples/thumbnails/update.png b/site/static/examples/thumbnails/update.png new file mode 100644 index 0000000000..1b84ccf5ba Binary files /dev/null and b/site/static/examples/thumbnails/update.png differ diff --git a/site/static/examples/thumbnails/writable-stores.png b/site/static/examples/thumbnails/writable-stores.png new file mode 100644 index 0000000000..2f21706974 Binary files /dev/null and b/site/static/examples/thumbnails/writable-stores.png differ diff --git a/site/static/global.css b/site/static/global.css index 38d1836a6c..63f9d6ad5e 100644 --- a/site/static/global.css +++ b/site/static/global.css @@ -380,7 +380,7 @@ button[outline] { transform: scaleX(1); } */ -a:hover > .icon { stroke: var(--flash) } +a:hover:not(.disabled) > .icon { stroke: var(--flash) } /* lists ---------------------------------- */ .listify ol, diff --git a/site/static/logo-mask.svg b/site/static/logo-mask.svg new file mode 100644 index 0000000000..d7919a61ab --- /dev/null +++ b/site/static/logo-mask.svg @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/site/static/prism.css b/site/static/prism.css index 4b7f86c4a4..912aee8834 100644 --- a/site/static/prism.css +++ b/site/static/prism.css @@ -29,6 +29,7 @@ pre[class*='language-'] { font: 300 var(--code-fs)/1.7 var(--font-mono); color: var(--base); tab-size: 2; + -moz-tab-size: 2; -webkit-hyphens: none; hyphens: none; } diff --git a/site/static/repl-runner.js b/site/static/repl-runner.js index 0d87322b2a..4e0194e726 100644 --- a/site/static/repl-runner.js +++ b/site/static/repl-runner.js @@ -3,143 +3,143 @@ const importCache = {}; function fetchImport(id) { - return new Promise((fulfil, reject) => { - curl([`https://bundle.run/${id}`]).then(module => { - importCache[id] = module; - fulfil(module); - }, err => { - console.error(err.stack); - reject(new Error(`Error loading ${id} from bundle.run`)); - }); - }); + return new Promise((fulfil, reject) => { + curl([`https://bundle.run/${id}`]).then(module => { + importCache[id] = module; + fulfil(module); + }, err => { + console.error(err.stack); + reject(new Error(`Error loading ${id} from bundle.run`)); + }); + }); } -function fetchImports(bundle, progressFunc) { - const missingImports = bundle.imports.filter(x => !importCache[x]); - let pendingImports = missingImports.length; - - if (missingImports.length) { - let promise = Promise.all( - missingImports.map(id => fetchImport(id).then(() => { - pendingImports -= 1; - if (progressFunc) progressFunc(pendingImports); - })) - ); - - return promise - } else { - return Promise.resolve(); - } +function fetchImports(imports, progressFunc) { + const missingImports = imports.filter(x => !importCache[x]); + let pendingImports = missingImports.length; + + if (missingImports.length) { + let promise = Promise.all( + missingImports.map(id => fetchImport(id).then(() => { + pendingImports -= 1; + if (progressFunc) progressFunc(pendingImports); + })) + ); + + return promise + } else { + return Promise.resolve(); + } } function handleMessage(ev) { - let { action, cmdId } = ev.data; - const sendMessage = (payload) => parent.postMessage( { ...payload }, ev.origin); - const sendReply = (payload) => sendMessage({ ...payload, cmdId }) - const sendOk = () => sendReply({ action: "cmdOk" }); - const sendError = (message, stack) => sendReply({ action: "cmdError", message, stack }) - - - if (action == "eval") { - let { script } = ev.data.args; - try { - eval(script); - sendOk(); - } catch (e) { - sendError(e.message, e.stack); - } - } - - if (action == "bind_props") { - let { props } = ev.data.args - - if (!window.component) { - // TODO can this happen? - console.warn('no component to bind to'); - sendOk(); - return; - } - - try { - props.forEach(prop => { - // TODO should there be a public API for binding? - // e.g. `component.$watch(prop, handler)`? - // (answer: probably) - window.component.$$.bound[prop] = value => { - sendMessage({ action:"prop_update", args: { prop, value } }) - }; - }); - sendOk(); - } catch (e) { - - sendError(e.message, e.stack); - } - } - - if (action == "set_prop") { - try { - if (!window.component) { - return; - } - let { prop, value } = ev.data.args; - component[prop] = value; - sendOk(); - } catch (e) { - sendError(e.message, e.stack); - } - } - - if (action == "catch_clicks") { - try { - let topOrigin = ev.origin; - document.body.addEventListener('click', event => { - if (event.which !== 1) return; - if (event.metaKey || event.ctrlKey || event.shiftKey) return; - if (event.defaultPrevented) return; - - // ensure target is a link - let el = event.target; - while (el && el.nodeName !== 'A') el = el.parentNode; - if (!el || el.nodeName !== 'A') return; - - if (el.hasAttribute('download') || el.getAttribute('rel') === 'external' || el.target) return; - - event.preventDefault(); - - if (el.href.startsWith(topOrigin)) { - const url = new URL(el.href); - if (url.hash[0] === '#') { - window.location.hash = url.hash; - return; - } - } - - window.open(el.href, '_blank'); - }); - sendOk(); - } catch(e) { - sendError(e.message, e.stack); - } - } - - - if (action == "fetch_imports") { - let { bundle } = ev.data.args; - fetchImports(bundle, (remaining) => { - sendMessage({action: "fetch_progress", args: { remaining }}); - }) - .then(() => { - bundle.imports.forEach(x=> { - const module = importCache[x]; - const name = bundle.importMap.get(x); - window[name] = module; - }); - sendOk(); - }) - .catch(e => { - sendError(e.message, e.stack); - }) - } + let { action, cmdId } = ev.data; + const sendMessage = (payload) => parent.postMessage( { ...payload }, ev.origin); + const sendReply = (payload) => sendMessage({ ...payload, cmdId }) + const sendOk = () => sendReply({ action: "cmdOk" }); + const sendError = (message, stack) => sendReply({ action: "cmdError", message, stack }) + + + if (action == "eval") { + let { script } = ev.data.args; + try { + eval(script); + sendOk(); + } catch (e) { + sendError(e.message, e.stack); + } + } + + if (action == "bind_props") { + let { props } = ev.data.args + + if (!window.component) { + // TODO can this happen? + console.warn('no component to bind to'); + sendOk(); + return; + } + + try { + props.forEach(prop => { + // TODO should there be a public API for binding? + // e.g. `component.$watch(prop, handler)`? + // (answer: probably) + window.component.$$.bound[prop] = value => { + sendMessage({ action:"prop_update", args: { prop, value } }) + }; + }); + sendOk(); + } catch (e) { + + sendError(e.message, e.stack); + } + } + + if (action == "set_prop") { + try { + if (!window.component) { + return; + } + let { prop, value } = ev.data.args; + component[prop] = value; + sendOk(); + } catch (e) { + sendError(e.message, e.stack); + } + } + + if (action == "catch_clicks") { + try { + let topOrigin = ev.origin; + document.body.addEventListener('click', event => { + if (event.which !== 1) return; + if (event.metaKey || event.ctrlKey || event.shiftKey) return; + if (event.defaultPrevented) return; + + // ensure target is a link + let el = event.target; + while (el && el.nodeName !== 'A') el = el.parentNode; + if (!el || el.nodeName !== 'A') return; + + if (el.hasAttribute('download') || el.getAttribute('rel') === 'external' || el.target) return; + + event.preventDefault(); + + if (el.href.startsWith(topOrigin)) { + const url = new URL(el.href); + if (url.hash[0] === '#') { + window.location.hash = url.hash; + return; + } + } + + window.open(el.href, '_blank'); + }); + sendOk(); + } catch(e) { + sendError(e.message, e.stack); + } + } + + + if (action == "fetch_imports") { + let { imports, import_map } = ev.data.args; + fetchImports(imports, (remaining) => { + sendMessage({action: "fetch_progress", args: { remaining }}); + }) + .then(() => { + imports.forEach(x=> { + const module = importCache[x]; + const name = import_map.get(x); + window[name] = module; + }); + sendOk(); + }) + .catch(e => { + sendError(e.message, e.stack); + }) + } } window.addEventListener("message", handleMessage, false) diff --git a/site/static/tutorial/dark-theme.css b/site/static/tutorial/dark-theme.css new file mode 100644 index 0000000000..e6bfb771f1 --- /dev/null +++ b/site/static/tutorial/dark-theme.css @@ -0,0 +1,5 @@ +body { + background-color: #333; + color: whitesmoke; + transition: all 0.5s; +} \ No newline at end of file diff --git a/site/static/tutorial/icons/email.svg b/site/static/tutorial/icons/email.svg new file mode 100644 index 0000000000..db656054ff --- /dev/null +++ b/site/static/tutorial/icons/email.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/icons/folder-open.svg b/site/static/tutorial/icons/folder-open.svg new file mode 100644 index 0000000000..9dac0ef9e9 --- /dev/null +++ b/site/static/tutorial/icons/folder-open.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/icons/folder.svg b/site/static/tutorial/icons/folder.svg new file mode 100644 index 0000000000..7d4a03f1d2 --- /dev/null +++ b/site/static/tutorial/icons/folder.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/icons/gif.svg b/site/static/tutorial/icons/gif.svg new file mode 100644 index 0000000000..315860a247 --- /dev/null +++ b/site/static/tutorial/icons/gif.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/icons/map-marker.svg b/site/static/tutorial/icons/map-marker.svg new file mode 100644 index 0000000000..4e9466c7bd --- /dev/null +++ b/site/static/tutorial/icons/map-marker.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/icons/md.svg b/site/static/tutorial/icons/md.svg new file mode 100644 index 0000000000..60bc36f4a7 --- /dev/null +++ b/site/static/tutorial/icons/md.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/icons/xlsx.svg b/site/static/tutorial/icons/xlsx.svg new file mode 100644 index 0000000000..6ee32e943d --- /dev/null +++ b/site/static/tutorial/icons/xlsx.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/site/static/tutorial/image.gif b/site/static/tutorial/image.gif new file mode 100644 index 0000000000..3ce9c237d5 Binary files /dev/null and b/site/static/tutorial/image.gif differ diff --git a/site/static/tutorial/kitten.png b/site/static/tutorial/kitten.png new file mode 100644 index 0000000000..6ef37691bc Binary files /dev/null and b/site/static/tutorial/kitten.png differ diff --git a/site/static/tutorial/music/beethoven.mp3 b/site/static/tutorial/music/beethoven.mp3 new file mode 100644 index 0000000000..3bda3ae676 Binary files /dev/null and b/site/static/tutorial/music/beethoven.mp3 differ diff --git a/site/static/tutorial/music/holst.mp3 b/site/static/tutorial/music/holst.mp3 new file mode 100644 index 0000000000..b1ba89f486 Binary files /dev/null and b/site/static/tutorial/music/holst.mp3 differ diff --git a/site/static/tutorial/music/mozart.mp3 b/site/static/tutorial/music/mozart.mp3 new file mode 100644 index 0000000000..d9a2d2781f Binary files /dev/null and b/site/static/tutorial/music/mozart.mp3 differ diff --git a/site/static/tutorial/music/satie.mp3 b/site/static/tutorial/music/satie.mp3 new file mode 100644 index 0000000000..c2488d7bb4 Binary files /dev/null and b/site/static/tutorial/music/satie.mp3 differ diff --git a/site/static/tutorial/music/strauss.mp3 b/site/static/tutorial/music/strauss.mp3 new file mode 100644 index 0000000000..db433dd35f Binary files /dev/null and b/site/static/tutorial/music/strauss.mp3 differ diff --git a/site/static/workers/bundler.js b/site/static/workers/bundler.js index de2152c19e..06a2364f93 100644 --- a/site/static/workers/bundler.js +++ b/site/static/workers/bundler.js @@ -14,7 +14,7 @@ self.addEventListener('message', async event => { version === 'local' ? '/repl/local?file=compiler.js' : `https://unpkg.com/svelte@${version}/compiler.js`, - `https://unpkg.com/rollup@0.68/dist/rollup.browser.js` + `https://unpkg.com/rollup@1/dist/rollup.browser.js` ); fulfil(); @@ -38,8 +38,8 @@ const commonCompilerOptions = { }; let cached = { - dom: null, - ssr: null + dom: {}, + ssr: {} }; let currentToken; @@ -62,10 +62,9 @@ function fetch_if_uncached(url) { async function getBundle(mode, cache, lookup) { let bundle; - let error; - let warningCount = 0; + const all_warnings = []; - const info = {}; + const new_cache = {}; try { bundle = await rollup.rollup({ @@ -89,6 +88,8 @@ async function getBundle(mode, cache, lookup) { if (importee.endsWith('.html')) importee = importee.replace(/\.html$/, '.svelte'); if (importee in lookup) return importee; + + throw new Error(`Could not resolve "${importee}" from "${importer}"`); }, load(id) { if (id.startsWith(`https://`)) return fetch_if_uncached(id); @@ -99,33 +100,41 @@ async function getBundle(mode, cache, lookup) { const name = id.replace(/^\.\//, '').replace(/\.svelte$/, ''); - const { js, stats, warnings } = svelte.compile(code, Object.assign({ - generate: mode, - format: 'esm', - name: name, - filename: name + '.svelte' - }, commonCompilerOptions)); - - (warnings || stats.warnings).forEach(warning => { // TODO remove stats post-launch - console.warn(warning.message); - console.log(warning.frame); - warningCount += 1; + const result = cache[id] && cache[id].code === code + ? cache[id].result + : svelte.compile(code, Object.assign({ + generate: mode, + format: 'esm', + name, + filename: name + '.svelte' + }, commonCompilerOptions)); + + new_cache[id] = { code, result }; + + (result.warnings || result.stats.warnings).forEach(warning => { // TODO remove stats post-launch + all_warnings.push({ + message: warning.message, + filename: warning.filename, + start: warning.start, + end: warning.end + }); }); - return js; + return result.js; } }], + inlineDynamicImports: true, onwarn(warning) { - console.warn(warning); - warningCount += 1; - }, - cache + all_warnings.push({ + message: warning.message + }); + } }); } catch (error) { - return { error, bundle: null, info: null, warningCount: null } + return { error, bundle: null, cache: new_cache, warnings: all_warnings }; } - return { bundle, info, error: null, warningCount }; + return { bundle, cache: new_cache, error: null, warnings: all_warnings }; } async function bundle(components) { @@ -140,6 +149,7 @@ async function bundle(components) { lookup[path] = component; }); + const import_map = new Map(); let dom; let error; @@ -154,30 +164,30 @@ async function bundle(components) { return; } - cached.dom = dom.bundle; + cached.dom = dom.cache; let uid = 1; - const importMap = new Map(); - const domResult = await dom.bundle.generate({ + const dom_result = (await dom.bundle.generate({ format: 'iife', name: 'SvelteComponent', globals: id => { const name = `import_${uid++}`; - importMap.set(id, name); + import_map.set(id, name); return name; }, + exports: 'named', sourcemap: true - }); + })).output[0]; if (token !== currentToken) return; - const ssr = dom.info.usesHooks + const ssr = false // TODO how can we do SSR? ? await getBundle('ssr', cached.ssr, lookup) : null; if (ssr) { - cached.ssr = ssr.bundle; + cached.ssr = ssr.cache; if (ssr.error) { throw ssr.error; } @@ -185,23 +195,22 @@ async function bundle(components) { if (token !== currentToken) return; - const ssrResult = ssr - ? await ssr.bundle.generate({ + const ssr_result = ssr + ? (await ssr.bundle.generate({ format: 'iife', name: 'SvelteComponent', - globals: id => importMap.get(id), + globals: id => import_map.get(id), + exports: 'named', sourcemap: true - }) + })).output[0] : null; return { - bundle: { - imports: dom.bundle.imports, - importMap - }, - dom: domResult, - ssr: ssrResult, - warningCount: dom.warningCount, + imports: dom_result.imports, + import_map, + dom: dom_result, + ssr: ssr_result, + warnings: dom.warnings, error: null }; } catch (err) { @@ -209,10 +218,11 @@ async function bundle(components) { delete e.toString; return { - bundle: null, + imports: [], + import_map, dom: null, ssr: null, - warningCount: dom.warningCount, + warnings: dom.warnings, error: Object.assign({}, e, { message: e.message, stack: e.stack diff --git a/site/static/workers/compiler.js b/site/static/workers/compiler.js index 0583186dc7..e919097310 100644 --- a/site/static/workers/compiler.js +++ b/site/static/workers/compiler.js @@ -29,22 +29,31 @@ const commonCompilerOptions = { css: false }; -function compile({ source, options, entry }) { +function compile({ id, source, options, entry }) { try { const { js, css, stats, vars } = svelte.compile( source, Object.assign({}, commonCompilerOptions, options) ); - const props = entry - ? (vars || stats.vars).map(v => v.writable && v.export_name).filter(Boolean) // TODO remove stats post-launch - : null; - - return { js: js.code, css: css.code, props }; + return { + id, + result: { + js: js.code, + css: css.code || `/* Add a tag to see compiled CSS */` + } + }; } catch (err) { - let result = `/* Error compiling component\n\n${err.message}`; - if (err.frame) result += `\n${err.frame}`; - result += `\n\n*/`; - return { code: result, props: null }; + let message = `/* Error compiling component\n\n${err.message}`; + if (err.frame) message += `\n${err.frame}`; + message += `\n\n*/`; + + return { + id, + result: { + js: message, + css: message + } + }; } } diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 8589ef6af7..4df2abad35 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -26,9 +26,7 @@ type ComponentOptions = { namespace?: string; tag?: string; immutable?: boolean; - props?: string; - props_object?: string; - props_node?: Node; + accessors?: boolean; }; // We need to tell estree-walker that it should always @@ -55,6 +53,7 @@ export default class Component { componentOptions: ComponentOptions; namespace: string; tag: string; + accessors: boolean; vars: Var[] = []; var_lookup: Map = new Map(); @@ -131,33 +130,8 @@ export default class Component { this.walk_module_js(); this.walk_instance_js_pre_template(); - if (this.componentOptions.props) { - this.has_reactive_assignments = true; - - const name = this.componentOptions.props_object; - - if (!this.ast.module && !this.ast.instance) { - this.add_var({ - name, - export_name: name, - implicit: true - }); - } - - const variable = this.var_lookup.get(name); - - if (!variable) { - this.error(this.componentOptions.props_node, { - code: 'missing-declaration', - message: `'${name}' is not defined` - }); - } - - variable.reassigned = true; - } - - this.name = this.getUniqueName(name); this.fragment = new Fragment(this, ast.html); + this.name = this.getUniqueName(name); this.walk_instance_js_post_template(); @@ -176,6 +150,12 @@ export default class Component { if (variable) { variable.referenced = true; + } else if (name === '$$props') { + this.add_var({ + name, + injected: true, + referenced: true + }); } else if (name[0] === '$') { this.add_var({ name, @@ -189,16 +169,9 @@ export default class Component { this.add_reference(subscribable_name); const variable = this.var_lookup.get(subscribable_name); - variable.subscribable = true; - } else if (!this.ast.instance) { - this.add_var({ - name, - export_name: name, - implicit: true, - mutated: false, - referenced: true, - writable: true - }); + if (variable) variable.subscribable = true; + } else { + this.usedNames.add(name); } } @@ -234,19 +207,20 @@ export default class Component { const banner = `/* ${this.file ? `${this.file} ` : ``}generated by Svelte v${"__VERSION__"} */`; - // TODO use same regex for both - result = result.replace(compileOptions.generate === 'ssr' ? /(@+|#+)(\w*(?:-\w*)?)/g : /(@+)(\w*(?:-\w*)?)/g, (match: string, sigil: string, name: string) => { - if (sigil === '@') { - if (internal_exports.has(name)) { - if (compileOptions.dev && internal_exports.has(`${name}Dev`)) name = `${name}Dev`; - this.helpers.add(name); - } + result = result + .replace(/__svelte:self__/g, this.name) + .replace(compileOptions.generate === 'ssr' ? /(@+|#+)(\w*(?:-\w*)?)/g : /(@+)(\w*(?:-\w*)?)/g, (match: string, sigil: string, name: string) => { + if (sigil === '@') { + if (internal_exports.has(name)) { + if (compileOptions.dev && internal_exports.has(`${name}Dev`)) name = `${name}Dev`; + this.helpers.add(name); + } - return this.alias(name); - } + return this.alias(name); + } - return sigil.slice(1) + name; - }); + return sigil.slice(1) + name; + }); const importedHelpers = Array.from(this.helpers) .sort() @@ -456,6 +430,12 @@ export default class Component { } if (node.type === 'ExportNamedDeclaration') { + if (node.source) { + this.error(node, { + code: `not-implemented`, + message: `A component currently cannot have an export ... from` + }); + } if (node.declaration) { if (node.declaration.type === 'VariableDeclaration') { node.declaration.declarations.forEach(declarator => { @@ -622,6 +602,11 @@ export default class Component { reassigned: true, initialised: true }); + } else if (name === '$$props') { + this.add_var({ + name, + injected: true + }); } else if (name[0] === '$') { this.add_var({ name, @@ -769,7 +754,7 @@ export default class Component { extractNames(declarator.id).forEach(name => { const variable = component.var_lookup.get(name); - if (variable.export_name || name === componentOptions.props_object) { + if (variable.export_name) { component.error(declarator, { code: 'destructured-prop', message: `Cannot declare props in destructured declaration` @@ -795,48 +780,37 @@ export default class Component { const { name } = declarator.id; const variable = component.var_lookup.get(name); - if (name === componentOptions.props_object) { - if (variable.export_name) { - component.error(declarator, { - code: 'exported-options-props', - message: `Cannot export props binding` - }); + if (variable.export_name) { + if (current_group && current_group.kind !== node.kind) { + current_group = null; } - // can't use the @ trick here, because we're - // manipulating the underlying magic string - const exclude_internal_props = component.helper('exclude_internal_props'); - - const suffix = code.original[declarator.end] === ';' - ? ` = ${exclude_internal_props}($$props)` - : ` = ${exclude_internal_props}($$props);` + const insert = variable.subscribable + ? get_insert(variable) + : null; - if (declarator.id.end === declarator.end) { - code.appendLeft(declarator.end, suffix); + if (!current_group || (current_group.insert && insert)) { + current_group = { kind: node.kind, declarators: [declarator], insert }; + coalesced_declarations.push(current_group); + } else if (insert) { + current_group.insert = insert; + current_group.declarators.push(declarator); } else { - code.overwrite(declarator.id.end, declarator.end, suffix); + current_group.declarators.push(declarator); } - } - if (variable.export_name) { - if (variable.subscribable) { - coalesced_declarations.push({ - kind: node.kind, - declarators: [declarator], - insert: get_insert(variable) - }); - current_group = null; - } else { - if (current_group && current_group.kind !== node.kind) { - current_group = null; - } + if (variable.name !== variable.export_name) { + code.prependRight(declarator.id.start, `${variable.export_name}:`) + } - if (!current_group) { - current_group = { kind: node.kind, declarators: [], insert: null }; - coalesced_declarations.push(current_group); - } + if (next) { + const next_variable = component.var_lookup.get(next.id.name) + const new_declaration = !next_variable.export_name + || (current_group.insert && next_variable.subscribable) - current_group.declarators.push(declarator); + if (new_declaration) { + code.overwrite(declarator.end, next.start, ` ${node.kind} `); + } } } else { current_group = null; @@ -868,8 +842,9 @@ export default class Component { }); coalesced_declarations.forEach(group => { - let c = 0; + const writable = group.kind === 'var' || group.kind === 'let'; + let c = 0; let combining = false; group.declarators.forEach(declarator => { @@ -878,7 +853,7 @@ export default class Component { if (combining) { code.overwrite(c, id.start, ', '); } else { - code.appendLeft(id.start, '{ '); + if (writable) code.appendLeft(id.start, '{ '); combining = true; } @@ -890,7 +865,7 @@ export default class Component { ? `; ${group.insert}` : ''; - const suffix = code.original[c] === ';' ? ` } = $$props${insert}` : ` } = $$props${insert};`; + const suffix = `${writable ? ` } = $$props` : ``}${insert}` + (code.original[c] === ';' ? `` : `;`); code.appendLeft(c, suffix); } }); @@ -911,6 +886,11 @@ export default class Component { const all_hoistable = node.declarations.every(d => { if (!d.init) return false; if (d.init.type !== 'Literal') return false; + + const v = this.var_lookup.get(d.id.name) + if (v.reassigned) return false + if (v.export_name && v.export_name !== v.name) return false + if (this.var_lookup.get(d.id.name).reassigned) return false; if (this.vars.find(variable => variable.name === d.id.name && variable.module)) return false; @@ -1029,6 +1009,7 @@ export default class Component { this.reactive_declaration_nodes.add(node); const assignees = new Set(); + const assignee_nodes = new Set(); const dependencies = new Set(); let scope = this.instance_scope; @@ -1041,16 +1022,23 @@ export default class Component { } if (node.type === 'AssignmentExpression') { - assignees.add(getObject(node.left).name); + const identifier = getObject(node.left) + assignee_nodes.add(identifier); + assignees.add(identifier.name); } else if (node.type === 'UpdateExpression') { - assignees.add(getObject(node.argument).name); + const identifier = getObject(node.argument); + assignees.add(identifier.name); } else if (isReference(node, parent)) { - const object = getObject(node); - const { name } = object; - - const owner = scope.findOwner(name); - if ((!owner || owner === component.instance_scope) && (name[0] === '$' || component.var_lookup.has(name))) { - dependencies.add(name); + const identifier = getObject(node); + if (!assignee_nodes.has(identifier)) { + const { name } = identifier; + const owner = scope.findOwner(name); + if ( + (!owner || owner === component.instance_scope) && + (name[0] === '$' || component.var_lookup.has(name) && component.var_lookup.get(name).writable) + ) { + dependencies.add(name); + } } this.skip(); @@ -1134,6 +1122,8 @@ export default class Component { } qualify(name) { + if (name === `$$props`) return `ctx.$$props`; + const variable = this.var_lookup.get(name); if (!variable) return name; @@ -1143,7 +1133,7 @@ export default class Component { return `ctx.${name}`; } - warn_if_undefined(node, template_scope: TemplateScope, allow_implicit?: boolean) { + warn_if_undefined(node, template_scope: TemplateScope) { let { name } = node; if (name[0] === '$') { @@ -1151,21 +1141,26 @@ export default class Component { this.has_reactive_assignments = true; } - if (allow_implicit && !this.ast.instance && !this.ast.module) return; if (this.var_lookup.has(name)) return; if (template_scope && template_scope.names.has(name)) return; if (globalWhitelist.has(name)) return; + let message = `'${name}' is not defined`; + if (!this.ast.instance) message += `. Consider adding a + text diff --git a/test/css/samples/omit-scoping-attribute-attribute-selector-equals-dynamic/input.svelte b/test/css/samples/omit-scoping-attribute-attribute-selector-equals-dynamic/input.svelte index dda0d98c7c..e66777cd08 100644 --- a/test/css/samples/omit-scoping-attribute-attribute-selector-equals-dynamic/input.svelte +++ b/test/css/samples/omit-scoping-attribute-attribute-selector-equals-dynamic/input.svelte @@ -1,3 +1,7 @@ + +

    this is styled

    this is unstyled

    diff --git a/test/css/samples/spread/input.svelte b/test/css/samples/spread/input.svelte index ab5f2e937e..aa43e4ae11 100644 --- a/test/css/samples/spread/input.svelte +++ b/test/css/samples/spread/input.svelte @@ -1,3 +1,7 @@ + +
    Big red Comic Sans
    diff --git a/test/css/samples/unused-selector-ternary/_config.js b/test/css/samples/unused-selector-ternary/_config.js index 68254477d9..4ff2713108 100644 --- a/test/css/samples/unused-selector-ternary/_config.js +++ b/test/css/samples/unused-selector-ternary/_config.js @@ -8,22 +8,22 @@ export default { code: `css-unused-selector`, message: "Unused CSS selector", start: { - line: 12, + line: 16, column: 1, - character: 123 + character: 163 }, end: { - line: 12, + line: 16, column: 13, - character: 135 + character: 175 }, - pos: 123, + pos: 163, frame: ` - 10: } - 11: - 12: .maybeactive { + 14: } + 15: + 16: .maybeactive { ^ - 13: color: green; - 14: }` + 17: color: green; + 18: }` }] }; \ No newline at end of file diff --git a/test/css/samples/unused-selector-ternary/input.svelte b/test/css/samples/unused-selector-ternary/input.svelte index 728dfa766a..f72592834f 100644 --- a/test/css/samples/unused-selector-ternary/input.svelte +++ b/test/css/samples/unused-selector-ternary/input.svelte @@ -1,3 +1,7 @@ + +
    `; - init(this, { target: this.shadowRoot }, null, create_fragment, safe_not_equal); + init(this, { target: this.shadowRoot }, null, create_fragment, safe_not_equal, []); if (options) { if (options.target) { diff --git a/test/js/samples/debug-empty/expected.js b/test/js/samples/debug-empty/expected.js index 4a6393388c..9fd782a3c4 100644 --- a/test/js/samples/debug-empty/expected.js +++ b/test/js/samples/debug-empty/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponentDev, addLoc, append, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; +import { SvelteComponentDev, addLoc, append, createElement, createText, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; const file = undefined; @@ -14,7 +14,7 @@ function create_fragment(ctx) { text2 = createText("!"); text3 = createText("\n"); debugger; - addLoc(h1, file, 0, 0, 0); + addLoc(h1, file, 4, 0, 38); }, l: function claim(nodes) { @@ -62,7 +62,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, ["name"]); const { ctx } = this.$$; const props = options.props || {}; @@ -70,15 +70,6 @@ class SvelteComponent extends SvelteComponentDev { console.warn(" was created without expected prop 'name'"); } } - - get name() { - return this.$$.ctx.name; - } - - set name(name) { - this.$set({ name }); - flush(); - } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/debug-empty/input.svelte b/test/js/samples/debug-empty/input.svelte index 11da4f6d15..24f03b00c1 100644 --- a/test/js/samples/debug-empty/input.svelte +++ b/test/js/samples/debug-empty/input.svelte @@ -1,2 +1,6 @@ + +

    Hello {name}!

    {@debug} \ No newline at end of file diff --git a/test/js/samples/debug-foo-bar-baz-things/expected.js b/test/js/samples/debug-foo-bar-baz-things/expected.js index b56d333238..ad8e0b24ab 100644 --- a/test/js/samples/debug-foo-bar-baz-things/expected.js +++ b/test/js/samples/debug-foo-bar-baz-things/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponentDev, addLoc, append, createElement, createText, destroyEach, detachNode, flush, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; +import { SvelteComponentDev, addLoc, append, createElement, createText, destroyEach, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; const file = undefined; @@ -9,7 +9,7 @@ function get_each_context(ctx, list, i) { return child_ctx; } -// (1:0) {#each things as thing} +// (8:0) {#each things as thing} function create_each_block(ctx) { var span, text0_value = ctx.thing.name, text0, text1; @@ -24,7 +24,7 @@ function create_each_block(ctx) { console.log({ foo, bar, baz, thing }); debugger; } - addLoc(span, file, 1, 1, 25); + addLoc(span, file, 8, 1, 116); }, m: function mount(target, anchor) { @@ -75,7 +75,7 @@ function create_fragment(ctx) { p = createElement("p"); text1 = createText("foo: "); text2 = createText(ctx.foo); - addLoc(p, file, 5, 0, 91); + addLoc(p, file, 12, 0, 182); }, l: function claim(nodes) { @@ -150,7 +150,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, ["things", "foo", "bar", "baz"]); const { ctx } = this.$$; const props = options.props || {}; @@ -167,42 +167,6 @@ class SvelteComponent extends SvelteComponentDev { console.warn(" was created without expected prop 'baz'"); } } - - get things() { - return this.$$.ctx.things; - } - - set things(things) { - this.$set({ things }); - flush(); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); - } - - get bar() { - return this.$$.ctx.bar; - } - - set bar(bar) { - this.$set({ bar }); - flush(); - } - - get baz() { - return this.$$.ctx.baz; - } - - set baz(baz) { - this.$set({ baz }); - flush(); - } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/debug-foo-bar-baz-things/input.svelte b/test/js/samples/debug-foo-bar-baz-things/input.svelte index 6fa8611415..df6095c52d 100644 --- a/test/js/samples/debug-foo-bar-baz-things/input.svelte +++ b/test/js/samples/debug-foo-bar-baz-things/input.svelte @@ -1,3 +1,10 @@ + + {#each things as thing} {thing.name} {@debug foo, bar, baz, thing} diff --git a/test/js/samples/debug-foo/expected.js b/test/js/samples/debug-foo/expected.js index 35d0a1f18f..a9af1676e2 100644 --- a/test/js/samples/debug-foo/expected.js +++ b/test/js/samples/debug-foo/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponentDev, addLoc, append, createElement, createText, destroyEach, detachNode, flush, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; +import { SvelteComponentDev, addLoc, append, createElement, createText, destroyEach, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; const file = undefined; @@ -9,7 +9,7 @@ function get_each_context(ctx, list, i) { return child_ctx; } -// (1:0) {#each things as thing} +// (6:0) {#each things as thing} function create_each_block(ctx) { var span, text0_value = ctx.thing.name, text0, text1; @@ -24,7 +24,7 @@ function create_each_block(ctx) { console.log({ foo }); debugger; } - addLoc(span, file, 1, 1, 25); + addLoc(span, file, 6, 1, 82); }, m: function mount(target, anchor) { @@ -75,7 +75,7 @@ function create_fragment(ctx) { p = createElement("p"); text1 = createText("foo: "); text2 = createText(ctx.foo); - addLoc(p, file, 5, 0, 74); + addLoc(p, file, 10, 0, 131); }, l: function claim(nodes) { @@ -148,7 +148,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, ["things", "foo"]); const { ctx } = this.$$; const props = options.props || {}; @@ -159,24 +159,6 @@ class SvelteComponent extends SvelteComponentDev { console.warn(" was created without expected prop 'foo'"); } } - - get things() { - return this.$$.ctx.things; - } - - set things(things) { - this.$set({ things }); - flush(); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); - } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/debug-foo/input.svelte b/test/js/samples/debug-foo/input.svelte index 6e926a4015..553f080d94 100644 --- a/test/js/samples/debug-foo/input.svelte +++ b/test/js/samples/debug-foo/input.svelte @@ -1,3 +1,8 @@ + + {#each things as thing} {thing.name} {@debug foo} diff --git a/test/js/samples/debug-ssr-foo/expected.js b/test/js/samples/debug-ssr-foo/expected.js index afad023a3f..c7edd8bf0a 100644 --- a/test/js/samples/debug-ssr-foo/expected.js +++ b/test/js/samples/debug-ssr-foo/expected.js @@ -4,8 +4,11 @@ import { create_ssr_component, debug, each, escape } from "svelte/internal"; const SvelteComponent = create_ssr_component(($$result, $$props, $$bindings, $$slots) => { let { things, foo } = $$props; + if ($$props.things === void 0 && $$bindings.things && things !== void 0) $$bindings.things(things); + if ($$props.foo === void 0 && $$bindings.foo && foo !== void 0) $$bindings.foo(foo); + return `${each(things, (thing) => `${escape(thing.name)} - ${debug(null, 2, 2, { foo })}`)} + ${debug(null, 7, 2, { foo })}`)}

    foo: ${escape(foo)}

    `; }); diff --git a/test/js/samples/debug-ssr-foo/input.svelte b/test/js/samples/debug-ssr-foo/input.svelte index 6e926a4015..553f080d94 100644 --- a/test/js/samples/debug-ssr-foo/input.svelte +++ b/test/js/samples/debug-ssr-foo/input.svelte @@ -1,3 +1,8 @@ + + {#each things as thing} {thing.name} {@debug foo} diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index 7ad954e330..8161f7c661 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, append, createComment, createElement as createElement_1, createText, destroyEach, detachNode, flush, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, append, createComment, createElement as createElement_1, createText, destroyEach, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; function get_each_context(ctx, list, i) { const child_ctx = Object.create(ctx); @@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) { return child_ctx; } -// (1:0) {#each createElement as node} +// (5:0) {#each createElement as node} function create_each_block(ctx) { var span, text_value = ctx.node, text; @@ -113,16 +113,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get createElement() { - return this.$$.ctx.createElement; - } - - set createElement(createElement) { - this.$set({ createElement }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["createElement"]); } } diff --git a/test/js/samples/deconflict-builtins/input.svelte b/test/js/samples/deconflict-builtins/input.svelte index 48a413b323..01052de947 100644 --- a/test/js/samples/deconflict-builtins/input.svelte +++ b/test/js/samples/deconflict-builtins/input.svelte @@ -1,3 +1,7 @@ + + {#each createElement as node} {node} {/each} \ No newline at end of file diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index f3e8c93ebe..c9754108af 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, flush, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, init, noop, safe_not_equal } from "svelte/internal"; import { onMount } from "svelte"; function create_fragment(ctx) { @@ -30,16 +30,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["foo"]); } } diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index e3dff9649d..b8976fd405 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponentDev, addLoc, append, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; +import { SvelteComponentDev, addLoc, append, createElement, createText, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; const file = undefined; @@ -56,8 +56,8 @@ function instance($$self, $$props, $$invalidate) { if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo); }; - $$self.$$.update = ($$dirty = { bar: 1, foo: 1 }) => { - if ($$dirty.bar || $$dirty.foo) { + $$self.$$.update = ($$dirty = { foo: 1 }) => { + if ($$dirty.foo) { bar = foo * 2; $$invalidate('bar', bar); } }; @@ -68,7 +68,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, ["foo"]); const { ctx } = this.$$; const props = options.props || {}; @@ -76,15 +76,6 @@ class SvelteComponent extends SvelteComponentDev { console.warn(" was created without expected prop 'foo'"); } } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); - } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/do-use-dataset/expected.js b/test/js/samples/do-use-dataset/expected.js index f340f71b01..fd8aeab7b2 100644 --- a/test/js/samples/do-use-dataset/expected.js +++ b/test/js/samples/do-use-dataset/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createElement, createText, detachNode, init, insert, noop, safe_not_equal } from "svelte/internal"; function create_fragment(ctx) { var div0, text, div1; @@ -51,16 +51,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get bar() { - return this.$$.ctx.bar; - } - - set bar(bar) { - this.$set({ bar }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["bar"]); } } diff --git a/test/js/samples/do-use-dataset/input.svelte b/test/js/samples/do-use-dataset/input.svelte index ffd72ac6ee..e340b2610f 100644 --- a/test/js/samples/do-use-dataset/input.svelte +++ b/test/js/samples/do-use-dataset/input.svelte @@ -1,2 +1,6 @@ + +
    \ No newline at end of file diff --git a/test/js/samples/dont-invalidate-this/expected.js b/test/js/samples/dont-invalidate-this/expected.js new file mode 100644 index 0000000000..573bafd826 --- /dev/null +++ b/test/js/samples/dont-invalidate-this/expected.js @@ -0,0 +1,42 @@ +/* generated by Svelte vX.Y.Z */ +import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, init, insert, noop, safe_not_equal } from "svelte/internal"; + +function create_fragment(ctx) { + var input, dispose; + + return { + c() { + input = createElement("input"); + dispose = addListener(input, "input", make_uppercase); + }, + + m(target, anchor) { + insert(target, input, anchor); + }, + + p: noop, + i: noop, + o: noop, + + d(detach) { + if (detach) { + detachNode(input); + } + + dispose(); + } + }; +} + +function make_uppercase() { + this.value = this.value.toUpperCase(); +} + +class SvelteComponent extends SvelteComponent_1 { + constructor(options) { + super(); + init(this, options, null, create_fragment, safe_not_equal, []); + } +} + +export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/dont-invalidate-this/input.svelte b/test/js/samples/dont-invalidate-this/input.svelte new file mode 100644 index 0000000000..5b0a565a3a --- /dev/null +++ b/test/js/samples/dont-invalidate-this/input.svelte @@ -0,0 +1,6 @@ + + diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected.js b/test/js/samples/dont-use-dataset-in-legacy/expected.js index 974ed23b28..ab0db608ee 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createElement, createText, detachNode, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; function create_fragment(ctx) { var div0, text, div1; @@ -51,16 +51,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get bar() { - return this.$$.ctx.bar; - } - - set bar(bar) { - this.$set({ bar }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["bar"]); } } diff --git a/test/js/samples/dont-use-dataset-in-legacy/input.svelte b/test/js/samples/dont-use-dataset-in-legacy/input.svelte index ffd72ac6ee..e340b2610f 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/input.svelte +++ b/test/js/samples/dont-use-dataset-in-legacy/input.svelte @@ -1,2 +1,6 @@ + +
    \ No newline at end of file diff --git a/test/js/samples/dont-use-dataset-in-svg/expected.js b/test/js/samples/dont-use-dataset-in-svg/expected.js index cc29258326..7648e60313 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, append, createSvgElement, detachNode, flush, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, append, createSvgElement, detachNode, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; function create_fragment(ctx) { var svg, g0, g1; @@ -49,16 +49,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get bar() { - return this.$$.ctx.bar; - } - - set bar(bar) { - this.$set({ bar }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["bar"]); } } diff --git a/test/js/samples/dont-use-dataset-in-svg/input.svelte b/test/js/samples/dont-use-dataset-in-svg/input.svelte index fe6c4eba9b..969377de33 100644 --- a/test/js/samples/dont-use-dataset-in-svg/input.svelte +++ b/test/js/samples/dont-use-dataset-in-svg/input.svelte @@ -1,3 +1,7 @@ + + diff --git a/test/js/samples/dynamic-import/expected.js b/test/js/samples/dynamic-import/expected.js index c7a82698c2..6647619329 100644 --- a/test/js/samples/dynamic-import/expected.js +++ b/test/js/samples/dynamic-import/expected.js @@ -44,7 +44,7 @@ function func() { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/each-block-array-literal/expected.js b/test/js/samples/each-block-array-literal/expected.js new file mode 100644 index 0000000000..8cc11dff47 --- /dev/null +++ b/test/js/samples/each-block-array-literal/expected.js @@ -0,0 +1,123 @@ +/* generated by Svelte vX.Y.Z */ +import { SvelteComponent as SvelteComponent_1, append, createComment, createElement, createText, destroyEach, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; + +function get_each_context(ctx, list, i) { + const child_ctx = Object.create(ctx); + child_ctx.num = list[i]; + return child_ctx; +} + +// (9:0) {#each [a, b, c, d, e] as num} +function create_each_block(ctx) { + var span, text_value = ctx.num, text; + + return { + c() { + span = createElement("span"); + text = createText(text_value); + }, + + m(target, anchor) { + insert(target, span, anchor); + append(span, text); + }, + + p(changed, ctx) { + if ((changed.a || changed.b || changed.c || changed.d || changed.e) && text_value !== (text_value = ctx.num)) { + setData(text, text_value); + } + }, + + d(detach) { + if (detach) { + detachNode(span); + } + } + }; +} + +function create_fragment(ctx) { + var each_anchor; + + var each_value = [ctx.a, ctx.b, ctx.c, ctx.d, ctx.e]; + + var each_blocks = []; + + for (var i = 0; i < 5; i += 1) { + each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); + } + + return { + c() { + for (var i = 0; i < 5; i += 1) { + each_blocks[i].c(); + } + + each_anchor = createComment(); + }, + + m(target, anchor) { + for (var i = 0; i < 5; i += 1) { + each_blocks[i].m(target, anchor); + } + + insert(target, each_anchor, anchor); + }, + + p(changed, ctx) { + if (changed.a || changed.b || changed.c || changed.d || changed.e) { + each_value = [ctx.a, ctx.b, ctx.c, ctx.d, ctx.e]; + + for (var i = 0; i < each_value.length; i += 1) { + const child_ctx = get_each_context(ctx, each_value, i); + + if (each_blocks[i]) { + each_blocks[i].p(changed, child_ctx); + } else { + each_blocks[i] = create_each_block(child_ctx); + each_blocks[i].c(); + each_blocks[i].m(each_anchor.parentNode, each_anchor); + } + } + + for (; i < 5; i += 1) { + each_blocks[i].d(1); + } + } + }, + + i: noop, + o: noop, + + d(detach) { + destroyEach(each_blocks, detach); + + if (detach) { + detachNode(each_anchor); + } + } + }; +} + +function instance($$self, $$props, $$invalidate) { + let { a, b, c, d, e } = $$props; + + $$self.$set = $$props => { + if ('a' in $$props) $$invalidate('a', a = $$props.a); + if ('b' in $$props) $$invalidate('b', b = $$props.b); + if ('c' in $$props) $$invalidate('c', c = $$props.c); + if ('d' in $$props) $$invalidate('d', d = $$props.d); + if ('e' in $$props) $$invalidate('e', e = $$props.e); + }; + + return { a, b, c, d, e }; +} + +class SvelteComponent extends SvelteComponent_1 { + constructor(options) { + super(); + init(this, options, instance, create_fragment, safe_not_equal, ["a", "b", "c", "d", "e"]); + } +} + +export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/each-block-array-literal/input.svelte b/test/js/samples/each-block-array-literal/input.svelte new file mode 100644 index 0000000000..cf25c139e0 --- /dev/null +++ b/test/js/samples/each-block-array-literal/input.svelte @@ -0,0 +1,11 @@ + + +{#each [a, b, c, d, e] as num} + {num} +{/each} \ No newline at end of file diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 0032b1c720..d43771b9a2 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, append, createElement, createText, destroyEach, detachAfter, detachNode, flush, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, append, createElement, createText, destroyEach, detachAfter, detachNode, init, insert, noop, safe_not_equal, setData } from "svelte/internal"; function get_each_context(ctx, list, i) { const child_ctx = Object.create(ctx); @@ -8,7 +8,7 @@ function get_each_context(ctx, list, i) { return child_ctx; } -// (1:0) {#each comments as comment, i} +// (8:0) {#each comments as comment, i} function create_each_block(ctx) { var div, strong, text0, text1, span, text2_value = ctx.comment.author, text2, text3, text4_value = ctx.elapsed(ctx.comment.time, ctx.time), text4, text5, text6, raw_value = ctx.comment.html, raw_before; @@ -156,43 +156,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get comments() { - return this.$$.ctx.comments; - } - - set comments(comments) { - this.$set({ comments }); - flush(); - } - - get elapsed() { - return this.$$.ctx.elapsed; - } - - set elapsed(elapsed) { - this.$set({ elapsed }); - flush(); - } - - get time() { - return this.$$.ctx.time; - } - - set time(time) { - this.$set({ time }); - flush(); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["comments", "elapsed", "time", "foo"]); } } diff --git a/test/js/samples/each-block-changed-check/input.svelte b/test/js/samples/each-block-changed-check/input.svelte index b5b5703857..999b346975 100644 --- a/test/js/samples/each-block-changed-check/input.svelte +++ b/test/js/samples/each-block-changed-check/input.svelte @@ -1,3 +1,10 @@ + + {#each comments as comment, i}
    {i} diff --git a/test/js/samples/each-block-keyed-animated/expected.js b/test/js/samples/each-block-keyed-animated/expected.js index e7e10208e4..cd37a916f6 100644 --- a/test/js/samples/each-block-keyed-animated/expected.js +++ b/test/js/samples/each-block-keyed-animated/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, animate, append, blankObject, createComment, createElement, createText, detachNode, fixAndOutroAndDestroyBlock, fix_position, flush, init, insert, noop, safe_not_equal, setData, updateKeyedEach } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, append, blankObject, createComment, createElement, createText, create_animation, detachNode, fixAndOutroAndDestroyBlock, fix_position, init, insert, noop, safe_not_equal, setData, updateKeyedEach } from "svelte/internal"; function get_each_context(ctx, list, i) { const child_ctx = Object.create(ctx); @@ -44,7 +44,7 @@ function create_each_block(key_1, ctx) { a() { stop_animation(); - stop_animation = animate(div, rect, foo, {}); + stop_animation = create_animation(div, rect, foo, {}); }, d(detach) { @@ -128,16 +128,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get things() { - return this.$$.ctx.things; - } - - set things(things) { - this.$set({ things }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["things"]); } } diff --git a/test/js/samples/each-block-keyed/expected.js b/test/js/samples/each-block-keyed/expected.js index c2dd23fb96..081391780f 100644 --- a/test/js/samples/each-block-keyed/expected.js +++ b/test/js/samples/each-block-keyed/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, append, blankObject, createComment, createElement, createText, destroyBlock, detachNode, flush, init, insert, noop, safe_not_equal, setData, updateKeyedEach } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, append, blankObject, createComment, createElement, createText, destroyBlock, detachNode, init, insert, noop, safe_not_equal, setData, updateKeyedEach } from "svelte/internal"; function get_each_context(ctx, list, i) { const child_ctx = Object.create(ctx); @@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) { return child_ctx; } -// (1:0) {#each things as thing (thing.id)} +// (5:0) {#each things as thing (thing.id)} function create_each_block(key_1, ctx) { var div, text_value = ctx.thing.name, text; @@ -98,16 +98,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get things() { - return this.$$.ctx.things; - } - - set things(things) { - this.$set({ things }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["things"]); } } diff --git a/test/js/samples/each-block-keyed/input.svelte b/test/js/samples/each-block-keyed/input.svelte index 909af032e9..e6493dcd58 100644 --- a/test/js/samples/each-block-keyed/input.svelte +++ b/test/js/samples/each-block-keyed/input.svelte @@ -1,3 +1,7 @@ + + {#each things as thing (thing.id)}
    {thing.name}
    {/each} \ No newline at end of file diff --git a/test/js/samples/event-handler-no-passive/expected.js b/test/js/samples/event-handler-no-passive/expected.js index 19cfed3124..da7882fdff 100644 --- a/test/js/samples/event-handler-no-passive/expected.js +++ b/test/js/samples/event-handler-no-passive/expected.js @@ -37,7 +37,7 @@ function touchstart_handler(e) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/event-modifiers/expected.js b/test/js/samples/event-modifiers/expected.js index b6c554a8b6..f31ad09238 100644 --- a/test/js/samples/event-modifiers/expected.js +++ b/test/js/samples/event-modifiers/expected.js @@ -57,7 +57,7 @@ function handleClick() { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/head-no-whitespace/expected.js b/test/js/samples/head-no-whitespace/expected.js index 9e38fe41d3..136be77b59 100644 --- a/test/js/samples/head-no-whitespace/expected.js +++ b/test/js/samples/head-no-whitespace/expected.js @@ -33,7 +33,7 @@ function create_fragment(ctx) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/hoisted-const/expected.js b/test/js/samples/hoisted-const/expected.js index 884f765ba7..26169b25fe 100644 --- a/test/js/samples/hoisted-const/expected.js +++ b/test/js/samples/hoisted-const/expected.js @@ -34,7 +34,7 @@ function get_answer() { return ANSWER; } class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/hoisted-let/expected.js b/test/js/samples/hoisted-let/expected.js index d94eb2a7b7..409e5b1b45 100644 --- a/test/js/samples/hoisted-let/expected.js +++ b/test/js/samples/hoisted-let/expected.js @@ -34,7 +34,7 @@ function get_answer() { return ANSWER; } class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index a4c9fbc163..b161285ffb 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, init, insert, noop, safe_not_equal } from "svelte/internal"; -// (3:0) {:else} +// (7:0) {:else} function create_else_block(ctx) { var p; @@ -23,7 +23,7 @@ function create_else_block(ctx) { }; } -// (1:0) {#if foo} +// (5:0) {#if foo} function create_if_block(ctx) { var p; @@ -104,16 +104,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["foo"]); } } diff --git a/test/js/samples/if-block-no-update/input.svelte b/test/js/samples/if-block-no-update/input.svelte index 57de219159..c7a0f6a98c 100644 --- a/test/js/samples/if-block-no-update/input.svelte +++ b/test/js/samples/if-block-no-update/input.svelte @@ -1,3 +1,7 @@ + + {#if foo}

    foo!

    {:else} diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 76c69b000f..db5fe0c42c 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, init, insert, noop, safe_not_equal } from "svelte/internal"; -// (1:0) {#if foo} +// (5:0) {#if foo} function create_if_block(ctx) { var p; @@ -78,16 +78,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["foo"]); } } diff --git a/test/js/samples/if-block-simple/input.svelte b/test/js/samples/if-block-simple/input.svelte index e36517e10c..545d81d44a 100644 --- a/test/js/samples/if-block-simple/input.svelte +++ b/test/js/samples/if-block-simple/input.svelte @@ -1,3 +1,7 @@ + + {#if foo}

    foo!

    {/if} \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js index 5988850ede..4b2c59672a 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createElement, detachNode, flush, init, insert, noop, safe_not_equal, setStyle } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createElement, detachNode, init, insert, noop, safe_not_equal, setStyle } from "svelte/internal"; function create_fragment(ctx) { var div; @@ -51,34 +51,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get color() { - return this.$$.ctx.color; - } - - set color(color) { - this.$set({ color }); - flush(); - } - - get x() { - return this.$$.ctx.x; - } - - set x(x) { - this.$set({ x }); - flush(); - } - - get y() { - return this.$$.ctx.y; - } - - set y(y) { - this.$set({ y }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["color", "x", "y"]); } } diff --git a/test/js/samples/inline-style-optimized-multiple/input.svelte b/test/js/samples/inline-style-optimized-multiple/input.svelte index d9448e0ab0..d5e2beb609 100644 --- a/test/js/samples/inline-style-optimized-multiple/input.svelte +++ b/test/js/samples/inline-style-optimized-multiple/input.svelte @@ -1 +1,7 @@ + +
    \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js index c1ed003c83..dd64e40950 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createElement, detachNode, flush, init, insert, noop, safe_not_equal, setStyle } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createElement, detachNode, init, insert, noop, safe_not_equal, setStyle } from "svelte/internal"; function create_fragment(ctx) { var div; @@ -44,16 +44,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get data() { - return this.$$.ctx.data; - } - - set data(data) { - this.$set({ data }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["data"]); } } diff --git a/test/js/samples/inline-style-optimized-url/input.svelte b/test/js/samples/inline-style-optimized-url/input.svelte index 677da52c30..2e660fe02d 100644 --- a/test/js/samples/inline-style-optimized-url/input.svelte +++ b/test/js/samples/inline-style-optimized-url/input.svelte @@ -1 +1,5 @@ + +
    \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js index 9d88cb7d35..3948bc5fb0 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createElement, detachNode, flush, init, insert, noop, safe_not_equal, setStyle } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createElement, detachNode, init, insert, noop, safe_not_equal, setStyle } from "svelte/internal"; function create_fragment(ctx) { var div; @@ -44,16 +44,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get color() { - return this.$$.ctx.color; - } - - set color(color) { - this.$set({ color }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["color"]); } } diff --git a/test/js/samples/inline-style-optimized/input.svelte b/test/js/samples/inline-style-optimized/input.svelte index 004fd595c9..b47ca48093 100644 --- a/test/js/samples/inline-style-optimized/input.svelte +++ b/test/js/samples/inline-style-optimized/input.svelte @@ -1 +1,5 @@ + +
    \ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js index 31bda3a217..b9379a6838 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, createElement, createText, detachNode, init, insert, noop, safe_not_equal } from "svelte/internal"; function create_fragment(ctx) { var div0, text, div1, div1_style_value; @@ -57,34 +57,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get style() { - return this.$$.ctx.style; - } - - set style(style) { - this.$set({ style }); - flush(); - } - - get key() { - return this.$$.ctx.key; - } - - set key(key) { - this.$set({ key }); - flush(); - } - - get value() { - return this.$$.ctx.value; - } - - set value(value) { - this.$set({ value }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["style", "key", "value"]); } } diff --git a/test/js/samples/inline-style-unoptimized/input.svelte b/test/js/samples/inline-style-unoptimized/input.svelte index eac76d5b6e..3893fa3f89 100644 --- a/test/js/samples/inline-style-unoptimized/input.svelte +++ b/test/js/samples/inline-style-unoptimized/input.svelte @@ -1,2 +1,8 @@ -
    -
    \ No newline at end of file + + +
    +
    \ No newline at end of file diff --git a/test/js/samples/input-files/expected.js b/test/js/samples/input-files/expected.js index 80a00a9701..697364106b 100644 --- a/test/js/samples/input-files/expected.js +++ b/test/js/samples/input-files/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, flush, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; function create_fragment(ctx) { var input, dispose; @@ -48,16 +48,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get files() { - return this.$$.ctx.files; - } - - set files(files) { - this.$set({ files }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["files"]); } } diff --git a/test/js/samples/input-files/input.svelte b/test/js/samples/input-files/input.svelte index 7c078b4885..f7d4159e37 100644 --- a/test/js/samples/input-files/input.svelte +++ b/test/js/samples/input-files/input.svelte @@ -1 +1,5 @@ + + \ No newline at end of file diff --git a/test/js/samples/input-range/expected.js b/test/js/samples/input-range/expected.js index 7a4cf6079a..fff193f8e5 100644 --- a/test/js/samples/input-range/expected.js +++ b/test/js/samples/input-range/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, flush, init, insert, noop, run_all, safe_not_equal, setAttribute, toNumber } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, init, insert, noop, run_all, safe_not_equal, setAttribute, toNumber } from "svelte/internal"; function create_fragment(ctx) { var input, dispose; @@ -56,16 +56,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get value() { - return this.$$.ctx.value; - } - - set value(value) { - this.$set({ value }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["value"]); } } diff --git a/test/js/samples/input-range/input.svelte b/test/js/samples/input-range/input.svelte index e080b9a81b..2fa0517f47 100644 --- a/test/js/samples/input-range/input.svelte +++ b/test/js/samples/input-range/input.svelte @@ -1 +1,5 @@ + + \ No newline at end of file diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js index 18c1535138..e97e4d1b0d 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, flush, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal"; function create_fragment(ctx) { var input, dispose; @@ -52,16 +52,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get foo() { - return this.$$.ctx.foo; - } - - set foo(foo) { - this.$set({ foo }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["foo"]); } } diff --git a/test/js/samples/input-without-blowback-guard/input.svelte b/test/js/samples/input-without-blowback-guard/input.svelte index 991c5e33ab..9c5bfa35dc 100644 --- a/test/js/samples/input-without-blowback-guard/input.svelte +++ b/test/js/samples/input-without-blowback-guard/input.svelte @@ -1 +1,5 @@ + + \ No newline at end of file diff --git a/test/js/samples/instrumentation-script-if-no-block/expected.js b/test/js/samples/instrumentation-script-if-no-block/expected.js index f5100961fc..4f7153e19e 100644 --- a/test/js/samples/instrumentation-script-if-no-block/expected.js +++ b/test/js/samples/instrumentation-script-if-no-block/expected.js @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/instrumentation-script-x-equals-x/expected.js b/test/js/samples/instrumentation-script-x-equals-x/expected.js index 45a968f94f..408e11279f 100644 --- a/test/js/samples/instrumentation-script-x-equals-x/expected.js +++ b/test/js/samples/instrumentation-script-x-equals-x/expected.js @@ -58,7 +58,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/instrumentation-template-if-no-block/expected.js b/test/js/samples/instrumentation-template-if-no-block/expected.js index e5248cf5dc..29a764a8d5 100644 --- a/test/js/samples/instrumentation-template-if-no-block/expected.js +++ b/test/js/samples/instrumentation-template-if-no-block/expected.js @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/instrumentation-template-x-equals-x/expected.js b/test/js/samples/instrumentation-template-x-equals-x/expected.js index 9f7ff64725..909c4bfef6 100644 --- a/test/js/samples/instrumentation-template-x-equals-x/expected.js +++ b/test/js/samples/instrumentation-template-x-equals-x/expected.js @@ -55,7 +55,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); + init(this, options, instance, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index f9e0807314..bc1d1f0155 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -29,7 +29,7 @@ function create_fragment(ctx) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal); + init(this, options, null, create_fragment, safe_not_equal, []); } } diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 8163a8a947..97b6dbc82c 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent as SvelteComponent_1, addListener, add_render_callback, createElement, detachNode, flush, init, insert, noop, run_all, safe_not_equal, timeRangesToArray } from "svelte/internal"; +import { SvelteComponent as SvelteComponent_1, addListener, add_render_callback, createElement, detachNode, init, insert, noop, run_all, safe_not_equal, timeRangesToArray } from "svelte/internal"; function create_fragment(ctx) { var audio, audio_updating = false, audio_animationframe, audio_is_paused = true, dispose; @@ -123,70 +123,7 @@ function instance($$self, $$props, $$invalidate) { class SvelteComponent extends SvelteComponent_1 { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal); - } - - get buffered() { - return this.$$.ctx.buffered; - } - - set buffered(buffered) { - this.$set({ buffered }); - flush(); - } - - get seekable() { - return this.$$.ctx.seekable; - } - - set seekable(seekable) { - this.$set({ seekable }); - flush(); - } - - get played() { - return this.$$.ctx.played; - } - - set played(played) { - this.$set({ played }); - flush(); - } - - get currentTime() { - return this.$$.ctx.currentTime; - } - - set currentTime(currentTime) { - this.$set({ currentTime }); - flush(); - } - - get duration() { - return this.$$.ctx.duration; - } - - set duration(duration) { - this.$set({ duration }); - flush(); - } - - get paused() { - return this.$$.ctx.paused; - } - - set paused(paused) { - this.$set({ paused }); - flush(); - } - - get volume() { - return this.$$.ctx.volume; - } - - set volume(volume) { - this.$set({ volume }); - flush(); + init(this, options, instance, create_fragment, safe_not_equal, ["buffered", "seekable", "played", "currentTime", "duration", "paused", "volume"]); } } diff --git a/test/js/samples/media-bindings/input.svelte b/test/js/samples/media-bindings/input.svelte index 3f7a0b66d1..169d5c9341 100644 --- a/test/js/samples/media-bindings/input.svelte +++ b/test/js/samples/media-bindings/input.svelte @@ -1 +1,11 @@ + +