markstream-svelte 0.0.6 → 0.1.0-beta.3
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/README.md +14 -17
- package/dist/components/CodeBlockNode.svelte +235 -266
- package/dist/components/CodeBlockNode.svelte.d.ts +6 -5
- package/dist/components/NodeOutlet.svelte +13 -2
- package/dist/components/NodeRenderer.svelte +16 -5
- package/dist/components/PreCodeNode.svelte +1 -1
- package/dist/components/shared/node-helpers.d.ts +14 -13
- package/dist/components/shared/node-helpers.js +1 -1
- package/dist/enhanceRenderedHtml.d.ts +5 -2
- package/dist/enhanceRenderedHtml.js +134 -40
- package/dist/index.css +10 -69
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -3
- package/dist/index.px.css +10 -69
- package/dist/index.tailwind.css +10 -69
- package/dist/optional/{monaco.d.ts → streamDiffs.d.ts} +5 -6
- package/dist/optional/streamDiffs.js +66 -0
- package/dist/types/codeBlock.d.ts +66 -0
- package/dist/utils/languageIcon.d.ts +1 -1
- package/dist/utils/languageIcon.js +7 -5
- package/package.json +16 -19
- package/dist/components/MarkdownCodeBlockNode.svelte +0 -15
- package/dist/components/MarkdownCodeBlockNode.svelte.d.ts +0 -8
- package/dist/optional/monaco.js +0 -84
- package/dist/types/monaco.d.ts +0 -65
- /package/dist/types/{monaco.js → codeBlock.js} +0 -0
package/dist/optional/monaco.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
let monacoModule = null;
|
|
2
|
-
let importAttempted = false;
|
|
3
|
-
let pendingImport = null;
|
|
4
|
-
let workersPreloaded = false;
|
|
5
|
-
let codeBlockRuntimeReady = false;
|
|
6
|
-
export function isCodeBlockRuntimeReady() {
|
|
7
|
-
return codeBlockRuntimeReady;
|
|
8
|
-
}
|
|
9
|
-
export function resetCodeBlockRuntimeReadyForTest() {
|
|
10
|
-
codeBlockRuntimeReady = false;
|
|
11
|
-
}
|
|
12
|
-
export async function preloadCodeBlockRuntime() {
|
|
13
|
-
const runtime = await getUseMonaco();
|
|
14
|
-
return !!runtime;
|
|
15
|
-
}
|
|
16
|
-
async function preloadWorkers(mod) {
|
|
17
|
-
if (workersPreloaded)
|
|
18
|
-
return;
|
|
19
|
-
workersPreloaded = true;
|
|
20
|
-
const existingEnv = globalThis === null || globalThis === void 0 ? void 0 : globalThis.MonacoEnvironment;
|
|
21
|
-
if (existingEnv && (typeof existingEnv.getWorker === 'function' || typeof existingEnv.getWorkerUrl === 'function'))
|
|
22
|
-
return;
|
|
23
|
-
if (typeof (mod === null || mod === void 0 ? void 0 : mod.preloadMonacoWorkers) === 'function')
|
|
24
|
-
await mod.preloadMonacoWorkers();
|
|
25
|
-
}
|
|
26
|
-
async function warmupShikiTokenizer(mod) {
|
|
27
|
-
const getOrCreateHighlighter = mod === null || mod === void 0 ? void 0 : mod.getOrCreateHighlighter;
|
|
28
|
-
if (typeof getOrCreateHighlighter !== 'function')
|
|
29
|
-
return true;
|
|
30
|
-
try {
|
|
31
|
-
const highlighter = await getOrCreateHighlighter(['vitesse-dark', 'vitesse-light'], ['plaintext', 'text', 'javascript']);
|
|
32
|
-
if (highlighter && typeof highlighter.codeToTokens === 'function') {
|
|
33
|
-
highlighter.codeToTokens('const a = 1', { lang: 'javascript', theme: 'vitesse-dark' });
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.warn('[markstream-svelte] Failed to warm up stream-monaco tokenizer.', error);
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export async function getUseMonaco() {
|
|
43
|
-
if (monacoModule)
|
|
44
|
-
return monacoModule;
|
|
45
|
-
if (pendingImport)
|
|
46
|
-
return await pendingImport;
|
|
47
|
-
if (importAttempted)
|
|
48
|
-
return null;
|
|
49
|
-
pendingImport = (async () => {
|
|
50
|
-
var _a;
|
|
51
|
-
// Prefer `stream-diffs`: smaller runtime without the heavy
|
|
52
|
-
// `monaco-editor` dependency. `stream-monaco` remains supported as a
|
|
53
|
-
// fallback for consumers who install it.
|
|
54
|
-
const candidates = [
|
|
55
|
-
async () => (await import('stream-diffs')),
|
|
56
|
-
async () => (await import('stream-monaco')),
|
|
57
|
-
];
|
|
58
|
-
for (const load of candidates) {
|
|
59
|
-
try {
|
|
60
|
-
const candidate = await load();
|
|
61
|
-
const resolved = (_a = candidate === null || candidate === void 0 ? void 0 : candidate.default) !== null && _a !== void 0 ? _a : candidate;
|
|
62
|
-
if (typeof (resolved === null || resolved === void 0 ? void 0 : resolved.useMonaco) !== 'function')
|
|
63
|
-
continue;
|
|
64
|
-
monacoModule = resolved;
|
|
65
|
-
await preloadWorkers(monacoModule);
|
|
66
|
-
codeBlockRuntimeReady = true;
|
|
67
|
-
if (typeof (monacoModule === null || monacoModule === void 0 ? void 0 : monacoModule.getOrCreateHighlighter) === 'function')
|
|
68
|
-
void warmupShikiTokenizer(monacoModule);
|
|
69
|
-
return monacoModule;
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
// Try the next candidate runtime.
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
importAttempted = true;
|
|
76
|
-
return null;
|
|
77
|
-
})();
|
|
78
|
-
try {
|
|
79
|
-
return await pendingImport;
|
|
80
|
-
}
|
|
81
|
-
finally {
|
|
82
|
-
pendingImport = null;
|
|
83
|
-
}
|
|
84
|
-
}
|
package/dist/types/monaco.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export interface CodeBlockMonacoThemeObject {
|
|
2
|
-
name: string;
|
|
3
|
-
base?: string;
|
|
4
|
-
inherit?: boolean;
|
|
5
|
-
colors?: Record<string, string>;
|
|
6
|
-
rules?: Array<Record<string, unknown>>;
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
}
|
|
9
|
-
export type CodeBlockMonacoTheme = string | CodeBlockMonacoThemeObject;
|
|
10
|
-
export type CodeBlockMonacoLanguage = string | ((...args: unknown[]) => unknown);
|
|
11
|
-
export interface CodeBlockDiffHideUnchangedRegionsOptions {
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
contextLineCount?: number;
|
|
14
|
-
minimumLineCount?: number;
|
|
15
|
-
revealLineCount?: number;
|
|
16
|
-
}
|
|
17
|
-
export type CodeBlockDiffHideUnchangedRegions = boolean | CodeBlockDiffHideUnchangedRegionsOptions;
|
|
18
|
-
export type CodeBlockDiffLineStyle = 'background' | 'bar';
|
|
19
|
-
export type CodeBlockDiffAppearance = 'auto' | 'light' | 'dark';
|
|
20
|
-
export type CodeBlockDiffUnchangedRegionStyle = 'line-info' | 'line-info-basic' | 'metadata' | 'simple';
|
|
21
|
-
export type CodeBlockDiffHunkActionKind = 'revert' | 'stage';
|
|
22
|
-
export type CodeBlockDiffHunkSide = 'upper' | 'lower';
|
|
23
|
-
export interface CodeBlockDiffHunkActionContext {
|
|
24
|
-
action: CodeBlockDiffHunkActionKind;
|
|
25
|
-
side: CodeBlockDiffHunkSide;
|
|
26
|
-
lineChange: unknown;
|
|
27
|
-
originalModel: unknown;
|
|
28
|
-
modifiedModel: unknown;
|
|
29
|
-
}
|
|
30
|
-
export interface CodeBlockMonacoOptions {
|
|
31
|
-
MAX_HEIGHT?: number | string;
|
|
32
|
-
fontSize?: number;
|
|
33
|
-
lineHeight?: number;
|
|
34
|
-
fontFamily?: string;
|
|
35
|
-
tabSize?: number;
|
|
36
|
-
readOnly?: boolean;
|
|
37
|
-
wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded' | string;
|
|
38
|
-
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent' | string;
|
|
39
|
-
theme?: string;
|
|
40
|
-
themes?: CodeBlockMonacoTheme[];
|
|
41
|
-
languages?: CodeBlockMonacoLanguage[];
|
|
42
|
-
renderSideBySide?: boolean;
|
|
43
|
-
useInlineViewWhenSpaceIsLimited?: boolean;
|
|
44
|
-
enableSplitViewResizing?: boolean;
|
|
45
|
-
ignoreTrimWhitespace?: boolean;
|
|
46
|
-
maxComputationTime?: number;
|
|
47
|
-
diffAlgorithm?: string;
|
|
48
|
-
renderIndicators?: boolean;
|
|
49
|
-
originalEditable?: boolean;
|
|
50
|
-
revealDebounceMs?: number;
|
|
51
|
-
revealStrategy?: 'bottom' | 'centerIfOutside' | 'center';
|
|
52
|
-
revealBatchOnIdleMs?: number;
|
|
53
|
-
updateThrottleMs?: number;
|
|
54
|
-
diffUpdateThrottleMs?: number;
|
|
55
|
-
diffAutoScroll?: boolean;
|
|
56
|
-
diffHideUnchangedRegions?: CodeBlockDiffHideUnchangedRegions;
|
|
57
|
-
diffLineStyle?: CodeBlockDiffLineStyle;
|
|
58
|
-
diffAppearance?: CodeBlockDiffAppearance;
|
|
59
|
-
diffUnchangedRegionStyle?: CodeBlockDiffUnchangedRegionStyle;
|
|
60
|
-
diffHunkActionsOnHover?: boolean;
|
|
61
|
-
diffHunkHoverHideDelayMs?: number;
|
|
62
|
-
onDiffHunkAction?: (context: CodeBlockDiffHunkActionContext) => void | boolean | Promise<void | boolean>;
|
|
63
|
-
scrollbar?: Record<string, unknown>;
|
|
64
|
-
[key: string]: unknown;
|
|
65
|
-
}
|
|
File without changes
|