UNPKG

@eik/node-client

Version:

Utilities for working with assets and import maps on an Eik server

48 lines (47 loc) 1.19 kB
/** * @typedef {object} AssetOptions * @property {string} [value=""] */ /** * Holds attributes for use when linking to assets hosted on Eik. * * @example * ``` * // JS and <script> * const script = eik.file("/app.js"); * const html = `<script * src="${script.value}" * ${script.integrity ? `integrity="${script.integrity}"` : ""} * type="module"></script>`; * ``` * @example * ``` * // CSS and <link> * const styles = eik.file("/styles.css"); * const html = `<link * href="${styles.value}" * ${styles.integrity ? `integrity="${styles.integrity}"` : ""} * rel="stylesheet" />`; * ``` */ export class Asset { /** * @param {AssetOptions} options */ constructor({ value }?: AssetOptions); /** * Value for use in [subresource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#examples). * Not calculated if `development` is `true`. * * @type {string | undefined} */ integrity: string | undefined; /** * URL to the file for use in `<script>` or `<link>`. * @type {string} */ value: string; } export type AssetOptions = { value?: string; };