-
Notifications
You must be signed in to change notification settings - Fork 0
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
18 changed files
with
667 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_TEMPLATE_PATH = exports.PACKAGE_ROOT = void 0; | ||
const path = require("path"); | ||
exports.PACKAGE_ROOT = path.join(__dirname, '..', '..', '..'); | ||
exports.DEFAULT_TEMPLATE_PATH = path.join(exports.PACKAGE_ROOT, 'template.html'); |
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,30 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pluginIndexHtml = void 0; | ||
const promises_1 = require("fs/promises"); | ||
const constants_1 = require("../constants"); | ||
function pluginIndexHtml() { | ||
return { | ||
name: 'shaco:index-html', | ||
apply: 'serve', | ||
configureServer(server) { | ||
return () => { | ||
server.middlewares.use(async (req, res, next) => { | ||
// read template.html | ||
let content = await (0, promises_1.readFile)(constants_1.DEFAULT_TEMPLATE_PATH, 'utf-8'); | ||
try { | ||
content = await server.transformIndexHtml(req.url, content, req.originalUrl); | ||
// response html borwer | ||
res.statusCode = 200; | ||
res.setHeader('Content-Type', 'text/html'); | ||
res.end(content); | ||
} | ||
catch (e) { | ||
return next(e); | ||
} | ||
}); | ||
}; | ||
}, | ||
}; | ||
} | ||
exports.pluginIndexHtml = pluginIndexHtml; |
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,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.App = void 0; | ||
const jsx_runtime_1 = require("react/jsx-runtime"); | ||
const theme_default_1 = require("../theme-default"); | ||
function App() { | ||
return (0, jsx_runtime_1.jsx)(theme_default_1.Layout, {}); | ||
} | ||
exports.App = App; |
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,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const jsx_runtime_1 = require("react/jsx-runtime"); | ||
const client_1 = require("react-dom/client"); | ||
const App_1 = require("./App"); | ||
function renderInBrowser() { | ||
const containerEl = document.getElementById("root"); | ||
if (!containerEl) { | ||
throw new Error("#root element not found"); | ||
} | ||
(0, client_1.createRoot)(containerEl).render((0, jsx_runtime_1.jsx)(App_1.App, {})); | ||
} | ||
renderInBrowser(); |
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,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Layout = void 0; | ||
const jsx_runtime_1 = require("react/jsx-runtime"); | ||
const react_1 = require("react"); | ||
function Layout() { | ||
const [count, setCount] = (0, react_1.useState)(0); | ||
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "This is Layout Component" }), (0, jsx_runtime_1.jsxs)("div", { children: [count, (0, jsx_runtime_1.jsx)("button", { onClick: () => setCount(count + 1), children: "Add Count" })] })] })); | ||
} | ||
exports.Layout = Layout; |
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,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Layout = void 0; | ||
var Layout_1 = require("./Layout"); | ||
Object.defineProperty(exports, "Layout", { enumerable: true, get: function () { return Layout_1.Layout; } }); |
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
Oops, something went wrong.