@rasterex/viewer 1.1.2 → 2.0.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/README.md CHANGED
@@ -131,6 +131,73 @@ by your self-hosted Rasterex Canvas deployment.
131
131
  not the display name. It lets the server reuse already processed content for the
132
132
  same file, which can make repeat opens faster.
133
133
 
134
+ ### Document Loading Lifecycle
135
+
136
+ Subscribe to document events before opening a file when your UI needs a loading
137
+ indicator or error message. `opening` starts the loading state. `fileReady`
138
+ confirms that Canvas has opened and activated the file; `fileLoadFailed` reports
139
+ a Canvas-side open failure. The SDK also emits `failed` for setup, readiness,
140
+ or timeout errors.
141
+
142
+ Canvas does not provide a documented numeric document-progress callback through
143
+ `viewer.documents`. Show an indeterminate loading indicator from `opening` until
144
+ one of the terminal events arrives.
145
+
146
+ ```ts
147
+ import { createViewer } from "@rasterex/viewer";
148
+
149
+ const viewer = createViewer({ container: "#rx-viewer" });
150
+
151
+ viewer.documents.on("opening", () => {
152
+ showLoadingIndicator();
153
+ clearOpenError();
154
+ });
155
+
156
+ viewer.documents.on("fileReady", (event) => {
157
+ hideLoadingIndicator();
158
+ console.log("File ready:", event.fileName);
159
+ });
160
+
161
+ viewer.documents.on("fileLoadFailed", (event) => {
162
+ console.error("Canvas could not open the file:", event.reason);
163
+ });
164
+
165
+ viewer.documents.on("failed", (event) => {
166
+ hideLoadingIndicator();
167
+ showOpenError(event.error.message);
168
+ });
169
+
170
+ await viewer.mount();
171
+ await viewer.ready();
172
+
173
+ try {
174
+ await viewer.documents.open({
175
+ url: "https://files.example.com/sample.pdf",
176
+ displayName: "sample.pdf"
177
+ });
178
+ } catch {
179
+ // The `failed` event above has already updated the UI.
180
+ }
181
+ ```
182
+
183
+ For a browser-local file selected by the user, call `openFile(...)` after the
184
+ same initialization and event setup:
185
+
186
+ ```ts
187
+ const fileInput = document.querySelector<HTMLInputElement>("#file-input");
188
+ const file = fileInput?.files?.[0];
189
+
190
+ if (file) {
191
+ try {
192
+ await viewer.documents.openFile(file, {
193
+ cacheId: "file_7f3a9c2_sample_pdf"
194
+ });
195
+ } catch {
196
+ // The `failed` event above has already updated the UI.
197
+ }
198
+ }
199
+ ```
200
+
134
201
  ### Create, Mount, And Open In One Call
135
202
 
136
203
  Use `createDocumentViewer` when the first action should be opening a document:
@@ -247,7 +314,7 @@ Hosted presets are exported from a separate entrypoint:
247
314
 
248
315
  ```ts
249
316
  import { createViewer } from "@rasterex/viewer";
250
- import { sandboxCanvas, takeoffDemo } from "@rasterex/viewer/demo-presets";
317
+ import { sandboxCanvas } from "@rasterex/viewer/demo-presets";
251
318
 
252
319
  const viewer = createViewer({
253
320
  container: "#rx-viewer",
@@ -256,9 +323,6 @@ const viewer = createViewer({
256
323
  });
257
324
  ```
258
325
 
259
- Takeoff is not loaded by default. Use `takeoffDemo` only when your application
260
- explicitly selects that preset.
261
-
262
326
  ## Cleanup
263
327
 
264
328
  Destroy the viewer when the page, route, or component no longer needs it:
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "1.1.2";
1
+ export declare const SDK_VERSION = "2.0.0";
2
2
  export declare const DEFAULT_VIEWER_URL = "https://sandbox.rasterex.com";
3
3
  export declare const DEFAULT_TARGET_ORIGIN = "https://sandbox.rasterex.com";
4
4
  export declare const DEFAULT_IFRAME_TITLE = "Rasterex Viewer";
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "1.1.2";
1
+ export const SDK_VERSION = "2.0.0";
2
2
  export const DEFAULT_VIEWER_URL = "https://sandbox.rasterex.com";
3
3
  export const DEFAULT_TARGET_ORIGIN = "https://sandbox.rasterex.com";
4
4
  export const DEFAULT_IFRAME_TITLE = "Rasterex Viewer";
@@ -12,13 +12,6 @@ export declare const betaViewerDemo: {
12
12
  targetOrigin: string;
13
13
  capabilities: readonly ["iframe"];
14
14
  };
15
- export declare const takeoffDemo: {
16
- id: string;
17
- label: string;
18
- viewerUrl: string;
19
- targetOrigin: string;
20
- capabilities: readonly ["iframe"];
21
- };
22
15
  export declare const DEMO_VIEWER_PRESETS: {
23
16
  sandboxCanvas: {
24
17
  id: string;
@@ -34,12 +27,5 @@ export declare const DEMO_VIEWER_PRESETS: {
34
27
  targetOrigin: string;
35
28
  capabilities: readonly ["iframe"];
36
29
  };
37
- takeoff: {
38
- id: string;
39
- label: string;
40
- viewerUrl: string;
41
- targetOrigin: string;
42
- capabilities: readonly ["iframe"];
43
- };
44
30
  };
45
31
  //# sourceMappingURL=demo-presets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"demo-presets.d.ts","sourceRoot":"","sources":["../src/demo-presets.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;CAAgB,CAAC;AAE5C,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;CAI/B,CAAC"}
1
+ {"version":3,"file":"demo-presets.d.ts","sourceRoot":"","sources":["../src/demo-presets.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;CAAgB,CAAC;AAE5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;CAG/B,CAAC"}
@@ -7,16 +7,8 @@ export const sandboxCanvas = {
7
7
  capabilities: ["iframe"]
8
8
  };
9
9
  export const betaViewerDemo = sandboxCanvas;
10
- export const takeoffDemo = {
11
- id: "takeoff",
12
- label: "Takeoff Demo",
13
- viewerUrl: "https://takeoff.viewsoft.com",
14
- targetOrigin: "https://takeoff.viewsoft.com",
15
- capabilities: ["iframe"]
16
- };
17
10
  export const DEMO_VIEWER_PRESETS = {
18
11
  sandboxCanvas,
19
- betaViewer: sandboxCanvas,
20
- takeoff: takeoffDemo
12
+ betaViewer: sandboxCanvas
21
13
  };
22
14
  //# sourceMappingURL=demo-presets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"demo-presets.js","sourceRoot":"","sources":["../src/demo-presets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,kBAAkB;IAC7B,YAAY,EAAE,qBAAqB;IACnC,YAAY,EAAE,CAAC,QAAQ,CAAU;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,SAAS;IACb,KAAK,EAAE,cAAc;IACrB,SAAS,EAAE,8BAA8B;IACzC,YAAY,EAAE,8BAA8B;IAC5C,YAAY,EAAE,CAAC,QAAQ,CAAU;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,UAAU,EAAE,aAAa;IACzB,OAAO,EAAE,WAAW;CACrB,CAAC"}
1
+ {"version":3,"file":"demo-presets.js","sourceRoot":"","sources":["../src/demo-presets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,kBAAkB;IAC7B,YAAY,EAAE,qBAAqB;IACnC,YAAY,EAAE,CAAC,QAAQ,CAAU;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,UAAU,EAAE,aAAa;CAC1B,CAAC"}
@@ -1,2 +1,2 @@
1
- export { DEMO_VIEWER_PRESETS, betaViewerDemo, sandboxCanvas, takeoffDemo } from "./demo-presets.js";
1
+ export { DEMO_VIEWER_PRESETS, betaViewerDemo, sandboxCanvas } from "./demo-presets.js";
2
2
  //# sourceMappingURL=demoPresets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"demoPresets.d.ts","sourceRoot":"","sources":["../src/demoPresets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,WAAW,EACZ,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"demoPresets.d.ts","sourceRoot":"","sources":["../src/demoPresets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,mBAAmB,CAAC"}
@@ -1,2 +1,2 @@
1
- export { DEMO_VIEWER_PRESETS, betaViewerDemo, sandboxCanvas, takeoffDemo } from "./demo-presets.js";
1
+ export { DEMO_VIEWER_PRESETS, betaViewerDemo, sandboxCanvas } from "./demo-presets.js";
2
2
  //# sourceMappingURL=demoPresets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"demoPresets.js","sourceRoot":"","sources":["../src/demoPresets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,WAAW,EACZ,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"demoPresets.js","sourceRoot":"","sources":["../src/demoPresets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasterex/viewer",
3
- "version": "1.1.2",
3
+ "version": "2.0.0",
4
4
  "description": "TypeScript SDK for embedding Rasterex Canvas in web applications via iframe and PostMessage. Built for customer self-hosted deployments; hosted Canvas is available for evaluation and proof-of-concept testing.",
5
5
  "author": {
6
6
  "name": "Rasterex Software AS",