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

makestatic-graph-resources

v1.1.12

Published

Create a resource graph

Downloads

5

Readme

Graph Resources

Create a graph of referenced resources



Install

yarn add makestatic-graph-resources

API

GraphResources

Create a graph of referenced resources.

For each HTML, CSS and Javascript file inspect the abstract syntax tree and create a resource graph of referenced assets.

GraphResources

new GraphResources(context)

Create a GraphResources plugin.

Enable this plugin for the graph phase.

  • context Object the processing context.

.sources

GraphResources.prototype.sources(file, context, options)

Inspects the abstract syntax tree for each file to find referenced resources and add them to the graph.

If a file does not have an associated abstract syntax tree a document is added to the resource graph but no parsing is performed on the document.

  • file Object the file being processed.
  • context Object the processing context.
  • options Object the plugin options.

Document

Represents a document entry in the graph.

Document

new Document(file)

Create a document.

  • file File the encapsulated file.

resources

readonly Array resources

List of resources referenced in this document.

file

readonly File file

Reference to the file that created this document.

id

readonly String id

Document identifier derived from the file path.

HtmlDocument

Represents an HTML document entry in the graph.

HtmlDocument

new HtmlDocument(file)

Create an HTML document.

  • file File the encapsulated file.

anchors

Object anchors

List of anchor links.

Plugins that execute during the verify phase can use this to check if named anchors exist on the page or test whether external links return a valid HTTP status code.

identifiers

Object identifiers

Map of id attributes.

Plugins that execute during the verify phase can use this to determine if a document contains duplicate id attributes.

ast

Object ast

Get a reference to the file abstract syntax tree.

.parse

HtmlDocument.prototype.parse()

Traverse the file abstract syntax tree and parse resources in to this document.

Note that in the case of a base element with an href attribute a resource is not created but all subsequent URLs are considered relative to the base URL.

  • href (a, area, base, link)
  • src (audio, embed, iframe, img, input, script, source, track, video)
  • action (form)
  • cite (blockquote, del, ins, q)
  • code (applet)
  • codebase (applet)
  • data (object)
  • manifest (html)

See Also

CssDocument

Represents a CSS document entry in the graph.

CssDocument

new CssDocument(file)

Create a CSS document.

  • file File the encapsulated file.

ast

Object ast

Get a reference to the file abstract syntax tree.

.parse

CssDocument.prototype.parse()

Traverse the file abstract syntax tree and parse resources in to this document.

This implementation parses @import rules using either string URLs or the url() function notation. It also parses all url() function declarations in normal CSS rule declarations.

Graph

Represents the application resource graph.

Graph

new Graph()

Create a resource graph.

map

readonly Object map

Maps file keys to resources.

.addDocument

Graph.prototype.addDocument()

Adds a document to the graph.

documents

readonly Array documents

List of documents without abstract syntax trees.

htmlDocuments

readonly Array htmlDocuments

List of HTML documents.

cssDocuments

readonly Array cssDocuments

List of CSS documents.

.createDocument

Graph.prototype.createDocument(file)

Create a document.

Returns a new document.

  • file File the encapsulated file.

.createHtmlDocument

Graph.prototype.createHtmlDocument(file)

Create an HTML document.

Returns a new HTML document.

  • file File the encapsulated file.

.createCssDocument

Graph.prototype.createCssDocument(file)

Create a CSS document.

Returns a new CSS document.

  • file File the encapsulated file.

Resource

Represents a referenced resource.

The resource may exist within the output file structure or may point to an external (absolute) resource.

Resource

new Resource(uri, node[, base])

Creates a resource.

  • uri String uniform resource identifier.
  • node Object abstract syntax tree node.
  • base String a base URL.

uri

readonly String uri

Uniform resource identifier.

node

readonly Object node

An abstract syntax tree node associated with this resource.

base

readonly String base

Base URL for this resource.

.isAbsolute

Resource.prototype.isAbsolute(uri)

Determine if a URI is absolute.

If no URI is given the URI for this resource is used.

Returns a boolean indicating if this resource is absolute.

  • uri String uniform resource identifier.

canonical

readonly String canonical

Get the canonical URI for this resource relative to the base if a base URL has been associated with this resource.

When no base URL is assigned to this resource it will return the uri.

License

MIT


Created by mkdoc on March 13, 2017