mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +00:00
link submodules
This commit is contained in:
parent
affa314f08
commit
da2be9d7c9
22
.github/ISSUE_TEMPLATE/bug-report.md
vendored
22
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@ -1,22 +0,0 @@
|
||||
---
|
||||
name: bug report
|
||||
about: experienced any broken/glitchy enhancer behaviour?
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
FILL OUT THIS TEMPLATE, REMOVING/REPLACING ALL NON-BOLD TEXT WITH YOUR OWN INFORMATION.
|
||||
BE AS CLEAR AND CONCISE AS POSSIBLE.
|
||||
|
||||
**describe the bug**
|
||||
what is the bug - what happens?
|
||||
|
||||
**expected behaviour**
|
||||
why is this a bug - what should be happening?
|
||||
|
||||
**screenshots**
|
||||
if applicable, add screenshots of your problem.
|
||||
|
||||
**platform**
|
||||
what OS are you using? e.g. windows 7, windows 10, WSL, ubuntu, arch linux, macOS
|
45
.github/ISSUE_TEMPLATE/feature-proposal.md
vendored
45
.github/ISSUE_TEMPLATE/feature-proposal.md
vendored
@ -1,45 +0,0 @@
|
||||
---
|
||||
name: feature proposal
|
||||
about: got an idea/request/suggestion for a new feature/module?
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
FILL OUT THIS TEMPLATE, REMOVING/REPLACING ALL NON-BOLD TEXT WITH YOUR OWN INFORMATION.
|
||||
BE AS CLEAR AND CONCISE AS POSSIBLE.
|
||||
|
||||
ONCE ALL INFORMATION HERE HAS BEEN FILLED IN, THE MODULE WILL BE REVIEWED & DISCUSSED
|
||||
BY OTHER CONTRIBUTORS AND BY THE COMMUNITY. IF IT IS APPROVED AS SOMETHING USEFUL/BENEFICIAL,
|
||||
THEN IT IS GUARANTEED TO BE ADDED TO THE ENHANCER.
|
||||
|
||||
IF YOU WOULD LIKE TO CONTRIBUTE AND CODE THIS YOURSELF, THAT'D BE AWESOME! JUST OPEN A
|
||||
PULL REQUEST WHEN YOU'RE READY. IF PROGRAMMING ISN'T YOUR THING, ANOTHER DEV WILL COME
|
||||
ALONG AND PICK THE IDEA UP.
|
||||
|
||||
ONCE SOMEONE STARTS WORK ON THIS, THE ISSUE WILL BE ASSIGNED TO THEIR GITHUB ACCOUNT
|
||||
SO MULTIPLE PEOPLE DON'T ALL WORK ON THE SAME THING: IF YOU PLAN ON MAKING THIS, SAY SO!
|
||||
|
||||
**problem**
|
||||
|
||||
why is this feature necessary? how will it help? what existing shortcomings does it address?
|
||||
|
||||
**solution**
|
||||
|
||||
how will this feature appear/act?
|
||||
|
||||
how could this be technically implemented using the available
|
||||
capabilities of the enhancer and notion?
|
||||
|
||||
**cons**
|
||||
|
||||
what are the potential costs or dangers of this feature, or things that may go
|
||||
outside of the enhancer's scope? e.g. bad performance, security issues, or
|
||||
modifying the data notion stores.
|
||||
|
||||
**alternatives**
|
||||
|
||||
would a different feature remove the need for this?
|
||||
|
||||
does this need to be implemented by the enhancer? could an external service work better?
|
||||
e.g. playing background music via noisli or youtube.
|
26
.github/workflows/potential-duplicates.yml
vendored
26
.github/workflows/potential-duplicates.yml
vendored
@ -1,26 +0,0 @@
|
||||
name: potential duplicates
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: bubkoo/potential-duplicates@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Label to set, when potential duplicates are detected.
|
||||
label: potential-duplicate
|
||||
# Get issues with state to compare. Supported state: 'all', 'closed', 'open'.
|
||||
state: all
|
||||
# If similarity is higher than this threshold([0,1]), issue will be marked as duplicate.
|
||||
threshold: 0.6
|
||||
# Reactions to be add to comment when potential duplicates are detected.
|
||||
# Available reactions: "-1", "+1", "confused", "laugh", "heart", "hooray", "rocket", "eyes"
|
||||
reactions: 'confused'
|
||||
# Comment to post when potential duplicates are detected.
|
||||
comment: >
|
||||
potential duplicates:
|
||||
{{#issues}}
|
||||
- [#{{ number }}] {{ title }} ({{ accuracy }}%)
|
||||
{{/issues}}
|
20
.github/workflows/submodules.yml
vendored
Normal file
20
.github/workflows/submodules.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name: 'update submodules'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: 'update submodules'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- name: pull updates
|
||||
run: |
|
||||
git pull --recurse-submodules
|
||||
git submodule update --remote --recursive
|
||||
- name: commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
16
.gitmodules
vendored
Normal file
16
.gitmodules
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
[submodule "api"]
|
||||
path = insert/api
|
||||
url = git@github.com:notion-enhancer/api.git
|
||||
branch = dev
|
||||
[submodule "repo"]
|
||||
path = insert/repo
|
||||
url = git@github.com:notion-enhancer/repo.git
|
||||
branch = dev
|
||||
[submodule "media"]
|
||||
path = insert/media
|
||||
url = git@github.com:notion-enhancer/media.git
|
||||
branch = main
|
||||
[submodule "dep"]
|
||||
path = insert/dep
|
||||
url = git@github.com:notion-enhancer/dep.git
|
||||
branch = main
|
1
insert/api
Submodule
1
insert/api
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit aff6f2dafa9d2666306f4e088da86528aeee0cd8
|
1
insert/dep
Submodule
1
insert/dep
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 9a3893fbd5af4d02b89ea4c6f2b35971a3a91408
|
44
insert/env/env.mjs
vendored
Normal file
44
insert/env/env.mjs
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* notion-enhancer core: api
|
||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (https://notion-enhancer.github.io/) under the MIT license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* environment-specific methods and constants
|
||||
* @module notion-enhancer/api/env
|
||||
*/
|
||||
|
||||
/**
|
||||
* the environment/platform name code is currently being executed in
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
export const name = process.platform;
|
||||
|
||||
/**
|
||||
* the current version of the enhancer
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
export const version = chrome.runtime.getManifest().version;
|
||||
|
||||
/**
|
||||
* open the enhancer's menu
|
||||
* @type {function}
|
||||
*/
|
||||
export const focusMenu = () => chrome.runtime.sendMessage({ action: 'focusMenu' });
|
||||
|
||||
/**
|
||||
* focus an active notion tab
|
||||
* @type {function}
|
||||
*/
|
||||
export const focusNotion = () => chrome.runtime.sendMessage({ action: 'focusNotion' });
|
||||
|
||||
/**
|
||||
* reload all notion and enhancer menu tabs to apply changes
|
||||
* @type {function}
|
||||
*/
|
||||
export const reload = () => chrome.runtime.sendMessage({ action: 'reload' });
|
51
insert/env/fs.mjs
vendored
Normal file
51
insert/env/fs.mjs
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* notion-enhancer core: api
|
||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (https://notion-enhancer.github.io/) under the MIT license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* environment-specific filesystem reading
|
||||
* @module notion-enhancer/api/fs
|
||||
*/
|
||||
|
||||
/**
|
||||
* transform a path relative to the enhancer root directory into an absolute path
|
||||
* @param {string} path - a url or within-the-enhancer filepath
|
||||
* @returns {string} an absolute filepath
|
||||
*/
|
||||
export const localPath = chrome.runtime.getURL;
|
||||
|
||||
/**
|
||||
* fetch and parse a json file's contents
|
||||
* @param {string} path - a url or within-the-enhancer filepath
|
||||
* @param {object} [opts] - the second argument of a fetch() request
|
||||
* @returns {object} the json value of the requested file as a js object
|
||||
*/
|
||||
export const getJSON = (path, opts = {}) =>
|
||||
fetch(path.startsWith('http') ? path : localPath(path), opts).then((res) => res.json());
|
||||
|
||||
/**
|
||||
* fetch a text file's contents
|
||||
* @param {string} path - a url or within-the-enhancer filepath
|
||||
* @param {object} [opts] - the second argument of a fetch() request
|
||||
* @returns {string} the text content of the requested file
|
||||
*/
|
||||
export const getText = (path, opts = {}) =>
|
||||
fetch(path.startsWith('http') ? path : localPath(path), opts).then((res) => res.text());
|
||||
|
||||
/**
|
||||
* check if a file exists
|
||||
* @param {string} path - a url or within-the-enhancer filepath
|
||||
* @returns {boolean} whether or not the file exists
|
||||
*/
|
||||
export const isFile = async (path) => {
|
||||
try {
|
||||
await fetch(path.startsWith('http') ? path : localPath(path));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
121
insert/env/storage.mjs
vendored
Normal file
121
insert/env/storage.mjs
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* notion-enhancer core: api
|
||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (https://notion-enhancer.github.io/) under the MIT license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* environment-specific data persistence
|
||||
* @module notion-enhancer/api/storage
|
||||
*/
|
||||
|
||||
const _queue = [],
|
||||
_onChangeListeners = [];
|
||||
|
||||
/**
|
||||
* get persisted data
|
||||
* @param {array<string>} path - the path of keys to the value being fetched
|
||||
* @param {*} [fallback] - a default value if the path is not matched
|
||||
* @returns {Promise} value ?? fallback
|
||||
*/
|
||||
export const get = (path, fallback = undefined) => {
|
||||
if (!path.length) return fallback;
|
||||
return new Promise((res, rej) =>
|
||||
chrome.storage.local.get(async (values) => {
|
||||
let value = values;
|
||||
while (path.length) {
|
||||
if (value === undefined) {
|
||||
value = fallback;
|
||||
break;
|
||||
}
|
||||
value = value[path.shift()];
|
||||
}
|
||||
res(value ?? fallback);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* persist data
|
||||
* @param {array<string>} path - the path of keys to the value being set
|
||||
* @param {*} value - the data to save
|
||||
* @returns {Promise} resolves when data has been saved
|
||||
*/
|
||||
export const set = (path, value) => {
|
||||
if (!path.length) return undefined;
|
||||
const precursor = _queue[_queue.length - 1] || undefined,
|
||||
interaction = new Promise(async (res, rej) => {
|
||||
if (precursor !== undefined) {
|
||||
await precursor;
|
||||
_queue.shift();
|
||||
}
|
||||
const pathClone = [...path],
|
||||
namespace = path[0];
|
||||
chrome.storage.local.get(async (values) => {
|
||||
let pointer = values,
|
||||
old;
|
||||
while (path.length) {
|
||||
const key = path.shift();
|
||||
if (!path.length) {
|
||||
old = pointer[key];
|
||||
pointer[key] = value;
|
||||
break;
|
||||
}
|
||||
pointer[key] = pointer[key] ?? {};
|
||||
pointer = pointer[key];
|
||||
}
|
||||
chrome.storage.local.set({ [namespace]: values[namespace] }, () => {
|
||||
_onChangeListeners.forEach((listener) =>
|
||||
listener({ type: 'set', path: pathClone, new: value, old })
|
||||
);
|
||||
res(value);
|
||||
});
|
||||
});
|
||||
});
|
||||
_queue.push(interaction);
|
||||
return interaction;
|
||||
};
|
||||
|
||||
/**
|
||||
* create a wrapper for accessing a partition of the storage
|
||||
* @param {array<string>} namespace - the path of keys to prefix all storage requests with
|
||||
* @param {function} [get] - the storage get function to be wrapped
|
||||
* @param {function} [set] - the storage set function to be wrapped
|
||||
* @returns {object} an object with the wrapped get/set functions
|
||||
*/
|
||||
export const db = (namespace, getFunc = get, setFunc = set) => {
|
||||
if (typeof namespace === 'string') namespace = [namespace];
|
||||
return {
|
||||
get: (path = [], fallback = undefined) => getFunc([...namespace, ...path], fallback),
|
||||
set: (path, value) => setFunc([...namespace, ...path], value),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* add an event listener for changes in storage
|
||||
* @param {onStorageChangeCallback} callback - called whenever a change in
|
||||
* storage is initiated from the current process
|
||||
*/
|
||||
export const addChangeListener = (callback) => {
|
||||
_onChangeListeners.push(callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* remove a listener added with storage.addChangeListener
|
||||
* @param {onStorageChangeCallback} callback
|
||||
*/
|
||||
export const removeChangeListener = (callback) => {
|
||||
_onChangeListeners = _onChangeListeners.filter((listener) => listener !== callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* @callback onStorageChangeCallback
|
||||
* @param {object} event
|
||||
* @param {string} event.type - 'set' or 'reset'
|
||||
* @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.old] - the previous value associated with the key
|
||||
*/
|
1
insert/media
Submodule
1
insert/media
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 0e56fb9242a00e41132b9ad30adef9ae910a2159
|
1
insert/repo
Submodule
1
insert/repo
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 4c589ec5915cccfb004098caf08e8934eb73ade7
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* notion-enhancer
|
||||
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (https://dragonwocky.me/notion-enhancer) under the MIT license
|
||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (https://notion-enhancer.github.io/) under the MIT license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
Loading…
Reference in New Issue
Block a user