Hello
', 'https://example.com'); console.log(win.document.body.innerHTML); ``` ### Response #### Success Response (200) - **Window** - A simulated window object with a document. #### Response Example (Object representing a window environment) ``` -------------------------------- ### Create HTTP Server with Middleware Source: https://github.com/stenciljs/core/blob/main/docs/dev-server.md Sets up the Express HTTP server, including essential middleware like compression, CORS, and JSON body parsing. It also configures request handling and static file serving. ```typescript const createHttpServer = (config: DevServerConfig) => { const app = express(); // Middleware stack app.use(compression()); app.use(cors(config.cors)); app.use(bodyParser.json()); // Request handling app.use(createRequestHandler(config)); // Static file serving app.use(express.static(config.root, { index: false, setHeaders: setCacheHeaders })); return app.listen(config.port, config.address); }; ``` -------------------------------- ### Build Feature Aggregation: Get Build Features Source: https://github.com/stenciljs/core/blob/main/docs/runtime.md Aggregates features across all components to determine the overall build requirements. ```typescript export const getBuildFeatures = (cmps: ComponentCompilerMeta[]): BuildFeatures => { const slot = cmps.some((c) => c.htmlTagNames.includes('slot')); const shadowDom = cmps.some((c) => c.encapsulation === 'shadow'); const slotRelocation = cmps.some((c) => c.encapsulation !== 'shadow' && c.htmlTagNames.includes('slot')); return { allRenderFn: cmps.every(c => c.hasRenderFn), prop: cmps.some(c => c.hasProp), state: cmps.some(c => c.hasState), method: cmps.some(c => c.hasMethod), // ... check every feature across all components }; }; ``` -------------------------------- ### Terser Dead Code Elimination Example Source: https://github.com/stenciljs/core/blob/main/docs/runtime.md Demonstrates how Terser removes code blocks that are conditionally excluded based on the BUILD object. ```typescript // Before if (BUILD.member) { initializeProps(elm, cmpMeta); } // After (when BUILD.member = false) if (false) { initializeProps(elm, cmpMeta); } // Final (removed entirely!) // ... nothing ... ``` -------------------------------- ### Inject Preview Script and HTML Source: https://github.com/stenciljs/core/blob/main/test/browser-compile/src/preview.html Use this code to dynamically inject a script and HTML content into a preview window. The script executes bundled code from the opener, and the HTML content is rendered in the body. ```javascript const script = document.createElement('script'); script.setAttribute('type', 'module'); script.innerHTML = 'console.log("PREVIEW!!");\n' + window.opener.bundledInput; document.head.appendChild(script); document.body.innerHTML = window.opener.htmlCodeInput; ``` -------------------------------- ### Define a Stencil Component Source: https://github.com/stenciljs/core/blob/main/readme.md This example shows how to define a Stencil component using TypeScript decorators. It includes properties and a render method. ```tsx import { Component, Prop, h } from '@stencil/core'; @Component({ tag: 'my-component', styleUrl: 'my-component.css', shadow: true, }) export class MyComponent { @Prop() first: string; @Prop() last: string; render() { return (