Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
148 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { DI } from '@leanup/lib/helpers/injector'; | ||
|
||
export const importCatch = (error: unknown): void => { | ||
console.warn(error); | ||
}; | ||
|
||
export const run = (name: string, packageJson: { default: Object }, bootstrap: Function): void => { | ||
DI.register('Framework', { | ||
...packageJson.default, | ||
name: name, | ||
}); | ||
import('./shares/register') | ||
.then(() => { | ||
import('./shares/routing') | ||
.then(() => { | ||
bootstrap(); | ||
}) | ||
.catch(importCatch); | ||
}) | ||
.catch(importCatch); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 10 additions & 21 deletions
31
packages/cli/frameworks/inferno/template/src/inferno.main.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,16 @@ | ||
import { render } from 'inferno'; | ||
|
||
import { DI } from '@leanup/lib/helpers/injector'; | ||
|
||
import { importCatch, run } from './app.run'; | ||
import { AppComponent } from './components/app/component.inferno'; | ||
|
||
import('inferno/package.json') | ||
.then((packageJson: any) => { | ||
DI.register('Framework', { | ||
...packageJson.default, | ||
name: 'Inferno', | ||
import(`inferno/package.json`) | ||
.then((packageJson: { default: Object }) => { | ||
run('Inferno', packageJson, () => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#inferno'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
render(<AppComponent />, htmlDivElement); | ||
} | ||
}); | ||
import('./shares/register') | ||
.then(() => { | ||
import('./shares/routing') | ||
.then(() => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#inferno'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
render(<AppComponent />, htmlDivElement); | ||
} | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
.catch(importCatch); |
32 changes: 11 additions & 21 deletions
32
packages/cli/frameworks/lit-element/template/src/lit-element.main.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
import './components/app/component.lit-element'; | ||
|
||
import { DI } from '@leanup/lib/helpers/injector'; | ||
import { importCatch, run } from './app.run'; | ||
|
||
import('lit-element/package.json') | ||
.then((packageJson: any) => { | ||
DI.register('Framework', { | ||
...packageJson.default, | ||
name: 'lit-element', | ||
import(`lit-element/package.json`) | ||
.then((packageJson: { default: Object }) => { | ||
run('lit-element', packageJson, () => { | ||
// Render the template to the document | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#lit-element'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
htmlDivElement.innerHTML = '<app-component />'; | ||
} | ||
}); | ||
import('./shares/register') | ||
.then(() => { | ||
import('./shares/routing') | ||
.then(() => { | ||
// Render the template to the document | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#lit-element'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
htmlDivElement.innerHTML = '<app-component />'; | ||
} | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
.catch(importCatch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 10 additions & 21 deletions
31
packages/cli/frameworks/react/template/src/react.main.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { DI } from '@leanup/lib/helpers/injector'; | ||
|
||
import { importCatch, run } from './app.run'; | ||
import { AppComponent } from './components/app/component.react'; | ||
|
||
import('react/package.json') | ||
.then((packageJson: any) => { | ||
DI.register('Framework', { | ||
...packageJson.default, | ||
name: 'React', | ||
import(`react/package.json`) | ||
.then((packageJson: { default: Object }) => { | ||
run('React', packageJson, () => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#react'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
ReactDOM.render(<AppComponent />, htmlDivElement); | ||
} | ||
}); | ||
import('./shares/register') | ||
.then(() => { | ||
import('./shares/routing') | ||
.then(() => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#react'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
ReactDOM.render(<AppComponent />, htmlDivElement); | ||
} | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
.catch(importCatch); |
37 changes: 13 additions & 24 deletions
37
packages/cli/frameworks/svelte/template/src/main.svelte.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
import { DI } from '@leanup/lib/helpers/injector'; | ||
|
||
import { importCatch, run } from './app.run'; | ||
import App from './components/app/component.svelte'; | ||
|
||
let app: unknown; | ||
|
||
import('svelte/package.json') | ||
.then((packageJson: any) => { | ||
DI.register('Framework', { | ||
...packageJson.default, | ||
name: 'Svelte', | ||
import(`svelte/package.json`) | ||
.then((packageJson: { default: Object }) => { | ||
run('Svelte', packageJson, () => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#svelte'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
app = new App({ | ||
target: htmlDivElement, | ||
}); | ||
} | ||
}); | ||
import('./shares/register') | ||
.then(() => { | ||
import('./shares/routing') | ||
.then(() => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#svelte'); | ||
if (htmlDivElement instanceof HTMLDivElement) { | ||
htmlDivElement.style.display = 'inline'; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
app = new App({ | ||
target: htmlDivElement, | ||
}); | ||
} | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
.catch(importCatch); | ||
|
||
export default app; |
32 changes: 15 additions & 17 deletions
32
packages/cli/frameworks/vanilla/template/src/main.vanilla.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import './components/app/component.vanilla'; | ||
|
||
import { DI } from '@leanup/lib/helpers/injector'; | ||
import { importCatch, run } from './app.run'; | ||
|
||
DI.register('Framework', { | ||
name: 'Vanilla', | ||
version: null, | ||
}); | ||
import('./shares/register') | ||
.then(() => { | ||
import('./shares/routing') | ||
.then(() => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#vanilla'); | ||
htmlDivElement.style.display = 'inline'; | ||
const appElement: HTMLElement = document.createElement('wc-app'); | ||
htmlDivElement.appendChild(appElement); | ||
}) | ||
.catch(); | ||
}) | ||
.catch(); | ||
run( | ||
'Vanilla', | ||
{ | ||
default: { | ||
version: null, | ||
}, | ||
}, | ||
() => { | ||
const htmlDivElement: HTMLDivElement | null = document.querySelector('div#vanilla'); | ||
htmlDivElement.style.display = 'inline'; | ||
const appElement: HTMLElement = document.createElement('wc-app'); | ||
htmlDivElement.appendChild(appElement); | ||
} | ||
); |
Oops, something went wrong.