Documentation
¶
Overview ¶
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- func Export(opts Options) error
- func IsBooleanType(cemType string) bool
- func MapCEMType(cemType string) string
- func TagNameToComponentName(tagName, stripPrefix string) string
- func ToAngularEventName(eventName string) string
- func ToCamelCase(s string) string
- func ToKebabCase(s string) string
- func ToPascalCase(s string) string
- func ToReactEventName(eventName string) string
- func ToVueEventName(eventName string) string
- type AngularExporter
- type ExportAttribute
- type ExportCssPart
- type ExportCssProperty
- type ExportElement
- type ExportEvent
- type ExportProperty
- type ExportSlot
- type FrameworkExportConfig
- type FrameworkExporter
- type Options
- type ReactExporter
- type VueExporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBooleanType ¶
IsBooleanType returns true if the CEM type is a boolean type. Used to determine attribute handling (boolean attributes vs string attributes).
func MapCEMType ¶
MapCEMType maps a CEM type string to a TypeScript type for use in generated wrappers. CEM types are already valid TypeScript, so this is mostly a passthrough. Empty types map to "unknown".
func TagNameToComponentName ¶
TagNameToComponentName converts a custom element tag name to a component name, optionally stripping a prefix. e.g. TagNameToComponentName("demo-button", "demo-") -> "Button" e.g. TagNameToComponentName("my-element", "") -> "MyElement"
func ToAngularEventName ¶
ToAngularEventName converts a kebab-case event name to an Angular camelCase event name. e.g. "my-event" -> "myEvent"
func ToCamelCase ¶
ToCamelCase converts a kebab-case string to camelCase. e.g. "my-event" -> "myEvent"
func ToKebabCase ¶
ToKebabCase converts a PascalCase or camelCase string to kebab-case. e.g. "DemoButton" -> "demo-button"
func ToPascalCase ¶
ToPascalCase converts a kebab-case string to PascalCase. e.g. "my-button" -> "MyButton"
func ToReactEventName ¶
ToReactEventName converts a kebab-case event name to a React event handler prop name. e.g. "my-event" -> "onMyEvent"
func ToVueEventName ¶
ToVueEventName returns the event name as-is for Vue (kebab-case is idiomatic). e.g. "my-event" -> "my-event"
Types ¶
type AngularExporter ¶
type AngularExporter struct{}
AngularExporter generates Angular standalone component wrappers.
func (*AngularExporter) ExportElement ¶
func (a *AngularExporter) ExportElement(element ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
func (*AngularExporter) ExportIndex ¶
func (a *AngularExporter) ExportIndex(elements []ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
func (*AngularExporter) Name ¶
func (a *AngularExporter) Name() string
type ExportAttribute ¶
type ExportAttribute struct {
Name string
FieldName string
Type string
Default string
Summary string
IsBoolean bool
}
ExportAttribute represents an attribute for template rendering.
type ExportCssPart ¶
ExportCssPart represents a CSS part.
type ExportCssProperty ¶
ExportCssProperty represents a CSS custom property.
type ExportElement ¶
type ExportElement struct {
TagName string
ClassName string
ModulePath string
ImportPath string
Summary string
Description string
Attributes []ExportAttribute
Properties []ExportProperty
Events []ExportEvent
Slots []ExportSlot
CssParts []ExportCssPart
CssProperties []ExportCssProperty
HasDefaultSlot bool
HasNamedSlots bool
}
ExportElement is a template-friendly representation of a custom element.
type ExportEvent ¶
type ExportEvent struct {
Name string
Type string
ReactName string
VueName string
AngularName string
Summary string
// IsNative is true for standard DOM events (click, focus, etc.) that React
// handles natively through HTMLAttributes. React wrappers should skip these
// to avoid type conflicts.
IsNative bool
}
ExportEvent represents an event with pre-computed framework-specific names.
type ExportProperty ¶
ExportProperty represents a property (public field not already an attribute).
type ExportSlot ¶
ExportSlot represents a slot.
type FrameworkExportConfig ¶
type FrameworkExportConfig struct {
Output string `mapstructure:"output" yaml:"output"`
StripPrefix string `mapstructure:"stripPrefix" yaml:"stripPrefix"`
PackageName string `mapstructure:"packageName" yaml:"packageName"`
ModuleName string `mapstructure:"moduleName" yaml:"moduleName"`
}
FrameworkExportConfig holds per-framework export settings from config or flags.
type FrameworkExporter ¶
type FrameworkExporter interface {
// Name returns the framework name (e.g. "react", "vue", "angular").
Name() string
// ExportElement generates files for a single custom element.
// Returns a map of filename -> content.
ExportElement(element ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
// ExportIndex generates barrel/index files for all elements.
// Returns a map of filename -> content.
ExportIndex(elements []ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
}
FrameworkExporter generates framework wrapper files for custom elements.
type Options ¶
type Options struct {
// Manifest is the parsed custom elements manifest.
Manifest *M.Package
// PackageName is the npm package name for import paths.
PackageName string
// Frameworks maps framework name to its config.
Frameworks map[string]FrameworkExportConfig
}
Options configures the export operation.
type ReactExporter ¶
type ReactExporter struct{}
ReactExporter generates React wrapper components.
func (*ReactExporter) ExportElement ¶
func (r *ReactExporter) ExportElement(element ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
func (*ReactExporter) ExportIndex ¶
func (r *ReactExporter) ExportIndex(elements []ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
func (*ReactExporter) Name ¶
func (r *ReactExporter) Name() string
type VueExporter ¶
type VueExporter struct{}
VueExporter generates Vue SFC wrapper components.
func (*VueExporter) ExportElement ¶
func (v *VueExporter) ExportElement(element ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
func (*VueExporter) ExportIndex ¶
func (v *VueExporter) ExportIndex(elements []ExportElement, cfg FrameworkExportConfig) (map[string]string, error)
func (*VueExporter) Name ¶
func (v *VueExporter) Name() string