diff --git a/apps/playground/package.json b/apps/playground/package.json index c2ae20e..2dd949e 100644 --- a/apps/playground/package.json +++ b/apps/playground/package.json @@ -13,7 +13,6 @@ "vite": "^5.2.6" }, "dependencies": { - "@sonnetjs/core": "0.0.23", - "@sonnetjs/html": "0.0.1" + "@sonnetjs/core": "0.0.23" } } \ No newline at end of file diff --git a/apps/playground/src/Counter.ts b/apps/playground/src/Counter.ts index e458fc5..114f2c2 100644 --- a/apps/playground/src/Counter.ts +++ b/apps/playground/src/Counter.ts @@ -1,5 +1,4 @@ import { $component, SonnetComponent } from '@sonnetjs/core'; -import { a, button, div, h1, img, p } from '@sonnetjs/html'; class Counter extends SonnetComponent { counter = 0; @@ -15,37 +14,18 @@ class Counter extends SonnetComponent { } public get() { - return div() - .children( - a() - .href('https://vitejs.dev') - .target('blank') - .children( - img() - .src('https://vitejs.dev/logo.svg') - .className('logo') - .alt('Vite Logo') - .get(), - ) - .get(), - h1().innerText('Vite').get(), - div() - .className('card') - .children( - button() - .id('counter') - .type('button') - .innerText(`count is ${this.counter}`) - .className('btn') - .get(), - ) - .get(), - p() - .innerText('Edit src/main.ts and save to test HMR.') - .className('read-the-docs') - .get(), - ) - .get(); + return /*html*/ ` +
+ `; } } diff --git a/apps/ssr-playground/package.json b/apps/ssr-playground/package.json index 1757aac..da734ab 100644 --- a/apps/ssr-playground/package.json +++ b/apps/ssr-playground/package.json @@ -15,8 +15,7 @@ "compression": "^1.7.4", "express": "^4.18.2", "sirv": "^2.0.4", - "@sonnetjs/core": "*", - "@sonnetjs/html": "0.0.2" + "@sonnetjs/core": "*" }, "devDependencies": { "@types/express": "^4.17.21", diff --git a/apps/ssr-playground/src/Counter.ts b/apps/ssr-playground/src/Counter.ts index e458fc5..114f2c2 100644 --- a/apps/ssr-playground/src/Counter.ts +++ b/apps/ssr-playground/src/Counter.ts @@ -1,5 +1,4 @@ import { $component, SonnetComponent } from '@sonnetjs/core'; -import { a, button, div, h1, img, p } from '@sonnetjs/html'; class Counter extends SonnetComponent { counter = 0; @@ -15,37 +14,18 @@ class Counter extends SonnetComponent { } public get() { - return div() - .children( - a() - .href('https://vitejs.dev') - .target('blank') - .children( - img() - .src('https://vitejs.dev/logo.svg') - .className('logo') - .alt('Vite Logo') - .get(), - ) - .get(), - h1().innerText('Vite').get(), - div() - .className('card') - .children( - button() - .id('counter') - .type('button') - .innerText(`count is ${this.counter}`) - .className('btn') - .get(), - ) - .get(), - p() - .innerText('Edit src/main.ts and save to test HMR.') - .className('read-the-docs') - .get(), - ) - .get(); + return /*html*/ ` + + `; } } diff --git a/apps/ssr-playground/src/entry-client.ts b/apps/ssr-playground/src/entry-client.ts index d17999d..bbf45d1 100644 --- a/apps/ssr-playground/src/entry-client.ts +++ b/apps/ssr-playground/src/entry-client.ts @@ -3,6 +3,6 @@ import { createApp } from '@sonnetjs/core'; import Counter from './Counter'; const app = createApp(); -app.root(Counter()); +app.root(Counter); app.ssr(); app.mount('#app'); diff --git a/packages/sonnet-core/package.json b/packages/sonnet-core/package.json index 50096b9..5333174 100644 --- a/packages/sonnet-core/package.json +++ b/packages/sonnet-core/package.json @@ -1,6 +1,6 @@ { "name": "@sonnetjs/core", - "version": "0.0.23", + "version": "0.0.24", "files": [ "dist" ], diff --git a/packages/sonnet-core/src/core/SonnetApp.ts b/packages/sonnet-core/src/core/SonnetApp.ts index 01d823e..987f4e8 100644 --- a/packages/sonnet-core/src/core/SonnetApp.ts +++ b/packages/sonnet-core/src/core/SonnetApp.ts @@ -79,17 +79,19 @@ export class SonnetApp { this._mountedId = selector; return; } - if (!this._ssr && isBrowser()) { + if (isBrowser()) { const el = document.querySelector(selector); if (el && this._component) { const component = this.initRootComponent(); - const getComponent = await component?.get(); + if (!this._ssr) { + const getComponent = await component?.get(); - if (typeof getComponent === 'string') { - el.innerHTML = getComponent as string; - } else if (getComponent instanceof Element) { - el.appendChild(getComponent); + if (typeof getComponent === 'string') { + el.innerHTML = getComponent as string; + } else if (getComponent instanceof Element) { + el.appendChild(getComponent); + } } } } diff --git a/tooling/tailwind/tsconfig.json b/tooling/tailwind/tsconfig.json index 4fdbc1d..940bd69 100644 --- a/tooling/tailwind/tsconfig.json +++ b/tooling/tailwind/tsconfig.json @@ -2,4 +2,4 @@ "extends": "@repo/typescript-config/base.json", "include": ["."], "exclude": ["dist", "build", "node_modules"] -} \ No newline at end of file +}