Extension - Web Component SDK
Quick Setup
Prerequisites
- NodeJS (version 8 or later) - tested with node 22
- Global npm packages
- VS Code recommended
Download
Use an installation path without spaces (at least on Windows)
- WEB-Component-SDK-Library - ptcs web components and API
- Unzip as
wc-sdk-library/
- Unzip as
- WEB-Component-SDK-Utility - Tooling to package the web component as a ThingWorx widget
- Unzip as
wc-sdk-utility/
- Unzip as
- A Sample Web Component - A simple web component
- Unzip as
simple-el/twx-wc-sdk/folder is already populated with content ofwc-sdk-Library(not sure which version)
- Unzip as
- A Sample Web Component Widget - A web component (simple-el) widget demo, ready to be used with the SDK utility
- Unzip as
simple-el-widget/
- Unzip as
ThingWorx Web Component SDK Utility Setup
In wc-sdk-utility/ :
npm installnpm link
Web Component Development
Documentation
Project Setup
In simple-el/:
- Delete content of
twx-wc-sdk/folder and replace with the content ofwc-sdk-library npm install
Development
- This is outside the scope of this post, but you may review:
simple-el.jsdemo web component- out of the box ptcs web components in
twx-wc-sdk/
Testing
npm start- Open URL from prompt in a browser
Widget / Extension package
Documentation
- Packaging a Web Component as a ThingWorx Widget
- .md in
wc-sdk-utility/doc
Setup
In simple-el-widget/:
- Create
tmp/folder next toinput/and copy thesimple-elweb component folder to it (or replace its content if it already exists)
Development
- This is outside the scope of this post, but you may review:
- the Widget and Extension config files in
input/widgets.json: extension definition (metadata.xml)widgets/sample-el.json: widget definition- Web Comp properties, services, events mapping and more...
ui/simpleel/simpleel.runtime.js: Widget custom code for behavior not achievable through mappings alone
- the Widget and Extension config files in
Build
Package the web component as Widget and build the Extension
External Resources
- PTC Help Center - Lit Web Component Development
- PTC Help Center - ThingWorx Web Component SDK
- lit.dev
- Web Components