1.0.5 • Published 21 days ago

@shgysk8zer0/kazoo v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

kazoo

A JavaScript monorepo for all the things!

CodeQL Node CI Lint Code Base

GitHub license GitHub last commit GitHub release GitHub Sponsors

npm node-current NPM Unpacked Size npm

GitHub followers GitHub forks GitHub stars Twitter Follow

Donate using Liberapay


Browser Support

To avoid bloat and duplication, polyfills are not included. However, all polyfills for modern browsers may be found in @shgysk8zer0/polyfills.

Or, you could just add them as a script (probably better for caching)

<script src="https://unpkg.com/@shgysk8zer0/polyfills@0.0.7/all.min.js" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-6D7++ok/uTOBioRnypzDxJYKgBEgNUmmnNO1ZKJAUyA21GK1vuHmOsoGswvTN157" fetchpriority="high" defer=""></script>

Required Polyfills (depending on browser support)

  • AbortSignal & AbortController
  • trustedTypes
  • scheduler
  • Sanitizer
  • Iterator.range()
  • Iterator helpers (e.g. iter.take(5).map().filter())
  • New Map & Set methods
  • arr.group()

Installation

npm

npm i @shgysk8zer0/kazoo

And for polyfills

npm i @shgysk8zer0/polyfills

As a git submodule

git submodule add https://github.com/shgysk8zer0/kazoo.git [:path/to/dest]

And for polyfills

git submodule add https://github.com/shgysk8zer0/polyfills.git [:path/to/dest]

Using an import map

Tip: To use in Rollup and load from unpkg, check out @shgysk8zer0/rollup-import.

From unpkg

<script type="importmap">
  {
    "imports": {
      "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo[@:version]/",
      "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills/all.min.js",
      "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills/"
    }
  }
</script>

From node_modules/

Note: This requires a correctly set <base href="/"> to the parent folder.

<script type="importmap">
  {
    "imports": {
      "@shgysk8zer0/kazoo/": "./node_modules/@shgysk8zer0/kazoo/",
      "@shgysk8zer0/polyfills": "./node_modules/@shgysk8zer0/kazoo/all.min.js",
      "@shgysk8zer0/polyfills/": "./node_modules/@shgysk8zer0/kazoo/polyfills/"
    }
  }
</script>

Example

import '@shgysk8zer0/polyfills';
import '@shgysk8zer0/kazoo/harden.js'; // Require `trustedTypes`
import { createElement } from '@shgysk8zer0/kazoo/elements.js';
import { getJSON } from '@shgysk8zer0/kazoo/http.js';
import { html } from '@shgysk8zer0/kazoo/dom.js';
import { createPolicy } from '@shgysk8zer0/kazoo/trust.js';
import { isTrustedScriptOrigin, createSanitizerCallback } from '@shgysk8zer0/kazoo/trust-policies.js';
import { createYouTubeEmbed } from '@shgysk8zer0/kazoo/youtube.js';

const sanitizer = new Sanitizer();
const policy = createPolicy('default', {
	createHTML: createSanitizerCallback(),
	createScript: () => trustedTypes.emptyScript,
	createScriptURL: input => {
		if (isTrustedScriptOrigin(input)) {
			return input;
		} else {
			throw new DOMException(`Untrusted Script URL: ${input}`);
		}
	}
});

document.getElementById('footer').append(
	createElement('span', { text: '© ' }),
	createElement('time', { text: new Date().getFullYear().toString() }),
);

document.getElementById('header')
  .append(createYouTubeEmbed('r-5eu3DpIbc', { width: 560, height: 315 }));

getJSON('./api/bacon.json').then(lines => {
	html('#main', policy.createHTML(lines.map(t => `<p>${t}</p>`).join('')));
});
1.0.5

21 days ago

1.0.4

1 month ago

1.0.2

1 month ago

1.0.3

1 month ago

1.0.1

1 month ago

1.0.0

1 month ago

0.3.4

2 months ago

0.3.3

2 months ago

0.3.2

4 months ago

0.3.1

4 months ago

0.3.0

4 months ago

0.2.10

5 months ago

0.1.0

11 months ago

0.2.1

10 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.2.7

6 months ago

0.2.6

6 months ago

0.2.9

6 months ago

0.2.8

6 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.0.17

11 months ago

0.0.16

12 months ago

0.0.15

12 months ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago