@shwfed/nuxt 0.1.8 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +6 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +7 -4
- package/dist/runtime/composables/useCheating.d.ts +1 -0
- package/dist/runtime/composables/useCheating.js +33 -0
- package/dist/runtime/plugins/markdown/index.d.ts +7 -0
- package/dist/runtime/plugins/markdown/index.js +25 -0
- package/dist/runtime/plugins/markdown/md.d.ts +9 -0
- package/dist/runtime/plugins/markdown/md.js +5 -0
- package/dist/runtime/types/directive.d.ts +9 -0
- package/package.json +9 -4
package/dist/module.d.mts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
|
-
|
|
4
|
+
clientId: string;
|
|
5
|
+
}
|
|
6
|
+
declare module 'nuxt/schema' {
|
|
7
|
+
interface PublicRuntimeConfig {
|
|
8
|
+
shwfed: ModuleOptions;
|
|
9
|
+
}
|
|
5
10
|
}
|
|
6
11
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
12
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
5
5
|
name: "@shwfed/nuxt",
|
|
6
6
|
configKey: "shwfed"
|
|
7
7
|
},
|
|
8
|
-
// Default configuration options of the Nuxt module
|
|
9
8
|
defaults: {},
|
|
10
|
-
setup(
|
|
9
|
+
setup(options, nuxt) {
|
|
11
10
|
const resolver = createResolver(import.meta.url);
|
|
12
|
-
|
|
11
|
+
nuxt.options.runtimeConfig.public.shwfed = options;
|
|
12
|
+
addPlugin(resolver.resolve("runtime/plugins/cel/index"));
|
|
13
|
+
addPlugin(resolver.resolve("runtime/plugins/markdown/index"));
|
|
14
|
+
addImportsDir(resolver.resolve("runtime/composables"));
|
|
15
|
+
nuxt.options.typescript.tsConfig.include?.push(resolver.resolve("runtime/types/directive.d.ts"));
|
|
13
16
|
}
|
|
14
17
|
});
|
|
15
18
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCheating: () => import("vue").Ref<boolean, boolean>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createGlobalState, onKeyStroke } from "@vueuse/core";
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
export const useCheating = createGlobalState(() => {
|
|
4
|
+
const isCheating = ref(false);
|
|
5
|
+
const keystrokes = ref([]);
|
|
6
|
+
onKeyStroke(true, (e) => {
|
|
7
|
+
keystrokes.value.push(e.code);
|
|
8
|
+
if (keystrokes.value.length > 10) {
|
|
9
|
+
keystrokes.value.shift();
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const cancel = watch(keystrokes, (keystrokes2) => {
|
|
13
|
+
const code = [
|
|
14
|
+
"ArrowUp",
|
|
15
|
+
"ArrowUp",
|
|
16
|
+
"ArrowDown",
|
|
17
|
+
"ArrowDown",
|
|
18
|
+
"ArrowLeft",
|
|
19
|
+
"ArrowRight",
|
|
20
|
+
"ArrowLeft",
|
|
21
|
+
"ArrowRight",
|
|
22
|
+
"KeyB",
|
|
23
|
+
"KeyA"
|
|
24
|
+
];
|
|
25
|
+
if (keystrokes2.every((keystroke, index) => code[index] === keystroke) && keystrokes2.length === code.length) {
|
|
26
|
+
isCheating.value = true;
|
|
27
|
+
cancel();
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
deep: true
|
|
31
|
+
});
|
|
32
|
+
return isCheating;
|
|
33
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
|
2
|
+
import MarkdownIt from "markdown-it";
|
|
3
|
+
import { md } from "./md.js";
|
|
4
|
+
export default defineNuxtPlugin((app) => {
|
|
5
|
+
const engine = new MarkdownIt("commonmark", {
|
|
6
|
+
html: true
|
|
7
|
+
});
|
|
8
|
+
app.vueApp.directive("md", {
|
|
9
|
+
beforeMount(el, v) {
|
|
10
|
+
if (["inline", "inline-flex", "inline-block"].includes(getComputedStyle(el).display)) {
|
|
11
|
+
el.innerHTML = engine.renderInline(v.value);
|
|
12
|
+
} else {
|
|
13
|
+
el.innerHTML = engine.render(v.value);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
beforeUpdate(el, v) {
|
|
17
|
+
el.innerHTML = engine.renderInline(v.value);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
provide: {
|
|
22
|
+
md
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Markdown = string & Record<never, never>;
|
|
2
|
+
/**
|
|
3
|
+
* Create Markdown text (**Not rendering it into HTML**).
|
|
4
|
+
*
|
|
5
|
+
* - Trim the leading and trailing whitespace of the input.
|
|
6
|
+
* - Escape special characters (except backtick as it will break parsing)
|
|
7
|
+
* - Use first line indent as the indent of the rest lines.
|
|
8
|
+
*/
|
|
9
|
+
export declare function md(...args: Parameters<typeof String.raw>): Markdown;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function md(...args) {
|
|
2
|
+
const original = String.raw(...args);
|
|
3
|
+
const indent = (original.startsWith("\n") ? original.slice(1) : original).split("\n", 1)[0]?.match(/^(\s*)/)?.[1]?.length ?? 0;
|
|
4
|
+
return original.trim().replaceAll("\\`", "`").split("\n").map((line) => line.replace(new RegExp(`^${String.raw`\s`.repeat(indent)}`), "")).join("\n");
|
|
5
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shwfed/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"workspaces": [
|
|
28
|
-
"playground"
|
|
28
|
+
"playground/*"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"prepack": "nuxt-module-build build",
|
|
@@ -43,9 +43,13 @@
|
|
|
43
43
|
"@date-fns/tz": "^1.4.1",
|
|
44
44
|
"@marcbachmann/cel-js": "^7.2.1",
|
|
45
45
|
"@nuxt/kit": "^4.3.0",
|
|
46
|
+
"@vueuse/core": "^14.1.0",
|
|
46
47
|
"date-fns": "^4.1.0",
|
|
47
48
|
"defu": "^6.1.4",
|
|
48
|
-
"effect": "^3.19.15"
|
|
49
|
+
"effect": "^3.19.15",
|
|
50
|
+
"markdown-it": "^14.1.0",
|
|
51
|
+
"reka-ui": "^2.7.0",
|
|
52
|
+
"vue": "^3.5.27"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
55
|
"@commitlint/cli": "^20.3.1",
|
|
@@ -53,11 +57,12 @@
|
|
|
53
57
|
"@nuxt/devtools": "^3.1.1",
|
|
54
58
|
"@nuxt/eslint": "1.13.0",
|
|
55
59
|
"@nuxt/eslint-config": "^1.13.0",
|
|
56
|
-
"@nuxt/icon": "2.2.1",
|
|
57
60
|
"@nuxt/module-builder": "^1.0.2",
|
|
58
61
|
"@nuxt/schema": "^4.3.0",
|
|
59
62
|
"@nuxt/test-utils": "^3.23.0",
|
|
63
|
+
"@types/markdown-it": "^14.1.2",
|
|
60
64
|
"@types/node": "latest",
|
|
65
|
+
"@vue/test-utils": "^2.4.6",
|
|
61
66
|
"changelogen": "^0.6.2",
|
|
62
67
|
"eslint": "^9.39.2",
|
|
63
68
|
"husky": "^9.1.7",
|