dev

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Example (CleanSourceRelativeOutput)
sourceRoot, err := os.MkdirTemp("", "openrun-source-*")
if err != nil {
	panic(err)
}
defer os.RemoveAll(sourceRoot) //nolint:errcheck

cleanRoot, err := cleanSourceRoot(sourceRoot)
if err != nil {
	panic(err)
}
outputPath := filepath.Join(cleanRoot, "static", "gen", "css", "style.css")

rel, err := cleanSourceRelativeOutput(sourceRoot, outputPath)
if err != nil {
	panic(err)
}

fmt.Println(rel)
Output:
static/gen/css/style.css
Example (EnsureSourceOutputDir)
sourceRoot, err := os.MkdirTemp("", "openrun-source-*")
if err != nil {
	panic(err)
}
defer os.RemoveAll(sourceRoot) //nolint:errcheck

target, err := ensureSourceOutputDir(sourceRoot, STYLE_FILE_PATH, 0700)
if err != nil {
	panic(err)
}

cleanRoot, err := cleanSourceRoot(sourceRoot)
if err != nil {
	panic(err)
}
rel, err := filepath.Rel(cleanRoot, target)
if err != nil {
	panic(err)
}
_, err = os.Stat(filepath.Dir(target))

fmt.Println(filepath.ToSlash(rel))
fmt.Println(err == nil)
Output:
static/gen/css/style.css
true
Example (SourceOutputAbsPath)
sourceRoot, err := os.MkdirTemp("", "openrun-source-*")
if err != nil {
	panic(err)
}
defer os.RemoveAll(sourceRoot) //nolint:errcheck

target, err := sourceOutputAbsPath(sourceRoot, "static/gen/esm/app.js")
if err != nil {
	panic(err)
}

cleanRoot, err := cleanSourceRoot(sourceRoot)
if err != nil {
	panic(err)
}
rel, err := filepath.Rel(cleanRoot, target)
if err != nil {
	panic(err)
}

fmt.Println(filepath.IsAbs(target))
fmt.Println(filepath.ToSlash(rel))
Output:
true
static/gen/esm/app.js

Index

Examples

Constants

View Source
const (
	STYLE_FILE_PATH = "static/gen/css/style.css"

	// The standalone tailwindcss v4 CLI does not bundle daisyui; @plugin "daisyui"
	// is resolved through node_modules, walking up from the input.css directory.
	// To avoid requiring any node_modules setup, the prebundled daisyui plugin is
	// downloaded next to the generated input.css and referenced by relative path.
	// The download urls are configured with daisyui_url and daisyui_theme_url in
	// the [system] server config.
	DAISYUI_MODULE_REF       = "daisyui"       // node_modules based plugin reference
	DAISYUI_THEME_MODULE_REF = "daisyui/theme" // node_modules based theme plugin reference
)
View Source
const (
	TailwindCSS types.StyleType = "tailwindcss"
	DaisyUI     types.StyleType = "daisyui"
	Other       types.StyleType = "other"
	None        types.StyleType = ""
)
View Source
const (
	// TODO: allow custom config file to be specified
	TAILWIND_CONFIG_FILE     = "tailwind.config.js"
	TAILWIND_CONFIG_CONTENTS = `
	module.exports = {
		content: [%s],
		theme: {
		  extend: {},
		},
	  
		plugins: [
		  %s
		],
		%s
	}`

	TAILWIND_INPUT_LEGACY_CONTENTS = `
	@tailwind base;
	@tailwind components;
	@tailwind utilities;
	`

	TAILWIND_INPUT_CONTENTS = `
	@import "tailwindcss" source(none);
	%s
	%s
	`
)

Variables

This section is empty.

Functions

func DaisyUIPluginFile added in v0.18.4

func DaisyUIPluginFile(url string) string

DaisyUIPluginFile is the work dir file name for the prebundled daisyui plugin downloaded from url. The name includes a hash of the url so that a url (version) change triggers a fresh download.

func DaisyUIThemePluginFile added in v0.18.4

func DaisyUIThemePluginFile(url string) string

DaisyUIThemePluginFile is the work dir file name for the prebundled daisyui theme plugin (used for custom themes) downloaded from url.

func NewLibrary

func NewLibrary(url string) *types.JSLibrary

func NewLibraryESM

func NewLibraryESM(packageName string, version string, esbuildArgs []string) *types.JSLibrary

Types

type AppDev

type AppDev struct {
	*types.Logger

	CustomLayout bool
	Config       *apptype.CodeConfig

	AppStyle *AppStyle

	JsLibs []types.JSLibrary
	// contains filtered or unexported fields
}

AppDev is the main object that represents a OpenRun app in dev mode. It is created when the app is loaded with is_dev true and handles the styling and js library related functionalities. Access to this is synced through the initMutex in App. The reload method in App is the main access point to this object

func NewAppDev

func NewAppDev(logger *types.Logger, sourceFS *appfs.WritableSourceFs, workFS *appfs.WorkFs, appStyle *AppStyle, systemConfig *types.SystemConfig) *AppDev

func (*AppDev) Close

func (a *AppDev) Close() error

Close the app dev session

func (*AppDev) GenerateHTML

func (a *AppDev) GenerateHTML() error

GenerateHTML generates the default HTML template files for the app.

func (*AppDev) SaveConfigLockFile

func (a *AppDev) SaveConfigLockFile() error

func (*AppDev) SetupJsLibs

func (a *AppDev) SetupJsLibs() error

SetupJsLibs sets up the js libraries for the app.

type AppStyle

type AppStyle struct {
	DisableWatcher bool

	Light string
	Dark  string
	// contains filtered or unexported fields
}

func (*AppStyle) GetStyleType

func (s *AppStyle) GetStyleType() types.StyleType

func (*AppStyle) Init

func (s *AppStyle) Init(appId types.AppId, appDef *starlarkstruct.Struct) error

Init initializes the AppStyle object from the app definition

func (*AppStyle) Setup

func (s *AppStyle) Setup(dev *AppDev) error

Setup sets up the style library for the app. This is called when the app is reloaded.

func (*AppStyle) StartWatcher

func (s *AppStyle) StartWatcher(dev *AppDev) error

StartWatcher starts the watcher process for the app. This is called when the app is reloaded.

func (*AppStyle) StopWatcher

func (s *AppStyle) StopWatcher() error

type CustomTheme added in v0.18.4

type CustomTheme struct {
	Name  string
	Props [][2]string
}

AppStyle is the style related configuration and state for an app. It is created when the App is loaded. It keeps track of the watcher process required to rebuild the CSS file when the tailwind/daisy config changes. The reload mutex lock in App is used to ensure only one call to the watcher is done at a time, no locking is implemented in AppStyle CustomTheme is a daisyui custom theme: the theme name and its CSS properties (color-scheme, --color-* etc), in declaration order

type JsLibManager

type JsLibManager struct {
	types.JSLibrary
}

func (*JsLibManager) Setup

func (j *JsLibManager) Setup(dev *AppDev, sourceFS *appfs.WritableSourceFs, workFS *appfs.WorkFs) (string, error)

type WatcherState

type WatcherState struct {
	// contains filtered or unexported fields
}

WatcherState is the state of the watcher process as of when it was last started.

Jump to

Keyboard shortcuts

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