diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..b1342d3 --- /dev/null +++ b/changelog.md @@ -0,0 +1,2 @@ +2.0.0 + * Breaking change: the renderer doesn't export a `template()` anymore but the dom-engine `load()` diff --git a/package-lock.json b/package-lock.json index c4bef3f..d82bba7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "anticore-server", - "version": "1.0.0", + "version": "2.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "anticore-server", - "version": "1.0.0", + "version": "2.0.0", "license": "MIT", "dependencies": { - "@lcf.vs/dom-engine": "^5.3.2", + "@lcf.vs/dom-engine": "^5.4.0", "fastify": "^3.20.2", "fastify-compress": "^3.6.0", "fastify-multipart": "^4.0.7", @@ -173,9 +173,9 @@ "dev": true }, "node_modules/@lcf.vs/dom-engine": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/@lcf.vs/dom-engine/-/dom-engine-5.3.2.tgz", - "integrity": "sha512-Qh769UinHQlL40O1RB3JRhIPSYqbypvJ+1rcver2cYSeZQfu0UAfAiZcNvgekhW8+oYXd62Ez6qH9nJFDRLiRA==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/@lcf.vs/dom-engine/-/dom-engine-5.4.0.tgz", + "integrity": "sha512-bhq1h20Z+yOcFhc2OxNcEQiZs8iaf4EV2VI7BRLLO3SkVIhfL+q+7Z2wNLOWidNwxkqiEu0VBiNTrViIPk/Reg==", "dependencies": { "jsdom": "^16.6.0" } @@ -3007,9 +3007,9 @@ "dev": true }, "@lcf.vs/dom-engine": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/@lcf.vs/dom-engine/-/dom-engine-5.3.2.tgz", - "integrity": "sha512-Qh769UinHQlL40O1RB3JRhIPSYqbypvJ+1rcver2cYSeZQfu0UAfAiZcNvgekhW8+oYXd62Ez6qH9nJFDRLiRA==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/@lcf.vs/dom-engine/-/dom-engine-5.4.0.tgz", + "integrity": "sha512-bhq1h20Z+yOcFhc2OxNcEQiZs8iaf4EV2VI7BRLLO3SkVIhfL+q+7Z2wNLOWidNwxkqiEu0VBiNTrViIPk/Reg==", "requires": { "jsdom": "^16.6.0" } diff --git a/package.json b/package.json index 44729b4..2dad852 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anticore-server", - "version": "1.0.0", + "version": "2.0.0", "description": "A low learning curve anticore server", "type": "module", "exports": { @@ -15,7 +15,7 @@ }, "author": "Lcf.vs", "dependencies": { - "@lcf.vs/dom-engine": "^5.3.2", + "@lcf.vs/dom-engine": "^5.4.0", "fastify": "^3.20.2", "fastify-compress": "^3.6.0", "fastify-multipart": "^4.0.7", diff --git a/readme.md b/readme.md index 9c37b08..b40a060 100644 --- a/readme.md +++ b/readme.md @@ -66,10 +66,10 @@ const application = app({ #### src/templates/layout/layout.js ```js -import { template } from 'anticore-server/renderer.js' +import { load } from 'anticore-server/renderer.js' // loads the ./template.html and associates the provided properties -export default await template(import.meta, { +export default await load(import.meta, {}, { branding: 'anticore-server', view: null // just to know which properties can be filled later, on every clone }) @@ -87,9 +87,9 @@ export default await template(import.meta, { #### src/templates/fragment/fragment.js ```js -import { template } from 'anticore-server/renderer.js' +import { load } from 'anticore-server/renderer.js' -export default await template(import.meta, { +export default await load(import.meta, {}, { view: null }) ``` @@ -104,9 +104,9 @@ export default await template(import.meta, { #### src/templates/error/error.js ```js -import { template } from 'anticore-server/renderer.js' +import { load } from 'anticore-server/renderer.js' -export default await template(import.meta, { +export default await load(import.meta, {}, { name: null, message: null }) @@ -123,9 +123,9 @@ export default await template(import.meta, { #### src/templates/views/home/home.js ```js -import { template } from 'anticore-server/renderer.js' +import { load } from 'anticore-server/renderer.js' -export default await template(import.meta, { +export default await load(import.meta, {}, { class: 'home', description: 'A homepage description', title: 'A homepage title' @@ -141,9 +141,9 @@ export default await template(import.meta, { #### src/templates/sse/message/message.js ```js -import { template } from 'anticore-server/renderer.js' +import { load } from 'anticore-server/renderer.js' -export default await template(import.meta, { +export default await load(import.meta, {}, { content: null }) ``` @@ -269,6 +269,10 @@ await serve(app) See it in action into the [anticore](https://github.com/Lcfvs/anticore) [demo](https://glitch.com/edit/#!/anticore-demo?path=src%2Fserve.js%3A1%3A0) +## Changelog + +[changelog](./changelog.md) + ## License [MIT](./license.md) diff --git a/renderer.js b/renderer.js index c4065f3..1ffc5bf 100644 --- a/renderer.js +++ b/renderer.js @@ -85,7 +85,7 @@ const renderXHR = ({ } } -export { serialize, source } +export { load, serialize, source } export const sse = async ({ error }, template, data, errors) => eol(await serialize(renderEvent({ error }, template, data, errors))) @@ -100,11 +100,3 @@ export const view = async ({ return serialize(method({ error, fragment, layout }, view, data, errors)) } -export const template = async ({ url }, { ...data } = {}) => { - const path = resolve(dirname(fileURLToPath(url)), './template.html') - - return { - [source]: `${await readFile(path)}`, - ...data - } -}