{"_id":"@axel669/hephaestus","_rev":"1-9bfa237ebb94f6242fde9bcfae882098","name":"@axel669/hephaestus","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@axel669/hephaestus","version":"0.1.0","description":"Library for doing fast and dirty work with generating static content from svelte files on a server.","main":"index.mjs","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"heph":"cli.mjs"},"author":"","license":"ISC","dependencies":{"fast-glob":"^3.2.11","fs-jetpack":"^4.3.1","svelte":"^3.48.0"},"gitHead":"0a1dcd7e48a99b2e330b02d40abd7a1cbdfa2537","_id":"@axel669/hephaestus@0.1.0","_nodeVersion":"14.15.1","_npmVersion":"8.5.3","dist":{"integrity":"sha512-xitxPWEEOyB6eiFnEyLrSk+Gn5BM61Qo8wUkCw9kEIs/FciK7X7Pbqp+NQAFAQXPFHeDUGXCQT2ybEJPCOc2hg==","shasum":"c0a38d8a169ac271f347e57e3ef64ccb5877e4a6","tarball":"https://registry.npmjs.org/@axel669/hephaestus/-/hephaestus-0.1.0.tgz","fileCount":11,"unpackedSize":14188,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDvwZdfHt5L/kOS1cU3HgURHjGF6uYiHD8lnyRe+Z2jKwIhANNzCZQtwz1N6OhGyp6pOATUbrYBnxMqIDd59tOR0/BX"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiotO8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqovQ//YHOY13gFUYj2TzfXUZX0WdYxEUoc08iDlGwtbFzVEgN5rUAo\r\n6OJrE5aVJiTsJHrk05mQkzd1XWPKeWEUjjCKryZHo/3sEilEk6ui+ZqzHCgp\r\nVgdPwPcXiUMFqzGK0u6RQQhN+Ch6/EPWLp1rdzwRSSH984CJU+o18G1EHx9a\r\nT0ndfbv8w9jTNhiN48AgOVtOiMG8IcEuRI0AqVCrthyBzCs1xgkvpvlloGF3\r\nnP33seC42SgkjD+meK6l5Ff3Y9FCoEMw2I4qFcbnXfecfzVxQrwLr+8ddfXn\r\npWWRdDBRCBVgXi/8emDeGRY3BzrhBZzS9b4o3vgmUyPzDVq+1gyJcgGmVTWv\r\nC+WC4JfA60Ebkd7mTJop52feOPiPTEiy8mV0mAjw17vMpWElanW1XfuKx/WZ\r\nDFTops39E6lYD5kqmYxOl6gRaZht/ZUqW4H/h9rveHSJ42tMdIlfo8a39Zjc\r\nAmdy5Xqsocrjnhz7r6/NRxqA/liwz7trmgrJ14VluPweUaqDSvtzJ1zVx3ih\r\n/AzRvIjI1ykzKxVPAJz2xqjnoLBr6TZzPgNjRuS/u4S9umwdiEXyLKTy4Axk\r\nRTNZN7YTr3DVNZAUN0wfKtFUe4whOI8b7I+omZOCXnM0chTL/L3T26S/WpTz\r\nF/Bq5WZcdgOnfiEEYzhRcgBdPKG4fybTuCg=\r\n=dY4G\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"axel669","email":"axel@axel669.net"},"directories":{},"maintainers":[{"name":"axel669","email":"axel@axel669.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hephaestus_0.1.0_1654838203949_0.4425816604753656"},"_hasShrinkwrap":false},"0.1.1":{"name":"@axel669/hephaestus","version":"0.1.1","description":"Library for doing fast and dirty work with generating static content from svelte files on a server.","main":"index.mjs","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"heph":"cli.mjs"},"author":{},"license":"ISC","dependencies":{"fast-glob":"^3.2.11","fs-jetpack":"^4.3.1","svelte":"^3.48.0"},"licenseText":"MIT License\n\nCopyright (c) 2022 Chris Morgan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@axel669/hephaestus@0.1.1","dist":{"shasum":"efc87d215dc882db3d06a57fd8ec2069cfd38070","integrity":"sha512-wqtIvVi0fdJVk5YGKVIQYgS4gY4nd5qWMMZIb2XxO6jKG5/8Fzs8D2gGdI96j4662gX7H89pBEp8g6ymc5bOng==","tarball":"https://registry.npmjs.org/@axel669/hephaestus/-/hephaestus-0.1.1.tgz","fileCount":12,"unpackedSize":14910,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCXyyYVjDB96vjUxWKI1xed/Yj8Uq+2U3JlvDJrx17owwIhAI0uiKVWq93Hcy2LhOoEWyn13z6nnB3zBbB8woPImwHu"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJipW8yACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpe7RAAgsg3+mGJW7QF+cIKICX++1gaE2PdW0J7u6kfg52lg8DXWMTR\r\neBNejShC3Tz8COttCEvD9GGj0Wbcgz5OmxeEgyGXEjqEA/4gYIWMEb077IWX\r\nq4HTggKlDLgca2rKiz0WX8O2lKnn6boyep7HROrPAcbP9FFgfX0h2ijMWdBQ\r\nx3Ab/O8RYrQ3cAjJ8QeTQonYGTzjQvAvkx33DKnMCRTK2eBAe13IbOuX5Zg3\r\nzrqzsb8ipqgg8wC9BxaUIJqCfsHUpMMSP0fgYhFnyJ7nmYPIKphKpgR6OFQ+\r\noBkmgStzdi8zJm2Wm07aMi1EgqNxWj/ba+ZhC9Jnd8T5T4b34I2vNHhftRId\r\nkOlVhN76DCnU6Yed6+9Ak2SwCVsyFC5/bVxZdDG6eLUt/bEOI0RtxEU1bnhg\r\n06ca6kerVYptCvPUwRPzNTHky1I6R42qGQYyPzYV2wLqDJ+l2sv1eBjmdScp\r\nvUEwEfhRERoecyWzeGwQRDQq8scwH4utnfXHyvld4v94CD/VWzBmA8sXQPGx\r\n6ElIWKQN38KwR38H6KjuxsLeAsX9ZROF62xsfgcq9Ez5UKlxqqh/wa2EU5zf\r\nG2kacmRoNsnbSRNAm8nveRCDFPgtdQACnUd3lOWO5dFcVkn7WT4JTCWFMgh8\r\nKKQ9oCcwfKJ1D9BZDCSBMyPM09xceNJFE3Q=\r\n=zY+r\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"axel669","email":"axel@axel669.net"},"directories":{},"maintainers":[{"name":"axel669","email":"axel@axel669.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hephaestus_0.1.1_1655009074419_0.9405132546327619"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-10T05:16:43.882Z","0.1.0":"2022-06-10T05:16:44.108Z","modified":"2022-06-12T04:44:34.629Z","0.1.1":"2022-06-12T04:44:34.565Z"},"maintainers":[{"name":"axel669","email":"axel@axel669.net"}],"description":"Library for doing fast and dirty work with generating static content from svelte files on a server.","license":"ISC","readme":"# Hephaestus\nLibrary for doing fast and dirty work with generating static content from\nsvelte files on a server.\n\n## Installation\n```bash\nyarn add @axel669/hephaestus\n```\n\n## Usage\n\n### Svelte Context Script\nHephaestus uses the `<script context=\"module\">` feature of Svelte to pass\ninformation to components when they are rendered (either on page load, or\nduring the build proces).\n\nA user should treat this script as a hook that runs when a page is loaded as\na component, before it is rendered in any context.\n\nThe `buildProps` and `get` functions are optional exports for build-time and\nhttp GET requests to render, but `post` **must** be exported if the page\nneeds to respond to a POST request.\n\n```html\n<script context=\"module\">\n    //  buildProps runs during the build phase (never during dynamic renders\n    //  in a server). The return value is an object that will be used as the\n    //  props that are passed into the component when rendering it.\n    export async function buildProps() {\n        return {\n            when: new Date()\n        }\n    }\n\n    //  The get/post functions are used to respond to http requests to the page.\n    //  Both functions can be optoinally async, and both take a single argument\n    //  that is the Express Request object, unmodified.\n    //  The return value should have a \"status\" property that is an http status\n    //  code to use for the response, and either a \"redirect\" or \"props\"\n    //  property.\n    //  The \"redirect\" property should be a URL to redirect to, and the status\n    //  property should say which kind of redirection it is (will default to\n    //  302 if one is not given).\n    //  The \"props\" property is an object that will be passed as the props to\n    //  the component when it is rendered and sent.\n    export async function get(req) {\n        return {\n            status: 200,\n            props: {\n                when: new Date(),\n                who: req.query.user,\n            }\n        }\n    }\n\n    export function post(req) {\n        return {\n            status: 200,\n            props: {\n                name: req.body.name\n            }\n        }\n    }\n</script>\n```\n\n### Express\n```js\nimport express from \"express\"\nimport heph from \"@axel669/hephaestus\"\n\nconst server = express()\n\nserver.use(\n    await heph({\n        source: \"content\",\n        error: \"$error.svelte\",\n        pass: /^api\\//,\n    })\n)\n```\n\n#### Expess API\n```js\nheph(config)\n\nconfig {\n    //  source is the directory where the svelte files are.\n    //  Files named $layout are automatically wrapped around page files inside\n    //  the given folder, and are nested in the order of the folders.\n    //  files that are prefixed with \"$\" will not be loaded as pages, but can\n    //  still be imported as components normally.\n    \"source\": String,\n\n    //  The filename of the error page (recommended to use $error.svelte).\n    //  The error page does not have any layout applied to it, and is sent\n    //  for any non 2xx response that is not a redirect.\n    //  Optional\n    \"error?\": String,\n\n    //  Any route that matches the given regex will not be processed at all\n    //  and handed to the next middleware function as normal for express.\n    //  If a route is not passed on and is not found as a page, a 404 is\n    //  returned even if a later piece of middleware might have it.\n    //  Optional\n    \"pass?\": RegExp,\n}\n```\n\n### Static Build\n`package.json`\n```json\n{\n    \"scripts\": {\n        \"build-static\": \"heph config.mjs\"\n    }\n}\n```\n\n#### CLI Config\n> `.mjs` file\n```js\nexport default {\n    //  source is the directory where the svelte files are.\n    //  Files named $layout are automatically wrapped around page files inside\n    //  the given folder, and are nested in the order of the folders.\n    //  files that are prefixed with \"$\" will not be loaded as pages, but can\n    //  still be imported as components normally.\n    \"source\": \"content\",\n\n    //  The filename of the error page (recommended to use $error.svelte).\n    //  The error page does not have any layout applied to it.\n    //  Optional\n    \"error?\": \"$error.svelte\",\n\n    //  The output folder for the static files.\n    \"dest\": \"public\",\n\n    //  Hooks that are run at specific times in the build process.\n    \"hooks?\": {\n        //  Hook that is run at startup, before any files are loaded or\n        //  processed.\n        async init() {\n        },\n        //  Hook that is run after all files have been written to disk.\n        async done() {\n        }\n    },\n\n    //  Directory for static files that will be copied into the output folder\n    //  after building the html files.\n    //  Optional\n    \"staticFiles?\": \"static\"\n}\n```\n\n## TODO\n- possibly add more hooks around build events\nOpen to sugestions for features.\n","readmeFilename":"README.md","author":{}}