diff --git a/api/_.mjs b/api/_.mjs index 334d08c..8c879ca 100644 --- a/api/_.mjs +++ b/api/_.mjs @@ -15,6 +15,8 @@ export * as fs from './fs.mjs'; /** environment-specific data persistence */ export * as storage from './storage.mjs'; +/** a basic wrapper around notion's unofficial api */ +export * as notion from './notion.mjs'; /** helpers for formatting, validating and parsing values */ export * as fmt from './fmt.mjs'; /** interactions with the enhancer's repository of mods */ diff --git a/api/components/_.mjs b/api/components/_.mjs index e1d98e6..a12c864 100644 --- a/api/components/_.mjs +++ b/api/components/_.mjs @@ -28,9 +28,10 @@ export { feather } from './feather.mjs'; /** * adds a view to the enhancer's side panel - * @param {string} param0.id - a uuid, used to restore it on reload if it was last open - * @param {string} param0.icon - an svg string - * @param {string} param0.title - the name of the view - * @param {Element} param0.$content - an element containing the content of the view + * @param {object} panel- information used to construct and render the panel + * @param {string} panel.id - a uuid, used to restore the last open view on reload + * @param {string} panel.icon - an svg string + * @param {string} panel.title - the name of the view + * @param {Element} panel.$content - an element containing the content of the view */ export { addPanelView } from './panel.mjs'; diff --git a/api/components/panel.mjs b/api/components/panel.mjs index f4c743b..6b9b745 100644 --- a/api/components/panel.mjs +++ b/api/components/panel.mjs @@ -222,10 +222,11 @@ web.loadStylesheet('api/components/panel.css'); /** * adds a view to the enhancer's side panel - * @param {string} param0.id - a uuid, used to restore the last open view on reload - * @param {string} param0.icon - an svg string - * @param {string} param0.title - the name of the view - * @param {Element} param0.$content - an element containing the content of the view + * @param {object} panel- information used to construct and render the panel + * @param {string} panel.id - a uuid, used to restore the last open view on reload + * @param {string} panel.icon - an svg string + * @param {string} panel.title - the name of the view + * @param {Element} panel.$content - an element containing the content of the view */ export const addPanelView = async ({ id, icon, title, $content }) => { const view = { diff --git a/api/fmt.mjs b/api/fmt.mjs index f905c01..1d6204a 100644 --- a/api/fmt.mjs +++ b/api/fmt.mjs @@ -81,6 +81,18 @@ export const slugger = (heading, slugs = new Set()) => { return slug; }; +/** + * generate a reasonably random uuidv4 string. uses crypto implementation if available + * (from https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid) + * @returns {string} a uuidv4 + */ +export const uuidv4 = () => + crypto?.randomUUID + ? crypto.randomUUID() + : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => + (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) + ); + const patterns = { alphanumeric: /^[\w\.-]+$/, uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, diff --git a/api/web.mjs b/api/web.mjs index d7ae5d1..656c447 100644 --- a/api/web.mjs +++ b/api/web.mjs @@ -24,7 +24,7 @@ export const jscolor = JSColor; /** * wait until a page is loaded and ready for modification - * @param {array} [selectors=[]] - wait for the existence of elements that match these css selectors + * @param {array} [selectors] - wait for the existence of elements that match these css selectors * @returns {Promise} a promise that will resolve when the page is ready */ export const whenReady = (selectors = []) => {