@dvina/artifact-renderer-core 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dvina
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @dvina/artifact-renderer-core
2
+
3
+ Advanced shared types for the Dvina Artifact Renderer.
4
+
5
+ Most users should install `@dvina/artifact-renderer` instead of this package directly.
6
+
7
+ Use this package only if you need the underlying document, theme, telemetry, or renderer contract types separately.
@@ -0,0 +1,108 @@
1
+ export type ViewerFormat = "pdf" | "docx" | "xls" | "xlsx" | "csv" | "pptx" | "audio" | "image" | "video" | "zip" | "epub" | "text" | "code" | "html" | "markdown" | "mermaid" | "json" | "jsonl" | "ndjson" | "tsv" | "xml" | "toml" | "ini" | "dotenv" | "yaml" | "unknown";
2
+ export type ViewerJsonPrimitive = string | number | boolean | null;
3
+ export type ViewerJsonValue = ViewerJsonPrimitive | {
4
+ [key: string]: ViewerJsonValue;
5
+ } | ViewerJsonValue[];
6
+ export type HtmlSandboxCapability = "allow-downloads" | "allow-forms" | "allow-modals" | "allow-pointer-lock" | "allow-popups" | "allow-popups-to-escape-sandbox" | "allow-same-origin" | "allow-scripts" | "allow-top-navigation-by-user-activation";
7
+ export type ViewerThemeMode = "light" | "dark";
8
+ export interface ViewerThemeTokens {
9
+ surface?: string;
10
+ surfaceMuted?: string;
11
+ text?: string;
12
+ accent?: string;
13
+ }
14
+ export interface ViewerTheme {
15
+ mode: ViewerThemeMode;
16
+ tokens?: ViewerThemeTokens;
17
+ }
18
+ export interface ViewerUrlSource {
19
+ kind: "url";
20
+ url: string;
21
+ }
22
+ export interface ViewerSessionSource {
23
+ kind: "session";
24
+ sessionId: string;
25
+ }
26
+ export type ViewerSource = ViewerUrlSource | ViewerSessionSource;
27
+ export interface ViewerDocument {
28
+ id: string;
29
+ name: string;
30
+ format: ViewerFormat;
31
+ source: ViewerSource;
32
+ renderOptions?: ViewerRenderOptions;
33
+ previewUrl?: string;
34
+ mimeType?: string;
35
+ size?: number;
36
+ downloadUrl?: string;
37
+ openUrl?: string;
38
+ }
39
+ export type SpreadsheetRenderMode = "fast" | "styled";
40
+ export interface HtmlRenderOptions {
41
+ revisionId?: string;
42
+ artifactData?: ViewerJsonValue;
43
+ sandbox?: HtmlSandboxCapability[];
44
+ bootstrap?: "auto" | "off";
45
+ }
46
+ export interface ViewerRenderOptions {
47
+ spreadsheetMode?: SpreadsheetRenderMode;
48
+ codeLanguage?: string;
49
+ html?: HtmlRenderOptions;
50
+ }
51
+ export type ViewerCapability = "load-document" | "pagination" | "slide-navigation" | "download" | "open-externally" | "resize-notifications" | "artifact-runtime";
52
+ export type ViewerState = "booting" | "waiting-for-init" | "initializing" | "loading-document" | "ready" | "unsupported" | "error";
53
+ export type ViewerUnsupportedReason = "format-not-supported" | "encrypted-document" | "missing-renderer" | "feature-not-available";
54
+ export type ViewerFallbackAction = "download" | "open-externally" | "retry";
55
+ export type ViewerTelemetryLevel = "info" | "warn" | "error";
56
+ export type ViewerErrorCode = "invalid-message" | "origin-mismatch" | "session-expired" | "document-fetch-failed" | "renderer-failed" | "timeout";
57
+ export interface ViewerUnsupportedDetails {
58
+ reason: ViewerUnsupportedReason;
59
+ message: string;
60
+ recommendedAction: ViewerFallbackAction;
61
+ }
62
+ export interface ViewerErrorDetails {
63
+ code: ViewerErrorCode;
64
+ message: string;
65
+ recoverable: boolean;
66
+ recommendedAction?: ViewerFallbackAction;
67
+ }
68
+ export interface ViewerTelemetryRecord {
69
+ name: string;
70
+ level: ViewerTelemetryLevel;
71
+ message: string;
72
+ context?: Record<string, string | number | boolean | null>;
73
+ }
74
+ export interface ViewerNavigationState {
75
+ kind: "none" | "pages" | "slides";
76
+ index: number;
77
+ total: number;
78
+ }
79
+ export interface ViewerRenderContext {
80
+ container: HTMLElement;
81
+ document: ViewerDocument;
82
+ theme?: ViewerTheme;
83
+ sessionToken?: string;
84
+ }
85
+ export interface ViewerRenderResult {
86
+ navigation?: ViewerNavigationState;
87
+ }
88
+ export interface ViewerRenderer {
89
+ readonly id: string;
90
+ readonly supportedFormats: readonly ViewerFormat[];
91
+ readonly capabilities: readonly ViewerCapability[];
92
+ canRender(document: ViewerDocument): boolean;
93
+ render(context: ViewerRenderContext): Promise<ViewerRenderResult>;
94
+ destroy?(): Promise<void> | void;
95
+ }
96
+ export interface SupportedRendererMatch {
97
+ kind: "supported";
98
+ renderer: ViewerRenderer;
99
+ }
100
+ export interface UnsupportedRendererMatch {
101
+ kind: "unsupported";
102
+ unsupported: ViewerUnsupportedDetails;
103
+ }
104
+ export type ViewerRendererMatch = SupportedRendererMatch | UnsupportedRendererMatch;
105
+ export declare function isViewerUrlSource(source: ViewerSource): source is ViewerUrlSource;
106
+ export declare function isViewerSessionSource(source: ViewerSource): source is ViewerSessionSource;
107
+ export declare function resolveRenderer(document: ViewerDocument, renderers: readonly ViewerRenderer[]): ViewerRendererMatch;
108
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,KAAK,GACL,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,UAAU,GACV,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,KAAK,GACL,KAAK,GACL,MAAM,GACN,KAAK,GACL,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEnE,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,GAClC,eAAe,EAAE,CAAC;AAEtB,MAAM,MAAM,qBAAqB,GAC7B,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,oBAAoB,GACpB,cAAc,GACd,gCAAgC,GAChC,mBAAmB,GACnB,eAAe,GACf,yCAAyC,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,CA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AAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,gBAAgB,EAAE,SAAS,YAAY,EAAE,CAAC;IACnD,QAAQ,CAAC,YAAY,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACnD,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC;IAC7C,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,wBAAwB,CAAC;CACvC;AAED,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;AAEpF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,eAAe,CAEjF;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,GACnB,MAAM,IAAI,mBAAmB,CAE/B;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,SAAS,cAAc,EAAE,GACnC,mBAAmB,CAkBrB"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ export function isViewerUrlSource(source) {
2
+ return source.kind === "url";
3
+ }
4
+ export function isViewerSessionSource(source) {
5
+ return source.kind === "session";
6
+ }
7
+ export function resolveRenderer(document, renderers) {
8
+ const renderer = renderers.find((candidate) => candidate.canRender(document));
9
+ if (renderer) {
10
+ return {
11
+ kind: "supported",
12
+ renderer,
13
+ };
14
+ }
15
+ return {
16
+ kind: "unsupported",
17
+ unsupported: {
18
+ reason: "missing-renderer",
19
+ message: `No renderer is registered for format \"${document.format}\".`,
20
+ recommendedAction: document.downloadUrl ? "download" : "open-externally",
21
+ },
22
+ };
23
+ }
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkMA,MAAM,UAAU,iBAAiB,CAAC,MAAoB;IACpD,OAAO,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAAoB;IAEpB,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,QAAwB,EACxB,SAAoC;IAEpC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE9E,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,QAAQ;SACT,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE;YACX,MAAM,EAAE,kBAAkB;YAC1B,OAAO,EAAE,0CAA0C,QAAQ,CAAC,MAAM,KAAK;YACvE,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB;SACzE;KACF,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@dvina/artifact-renderer-core",
3
+ "version": "0.0.1",
4
+ "description": "Core types and renderer contracts for Dvina Artifact Renderer.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "license": "MIT",
21
+ "sideEffects": false,
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/dvina/artifact-renderer.git",
25
+ "directory": "packages/core"
26
+ },
27
+ "homepage": "https://github.com/dvina/artifact-renderer#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/dvina/artifact-renderer/issues"
30
+ },
31
+ "keywords": [
32
+ "dvina",
33
+ "artifact-renderer",
34
+ "iframe",
35
+ "viewer",
36
+ "types"
37
+ ],
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc -p tsconfig.json",
46
+ "check": "tsc -p tsconfig.json --noEmit"
47
+ }
48
+ }