export

package
v0.9.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(opts Options) error

Export generates framework wrappers for all custom elements in the manifest.

func IsBooleanType

func IsBooleanType(cemType string) bool

IsBooleanType returns true if the CEM type is a boolean type. Used to determine attribute handling (boolean attributes vs string attributes).

func MapCEMType

func MapCEMType(cemType string) string

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

func TagNameToComponentName(tagName, stripPrefix string) string

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

func ToAngularEventName(eventName string) string

ToAngularEventName converts a kebab-case event name to an Angular camelCase event name. e.g. "my-event" -> "myEvent"

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase converts a kebab-case string to camelCase. e.g. "my-event" -> "myEvent"

func ToKebabCase

func ToKebabCase(s string) string

ToKebabCase converts a PascalCase or camelCase string to kebab-case. e.g. "DemoButton" -> "demo-button"

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts a kebab-case string to PascalCase. e.g. "my-button" -> "MyButton"

func ToReactEventName

func ToReactEventName(eventName string) string

ToReactEventName converts a kebab-case event name to a React event handler prop name. e.g. "my-event" -> "onMyEvent"

func ToVueEventName

func ToVueEventName(eventName string) string

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

type ExportCssPart struct {
	Name    string
	Summary string
}

ExportCssPart represents a CSS part.

type ExportCssProperty

type ExportCssProperty struct {
	Name    string
	Default string
	Syntax  string
	Summary string
}

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

type ExportProperty struct {
	Name     string
	Type     string
	Default  string
	Summary  string
	Readonly bool
}

ExportProperty represents a property (public field not already an attribute).

type ExportSlot

type ExportSlot struct {
	Name    string
	Summary string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL