-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
49 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ import { createCSSSheet, css, styleMap } from '@mantou/gem/lib/utils'; | |
|
||
import { theme } from '../lib/theme'; | ||
|
||
const prismjs = 'https://esm.sh/[email protected]'; | ||
|
||
// https://github.com/PrismJS/prism/blob/master/plugins/autoloader/prism-autoloader.js | ||
const langDependencies: Record<string, string | string[]> = { | ||
javascript: 'clike', | ||
|
@@ -358,8 +360,7 @@ export class DuoyunCodeBlockElement extends GemElement { | |
this.effect( | ||
async () => { | ||
if (!this.codeRef.element) return; | ||
const esmHost = 'https://cdn.skypack.dev/[email protected]'; | ||
await import(/* @vite-ignore */ /* webpackIgnore: true */ `${esmHost}?min`); | ||
await import(/* @vite-ignore */ /* webpackIgnore: true */ prismjs); | ||
const { Prism } = window as any; | ||
if (this.codelang && !Prism.languages[this.codelang]) { | ||
const lang = langAliases[this.codelang] || this.codelang; | ||
|
@@ -369,12 +370,12 @@ export class DuoyunCodeBlockElement extends GemElement { | |
langDeps.map((langDep) => { | ||
if (!Prism.languages[langDep]) { | ||
return import( | ||
/* @vite-ignore */ /* webpackIgnore: true */ `${esmHost}/components/prism-${langDep}.min.js` | ||
/* @vite-ignore */ /* webpackIgnore: true */ `${prismjs}/components/prism-${langDep}.min.js` | ||
); | ||
} | ||
}), | ||
); | ||
await import(/* @vite-ignore */ /* webpackIgnore: true */ `${esmHost}/components/prism-${lang}.min.js`); | ||
await import(/* @vite-ignore */ /* webpackIgnore: true */ `${prismjs}/components/prism-${lang}.min.js`); | ||
} catch { | ||
// | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { styleMap } from '@mantou/gem/lib/utils'; | |
|
||
import { theme } from '../helper/theme'; | ||
|
||
const prismjs = 'https://cdn.skypack.dev/[email protected]'; | ||
const prismjs = 'https://esm.sh/[email protected]'; | ||
|
||
let contenteditableValue = 'true'; | ||
(() => { | ||
|
@@ -320,7 +320,7 @@ export class Pre extends GemElement { | |
if (!this.getBoundingClientRect().width) return; | ||
if (this.status === 'hidden') return; | ||
if (!this.codeRef.element) return; | ||
await import(/* @vite-ignore */ /* webpackIgnore: true */ `${prismjs}?min`); | ||
await import(/* @vite-ignore */ /* webpackIgnore: true */ prismjs); | ||
const { Prism } = window as any; | ||
if (this.codelang && !Prism.languages[this.codelang]) { | ||
const lang = langAliases[this.codelang] || this.codelang; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import type { Main } from '../element/elements/main'; | |
import type { GemBookElement } from '../element'; | ||
|
||
const tsMorph = 'https://esm.sh/[email protected]'; | ||
const gemAnalyzer = 'https://jspm.dev/gem-analyzer'; | ||
const gemAnalyzer = 'https://esm.sh/gem-analyzer'; | ||
|
||
type State = { elements?: ElementDetail[]; exports?: ExportDetail[]; error?: any }; | ||
|
||
|
@@ -73,9 +73,10 @@ customElements.whenDefined('gem-book').then(() => { | |
|
||
#parseFile = async (text: string) => { | ||
const { Project } = (await import(/* webpackIgnore: true */ tsMorph)) as typeof import('ts-morph'); | ||
const { getElements, getExports } = GemBookPluginElement.devMode | ||
? await import('gem-analyzer') | ||
: ((await import(/* webpackIgnore: true */ gemAnalyzer)) as typeof import('gem-analyzer')); | ||
const { getElements, getExports } = | ||
config.github === 'https://github.com/mantou132/gem' | ||
? await import('gem-analyzer') | ||
: ((await import(/* webpackIgnore: true */ gemAnalyzer)) as typeof import('gem-analyzer')); | ||
const project = new Project({ useInMemoryFileSystem: true }); | ||
const file = project.createSourceFile(this.src, text); | ||
return { elements: getElements(file), exports: getExports(file) }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import type { GemBookElement } from '../element'; | ||
|
||
const url = 'https://jspm.dev/[email protected]'; | ||
const gitalkUrl = 'https://esm.sh/[email protected]'; | ||
const gitalkCSSUrl = 'https://esm.sh/[email protected]/dist/gitalk.css'; | ||
|
||
customElements.whenDefined('gem-book').then(async () => { | ||
const { GemBookPluginElement } = customElements.get('gem-book') as typeof GemBookElement; | ||
|
@@ -17,7 +18,7 @@ customElements.whenDefined('gem-book').then(async () => { | |
|
||
render() { | ||
return html` | ||
<link rel="stylesheet" href="${url}/dist/gitalk.css" /> | ||
<link rel="stylesheet" href=${gitalkCSSUrl} /> | ||
<div id="comment"></div> | ||
<style> | ||
:host { | ||
|
@@ -70,7 +71,7 @@ customElements.whenDefined('gem-book').then(async () => { | |
const ele = this.shadowRoot?.querySelector('#comment'); | ||
if (!ele) return; | ||
ele.innerHTML = ''; | ||
const { default: Gitalk } = await import(/* webpackIgnore: true */ url); | ||
const { default: Gitalk } = await import(/* webpackIgnore: true */ gitalkUrl); | ||
const [_, owner, repo] = github ? new URL(github).pathname.split('/') : []; | ||
new Gitalk({ | ||
clientID: this.clientID, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ import type { RefObject } from '@mantou/gem'; | |
|
||
import type { GemBookElement } from '../element'; | ||
|
||
const moduleLink = 'https://cdn.skypack.dev/@docsearch/[email protected]'; | ||
const styleLink = 'https://unpkg.com/@docsearch/[email protected]/dist/style.css'; | ||
const moduleLink = 'https://esm.sh/@docsearch/[email protected]'; | ||
const styleLink = 'https://esm.sh/@docsearch/[email protected]/dist/style.css'; | ||
|
||
customElements.whenDefined('gem-book').then(async () => { | ||
const { GemBookPluginElement } = customElements.get('gem-book') as typeof GemBookElement; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters