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 ¶
- Constants
- func DaisyUIPluginFile(url string) string
- func DaisyUIThemePluginFile(url string) string
- func NewLibrary(url string) *types.JSLibrary
- func NewLibraryESM(packageName string, version string, esbuildArgs []string) *types.JSLibrary
- type AppDev
- type AppStyle
- type CustomTheme
- type JsLibManager
- type WatcherState
Examples ¶
Constants ¶
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 )
const ( TailwindCSS types.StyleType = "tailwindcss" DaisyUI types.StyleType = "daisyui" Other types.StyleType = "other" None types.StyleType = "" )
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
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
DaisyUIThemePluginFile is the work dir file name for the prebundled daisyui theme plugin (used for custom themes) downloaded from url.
func NewLibrary ¶
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) GenerateHTML ¶
GenerateHTML generates the default HTML template files for the app.
func (*AppDev) SaveConfigLockFile ¶
func (*AppDev) SetupJsLibs ¶
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 (*AppStyle) Setup ¶
Setup sets up the style library for the app. This is called when the app is reloaded.
func (*AppStyle) StartWatcher ¶
StartWatcher starts the watcher process for the app. This is called when the app is reloaded.
func (*AppStyle) StopWatcher ¶
type CustomTheme ¶ added in v0.18.4
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 ¶
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.