npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jdeighan/starbucks

v10.0.4

Published

A svelte language extension

Downloads

23

Readme

starbucks - a sveltekit utility

Date: 8/27/2021

How starbucks() transforms *.starbucks files to *.svelte files:

A simple webpage

#starbucks webpage

h1 Hello, World!

becomes

<h1>
   Hello, World!
</h1>

A simple component

#starbucks component

h1 Hello, World!

becomes

<h1>
   Hello, World!
</h1>

NOTE: The above both produce the same output. However, handling of parameters differs between web pages and components

NOTE: The above resembles pug syntax, but it's not. See attributes below.

Multiple HTML elements

#starbucks webpage

h1 Hello, World!
p a paragraph

becomes

<h1>
   Hello, World!
</h1>
<p>
   a paragraph
</p>

Nested HTML elements

#starbucks webpage

div
	h1 Hello, World!
	p a paragraph

becomes

<div>
   <h1>
      Hello, World!
   </h1>
   <p>
      a paragraph
   </p>
</div>

Comments

#starbucks webpage

# --- this is a comment
#
# --- this is another comment

p a paragraph

becomes

<p>
   a paragraph
</p>

i.e. both comments and empty lines are ignored. A comment is a line where the first non-whitespace character is a '#' and either 1) the '#' is immediately followed by a whitespace character, or 2) there is nothing following the '#' on the line.

This is true inside script and style sections, as well as markdown. However, in #included markdown files, '# header' will be changed to 'header' followed by '======' and '##header' wil be changed to 'header' followed by '------'.

HTML attributes

#starbucks webpage

p class=bold a paragraph

becomes

<p class="bold">
   a paragraph
</p>

#starbucks webpage

p class='bold' a paragraph

becomes

<p class="bold">
   a paragraph
</p>

#starbucks webpage

p class="bold" a paragraph

becomes

<p class="bold">
   a paragraph
</p>

#starbucks webpage

p.bold a paragraph

becomes

<p class="bold">
   a paragraph
</p>

#starbucks webpage

p.bold class="red" a paragraph

becomes

<p class="bold red">
   a paragraph
</p>

#starbucks webpage

p.bold name="mine" a paragraph

becomes

<p name="mine" class="bold">
   a paragraph
</p>

#starbucks webpage

p.bold name="mine" 'a paragraph'

becomes

<p name="mine" class="bold">
   a paragraph
</p>

i.e. you can quote the text contained in an element if you're afraid that it might be interpreted as an attribute

#starbucks webpage

p.bold name="mine" "a paragraph"

becomes

<p name="mine" class="bold">
   a paragraph
</p>

Parameters in a component

#starbucks component (name)

h1 title

becomes

<h1>
   title
</h1>

<script>
   import {undef,say,ask,isEmpty,nonEmpty} from '@jdeighan/coffee-utils'
export var name = undef;

</script>

NOTE: Whenever there is a <script> section, some common functions are automatically imported. TO DO: check which are actually used and only import those. Also, there should be a semicolon terminating the import statement.

NOTE: The export statement should be indented. The blank line should not appear.

Parameters in a web page

#starbucks webpage (name)

h1 title

becomes

<script context="module">
export var load = function({page}) {
  return {
    props: {name}
  };
};

</script>

<h1>
	title
</h1>

Substitution of env vars using {{name}}

NOTE: This requires a .env file in a valid location, e.g. a file named .env in the same dir containing the source starbucks file containing:

name = John
color = lightGray

Then,

#starbucks webpage

h1 My name is {{name}}

becomes

<h1>
	My name is John
</h1>

#starbucks webpage

script
	myName = '{{name}}'

becomes


<script>
	import {undef,say,ask,isEmpty,nonEmpty} from '@jdeighan/coffee-utils'
var myName;

myName = 'John';

</script>

#starbucks webpage

style
	p
		background-color: {{color}}

becomes


<style>
p {
		background-color: lightGray;
}
</style>

Command #envvar

NOTE: In starbucks syntax, a command is a line on which the first non-whitespace character is '#', which is immediately followed by the name of the command, which always consists of one or more lower-case letters

#starbucks webpage

#envvar lastName = Deighan
p My last name is {{lastName}}

becomes

<p>
	My last name is Deighan
</p>

Command #if

#starbucks webpage

#envvar lastName = Deighan

#if known
	p My last name is {{lastName}}
#else
	p I don't know

becomes

{#if known }
	<p>
		My last name is Deighan
	</p>
{:else}
	<p>
		I don't know
	</p>
{/if}

NOTE: known is a JavaScript variable, and if it changes, the block of code that is displayed may change. However, lastName is a constant at the time that this code is generated, and as such, will always be 'Deighan'.

#starbucks webpage

#envvar lastName = Deighan

#if known
	p My last name is {{lastName}}
#elsif standard
	p My last name is Smith
#else
	p I don't know

becomes

{#if known }
	<p>
		My last name is Deighan
	</p>
{:else if standard }
	<p>
		My last name is Smith
	</p>
{:else}
	<p>
		I don't know
	</p>
{/if}

Command #for

#starbucks webpage

#envvar lastName = Deighan

#for name in lNames
	p My name is {name}

becomes

{#each lNames as name}
	<p>
		My name is {name}
	</p>
{/each}

#starbucks webpage

#for name,i in lNames
	p {i}. My name is {name}

becomes

{#each lNames as name,i}
	<p>
		{i}. My name is {name}
	</p>
{/each}

#starbucks webpage

#for name,i in lNames  (key  =  id)
	p {i}. My name is {name}

becomes

{#each lNames as name,i (id)}
	<p>
		{i}. My name is {name}
	</p>
{/each}

Command #await

#starbucks webpage

#await fetch('https://disease.sh/v3/covid-19/historical/all?lastdays=30')
	p please wait...
#then lData
	ul
		#for n,i in lData
			li [{i}] {n}
#catch err
	div.error {err.message}

becomes

{#await fetch('https://disease.sh/v3/covid-19/historical/all?lastdays=30')}
	<p>
		please wait...
	</p>
{:then lData}
	<ul>
		{#each lData as n,i}
			<li>
				[{i}] {n}
			</li>
		{/each}
	</ul>
{:catch err}
	<div class="error">
		{err.message}
	</div>
{/await}

Nested Styles (a la SASS)

#starbucks webpage

h1.error
	p.message {err.message}
	p.solution Please set env var dir_root

style
	h1.error
		p.message
			background-color: red
		p.solution
			background-color: orange

becomes

<h1 class="error">
	<p class="message">
		{err.message}
	</p>
	<p class="solution">
		Please set env var dir_root
	</p>
</h1>

<style>
h1.error p.message {
		background-color: red;
}
h1.error p.solution {
		background-color: orange;
}
</style>

Attribute values = {...}

becomes