srcpack

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright (c) 2021 Guy A. Ross This source code is licensed under the GNU GPLv3 found in the license file in the root directory of this source tree.

Copyright (c) 2021 Guy A. Ross This source code is licensed under the GNU GPLv3 found in the license file in the root directory of this source tree.

Copyright (c) 2021 Guy A. Ross This source code is licensed under the GNU GPLv3 found in the license file in the root directory of this source tree.

Copyright (c) 2021 Guy A. Ross This source code is licensed under the GNU GPLv3 found in the license file in the root directory of this source tree.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidComponentType = errors.New("invalid component type")

Functions

func New

func New(path string, c []*Component, webDirPath string) (*dependtree.DependencySourceMap, error)

Types

type CachedEnvKeys

type CachedEnvKeys map[string]string

CachedEnvKeys represents a map where the key is the filepath for the env setting and where the value is a bundler key

type Component

type Component struct {
	WebDir string

	Name      string
	BundleKey string

	WebWrapper webwrapper.JSWebWrapper
	Bundler    bundler.Bundler
	JsParser   jsparse.JSParser
	// contains filtered or unexported fields
}

component that has been successfully ran, and output from a packing method. a component represents a source file that has a valid parser

func NewComponent

func NewComponent(ctx context.Context, opts *NewComponentOpts) (*Component, error)

NewComponent creates a new component that represents a packaged & bundled web component

func (*Component) Dependencies

func (s *Component) Dependencies() []*jsparse.ImportDependency

Dependencies returns the dependencies on the component

func (*Component) OriginalFilePath

func (s *Component) OriginalFilePath() string

OriginalFilePath returns the original file path on the component

func (*Component) Repack

func (s *Component) Repack() error

Repack repacks a component following the following processes

  • parses the provided filepath with the the components jsparser
  • reapplies the component web wrapper
  • bundles the component

func (*Component) RepackForWaitGroup

func (s *Component) RepackForWaitGroup(wg *sync.WaitGroup, c chan error)

RepackForWaitGroup given a wait group, repacks the component using the underlying "Repack" method.

type DefaultPackerOpts

type DefaultPackerOpts struct {
	WebDir           string
	BundlerMode      string
	NodeModuleDir    string
	CachedBundleKeys CachedEnvKeys
}

DefaultPackerOpts options for creating a new default packer

type JSDependencyTree

type JSDependencyTree struct {
	WebDir string

	JsParser jsparse.JSParser
	// contains filtered or unexported fields
}

javascript dependency tree, used to create a dependency tree from javascript files this struct should salsify the requirements for "DependencyTree" interface

func (*JSDependencyTree) DirList

func (s *JSDependencyTree) DirList(path string) ([]string, error)

func (*JSDependencyTree) PathDependencies

func (s *JSDependencyTree) PathDependencies(path string) ([]string, error)

uses the js parser to get all of the dependencies for the specified file.

type NewComponentOpts

type NewComponentOpts struct {
	FilePath   string
	WebDir     string
	DefaultKey string

	JSParser      jsparse.JSParser
	Bundler       bundler.Bundler
	JSWebWrappers webwrapper.JSWebWrapperMap
}

NewComponentOpts options for creating a new component

type PackHook

type PackHook interface {
	Pre(filePath string)                       // "pre" runs before each component packing iteration
	Post(filepath string, elapsedTime float64) // "post" runs after each component packing iteration
	Close()
}

hooks for logging the pre & post operations of the packing process.

type PackedComponentList

type PackedComponentList []*Component

func (*PackedComponentList) RepackMany

func (l *PackedComponentList) RepackMany(logger log.Logger) error

type Packer

type Packer struct {
	Bundler          bundler.Bundler
	JsParser         jsparse.JSParser
	ValidWebWrappers webwrapper.JSWebWrapperMap
	Logger           log.Logger

	AssetDir string
	WebDir   string
	// contains filtered or unexported fields
}

packer is the primary struct used for packing a directory of javascript files into valid web components.

func NewDefaultPacker

func NewDefaultPacker(logger log.Logger, opts *DefaultPackerOpts) *Packer

func (*Packer) PackMany

func (s *Packer) PackMany(pages []string) ([]*Component, error)

packs the provided file paths into the orbit root directory

func (*Packer) ReattachLogger

func (p *Packer) ReattachLogger(logger log.Logger) *Packer

type SrcDependency

type SrcDependency interface {
	OriginalFilePath() string
	Dependencies() []*jsparse.ImportDependency
}

type SyncHook

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

func NewSyncHook

func NewSyncHook(logger log.Logger) *SyncHook

func (*SyncHook) Close

func (s *SyncHook) Close()

func (*SyncHook) Post

func (s *SyncHook) Post(filePath string, elapsedTime float64)

func (*SyncHook) Pre

func (s *SyncHook) Pre(filePath string)

func (*SyncHook) WrapFunc

func (s *SyncHook) WrapFunc(filepath string, do func())

Jump to

Keyboard shortcuts

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