@mzebley/mark-down 1.2.1 → 1.2.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 +16 -22
- package/dist/angular/index.d.ts +20 -0
- package/dist/angular/index.js +68 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/browser.js +771 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-BRKEJJFQ.js +17 -0
- package/dist/chunk-BRKEJJFQ.js.map +1 -0
- package/dist/chunk-WZCXKUXV.js +245 -0
- package/dist/chunk-WZCXKUXV.js.map +1 -0
- package/dist/chunk-X5L6GGFF.js +379 -0
- package/dist/chunk-X5L6GGFF.js.map +1 -0
- package/dist/chunk-ZEQXN4ZD.js +21 -0
- package/dist/chunk-ZEQXN4ZD.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/inline.d.ts +12 -0
- package/{src/inline.ts → dist/inline.js} +35 -36
- package/dist/inline.js.map +1 -0
- package/dist/mark-down-inline.umd.js +17423 -0
- package/dist/mark-down-inline.umd.js.map +1 -0
- package/dist/sanitize-DI2uKnlG.d.ts +10 -0
- package/dist/slug.d.ts +3 -0
- package/dist/slug.js +8 -0
- package/dist/slug.js.map +1 -0
- package/dist/snippet-client-S6E_j24g.d.ts +66 -0
- package/package.json +5 -1
- package/src/angular/index.ts +0 -47
- package/src/browser.ts +0 -141
- package/src/errors.ts +0 -19
- package/src/front-matter.ts +0 -111
- package/src/index.ts +0 -5
- package/src/markdown.ts +0 -11
- package/src/slug.ts +0 -21
- package/src/snippet-client.ts +0 -412
- package/src/types.ts +0 -49
- package/tsconfig.json +0 -7
- package/tsup.config.ts +0 -59
package/src/snippet-client.ts
DELETED
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
import { normalizeSlug } from "./slug";
|
|
2
|
-
import { parseFrontMatter } from "./front-matter";
|
|
3
|
-
import { renderMarkdown } from "./markdown";
|
|
4
|
-
import { ManifestLoadError, SnippetNotFoundError } from "./errors";
|
|
5
|
-
import type {
|
|
6
|
-
ManifestSource,
|
|
7
|
-
ResponseLike,
|
|
8
|
-
Snippet,
|
|
9
|
-
SnippetClientOptions,
|
|
10
|
-
SnippetFetcherResult,
|
|
11
|
-
SnippetMeta,
|
|
12
|
-
SnippetSearchFilter
|
|
13
|
-
} from "./types";
|
|
14
|
-
|
|
15
|
-
export { ManifestLoadError, SnippetNotFoundError } from "./errors";
|
|
16
|
-
|
|
17
|
-
interface SnippetClientInternalOptions {
|
|
18
|
-
manifest: ManifestSource;
|
|
19
|
-
base?: string;
|
|
20
|
-
fetch: (url: string) => Promise<string>;
|
|
21
|
-
frontMatter: boolean;
|
|
22
|
-
cache: boolean;
|
|
23
|
-
verbose: boolean;
|
|
24
|
-
render: (markdown: string) => Promise<string>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const HTTP_PATTERN = /^https?:\/\//i;
|
|
28
|
-
|
|
29
|
-
export class SnippetClient {
|
|
30
|
-
private readonly options: SnippetClientInternalOptions;
|
|
31
|
-
private readonly manifestUrl?: string;
|
|
32
|
-
private readonly inferredBase?: string;
|
|
33
|
-
|
|
34
|
-
private manifestPromise?: Promise<SnippetMeta[]>;
|
|
35
|
-
private readonly snippetCache = new Map<string, Promise<Snippet>>();
|
|
36
|
-
|
|
37
|
-
constructor(options: SnippetClientOptions) {
|
|
38
|
-
if (!options || !options.manifest) {
|
|
39
|
-
throw new ManifestLoadError("A manifest source must be provided to SnippetClient.");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
this.manifestUrl = typeof options.manifest === "string" ? options.manifest : undefined;
|
|
43
|
-
this.inferredBase = this.manifestUrl ? deriveBaseFromManifest(this.manifestUrl) : undefined;
|
|
44
|
-
|
|
45
|
-
const fetcher = options.fetch ?? defaultFetch;
|
|
46
|
-
|
|
47
|
-
const renderOption = options.render;
|
|
48
|
-
|
|
49
|
-
const renderer = renderOption
|
|
50
|
-
? async (markdown: string) => Promise.resolve(renderOption(markdown))
|
|
51
|
-
: async (markdown: string) => Promise.resolve(renderMarkdown(markdown));
|
|
52
|
-
|
|
53
|
-
this.options = {
|
|
54
|
-
manifest: options.manifest,
|
|
55
|
-
base: options.base,
|
|
56
|
-
fetch: async (url: string) => {
|
|
57
|
-
const response = await fetcher(url);
|
|
58
|
-
if (typeof response === "string") {
|
|
59
|
-
return response;
|
|
60
|
-
}
|
|
61
|
-
return resolveResponseText(response, url);
|
|
62
|
-
},
|
|
63
|
-
frontMatter: options.frontMatter !== false,
|
|
64
|
-
cache: options.cache !== false,
|
|
65
|
-
verbose: options.verbose === true,
|
|
66
|
-
render: renderer
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async get(slug: string): Promise<Snippet> {
|
|
71
|
-
const manifest = await this.loadManifest();
|
|
72
|
-
const entry = manifest.find((item) => item.slug === slug);
|
|
73
|
-
if (!entry) {
|
|
74
|
-
throw new SnippetNotFoundError(slug);
|
|
75
|
-
}
|
|
76
|
-
return this.loadSnippet(entry);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async listAll(): Promise<SnippetMeta[]> {
|
|
80
|
-
const manifest = await this.loadManifest();
|
|
81
|
-
return manifest.map(cloneMeta);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async listByGroup(group: string): Promise<SnippetMeta[]> {
|
|
85
|
-
const manifest = await this.loadManifest();
|
|
86
|
-
return manifest
|
|
87
|
-
.filter((item) => (item.group ?? null) === group)
|
|
88
|
-
.map(cloneMeta);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async listByType(type: string): Promise<SnippetMeta[]> {
|
|
92
|
-
const manifest = await this.loadManifest();
|
|
93
|
-
return manifest
|
|
94
|
-
.filter((item) => item.type === type)
|
|
95
|
-
.map(cloneMeta);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async search(filter: SnippetSearchFilter): Promise<SnippetMeta[]> {
|
|
99
|
-
const manifest = await this.loadManifest();
|
|
100
|
-
const tags = filter.tags ?? [];
|
|
101
|
-
const mode = filter.tagsMode ?? "any";
|
|
102
|
-
|
|
103
|
-
return manifest
|
|
104
|
-
.filter((item) => {
|
|
105
|
-
if (filter.type && item.type !== filter.type) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
if (filter.group && (item.group ?? undefined) !== filter.group) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
if (!tags.length) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
const metaTags = item.tags ?? [];
|
|
115
|
-
if (!metaTags.length) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
if (mode === "all") {
|
|
119
|
-
return tags.every((tag) => metaTags.includes(tag));
|
|
120
|
-
}
|
|
121
|
-
return tags.some((tag) => metaTags.includes(tag));
|
|
122
|
-
})
|
|
123
|
-
.map(cloneMeta);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async getHtml(slug: string): Promise<string> {
|
|
127
|
-
const snippet = await this.get(slug);
|
|
128
|
-
return snippet.html;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
invalidate(): void {
|
|
132
|
-
this.manifestPromise = undefined;
|
|
133
|
-
this.snippetCache.clear();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
invalidateSlug(slug: string): void {
|
|
137
|
-
this.snippetCache.delete(slug);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
private async loadManifest(): Promise<SnippetMeta[]> {
|
|
141
|
-
if (this.options.cache && this.manifestPromise) {
|
|
142
|
-
return this.manifestPromise;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const promise = this.resolveManifest();
|
|
146
|
-
if (this.options.cache) {
|
|
147
|
-
this.manifestPromise = promise;
|
|
148
|
-
}
|
|
149
|
-
return promise;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private async resolveManifest(): Promise<SnippetMeta[]> {
|
|
153
|
-
const source = this.options.manifest;
|
|
154
|
-
let entries: SnippetMeta[];
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
if (Array.isArray(source)) {
|
|
158
|
-
entries = source.map(normalizeManifestEntry);
|
|
159
|
-
} else if (typeof source === "function") {
|
|
160
|
-
const result = await source();
|
|
161
|
-
if (!Array.isArray(result)) {
|
|
162
|
-
throw new ManifestLoadError("Manifest loader must resolve to an array of snippet metadata.");
|
|
163
|
-
}
|
|
164
|
-
entries = result.map(normalizeManifestEntry);
|
|
165
|
-
} else {
|
|
166
|
-
const raw = await this.options.fetch(source);
|
|
167
|
-
entries = parseManifest(raw, source).map(normalizeManifestEntry);
|
|
168
|
-
}
|
|
169
|
-
} catch (error) {
|
|
170
|
-
if (error instanceof ManifestLoadError) {
|
|
171
|
-
throw error;
|
|
172
|
-
}
|
|
173
|
-
throw new ManifestLoadError("Failed to load snippet manifest.", error);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return entries.map(cloneMeta);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private loadSnippet(meta: SnippetMeta): Promise<Snippet> {
|
|
180
|
-
const cached = this.options.cache ? this.snippetCache.get(meta.slug) : undefined;
|
|
181
|
-
if (cached) {
|
|
182
|
-
return cached;
|
|
183
|
-
}
|
|
184
|
-
const promise = this.fetchSnippet(meta);
|
|
185
|
-
if (this.options.cache) {
|
|
186
|
-
this.snippetCache.set(meta.slug, promise);
|
|
187
|
-
}
|
|
188
|
-
return promise;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private async fetchSnippet(meta: SnippetMeta): Promise<Snippet> {
|
|
192
|
-
const url = this.resolveSnippetPath(meta.path);
|
|
193
|
-
let raw: string;
|
|
194
|
-
try {
|
|
195
|
-
raw = await this.options.fetch(url);
|
|
196
|
-
} catch (error) {
|
|
197
|
-
throw new ManifestLoadError(`Failed to fetch snippet at '${url}'.`, error);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const frontMatter = this.options.frontMatter ? parseFrontMatter(raw) : undefined;
|
|
201
|
-
const body = frontMatter?.content ?? raw;
|
|
202
|
-
const html = await this.options.render(body);
|
|
203
|
-
|
|
204
|
-
const merged: SnippetMeta = {
|
|
205
|
-
...meta,
|
|
206
|
-
...pickMeta(frontMatter?.meta),
|
|
207
|
-
extra: mergeExtra(meta.extra, frontMatter?.extra)
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
if (frontMatter?.slug) {
|
|
211
|
-
try {
|
|
212
|
-
const normalizedFrontSlug = normalizeSlug(frontMatter.slug);
|
|
213
|
-
if (normalizedFrontSlug !== meta.slug && this.options.verbose) {
|
|
214
|
-
console.warn(
|
|
215
|
-
`Front-matter slug '${frontMatter.slug}' (normalized: '${normalizedFrontSlug}') differs from manifest slug '${meta.slug}'.`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
} catch (error) {
|
|
219
|
-
if (this.options.verbose) {
|
|
220
|
-
console.warn(`Failed to normalize front-matter slug '${frontMatter.slug}':`, error);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const snippet: Snippet = { ...merged, html, raw: body, markdown: body };
|
|
226
|
-
if (merged.tags) {
|
|
227
|
-
snippet.tags = [...merged.tags];
|
|
228
|
-
}
|
|
229
|
-
return snippet;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private resolveSnippetPath(path: string): string {
|
|
233
|
-
if (HTTP_PATTERN.test(path)) {
|
|
234
|
-
return normalizeForwardSlashes(path);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const base = this.options.base ?? this.inferredBase ?? "";
|
|
238
|
-
|
|
239
|
-
if (path.startsWith("/")) {
|
|
240
|
-
if (base) {
|
|
241
|
-
return joinPaths(base, path);
|
|
242
|
-
}
|
|
243
|
-
return normalizeForwardSlashes(path);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (base) {
|
|
247
|
-
return joinPaths(base, path);
|
|
248
|
-
}
|
|
249
|
-
return normalizeForwardSlashes(path);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function parseManifest(raw: string, source: string): SnippetMeta[] {
|
|
254
|
-
let parsed: unknown;
|
|
255
|
-
try {
|
|
256
|
-
parsed = JSON.parse(raw);
|
|
257
|
-
} catch (error) {
|
|
258
|
-
throw new ManifestLoadError(`Manifest at '${source}' is not valid JSON.`, error);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (!Array.isArray(parsed)) {
|
|
262
|
-
throw new ManifestLoadError(`Manifest at '${source}' must be a JSON array.`);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return parsed as SnippetMeta[];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function normalizeManifestEntry(entry: SnippetMeta): SnippetMeta {
|
|
269
|
-
if (!entry.slug) {
|
|
270
|
-
throw new ManifestLoadError("Manifest entry is missing required 'slug' property.");
|
|
271
|
-
}
|
|
272
|
-
if (!entry.path) {
|
|
273
|
-
throw new ManifestLoadError(`Manifest entry for '${entry.slug}' is missing required 'path'.`);
|
|
274
|
-
}
|
|
275
|
-
const normalized: SnippetMeta = {
|
|
276
|
-
slug: entry.slug,
|
|
277
|
-
title: entry.title,
|
|
278
|
-
type: entry.type,
|
|
279
|
-
order: entry.order,
|
|
280
|
-
tags: entry.tags ? [...entry.tags] : undefined,
|
|
281
|
-
path: normalizeForwardSlashes(entry.path),
|
|
282
|
-
group: entry.group ?? null,
|
|
283
|
-
draft: entry.draft,
|
|
284
|
-
extra: cloneRecord(entry.extra)
|
|
285
|
-
};
|
|
286
|
-
return normalized;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function deriveBaseFromManifest(manifest: string): string | undefined {
|
|
290
|
-
if (HTTP_PATTERN.test(manifest)) {
|
|
291
|
-
try {
|
|
292
|
-
const url = new URL(manifest);
|
|
293
|
-
url.hash = "";
|
|
294
|
-
url.search = "";
|
|
295
|
-
const path = url.pathname;
|
|
296
|
-
url.pathname = path.replace(/[^/]*$/, "");
|
|
297
|
-
return url.toString();
|
|
298
|
-
} catch (error) {
|
|
299
|
-
console.warn(`Unable to derive base from manifest '${manifest}':`, error);
|
|
300
|
-
return undefined;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const sanitized = manifest.replace(/[?#].*$/, "");
|
|
305
|
-
const index = sanitized.lastIndexOf("/");
|
|
306
|
-
if (index === -1) {
|
|
307
|
-
return undefined;
|
|
308
|
-
}
|
|
309
|
-
return sanitized.slice(0, index + 1);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function joinPaths(base: string, relative: string): string {
|
|
313
|
-
if (HTTP_PATTERN.test(base)) {
|
|
314
|
-
return new URL(relative, base).toString();
|
|
315
|
-
}
|
|
316
|
-
const leading = base.endsWith("/") ? base : `${base}/`;
|
|
317
|
-
const trimmed = relative.startsWith("/") ? relative.slice(1) : relative;
|
|
318
|
-
return normalizeForwardSlashes(`${leading}${trimmed}`);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function normalizeForwardSlashes(value: string): string {
|
|
322
|
-
if (HTTP_PATTERN.test(value)) {
|
|
323
|
-
try {
|
|
324
|
-
const url = new URL(value);
|
|
325
|
-
url.pathname = url.pathname.replace(/\/{2,}/g, "/");
|
|
326
|
-
return url.toString();
|
|
327
|
-
} catch {
|
|
328
|
-
// fall back to manual normalization below
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (value.startsWith("//")) {
|
|
333
|
-
return `//${value.slice(2).replace(/\/{2,}/g, "/")}`;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (value.startsWith("/")) {
|
|
337
|
-
return `/${value
|
|
338
|
-
.slice(1)
|
|
339
|
-
.replace(/\/{2,}/g, "/")}`;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return value.replace(/\/{2,}/g, "/");
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function mergeExtra(
|
|
346
|
-
base: Record<string, unknown> | undefined,
|
|
347
|
-
overrides: Record<string, unknown> | undefined
|
|
348
|
-
): Record<string, unknown> | undefined {
|
|
349
|
-
if (!base && !overrides) {
|
|
350
|
-
return undefined;
|
|
351
|
-
}
|
|
352
|
-
return { ...(base ?? {}), ...(overrides ?? {}) };
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function cloneRecord<T extends Record<string, unknown> | undefined>(value: T): T {
|
|
356
|
-
if (!value) {
|
|
357
|
-
return value;
|
|
358
|
-
}
|
|
359
|
-
return { ...value } as T;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function cloneMeta(meta: SnippetMeta): SnippetMeta {
|
|
363
|
-
return {
|
|
364
|
-
...meta,
|
|
365
|
-
tags: meta.tags ? [...meta.tags] : undefined,
|
|
366
|
-
extra: cloneRecord(meta.extra)
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
async function defaultFetch(url: string): Promise<SnippetFetcherResult> {
|
|
371
|
-
const runtimeFetch = (globalThis as typeof globalThis & { fetch?: typeof fetch }).fetch;
|
|
372
|
-
if (!runtimeFetch) {
|
|
373
|
-
throw new ManifestLoadError("No global fetch implementation is available. Provide a custom fetch function.");
|
|
374
|
-
}
|
|
375
|
-
return runtimeFetch(url);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
async function resolveResponseText(response: ResponseLike, url: string): Promise<string> {
|
|
379
|
-
if (!response.ok) {
|
|
380
|
-
throw new ManifestLoadError(`Request to '${url}' failed with status ${response.status}.`);
|
|
381
|
-
}
|
|
382
|
-
return response.text();
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function pickMeta(meta?: Partial<SnippetMeta>): Partial<SnippetMeta> {
|
|
386
|
-
if (!meta) {
|
|
387
|
-
return {};
|
|
388
|
-
}
|
|
389
|
-
const result: Partial<SnippetMeta> = {};
|
|
390
|
-
if (meta.title !== undefined) {
|
|
391
|
-
result.title = meta.title;
|
|
392
|
-
}
|
|
393
|
-
if (meta.type !== undefined) {
|
|
394
|
-
result.type = meta.type;
|
|
395
|
-
}
|
|
396
|
-
if (meta.order !== undefined) {
|
|
397
|
-
result.order = meta.order;
|
|
398
|
-
}
|
|
399
|
-
if (meta.tags !== undefined) {
|
|
400
|
-
result.tags = [...meta.tags];
|
|
401
|
-
}
|
|
402
|
-
if (meta.group !== undefined) {
|
|
403
|
-
result.group = meta.group;
|
|
404
|
-
}
|
|
405
|
-
if (meta.draft !== undefined) {
|
|
406
|
-
result.draft = meta.draft;
|
|
407
|
-
}
|
|
408
|
-
if (meta.path !== undefined) {
|
|
409
|
-
result.path = meta.path;
|
|
410
|
-
}
|
|
411
|
-
return result;
|
|
412
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export interface SnippetMeta {
|
|
2
|
-
slug: string;
|
|
3
|
-
title?: string;
|
|
4
|
-
type?: string;
|
|
5
|
-
order?: number;
|
|
6
|
-
tags?: string[];
|
|
7
|
-
path: string;
|
|
8
|
-
group?: string | null;
|
|
9
|
-
draft?: boolean;
|
|
10
|
-
extra?: Record<string, unknown>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Snippet extends SnippetMeta {
|
|
14
|
-
html: string;
|
|
15
|
-
raw?: string;
|
|
16
|
-
markdown?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface SnippetSearchFilter {
|
|
20
|
-
type?: string;
|
|
21
|
-
group?: string;
|
|
22
|
-
tags?: string[];
|
|
23
|
-
tagsMode?: "any" | "all";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type ManifestSource =
|
|
27
|
-
| string
|
|
28
|
-
| SnippetMeta[]
|
|
29
|
-
| (() => Promise<SnippetMeta[]> | SnippetMeta[]);
|
|
30
|
-
|
|
31
|
-
export interface ResponseLike {
|
|
32
|
-
ok: boolean;
|
|
33
|
-
status: number;
|
|
34
|
-
text(): Promise<string>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type SnippetFetcherResult = string | ResponseLike;
|
|
38
|
-
|
|
39
|
-
export type SnippetFetcher = (url: string) => Promise<SnippetFetcherResult>;
|
|
40
|
-
|
|
41
|
-
export interface SnippetClientOptions {
|
|
42
|
-
manifest: ManifestSource;
|
|
43
|
-
base?: string;
|
|
44
|
-
fetch?: SnippetFetcher;
|
|
45
|
-
frontMatter?: boolean;
|
|
46
|
-
cache?: boolean;
|
|
47
|
-
verbose?: boolean;
|
|
48
|
-
render?: (markdown: string) => string | Promise<string>;
|
|
49
|
-
}
|
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig([
|
|
4
|
-
{
|
|
5
|
-
entry: {
|
|
6
|
-
index: "src/index.ts",
|
|
7
|
-
slug: "src/slug.ts",
|
|
8
|
-
inline: "src/inline.ts",
|
|
9
|
-
"angular/index": "src/angular/index.ts"
|
|
10
|
-
},
|
|
11
|
-
format: ["esm"],
|
|
12
|
-
dts: true,
|
|
13
|
-
sourcemap: true,
|
|
14
|
-
clean: true,
|
|
15
|
-
target: "es2020",
|
|
16
|
-
external: ["@angular/core", "@angular/common", "@angular/router", "@angular/platform-browser", "rxjs"],
|
|
17
|
-
outExtension() {
|
|
18
|
-
return {
|
|
19
|
-
js: ".js"
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
entry: {
|
|
25
|
-
browser: "src/browser.ts"
|
|
26
|
-
},
|
|
27
|
-
format: ["esm"],
|
|
28
|
-
dts: true,
|
|
29
|
-
sourcemap: true,
|
|
30
|
-
clean: false,
|
|
31
|
-
target: "es2020",
|
|
32
|
-
platform: "browser",
|
|
33
|
-
splitting: false,
|
|
34
|
-
outExtension() {
|
|
35
|
-
return {
|
|
36
|
-
js: ".js"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
entry: {
|
|
42
|
-
"mark-down-inline": "src/inline.ts"
|
|
43
|
-
},
|
|
44
|
-
format: ["iife"],
|
|
45
|
-
globalName: "markDownInline",
|
|
46
|
-
dts: false,
|
|
47
|
-
sourcemap: true,
|
|
48
|
-
clean: false,
|
|
49
|
-
platform: "browser",
|
|
50
|
-
minify: false,
|
|
51
|
-
target: "es2018",
|
|
52
|
-
splitting: false,
|
|
53
|
-
outExtension() {
|
|
54
|
-
return {
|
|
55
|
-
js: ".umd.js"
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
]);
|