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 🙏

© 2025 – Pkg Stats / Ryan Hefner

shacled-turtle

v0.0.3

Published

Code Mirror Turtle language support with autocompletion

Readme

Shacled Turtle 🐢

A Code Mirror 6 Turtle language support that provides autocompletion based on the content of a schema graph. Schemas can be written by using either RDFS, SHACL or a mix of both (= your usual ontology and validation RDF graphs).

How to use

You can use this extension like any other Code Mirror 6 extension.

For example, by using parcel:

  • Start a new project: npm init

  • Install the dependencies: npm install @codemirror/basic-setup @codemirror/state @codemirror/view shacled-turtle n3

  • Install parcel and n3 types npm install --save-dev parcel @types/n3

  • Make a file named index.ts with the following content:

import { basicSetup } from "@codemirror/basic-setup";
import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import { shacledTurtle, changeSchema } from "shacled-turtle";
import * as n3 from "n3";

const prefixes = 
`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix ex: <http://example.com/ns#> .
@prefix s: <http://schema.org/> .`;

// Build a CodeMirror editor with the Shacled Turtle extension
const editor = new EditorView({
  parent: document.getElementById("editorparent")!,
  state: EditorState.create({
    doc: prefixes + "\n\n\n\n\n",
    extensions: [basicSetup, shacledTurtle()]
  })
});

// Write the corresponding schema with SHACL
const shapeGraph = prefixes + `
  ex:PersonShape a sh:NodeShape ;
    sh:targetClass s:Person ;
    sh:property [ sh:path s:name ] .
`;

// Tell the editor that the schema used to provide autocompletion is
// the schema graph described in variable shapeGraph.
changeSchema(editor.state, new n3.Parser().parse(shapeGraph));
  • Make a file named index.html with the following content
<html>
  <body>
    <h1>Shacled Turtle Basic example</h1>
    <div id="editorparent"></div>
    <script src="index.ts" type="module"></script>
  </body>
</html>
  • Run npx parcel ./index.html -p 8080

  • Open on your favorite broswer http://localhost:8080

On the code editor, type ex:Alice r, the editor suggests rdf:type then s:Person.

After ex:Alice rdf:type s:Person . , write ex:alice s and the engine will suggest s:name because it knows Alice is a person.

License

Published under either the CeCCIL-B license or the MIT License by INSA Lyon / Julian Bruyat.