-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
19 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,7 @@ async function unocss(config, content, id) { | |
const generatorKey = config?.filename ?? "."; | ||
let uno = unoGenerators.get(generatorKey); | ||
if (!uno || uno.configCSS !== config?.css) { | ||
uno = import("npm:@esm.sh/[email protected].1").then(({ init }) => init(config?.css)); | ||
uno = import("npm:@esm.sh/[email protected].2").then(({ init }) => init(config?.css)); | ||
uno.configCSS = config?.css; | ||
unoGenerators.set(generatorKey, uno); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ type LoaderWorker struct { | |
outReader *bufio.Reader | ||
} | ||
|
||
func (lw *LoaderWorker) Start(loaderjs []byte) (err error) { | ||
func (l *LoaderWorker) Start(loaderjs []byte) (err error) { | ||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
return | ||
|
@@ -41,35 +41,40 @@ func (lw *LoaderWorker) Start(loaderjs []byte) (err error) { | |
return | ||
} | ||
} | ||
|
||
denoPath, err := getDenoPath() | ||
if err != nil { | ||
err = errors.New("deno not found, please install deno first") | ||
return | ||
} | ||
|
||
cmd := exec.Command(denoPath, "run", "--no-lock", "-A", jsPath) | ||
cmd.Stdin, lw.stdin = io.Pipe() | ||
lw.stdout, cmd.Stdout = io.Pipe() | ||
cmd.Stdin, l.stdin = io.Pipe() | ||
l.stdout, cmd.Stdout = io.Pipe() | ||
err = cmd.Start() | ||
if err != nil { | ||
lw.stdin = nil | ||
lw.stdout = nil | ||
l.stdin = nil | ||
l.stdout = nil | ||
} else { | ||
lw.outReader = bufio.NewReader(lw.stdout) | ||
l.outReader = bufio.NewReader(l.stdout) | ||
if os.Getenv("DEBUG") == "1" { | ||
denoVersion, _ := exec.Command(denoPath, "-v").Output() | ||
fmt.Println(term.Dim(fmt.Sprintf("[debug] loader process started (runtime: %s)", strings.TrimSpace(string(denoVersion))))) | ||
} | ||
} | ||
|
||
// pre-install npm deps | ||
cmd = exec.Command(denoPath, "cache", "npm:@esm.sh/[email protected]", "npm:@esm.sh/[email protected]", "npm:@esm.sh/[email protected]") | ||
cmd.Start() | ||
return | ||
} | ||
|
||
func (lw *LoaderWorker) Load(loaderType string, args []any) (lang string, code string, err error) { | ||
func (l *LoaderWorker) Load(loaderType string, args []any) (lang string, code string, err error) { | ||
// only one load can be invoked at a time | ||
lw.lock.Lock() | ||
defer lw.lock.Unlock() | ||
l.lock.Lock() | ||
defer l.lock.Unlock() | ||
|
||
if lw.outReader == nil { | ||
if l.outReader == nil { | ||
err = errors.New("loader not started") | ||
return | ||
} | ||
|
@@ -88,13 +93,13 @@ func (lw *LoaderWorker) Load(loaderType string, args []any) (lang string, code s | |
loaderArgs := make([]any, len(args)+1) | ||
loaderArgs[0] = loaderType | ||
copy(loaderArgs[1:], args) | ||
err = json.NewEncoder(lw.stdin).Encode(loaderArgs) | ||
err = json.NewEncoder(l.stdin).Encode(loaderArgs) | ||
if err != nil { | ||
return | ||
} | ||
for { | ||
var line []byte | ||
line, err = lw.outReader.ReadBytes('\n') | ||
line, err = l.outReader.ReadBytes('\n') | ||
if err != nil { | ||
return | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,5 +98,5 @@ func transformSvelte(npmrc *NpmRC, importMap common.ImportMap, args []string) (o | |
} | ||
|
||
func generateUnoCSS(npmrc *NpmRC, args []string) (output *LoaderOutput, err error) { | ||
return runLoader(npmrc, "unocss", args, PackageId{"@esm.sh/unocss", "0.2.1"}, "@iconify/[email protected].269") | ||
return runLoader(npmrc, "unocss", args, PackageId{"@esm.sh/unocss", "0.2.2"}, "@iconify/[email protected].271") | ||
} |