mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-07 05:59:02 +00:00
cleanup folder structure, fix storage callback doc
This commit is contained in:
parent
6008623812
commit
b6b997ca23
@ -12,7 +12,7 @@
|
|||||||
* @module notion-enhancer/api/components/corner-action
|
* @module notion-enhancer/api/components/corner-action
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { web } from '../_.mjs';
|
import { web } from '../../index.mjs';
|
||||||
|
|
||||||
web.loadStylesheet('api/components/corner-action.css');
|
web.loadStylesheet('api/components/corner-action.css');
|
||||||
|
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/components/feather
|
* @module notion-enhancer/api/components/feather
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fs, web } from '../_.mjs';
|
import { fs, web } from '../../index.mjs';
|
||||||
|
|
||||||
let _$iconSheet;
|
let _$iconSheet;
|
||||||
|
|
@ -12,7 +12,7 @@
|
|||||||
* @module notion-enhancer/api/components/side-panel
|
* @module notion-enhancer/api/components/side-panel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fmt, web, components, registry } from '../_.mjs';
|
import { fmt, web, components, registry } from '../../index.mjs';
|
||||||
|
|
||||||
web.loadStylesheet('api/components/panel.css');
|
web.loadStylesheet('api/components/panel.css');
|
||||||
|
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/components/tooltip
|
* @module notion-enhancer/api/components/tooltip
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fmt, web } from '../_.mjs';
|
import { fmt, web } from '../../index.mjs';
|
||||||
|
|
||||||
const _$tooltip = web.html`<div id="enhancer--tooltip"></div>`;
|
const _$tooltip = web.html`<div id="enhancer--tooltip"></div>`;
|
||||||
web.loadStylesheet('api/components/tooltip.css');
|
web.loadStylesheet('api/components/tooltip.css');
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/env
|
* @module notion-enhancer/api/env
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as env from '../env/env.mjs';
|
import * as env from '../../env/env.mjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the environment/platform name code is currently being executed in
|
* the environment/platform name code is currently being executed in
|
@ -11,9 +11,10 @@
|
|||||||
* @module notion-enhancer/api/fmt
|
* @module notion-enhancer/api/fmt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { web, fs, components } from './_.mjs';
|
import { web, fs, components } from '../index.mjs';
|
||||||
|
import '../../dep/prism.min.js';
|
||||||
|
import '../../dep/markdown-it.min.js';
|
||||||
|
|
||||||
import '../dep/prism.min.js';
|
|
||||||
/** syntax highlighting using https://prismjs.com/ */
|
/** syntax highlighting using https://prismjs.com/ */
|
||||||
export const prism = Prism;
|
export const prism = Prism;
|
||||||
Prism.manual = true;
|
Prism.manual = true;
|
||||||
@ -24,7 +25,6 @@ Prism.hooks.add('complete', async (event) => {
|
|||||||
.prepend(web.html`${await components.feather('clipboard')}`);
|
.prepend(web.html`${await components.feather('clipboard')}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
import '../dep/markdown-it.min.js';
|
|
||||||
/** markdown -> html using https://github.com/markdown-it/markdown-it/ */
|
/** markdown -> html using https://github.com/markdown-it/markdown-it/ */
|
||||||
export const md = new markdownit({
|
export const md = new markdownit({
|
||||||
linkify: true,
|
linkify: true,
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/fs
|
* @module notion-enhancer/api/fs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as fs from '../env/fs.mjs';
|
import * as fs from '../../env/fs.mjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transform a path relative to the enhancer root directory into an absolute path
|
* transform a path relative to the enhancer root directory into an absolute path
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/notion
|
* @module notion-enhancer/api/notion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { web, fs, fmt } from './_.mjs';
|
import { web, fs, fmt } from '../index.mjs';
|
||||||
|
|
||||||
const standardiseUUID = (uuid) => {
|
const standardiseUUID = (uuid) => {
|
||||||
if (uuid?.length === 32 && !uuid.includes('-')) {
|
if (uuid?.length === 32 && !uuid.includes('-')) {
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { fmt, registry } from './_.mjs';
|
import { fmt, registry } from '../index.mjs';
|
||||||
|
|
||||||
const check = async (
|
const check = async (
|
||||||
mod,
|
mod,
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/registry
|
* @module notion-enhancer/api/registry
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { env, fs, storage } from './_.mjs';
|
import { env, fs, storage } from '../index.mjs';
|
||||||
import { validate } from './registry-validation.mjs';
|
import { validate } from './registry-validation.mjs';
|
||||||
|
|
||||||
/**
|
/**
|
@ -11,7 +11,7 @@
|
|||||||
* @module notion-enhancer/api/storage
|
* @module notion-enhancer/api/storage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as storage from '../env/storage.mjs';
|
import * as storage from '../../env/storage.mjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get persisted data
|
* get persisted data
|
||||||
@ -59,9 +59,7 @@ export const removeChangeListener = storage.removeChangeListener;
|
|||||||
/**
|
/**
|
||||||
* @callback onStorageChangeCallback
|
* @callback onStorageChangeCallback
|
||||||
* @param {object} event
|
* @param {object} event
|
||||||
* @param {string} event.type - 'set' or 'reset'
|
* @param {string} event.path- the path of keys to the changed value
|
||||||
* @param {string} event.namespace- the name of the store, e.g. a mod id
|
|
||||||
* @param {string} [event.key] - the key associated with the changed value
|
|
||||||
* @param {string} [event.new] - the new value being persisted to the store
|
* @param {string} [event.new] - the new value being persisted to the store
|
||||||
* @param {string} [event.old] - the previous value associated with the key
|
* @param {string} [event.old] - the previous value associated with the key
|
||||||
*/
|
*/
|
@ -11,14 +11,14 @@
|
|||||||
* @module notion-enhancer/api/web
|
* @module notion-enhancer/api/web
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fs } from './_.mjs';
|
import { fs } from '../index.mjs';
|
||||||
|
import '../../dep/jscolor.min.js';
|
||||||
|
|
||||||
let _hotkeyEventListeners = [],
|
let _hotkeyEventListeners = [],
|
||||||
_documentObserver,
|
_documentObserver,
|
||||||
_documentObserverListeners = [],
|
_documentObserverListeners = [],
|
||||||
_documentObserverEvents = [];
|
_documentObserverEvents = [];
|
||||||
|
|
||||||
import '../dep/jscolor.min.js';
|
|
||||||
/** color picker with alpha channel using https://jscolor.com/ */
|
/** color picker with alpha channel using https://jscolor.com/ */
|
||||||
export const jscolor = JSColor;
|
export const jscolor = JSColor;
|
||||||
|
|
@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** environment-specific methods and constants */
|
/** environment-specific methods and constants */
|
||||||
env: require('notion-enhancer/api/env.cjs'),
|
env: require('notion-enhancer/api/node/env.cjs'),
|
||||||
/** environment-specific file reading */
|
/** environment-specific file reading */
|
||||||
fs: require('notion-enhancer/api/fs.cjs'),
|
fs: require('notion-enhancer/api/node/fs.cjs'),
|
||||||
/** environment-specific data persistence */
|
/** environment-specific data persistence */
|
||||||
storage: require('notion-enhancer/api/storage.cjs'),
|
storage: require('notion-enhancer/api/node/storage.cjs'),
|
||||||
/** helpers for formatting, validating and parsing values */
|
/** helpers for formatting, validating and parsing values */
|
||||||
fmt: require('notion-enhancer/api/fmt.cjs'),
|
fmt: require('notion-enhancer/api/node/fmt.cjs'),
|
||||||
/** interactions with the enhancer's repository of mods */
|
/** interactions with the enhancer's repository of mods */
|
||||||
registry: require('notion-enhancer/api/registry.cjs'),
|
registry: require('notion-enhancer/api/node/registry.cjs'),
|
||||||
};
|
};
|
@ -9,19 +9,19 @@
|
|||||||
/** @module notion-enhancer/api */
|
/** @module notion-enhancer/api */
|
||||||
|
|
||||||
/** environment-specific methods and constants */
|
/** environment-specific methods and constants */
|
||||||
export * as env from './env.mjs';
|
export * as env from './client/env.mjs';
|
||||||
/** environment-specific file reading */
|
/** environment-specific file reading */
|
||||||
export * as fs from './fs.mjs';
|
export * as fs from './client/fs.mjs';
|
||||||
/** environment-specific data persistence */
|
/** environment-specific data persistence */
|
||||||
export * as storage from './storage.mjs';
|
export * as storage from './client/storage.mjs';
|
||||||
|
|
||||||
/** a basic wrapper around notion's unofficial api */
|
/** a basic wrapper around notion's unofficial api */
|
||||||
export * as notion from './notion.mjs';
|
export * as notion from './client/notion.mjs';
|
||||||
/** helpers for formatting, validating and parsing values */
|
/** helpers for formatting, validating and parsing values */
|
||||||
export * as fmt from './fmt.mjs';
|
export * as fmt from './client/fmt.mjs';
|
||||||
/** interactions with the enhancer's repository of mods */
|
/** interactions with the enhancer's repository of mods */
|
||||||
export * as registry from './registry.mjs';
|
export * as registry from './client/registry.mjs';
|
||||||
/** helpers for manipulation of a webpage */
|
/** helpers for manipulation of a webpage */
|
||||||
export * as web from './web.mjs';
|
export * as web from './client/web.mjs';
|
||||||
/** shared notion-style elements */
|
/** shared notion-style elements */
|
||||||
export * as components from './components/_.mjs';
|
export * as components from './client/components/index.mjs';
|
@ -12,7 +12,7 @@ module.exports = {};
|
|||||||
* @module notion-enhancer/api/env
|
* @module notion-enhancer/api/env
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const env = require('../env/env.cjs');
|
const env = require('notion-enhancer/env/env.cjs');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the environment/platform name code is currently being executed in
|
* the environment/platform name code is currently being executed in
|
@ -131,7 +131,7 @@ module.exports.is = async (value, type, { extension = '' } = {}) => {
|
|||||||
case 'color':
|
case 'color':
|
||||||
return typeof value === 'string' && test(value, patterns[type]) && extension;
|
return typeof value === 'string' && test(value, patterns[type]) && extension;
|
||||||
case 'file': {
|
case 'file': {
|
||||||
const { isFile } = require('notion-enhancer/api/fs.cjs');
|
const { isFile } = require('notion-enhancer/api/node/fs.cjs');
|
||||||
return typeof value === 'string' && value && (await isFile(value)) && extension;
|
return typeof value === 'string' && value && (await isFile(value)) && extension;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ module.exports = {};
|
|||||||
* @module notion-enhancer/api/fs
|
* @module notion-enhancer/api/fs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('../env/fs.cjs');
|
const fs = require('notion-enhancer/env/fs.cjs');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transform a path relative to the enhancer root directory into an absolute path
|
* transform a path relative to the enhancer root directory into an absolute path
|
@ -19,7 +19,7 @@ const check = async (
|
|||||||
optional = false,
|
optional = false,
|
||||||
} = {}
|
} = {}
|
||||||
) => {
|
) => {
|
||||||
const { is } = require('notion-enhancer/api/fmt.cjs');
|
const { is } = require('notion-enhancer/api/node/fmt.cjs');
|
||||||
let test;
|
let test;
|
||||||
for (const type of Array.isArray(types) ? [types] : types.split('|')) {
|
for (const type of Array.isArray(types) ? [types] : types.split('|')) {
|
||||||
if (type === 'file') {
|
if (type === 'file') {
|
||||||
@ -39,7 +39,7 @@ const check = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const validateEnvironments = async (mod) => {
|
const validateEnvironments = async (mod) => {
|
||||||
const { supportedEnvs } = require('notion-enhancer/api/registry.cjs');
|
const { supportedEnvs } = require('notion-enhancer/api/node/registry.cjs');
|
||||||
mod.environments = mod.environments ?? supportedEnvs;
|
mod.environments = mod.environments ?? supportedEnvs;
|
||||||
const isArray = await check(mod, 'environments', mod.environments, 'array');
|
const isArray = await check(mod, 'environments', mod.environments, 'array');
|
||||||
if (!isArray) return false;
|
if (!isArray) return false;
|
||||||
@ -134,7 +134,7 @@ const validateEnvironments = async (mod) => {
|
|||||||
return tests;
|
return tests;
|
||||||
},
|
},
|
||||||
validateOptions = async (mod) => {
|
validateOptions = async (mod) => {
|
||||||
const { supportedEnvs, optionTypes } = require('notion-enhancer/api/registry.cjs'),
|
const { supportedEnvs, optionTypes } = require('notion-enhancer/api/node/registry.cjs'),
|
||||||
isArray = await check(mod, 'options', mod.options, 'array');
|
isArray = await check(mod, 'options', mod.options, 'array');
|
||||||
if (!isArray) return false;
|
if (!isArray) return false;
|
||||||
const tests = [];
|
const tests = [];
|
@ -41,7 +41,7 @@ module.exports.optionTypes = ['toggle', 'select', 'text', 'number', 'color', 'fi
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
module.exports.profileName = async () => {
|
module.exports.profileName = async () => {
|
||||||
const storage = require('notion-enhancer/api/storage.cjs');
|
const storage = require('notion-enhancer/api/node/storage.cjs');
|
||||||
return storage.get(['currentprofile'], 'default');
|
return storage.get(['currentprofile'], 'default');
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ module.exports.profileName = async () => {
|
|||||||
* @returns {object} the get/set functions for the profile's storage
|
* @returns {object} the get/set functions for the profile's storage
|
||||||
*/
|
*/
|
||||||
module.exports.profileDB = async () => {
|
module.exports.profileDB = async () => {
|
||||||
const storage = require('notion-enhancer/api/storage.cjs');
|
const storage = require('notion-enhancer/api/node/storage.cjs');
|
||||||
return storage.db(['profiles', await module.exports.profileName()]);
|
return storage.db(['profiles', await module.exports.profileName()]);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,8 +63,8 @@ let _list,
|
|||||||
*/
|
*/
|
||||||
module.exports.list = async (filter = (mod) => true) => {
|
module.exports.list = async (filter = (mod) => true) => {
|
||||||
if (!_list) {
|
if (!_list) {
|
||||||
const { validate } = require('notion-enhancer/api/registry-validation.cjs'),
|
const { validate } = require('notion-enhancer/api/node/registry-validation.cjs'),
|
||||||
{ getJSON } = require('notion-enhancer/api/fs.cjs');
|
{ getJSON } = require('notion-enhancer/api/node/fs.cjs');
|
||||||
_list = new Promise(async (res, rej) => {
|
_list = new Promise(async (res, rej) => {
|
||||||
const passed = [];
|
const passed = [];
|
||||||
for (const dir of await getJSON('repo/registry.json')) {
|
for (const dir of await getJSON('repo/registry.json')) {
|
||||||
@ -112,7 +112,7 @@ module.exports.get = async (id) => {
|
|||||||
* @returns {boolean} whether or not the mod is enabled
|
* @returns {boolean} whether or not the mod is enabled
|
||||||
*/
|
*/
|
||||||
module.exports.enabled = async (id) => {
|
module.exports.enabled = async (id) => {
|
||||||
const env = require('notion-enhancer/api/env.cjs'),
|
const env = require('notion-enhancer/api/node/env.cjs'),
|
||||||
mod = await module.exports.get(id);
|
mod = await module.exports.get(id);
|
||||||
if (!mod.environments.includes(env.name)) return false;
|
if (!mod.environments.includes(env.name)) return false;
|
||||||
if (module.exports.core.includes(id)) return true;
|
if (module.exports.core.includes(id)) return true;
|
||||||
@ -149,7 +149,7 @@ module.exports.optionDefault = async (id, key) => {
|
|||||||
* @returns {object} an object with the wrapped get/set functions
|
* @returns {object} an object with the wrapped get/set functions
|
||||||
*/
|
*/
|
||||||
module.exports.db = async (id) => {
|
module.exports.db = async (id) => {
|
||||||
const storage = require('notion-enhancer/api/storage.cjs'),
|
const storage = require('notion-enhancer/api/node/storage.cjs'),
|
||||||
db = await module.exports.profileDB();
|
db = await module.exports.profileDB();
|
||||||
return storage.db(
|
return storage.db(
|
||||||
[id],
|
[id],
|
@ -12,7 +12,7 @@ module.exports = {};
|
|||||||
* @module notion-enhancer/api/storage
|
* @module notion-enhancer/api/storage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const storage = require('../env/storage.cjs');
|
const storage = require('notion-enhancer/env/storage.cjs');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get persisted data
|
* get persisted data
|
||||||
@ -60,9 +60,7 @@ module.exports.removeChangeListener = storage.removeChangeListener;
|
|||||||
/**
|
/**
|
||||||
* @callback onStorageChangeCallback
|
* @callback onStorageChangeCallback
|
||||||
* @param {object} event
|
* @param {object} event
|
||||||
* @param {string} event.type - 'set' or 'reset'
|
* @param {string} event.path- the path of keys to the changed value
|
||||||
* @param {string} event.namespace- the name of the store, e.g. a mod id
|
|
||||||
* @param {string} [event.key] - the key associated with the changed value
|
|
||||||
* @param {string} [event.new] - the new value being persisted to the store
|
* @param {string} [event.new] - the new value being persisted to the store
|
||||||
* @param {string} [event.old] - the previous value associated with the key
|
* @param {string} [event.old] - the previous value associated with the key
|
||||||
*/
|
*/
|
Loading…
Reference in New Issue
Block a user