do11y 0.4.3 → 0.5.0
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/docs/plugins/options.d.ts +10 -12
- package/dist/docs/plugins/options.js +37 -33
- package/dist/docs/plugins/routes.js +4 -5
- package/dist/docs/plugins/sandbox.d.ts +1 -1
- package/dist/docs/plugins/sandbox.js +3 -3
- package/dist/ui/index.js +1 -1
- package/dist/ui/sandbox-iframe.js +1 -1
- package/dist/ui/sandbox.js +1 -1
- package/package.json +1 -1
- package/src/types.d.ts +20 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
-
import type { App
|
|
2
|
+
import type { App } from "vue";
|
|
3
3
|
import type { Router } from "vue-router";
|
|
4
4
|
import type { BundledTheme, ShikiTransformer, StringLiteralUnion, ThemeInput } from "shiki";
|
|
5
5
|
import type { MarkdownPluginOptions } from "./markdown.js";
|
|
@@ -8,18 +8,10 @@ export interface Options extends MarkdownPluginOptions {
|
|
|
8
8
|
* Additional setup for the app.
|
|
9
9
|
*/
|
|
10
10
|
setup?(app: App, router: Router): void | Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* The wrapper component for sandboxes.
|
|
13
|
-
*/
|
|
14
|
-
Sandbox?: () => Promise<Component>;
|
|
15
11
|
/**
|
|
16
12
|
* Additional setup for the sandbox app.
|
|
17
13
|
*/
|
|
18
14
|
setupSandbox?(app: App): void | Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Custom wrapper component for `.vue.sandbox` imports.
|
|
21
|
-
*/
|
|
22
|
-
SandboxIframe?: () => Promise<Component>;
|
|
23
15
|
/**
|
|
24
16
|
* The code highlighter.
|
|
25
17
|
* - Markdown code blocks
|
|
@@ -76,9 +68,15 @@ export interface ResolvedOptions extends Omit<Options, "highlighter"> {
|
|
|
76
68
|
};
|
|
77
69
|
}
|
|
78
70
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
71
|
+
* Adds the ability to import options and setup files.
|
|
72
|
+
*
|
|
73
|
+
* `do11y:options` → `docs/do11y/do11y.ts`
|
|
74
|
+
*
|
|
75
|
+
* `do11y:home` → `docs/do11y/pages/Home.vue`
|
|
76
|
+
* `do11y:page-layout` → `docs/do11y/layout/Page.vue`
|
|
77
|
+
*
|
|
78
|
+
* `do11y:sandbox` → `docs/do11y/pages/Sandbox.vue`
|
|
79
|
+
* `do11y:sandbox-iframe` → `docs/do11y/layout/SandboxIframe.vue`
|
|
82
80
|
*/
|
|
83
81
|
declare const _default: () => Plugin;
|
|
84
82
|
export default _default;
|
|
@@ -2,37 +2,41 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { do11y } from "../files.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Adds the ability to import options and setup files.
|
|
6
|
+
*
|
|
7
|
+
* `do11y:options` → `docs/do11y/do11y.ts`
|
|
8
|
+
*
|
|
9
|
+
* `do11y:home` → `docs/do11y/pages/Home.vue`
|
|
10
|
+
* `do11y:page-layout` → `docs/do11y/layout/Page.vue`
|
|
11
|
+
*
|
|
12
|
+
* `do11y:sandbox` → `docs/do11y/pages/Sandbox.vue`
|
|
13
|
+
* `do11y:sandbox-iframe` → `docs/do11y/layout/SandboxIframe.vue`
|
|
8
14
|
*/
|
|
9
|
-
export default () =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
});
|
|
15
|
+
export default () => {
|
|
16
|
+
const setupFiles = {
|
|
17
|
+
"do11y:options": join(do11y, "do11y.js"),
|
|
18
|
+
"do11y:home": join(do11y, "pages", "Home.vue"),
|
|
19
|
+
"do11y:page-layout": join(do11y, "layout", "Page.vue"),
|
|
20
|
+
"do11y:sandbox": join(do11y, "pages", "Sandbox.vue"),
|
|
21
|
+
"do11y:sandbox-iframe": join(do11y, "layout", "SandboxIframe.vue"),
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
name: "do11y:options",
|
|
25
|
+
async resolveId(id, importer) {
|
|
26
|
+
if (Object.keys(setupFiles).includes(id)) {
|
|
27
|
+
/* prettier-ignore */
|
|
28
|
+
return existsSync(setupFiles[id])
|
|
29
|
+
? this.resolve(setupFiles[id], importer)
|
|
30
|
+
: `\0${id}`;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
async load(id) {
|
|
34
|
+
if (id.startsWith("\0") && Object.keys(setupFiles).includes(id.replace("\0", ""))) {
|
|
35
|
+
return {
|
|
36
|
+
code: "export default undefined",
|
|
37
|
+
moduleType: "js",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -2,8 +2,8 @@ import { join, parse } from "node:path";
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
3
3
|
import { globSync } from "tinyglobby";
|
|
4
4
|
import { root, do11y } from "../files.js";
|
|
5
|
-
import fm from "front-matter";
|
|
6
5
|
import { toParamId } from "./sandbox.js";
|
|
6
|
+
import fm from "front-matter";
|
|
7
7
|
/**
|
|
8
8
|
* Adds the ability to import routes through `do11y:routes`.
|
|
9
9
|
*
|
|
@@ -24,9 +24,10 @@ export default () => {
|
|
|
24
24
|
.map((path) => ({ path, frontmatter: fm(readFileSync(path, "utf-8")).attributes }))
|
|
25
25
|
.filter((file) => typeof file.frontmatter.title === "string" && typeof file.frontmatter.slug === "string");
|
|
26
26
|
/* prettier-ignore */
|
|
27
|
-
|
|
27
|
+
let pages = existsSync(join(do11y, "pages"))
|
|
28
28
|
? readdirSync(join(do11y, "pages")).filter((page) => page !== "Home.vue" && (page.endsWith(".md") || page.endsWith(".vue")))
|
|
29
29
|
: [];
|
|
30
|
+
pages = pages.filter((page) => page !== "Sandbox.vue");
|
|
30
31
|
return {
|
|
31
32
|
name: "do11y:routes",
|
|
32
33
|
resolveId(id) {
|
|
@@ -60,8 +61,6 @@ export default () => {
|
|
|
60
61
|
import Home from 'do11y:home';
|
|
61
62
|
import options from 'do11y:options';
|
|
62
63
|
|
|
63
|
-
import { RouterView } from 'vue-router';
|
|
64
|
-
|
|
65
64
|
const homeRoute = {
|
|
66
65
|
path: "/",
|
|
67
66
|
component: Home,
|
|
@@ -72,7 +71,7 @@ export default () => {
|
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
const customRoutes = (options
|
|
74
|
+
const customRoutes = (options?.routes ?? []).map(page => ({
|
|
76
75
|
...page,
|
|
77
76
|
|
|
78
77
|
meta: {
|
|
@@ -2,7 +2,7 @@ import type { Plugin } from "vite";
|
|
|
2
2
|
export declare const toParamId: (path: string) => string;
|
|
3
3
|
/**
|
|
4
4
|
* Creates a seprate sandbox app, and
|
|
5
|
-
* adds access to sandbox components through `do11y:
|
|
5
|
+
* adds access to sandbox components through `do11y:sandboxes`.
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: () => Plugin;
|
|
8
8
|
export default _default;
|
|
@@ -5,10 +5,10 @@ import { indexHtml } from "../html/plugin.js";
|
|
|
5
5
|
export const toParamId = (path) => parse(path).name.toLowerCase().replace(".sandbox", "").replace(".vue", "");
|
|
6
6
|
/**
|
|
7
7
|
* Creates a seprate sandbox app, and
|
|
8
|
-
* adds access to sandbox components through `do11y:
|
|
8
|
+
* adds access to sandbox components through `do11y:sandboxes`.
|
|
9
9
|
*/
|
|
10
10
|
export default () => {
|
|
11
|
-
const moduleId = "do11y:
|
|
11
|
+
const moduleId = "do11y:sandboxes";
|
|
12
12
|
const resolvedModuleId = "\0" + moduleId;
|
|
13
13
|
const sandboxFiles = globSync(["(docs|src|packages)/**/*.sandbox.vue"], {
|
|
14
14
|
ignore: ["**/node_modules/**", "**/dist/**"],
|
|
@@ -17,7 +17,7 @@ export default () => {
|
|
|
17
17
|
cwd: root,
|
|
18
18
|
});
|
|
19
19
|
return {
|
|
20
|
-
name: "do11y:
|
|
20
|
+
name: "do11y:sandboxes",
|
|
21
21
|
...indexHtml(ui, "sandbox"),
|
|
22
22
|
resolveId(id) {
|
|
23
23
|
if (id === moduleId) {
|
package/dist/ui/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createApp as e,createBlock as t,defineComponent as n,onBeforeMount as r,openBlock as i,resolveComponent as a,unref as o}from"vue";import
|
|
1
|
+
import{createApp as e,createBlock as t,defineComponent as n,onBeforeMount as r,openBlock as i,resolveComponent as a,unref as o}from"vue";import{createRouter as s,createWebHistory as c}from"vue-router";import l from"do11y:routes";import u from"do11y:options";import d from"do11y:page-layout";import f from"do11y:css";var p=n({__name:`Page`,setup(e){return r(async()=>{let e=document.createElement(`style`);e.innerHTML=f,document.head.appendChild(e)}),(e,n)=>{let r=a(`RouterView`);return o(d)?(i(),t(o(d),{key:0})):(i(),t(r,{key:1}))}}});(async()=>{let t=s({history:c(`/`),routes:l,scrollBehavior(e,t,n){if(!e.hash)return;let r=document.querySelector(e.hash);if(!r)return;let i=parseFloat(getComputedStyle(r).scrollMarginTop);return{el:e.hash,top:isNaN(i)?n?.top??0:i}}}),n=e(p);await u?.setup?.(n,t),n.use(t),n.mount(`#app`)})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computed as e,createBlock as t,createElementBlock as n,defineComponent as r,mergeProps as i,
|
|
1
|
+
import{computed as e,createBlock as t,createElementBlock as n,defineComponent as r,mergeProps as i,openBlock as a,unref as o}from"vue";import s from"do11y:sandbox-iframe";var c=[`title`,`src`],l=r({__name:`SandboxIframe`,props:{title:{},id:{},url:{},highlightedSource:{},highlightedStylelessSource:{},highlightedCssSource:{},passedProps:{}},setup(r){let l=r,u=e(()=>`/sandbox?id=${l.id}`);return(e,l)=>o(s)?(a(),t(o(s),i({key:0,title:r.title,id:r.id,url:u.value,"highlighted-source":r.highlightedSource,"highlighted-css-source":r.highlightedCssSource,"highlighted-styleless-source":r.highlightedStylelessSource},r.passedProps),null,16,[`title`,`id`,`url`,`highlighted-source`,`highlighted-css-source`,`highlighted-styleless-source`])):(a(),n(`iframe`,{key:1,title:r.title,src:u.value},null,8,c))}});export{l as default};
|
package/dist/ui/sandbox.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createApp as e,createBlock as t,createCommentVNode as n,defineComponent as r,onBeforeMount as i,openBlock as a,shallowRef as o,unref as s,withCtx as c}from"vue";import
|
|
1
|
+
import{createApp as e,createBlock as t,createCommentVNode as n,defineComponent as r,onBeforeMount as i,openBlock as a,shallowRef as o,unref as s,withCtx as c}from"vue";import{parseQuery as l}from"vue-router";import u from"do11y:sandboxes";import d from"do11y:sandbox";e(r({__name:`Sandbox`,setup(e){let r=l(window.location.search),f=o();return i(async()=>{let{component:e}=u.find(({url:e})=>e===r.id)??{};f.value=await e?.()}),(e,r)=>s(d)?(a(),t(s(d),{key:0},{default:c(()=>[f.value?(a(),t(s(f),{key:0})):n(``,!0)]),_:1})):n(``,!0)}})).mount(`#app`);
|
package/package.json
CHANGED
package/src/types.d.ts
CHANGED
|
@@ -16,11 +16,13 @@ declare module "do11y:routes" {
|
|
|
16
16
|
declare module "do11y:options" {
|
|
17
17
|
import type { Options } from "do11y";
|
|
18
18
|
|
|
19
|
-
const options:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const options:
|
|
20
|
+
| (Omit<Options, "Layout" | "Sandbox" | "SandboxIframe"> & {
|
|
21
|
+
Layout: () => Promise<{ default: Component }>;
|
|
22
|
+
Sandbox?: () => Promise<{ default: Component }>;
|
|
23
|
+
SandboxIframe?: () => Promise<{ default: Component }>;
|
|
24
|
+
})
|
|
25
|
+
| undefined;
|
|
24
26
|
|
|
25
27
|
export default options;
|
|
26
28
|
}
|
|
@@ -37,12 +39,24 @@ declare module "do11y:page-layout" {
|
|
|
37
39
|
export default layout;
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
declare module "do11y:sandbox" {
|
|
43
|
+
import type { Component } from "vue";
|
|
44
|
+
const sandbox: Component | undefined;
|
|
45
|
+
export default sandbox;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module "do11y:sandbox-iframe" {
|
|
49
|
+
import type { Component } from "vue";
|
|
50
|
+
const iframe: Component | undefined;
|
|
51
|
+
export default iframe;
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
declare module "do11y:css" {
|
|
41
55
|
const css: string;
|
|
42
56
|
export default string;
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
declare module "do11y:
|
|
59
|
+
declare module "do11y:sandboxes" {
|
|
46
60
|
import type { Component } from "vue";
|
|
47
61
|
|
|
48
62
|
const sandboxes: {
|