diorama-js 0.1.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/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/index.cjs +2283 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +186 -0
- package/dist/index.d.ts +186 -0
- package/dist/index.js +2269 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +2330 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +145 -0
- package/dist/react.d.ts +145 -0
- package/dist/react.js +2327 -0
- package/dist/react.js.map +1 -0
- package/dist/svelte.cjs +2297 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +152 -0
- package/dist/svelte.d.ts +152 -0
- package/dist/svelte.js +2294 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.cjs +2327 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +146 -0
- package/dist/vue.d.ts +146 -0
- package/dist/vue.js +2324 -0
- package/dist/vue.js.map +1 -0
- package/package.json +120 -0
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base error class for all Diorama errors.
|
|
5
|
+
* Every error has a `code` property for programmatic handling.
|
|
6
|
+
*/
|
|
7
|
+
declare class DioramaError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
constructor(code: string, message: string);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ProjectType = 'static' | 'static-esm' | 'jsx' | 'typescript' | 'jsx-typescript' | 'vite';
|
|
13
|
+
type CDNProviderName = 'esm.sh' | 'skypack' | 'unpkg';
|
|
14
|
+
type CacheStrategy = 'normal' | 'aggressive';
|
|
15
|
+
type LoadingStrategy = 'eager' | 'click' | 'viewport';
|
|
16
|
+
/**
|
|
17
|
+
* Built-in decorative frame styles that wrap the rendered iframe.
|
|
18
|
+
*
|
|
19
|
+
* - `'none'` — No frame (default).
|
|
20
|
+
* - `'standard'` — Clean, minimal border with subtle shadow.
|
|
21
|
+
* - `'polaroid'` — Polaroid-photo style with thick white bottom.
|
|
22
|
+
* - `'museum'` — Ornate golden frame like a fine-art gallery.
|
|
23
|
+
* - `'terminal'` — Dark terminal / code-editor chrome.
|
|
24
|
+
* - `'postcard'` — Vintage postcard with stamp and postmark.
|
|
25
|
+
* - `'blueprint'` — Technical blueprint with grid overlay border.
|
|
26
|
+
* - `'browser'` — Browser window chrome with address bar.
|
|
27
|
+
*/
|
|
28
|
+
type FrameStyle = 'none' | 'standard' | 'polaroid' | 'museum' | 'terminal' | 'postcard' | 'blueprint' | 'browser';
|
|
29
|
+
interface DioramaOptions {
|
|
30
|
+
/** Enable localStorage caching. Default: `true`. */
|
|
31
|
+
cache?: boolean;
|
|
32
|
+
/** Cache time-to-live in seconds. Default: `3600` (1 hour). */
|
|
33
|
+
cacheTTL?: number;
|
|
34
|
+
/** Cache strategy. `'aggressive'` also caches the tree SHA. Default: `'normal'`. */
|
|
35
|
+
cacheStrategy?: CacheStrategy;
|
|
36
|
+
/** CDN used to resolve bare npm imports. Default: `'esm.sh'`. */
|
|
37
|
+
cdnProvider?: CDNProviderName;
|
|
38
|
+
/** Optional GitHub personal-access token (increases rate limit to 5 000/h). */
|
|
39
|
+
githubToken?: string;
|
|
40
|
+
/** URL to the esbuild-wasm binary. `'auto'` loads from esm.sh. */
|
|
41
|
+
esbuildWasmURL?: string | 'auto';
|
|
42
|
+
/** Maximum parallel file fetches. Default: `6`. */
|
|
43
|
+
maxConcurrentFetches?: number;
|
|
44
|
+
/** Total render timeout in milliseconds. Default: `30000`. */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
}
|
|
47
|
+
interface RenderOptions {
|
|
48
|
+
/** Override the branch to render. */
|
|
49
|
+
branch?: string;
|
|
50
|
+
/** Render a subdirectory within the repo. */
|
|
51
|
+
subdirectory?: string;
|
|
52
|
+
/** When to create and populate the iframe. Default: `'eager'`. */
|
|
53
|
+
loading?: LoadingStrategy;
|
|
54
|
+
/** Image URL shown as a placeholder for `click` / `viewport` loading. */
|
|
55
|
+
placeholder?: string;
|
|
56
|
+
/** CSS height of the iframe. Default: `'500px'`. */
|
|
57
|
+
height?: string;
|
|
58
|
+
/** Decorative frame style wrapping the iframe. Default: `'none'`. */
|
|
59
|
+
frame?: FrameStyle;
|
|
60
|
+
/** Allow click-to-expand the preview to fill the viewport. Default: `false`. */
|
|
61
|
+
expand?: boolean;
|
|
62
|
+
/** Iframe sandbox flags. Default: `['allow-scripts']`. */
|
|
63
|
+
sandbox?: string[];
|
|
64
|
+
/** Override automatic project type detection. */
|
|
65
|
+
projectType?: ProjectType;
|
|
66
|
+
/** Override entry point detection. */
|
|
67
|
+
entryPoint?: string;
|
|
68
|
+
/** Glob patterns of files to include. */
|
|
69
|
+
include?: string[];
|
|
70
|
+
/** Glob patterns of files to exclude. */
|
|
71
|
+
exclude?: string[];
|
|
72
|
+
/** Called when rendering completes successfully. */
|
|
73
|
+
onLoad?: () => void;
|
|
74
|
+
/** Called when an error occurs at any pipeline stage. */
|
|
75
|
+
onError?: (error: DioramaError) => void;
|
|
76
|
+
}
|
|
77
|
+
interface DioramaInstance {
|
|
78
|
+
/** Re-fetch the project and re-render. */
|
|
79
|
+
reload(): Promise<void>;
|
|
80
|
+
/** Remove the iframe, revoke Blob URLs, clean up observers. */
|
|
81
|
+
destroy(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare class Diorama {
|
|
85
|
+
private options;
|
|
86
|
+
private cache;
|
|
87
|
+
constructor(options?: DioramaOptions);
|
|
88
|
+
/**
|
|
89
|
+
* Fetch, transform, and render a GitHub project inside a
|
|
90
|
+
* sandboxed iframe.
|
|
91
|
+
*
|
|
92
|
+
* @param container CSS selector or DOM element.
|
|
93
|
+
* @param repoURL GitHub URL or `owner/repo` shorthand.
|
|
94
|
+
* @param options Per-render options.
|
|
95
|
+
* @returns A handle for reloading or destroying the instance.
|
|
96
|
+
*/
|
|
97
|
+
render(container: string | HTMLElement, repoURL: string, options?: RenderOptions): Promise<DioramaInstance>;
|
|
98
|
+
/**
|
|
99
|
+
* Pre-fetch a project (resolve + cache) without rendering.
|
|
100
|
+
*/
|
|
101
|
+
prefetch(repoURL: string, options?: Pick<RenderOptions, 'branch' | 'subdirectory'>): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Clear cached data.
|
|
104
|
+
* @param repoSlug Optional `owner/repo` to clear a specific entry.
|
|
105
|
+
*/
|
|
106
|
+
clearCache(repoSlug?: string): void;
|
|
107
|
+
private fetchProject;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare const DioramaPreview: vue.DefineComponent<{
|
|
111
|
+
repo: string;
|
|
112
|
+
loading: LoadingStrategy;
|
|
113
|
+
height: string;
|
|
114
|
+
frame: FrameStyle;
|
|
115
|
+
expand: boolean;
|
|
116
|
+
branch?: string | undefined;
|
|
117
|
+
subdirectory?: string | undefined;
|
|
118
|
+
placeholder?: string | undefined;
|
|
119
|
+
options?: DioramaOptions | undefined;
|
|
120
|
+
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("load" | "error")[], "load" | "error", vue.PublicProps, Readonly<{
|
|
123
|
+
repo: string;
|
|
124
|
+
loading: LoadingStrategy;
|
|
125
|
+
height: string;
|
|
126
|
+
frame: FrameStyle;
|
|
127
|
+
expand: boolean;
|
|
128
|
+
branch?: string | undefined;
|
|
129
|
+
subdirectory?: string | undefined;
|
|
130
|
+
placeholder?: string | undefined;
|
|
131
|
+
options?: DioramaOptions | undefined;
|
|
132
|
+
}> & Readonly<{
|
|
133
|
+
onLoad?: ((...args: any[]) => any) | undefined;
|
|
134
|
+
onError?: ((...args: any[]) => any) | undefined;
|
|
135
|
+
}>, {
|
|
136
|
+
branch: string;
|
|
137
|
+
subdirectory: string;
|
|
138
|
+
loading: LoadingStrategy;
|
|
139
|
+
placeholder: string;
|
|
140
|
+
height: string;
|
|
141
|
+
frame: FrameStyle;
|
|
142
|
+
expand: boolean;
|
|
143
|
+
options: DioramaOptions;
|
|
144
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
145
|
+
|
|
146
|
+
export { Diorama, DioramaPreview };
|