Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo & development updates, Docs rewrite, CI improvements, and more #711

Merged
merged 42 commits into from
Jul 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
982198d
test: migrate to vitest
favna Jan 23, 2023
4610ff3
chore: update to yarn v3
favna Jan 23, 2023
7e23551
chore: fully update to husky v8
favna Jan 23, 2023
789beab
chore: update gitignore for yarn v3
favna Jan 23, 2023
23758c3
chore: regenerate dist for package updates
favna Jan 23, 2023
834b14a
chore: add missing pinst dev-dep
favna Jan 23, 2023
bf65a19
chore: cleanup and bump more dev dependencies
favna Jan 23, 2023
e10cd4b
style: run prettier on whole repo
favna Jan 23, 2023
1e94fda
chore: change issue templates to yaml format
favna Jan 23, 2023
00621e9
chore: add prettierignore file
favna Jan 23, 2023
36e8b9f
chore: fix emojis in issue templates
favna Jan 23, 2023
a52bb57
chore: try to fix github issue templates
favna Jan 23, 2023
7899aee
chore: try to fix github issue templates
favna Jan 23, 2023
e1af448
ci: update github workflows
favna Jan 23, 2023
f625348
chore: switch from yarn to npm
favna Jan 23, 2023
ae5339e
chore: update to vuepress 2
favna Jan 24, 2023
bd7555c
fix: fixed config, packages, and twitter social button
favna Jan 26, 2023
29b2599
fix: fixed navbar
favna Jan 26, 2023
99c4c06
style: prettier formatting
favna Jan 26, 2023
6b7fbc1
style: fix palette
favna Jan 26, 2023
a3f63fd
chore: cleanup client config
favna Jan 26, 2023
6e2a592
fix: fixed version display and active search plugin
favna Jan 26, 2023
e8033af
chore: add missing dep for plugin-search
favna Jan 26, 2023
9b5421a
feat: finish all but state handling of live demo
favna Jan 27, 2023
c47f3d4
feat: improve fuse keys
favna Jan 27, 2023
fe0d33e
feat: properly configure monaco editors
favna Jan 27, 2023
46c561c
feat: implementing reacting to option changes
favna Jan 27, 2023
1d6670c
chore: update dev deps
favna Jan 27, 2023
67a10cf
fix: re-implement sidebar advertisements
favna Jan 27, 2023
5969ca7
fix: build fixes
favna Jan 27, 2023
3ae8299
fix: vite SSR build fixes
favna Jan 27, 2023
0f9f89e
refactor: cleanup vue 2 style code
favna Jan 27, 2023
b49b2ff
refactor: fixup job listing page, vue3 style
favna Jan 27, 2023
ef99f56
fix: support -> donate for clarity of what it is
favna Jan 27, 2023
ad3e9ac
refactor: cleanup unused components
favna Jan 27, 2023
42cb6ab
refactor: enable setup script for adunit
favna Jan 27, 2023
bdf98c8
refactor: rewrite bsa to vue3 style
favna Jan 27, 2023
77282b5
style: prettier formatting
favna Jan 27, 2023
ca0cbbb
fix: fixed browserconfig xml file
favna Jan 27, 2023
bc155a3
fix: add favicon on public root
favna Jan 27, 2023
0dc5e68
chore: regenerate lock file
favna Jan 27, 2023
08048e5
style: add EOF for npmrc
favna Jan 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: implementing reacting to option changes
  • Loading branch information
favna committed Jan 27, 2023
commit 46c561c05c97abd05f7ab7de7e78b03ede8d07da
49 changes: 35 additions & 14 deletions docs/.vuepress/components/Demo/Demo.vue
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
id="main-monaco-editor"
file-name="main.js"
file-description="entry module"
@update:modelValue="updateMainJsData"
></MonacoEditor>
</section>

@@ -47,6 +48,7 @@

<script setup lang="ts">
import { Stopwatch } from '@sapphire/stopwatch'
import {isNullish, isObject, tryParseJSON} from '@sapphire/utilities'
import { reactive } from 'vue'
import type FuseTypes from '../../../../dist/fuse'
import Fuse from '../../../../dist/fuse.esm.js'
@@ -59,7 +61,7 @@ interface State {
mainJsData: string
resultsData: string
count: number | null
searchTime: number | null
searchTime: string | null
fuseSearchOptions: FuseTypes.IFuseOptions<never>
}

@@ -76,14 +78,13 @@ const defaultFuseSearchOptions: FuseTypes.IFuseOptions<never> = {
useExtendedSearch: false,
ignoreLocation: false,
ignoreFieldNorm: false,
fieldNormWeight: 1,
keys: ['title', 'author.firstName']
fieldNormWeight: 1
}

let codify = (
function codify(
searchPattern: string,
fuseSearchOptions: FuseTypes.IFuseOptions<never> = defaultFuseSearchOptions
): string => {
): string {
return `
const Fuse = require('fuse.js');

@@ -115,10 +116,29 @@ const state = reactive<State>({
fuseSearchOptions: defaultFuseSearchOptions
})

const isNullish = <T>(
value: null | undefined | T
): value is null | undefined => {
return value === null || value === undefined
function removeComments(str: string) {
let lines = str.split('\n')
lines = lines.filter((line) => !line.startsWith('//'))
return lines.join('\n')
}

function updateMainJsData(newValue: string) {
const newFuseOptionsString = removeComments(
newValue
.replace(/const Fuse = require\('fuse\.js'\);\n\n/, '')
.replace(/const fuse = new Fuse\(list, fuseOptions\);\n\n/, '')
.replace(/\/\/ Change the pattern\n/, '')
.replace(/const searchPattern = ".+"\n\n/, '')
.replace(/return fuse\.search\(searchPattern\)/, '')
.replace(/\n\n/, '')
.replace(/\t/g, '')
.replaceAll(';', '')
.replace(/const fuseOptions = /, '')
).replaceAll(/([a-zA-Z]+):/g, '"$1":')

const newFuseOptions = tryParseJSON(newFuseOptionsString)

doFuseSearch(isObject(newFuseOptions) ? newFuseOptions : undefined)
}

function onSearchPatternKeyUp() {
@@ -127,21 +147,22 @@ function onSearchPatternKeyUp() {
doFuseSearch()
}

function doFuseSearch() {
function doFuseSearch(fuseSearchOptions = state.fuseSearchOptions) {
try {
const fuseOptions: FuseTypes.IFuseOptions<never> = {
...state.fuseSearchOptions,
keys: ['title', 'author.firstName']
keys: ['title', 'author.firstName'],
...fuseSearchOptions
}

const fuse = new Fuse(JSON.parse(state.jsonData), state.fuseSearchOptions)
const fuse = new Fuse(JSON.parse(state.jsonData), fuseOptions)

const stopwatch = new Stopwatch()

const result = fuse.search(state.searchPattern)
const searchTime = stopwatch.stop().duration

state.count = result.length
state.searchTime = Math.floor(stopwatch.stop().duration)
state.searchTime = searchTime.toFixed(1)
state.resultsData = JSON.stringify(result, null, 2)
} catch {
state.count = null
2 changes: 1 addition & 1 deletion docs/.vuepress/components/Demo/MonacoEditor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import * as Monaco from 'monaco-editor'
import { computed, defineProps, onMounted, ref, watch } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import loader from '@monaco-editor/loader';

interface Emits {