@printwithsynergy/lens-pdf 0.3.0-beta.81
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 +661 -0
- package/README.md +344 -0
- package/dist/browser/codexOverlay.d.ts +109 -0
- package/dist/browser/codexOverlay.d.ts.map +1 -0
- package/dist/browser/codexOverlay.js +256 -0
- package/dist/browser/codexOverlay.js.map +1 -0
- package/dist/browser/constants.d.ts +13 -0
- package/dist/browser/constants.d.ts.map +1 -0
- package/dist/browser/constants.js +13 -0
- package/dist/browser/constants.js.map +1 -0
- package/dist/browser/index.d.ts +211 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +1190 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/pantone-gold.d.ts +59 -0
- package/dist/browser/pantone-gold.d.ts.map +1 -0
- package/dist/browser/pantone-gold.js +237 -0
- package/dist/browser/pantone-gold.js.map +1 -0
- package/dist/components/AnnotationCanvas.d.ts +27 -0
- package/dist/components/AnnotationCanvas.d.ts.map +1 -0
- package/dist/components/AnnotationCanvas.js +401 -0
- package/dist/components/AnnotationCanvas.js.map +1 -0
- package/dist/components/AnnotationNotesPanel.d.ts +15 -0
- package/dist/components/AnnotationNotesPanel.d.ts.map +1 -0
- package/dist/components/AnnotationNotesPanel.js +235 -0
- package/dist/components/AnnotationNotesPanel.js.map +1 -0
- package/dist/components/AnnotationThread.d.ts +18 -0
- package/dist/components/AnnotationThread.d.ts.map +1 -0
- package/dist/components/AnnotationThread.js +163 -0
- package/dist/components/AnnotationThread.js.map +1 -0
- package/dist/components/AnnotationToolbar.d.ts +39 -0
- package/dist/components/AnnotationToolbar.d.ts.map +1 -0
- package/dist/components/AnnotationToolbar.js +258 -0
- package/dist/components/AnnotationToolbar.js.map +1 -0
- package/dist/components/BoxOverlay.d.ts +20 -0
- package/dist/components/BoxOverlay.d.ts.map +1 -0
- package/dist/components/BoxOverlay.js +107 -0
- package/dist/components/BoxOverlay.js.map +1 -0
- package/dist/components/ColorPickerTool.d.ts +11 -0
- package/dist/components/ColorPickerTool.d.ts.map +1 -0
- package/dist/components/ColorPickerTool.js +220 -0
- package/dist/components/ColorPickerTool.js.map +1 -0
- package/dist/components/DensitometerTool.d.ts +25 -0
- package/dist/components/DensitometerTool.d.ts.map +1 -0
- package/dist/components/DensitometerTool.js +246 -0
- package/dist/components/DensitometerTool.js.map +1 -0
- package/dist/components/DielineInfoPanel.d.ts +27 -0
- package/dist/components/DielineInfoPanel.d.ts.map +1 -0
- package/dist/components/DielineInfoPanel.js +23 -0
- package/dist/components/DielineInfoPanel.js.map +1 -0
- package/dist/components/DielineOverlay.d.ts +10 -0
- package/dist/components/DielineOverlay.d.ts.map +1 -0
- package/dist/components/DielineOverlay.js +57 -0
- package/dist/components/DielineOverlay.js.map +1 -0
- package/dist/components/FindingsSidebar.d.ts +50 -0
- package/dist/components/FindingsSidebar.d.ts.map +1 -0
- package/dist/components/FindingsSidebar.js +78 -0
- package/dist/components/FindingsSidebar.js.map +1 -0
- package/dist/components/LayerCanvas.d.ts +30 -0
- package/dist/components/LayerCanvas.d.ts.map +1 -0
- package/dist/components/LayerCanvas.js +84 -0
- package/dist/components/LayerCanvas.js.map +1 -0
- package/dist/components/LayerPanel.d.ts +9 -0
- package/dist/components/LayerPanel.d.ts.map +1 -0
- package/dist/components/LayerPanel.js +144 -0
- package/dist/components/LayerPanel.js.map +1 -0
- package/dist/components/LensPDF.d.ts +61 -0
- package/dist/components/LensPDF.d.ts.map +1 -0
- package/dist/components/LensPDF.js +49 -0
- package/dist/components/LensPDF.js.map +1 -0
- package/dist/components/LensPDFDemo.d.ts +160 -0
- package/dist/components/LensPDFDemo.d.ts.map +1 -0
- package/dist/components/LensPDFDemo.js +1060 -0
- package/dist/components/LensPDFDemo.js.map +1 -0
- package/dist/components/LensPDFDemo.styles.d.ts +38 -0
- package/dist/components/LensPDFDemo.styles.d.ts.map +1 -0
- package/dist/components/LensPDFDemo.styles.js +282 -0
- package/dist/components/LensPDFDemo.styles.js.map +1 -0
- package/dist/components/LensPDFViewer.d.ts +79 -0
- package/dist/components/LensPDFViewer.d.ts.map +1 -0
- package/dist/components/LensPDFViewer.js +254 -0
- package/dist/components/LensPDFViewer.js.map +1 -0
- package/dist/components/MeasureTool.d.ts +16 -0
- package/dist/components/MeasureTool.d.ts.map +1 -0
- package/dist/components/MeasureTool.js +137 -0
- package/dist/components/MeasureTool.js.map +1 -0
- package/dist/components/MobileBottomSheet.d.ts +12 -0
- package/dist/components/MobileBottomSheet.d.ts.map +1 -0
- package/dist/components/MobileBottomSheet.js +113 -0
- package/dist/components/MobileBottomSheet.js.map +1 -0
- package/dist/components/MobileDrawer.d.ts +31 -0
- package/dist/components/MobileDrawer.d.ts.map +1 -0
- package/dist/components/MobileDrawer.js +67 -0
- package/dist/components/MobileDrawer.js.map +1 -0
- package/dist/components/PageCanvas.d.ts +33 -0
- package/dist/components/PageCanvas.d.ts.map +1 -0
- package/dist/components/PageCanvas.js +385 -0
- package/dist/components/PageCanvas.js.map +1 -0
- package/dist/components/PageNavigator.d.ts +18 -0
- package/dist/components/PageNavigator.d.ts.map +1 -0
- package/dist/components/PageNavigator.js +44 -0
- package/dist/components/PageNavigator.js.map +1 -0
- package/dist/components/SeparationCanvas.d.ts +12 -0
- package/dist/components/SeparationCanvas.d.ts.map +1 -0
- package/dist/components/SeparationCanvas.js +174 -0
- package/dist/components/SeparationCanvas.js.map +1 -0
- package/dist/components/TACHeatmapOverlay.d.ts +17 -0
- package/dist/components/TACHeatmapOverlay.d.ts.map +1 -0
- package/dist/components/TACHeatmapOverlay.js +119 -0
- package/dist/components/TACHeatmapOverlay.js.map +1 -0
- package/dist/components/ZoomControls.d.ts +11 -0
- package/dist/components/ZoomControls.d.ts.map +1 -0
- package/dist/components/ZoomControls.js +26 -0
- package/dist/components/ZoomControls.js.map +1 -0
- package/dist/components/defaultShellPlugins.d.ts +3 -0
- package/dist/components/defaultShellPlugins.d.ts.map +1 -0
- package/dist/components/defaultShellPlugins.js +273 -0
- package/dist/components/defaultShellPlugins.js.map +1 -0
- package/dist/components/index.d.ts +32 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +32 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/presets.d.ts +8 -0
- package/dist/components/presets.d.ts.map +1 -0
- package/dist/components/presets.js +14 -0
- package/dist/components/presets.js.map +1 -0
- package/dist/components/shellPlugins.d.ts +105 -0
- package/dist/components/shellPlugins.d.ts.map +1 -0
- package/dist/components/shellPlugins.js +52 -0
- package/dist/components/shellPlugins.js.map +1 -0
- package/dist/components/useIsMobile.d.ts +16 -0
- package/dist/components/useIsMobile.d.ts.map +1 -0
- package/dist/components/useIsMobile.js +30 -0
- package/dist/components/useIsMobile.js.map +1 -0
- package/dist/fallback-pdfjs/index.d.ts +60 -0
- package/dist/fallback-pdfjs/index.d.ts.map +1 -0
- package/dist/fallback-pdfjs/index.js +163 -0
- package/dist/fallback-pdfjs/index.js.map +1 -0
- package/dist/host/LensPDFProvider.d.ts +36 -0
- package/dist/host/LensPDFProvider.d.ts.map +1 -0
- package/dist/host/LensPDFProvider.js +12 -0
- package/dist/host/LensPDFProvider.js.map +1 -0
- package/dist/host/index.d.ts +167 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +173 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/pdfFallback.d.ts +50 -0
- package/dist/host/pdfFallback.d.ts.map +1 -0
- package/dist/host/pdfFallback.js +171 -0
- package/dist/host/pdfFallback.js.map +1 -0
- package/dist/host/pdfValidation.d.ts +45 -0
- package/dist/host/pdfValidation.d.ts.map +1 -0
- package/dist/host/pdfValidation.js +78 -0
- package/dist/host/pdfValidation.js.map +1 -0
- package/dist/host/shareLink.d.ts +80 -0
- package/dist/host/shareLink.d.ts.map +1 -0
- package/dist/host/shareLink.js +114 -0
- package/dist/host/shareLink.js.map +1 -0
- package/dist/host/useLensPDF.d.ts +73 -0
- package/dist/host/useLensPDF.d.ts.map +1 -0
- package/dist/host/useLensPDF.js +213 -0
- package/dist/host/useLensPDF.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/context.d.ts +70 -0
- package/dist/plugin/context.d.ts.map +1 -0
- package/dist/plugin/context.js +16 -0
- package/dist/plugin/context.js.map +1 -0
- package/dist/plugin/findings-location.d.ts +53 -0
- package/dist/plugin/findings-location.d.ts.map +1 -0
- package/dist/plugin/findings-location.js +72 -0
- package/dist/plugin/findings-location.js.map +1 -0
- package/dist/plugin/index.d.ts +19 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +16 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/registry.d.ts +61 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/registry.js +102 -0
- package/dist/plugin/registry.js.map +1 -0
- package/dist/plugin/services.d.ts +380 -0
- package/dist/plugin/services.d.ts.map +1 -0
- package/dist/plugin/services.js +104 -0
- package/dist/plugin/services.js.map +1 -0
- package/dist/plugin/types.d.ts +198 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/types.js +24 -0
- package/dist/plugin/types.js.map +1 -0
- package/dist/types/index.d.ts +191 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +95 -0
- package/dist/types/index.js.map +1 -0
- package/dist/units/index.d.ts +64 -0
- package/dist/units/index.d.ts.map +1 -0
- package/dist/units/index.js +98 -0
- package/dist/units/index.js.map +1 -0
- package/docs/architecture.md +90 -0
- package/docs/components.md +569 -0
- package/docs/contributing.md +78 -0
- package/docs/fallback.md +174 -0
- package/docs/lens-pdf-viewer.md +128 -0
- package/docs/licensing.md +78 -0
- package/docs/measurement-units.md +87 -0
- package/docs/plugins.md +256 -0
- package/docs/security.md +69 -0
- package/docs/server.md +212 -0
- package/docs/services.md +210 -0
- package/docs/share-links.md +111 -0
- package/docs/theming.md +164 -0
- package/docs/validation.md +83 -0
- package/package.json +139 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viewer plugin registry — runtime registration + slot-aware lookup.
|
|
3
|
+
*
|
|
4
|
+
* Plugin packs call `register(plugin)` during module load (typically
|
|
5
|
+
* from a top-level `register.ts` the consumer imports for side
|
|
6
|
+
* effects). The viewer reads `getPluginsForSlot(slot)` at render
|
|
7
|
+
* time to find what to mount.
|
|
8
|
+
*
|
|
9
|
+
* The registry is process-wide. Apps mounting two viewer instances on
|
|
10
|
+
* the same page currently share the same plugin set; per-instance
|
|
11
|
+
* scoping is a future addition.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
import type { ViewerPlugin, ViewerSlot } from "./types";
|
|
16
|
+
/**
|
|
17
|
+
* Register a plugin. Throws on duplicate id, or on a second
|
|
18
|
+
* `replaces` claim against the same target.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare function register(plugin: ViewerPlugin): void;
|
|
23
|
+
/**
|
|
24
|
+
* Unregister a plugin by id. No-op if absent. Also clears any
|
|
25
|
+
* `replaces` claim this plugin held, freeing the target for a
|
|
26
|
+
* subsequent override.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function unregister(id: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Return every registered plugin for a slot, sorted by `order` asc
|
|
33
|
+
* (where supported by the plugin shape; defaults to insertion order).
|
|
34
|
+
*
|
|
35
|
+
* Plugins that have been overridden via another plugin's `replaces`
|
|
36
|
+
* field are filtered out — the overrider takes their place when it
|
|
37
|
+
* shares the same slot. Cross-slot overrides also remove the
|
|
38
|
+
* original from this slot (the override declares an intent to take
|
|
39
|
+
* over the named feature; rendering the replaced one alongside
|
|
40
|
+
* would defeat the override semantics).
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function getPluginsForSlot<S extends ViewerSlot>(slot: S): Array<Extract<ViewerPlugin, {
|
|
45
|
+
slot: S;
|
|
46
|
+
}>>;
|
|
47
|
+
/**
|
|
48
|
+
* Snapshot of every registered plugin (mainly for tests / debugging).
|
|
49
|
+
* Includes plugins that have been overridden — `getPluginsForSlot`
|
|
50
|
+
* filters those out, but they remain in the registry.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function listAll(): ReadonlyArray<ViewerPlugin>;
|
|
55
|
+
/**
|
|
56
|
+
* Reset the registry. **Test-only.** Production code never calls this.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function _resetRegistryForTesting(): void;
|
|
61
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../plugin/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAOxD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAkBnD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAM3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,UAAU,EACpD,IAAI,EAAE,CAAC,GACN,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC,CAa3C;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,aAAa,CAAC,YAAY,CAAC,CAErD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viewer plugin registry — runtime registration + slot-aware lookup.
|
|
3
|
+
*
|
|
4
|
+
* Plugin packs call `register(plugin)` during module load (typically
|
|
5
|
+
* from a top-level `register.ts` the consumer imports for side
|
|
6
|
+
* effects). The viewer reads `getPluginsForSlot(slot)` at render
|
|
7
|
+
* time to find what to mount.
|
|
8
|
+
*
|
|
9
|
+
* The registry is process-wide. Apps mounting two viewer instances on
|
|
10
|
+
* the same page currently share the same plugin set; per-instance
|
|
11
|
+
* scoping is a future addition.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
const _registry = new Map();
|
|
16
|
+
// id-of-target → id-of-overrider. When `replaces` is set on a
|
|
17
|
+
// registered plugin, that plugin shadows the target in slot lookups.
|
|
18
|
+
const _overrides = new Map();
|
|
19
|
+
/**
|
|
20
|
+
* Register a plugin. Throws on duplicate id, or on a second
|
|
21
|
+
* `replaces` claim against the same target.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export function register(plugin) {
|
|
26
|
+
if (_registry.has(plugin.id)) {
|
|
27
|
+
throw new Error(`viewer plugin already registered: ${plugin.id} ` +
|
|
28
|
+
`(version ${_registry.get(plugin.id)?.version})`);
|
|
29
|
+
}
|
|
30
|
+
if (plugin.replaces !== undefined) {
|
|
31
|
+
const claimer = _overrides.get(plugin.replaces);
|
|
32
|
+
if (claimer !== undefined) {
|
|
33
|
+
throw new Error(`viewer plugin override conflict: '${plugin.id}' tried to ` +
|
|
34
|
+
`replace '${plugin.replaces}', but '${claimer}' already does`);
|
|
35
|
+
}
|
|
36
|
+
_overrides.set(plugin.replaces, plugin.id);
|
|
37
|
+
}
|
|
38
|
+
_registry.set(plugin.id, plugin);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Unregister a plugin by id. No-op if absent. Also clears any
|
|
42
|
+
* `replaces` claim this plugin held, freeing the target for a
|
|
43
|
+
* subsequent override.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export function unregister(id) {
|
|
48
|
+
const plugin = _registry.get(id);
|
|
49
|
+
if (plugin?.replaces !== undefined) {
|
|
50
|
+
_overrides.delete(plugin.replaces);
|
|
51
|
+
}
|
|
52
|
+
_registry.delete(id);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Return every registered plugin for a slot, sorted by `order` asc
|
|
56
|
+
* (where supported by the plugin shape; defaults to insertion order).
|
|
57
|
+
*
|
|
58
|
+
* Plugins that have been overridden via another plugin's `replaces`
|
|
59
|
+
* field are filtered out — the overrider takes their place when it
|
|
60
|
+
* shares the same slot. Cross-slot overrides also remove the
|
|
61
|
+
* original from this slot (the override declares an intent to take
|
|
62
|
+
* over the named feature; rendering the replaced one alongside
|
|
63
|
+
* would defeat the override semantics).
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export function getPluginsForSlot(slot) {
|
|
68
|
+
const matches = [];
|
|
69
|
+
for (const plugin of _registry.values()) {
|
|
70
|
+
if (plugin.slot !== slot)
|
|
71
|
+
continue;
|
|
72
|
+
if (_overrides.has(plugin.id))
|
|
73
|
+
continue; // someone replaces this
|
|
74
|
+
matches.push(plugin);
|
|
75
|
+
}
|
|
76
|
+
matches.sort((a, b) => {
|
|
77
|
+
const ao = "order" in a ? (a.order ?? 0) : 0;
|
|
78
|
+
const bo = "order" in b ? (b.order ?? 0) : 0;
|
|
79
|
+
return ao - bo;
|
|
80
|
+
});
|
|
81
|
+
return matches;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Snapshot of every registered plugin (mainly for tests / debugging).
|
|
85
|
+
* Includes plugins that have been overridden — `getPluginsForSlot`
|
|
86
|
+
* filters those out, but they remain in the registry.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export function listAll() {
|
|
91
|
+
return Array.from(_registry.values());
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Reset the registry. **Test-only.** Production code never calls this.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export function _resetRegistryForTesting() {
|
|
99
|
+
_registry.clear();
|
|
100
|
+
_overrides.clear();
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../plugin/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,SAAS,GAA8B,IAAI,GAAG,EAAE,CAAC;AACvD,8DAA8D;AAC9D,qEAAqE;AACrE,MAAM,UAAU,GAAwB,IAAI,GAAG,EAAE,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,qCAAqC,MAAM,CAAC,EAAE,GAAG;YAC/C,YAAY,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,CACnD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,qCAAqC,MAAM,CAAC,EAAE,aAAa;gBACzD,YAAY,MAAM,CAAC,QAAQ,WAAW,OAAO,gBAAgB,CAChE,CAAC;QACJ,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EA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AAE,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,SAAS,CAAC,KAAK,EAAE,CAAC;IAClB,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viewer services — host-supplied data-source protocols.
|
|
3
|
+
*
|
|
4
|
+
* Components reach page images, layers, separations, annotations,
|
|
5
|
+
* telemetry, i18n, and theme tokens through these protocols rather
|
|
6
|
+
* than hardcoding any backend specifics. Hosts implement the
|
|
7
|
+
* protocols their backend supports; the rest fall through to no-op
|
|
8
|
+
* defaults (see `host/index.ts`) and the consuming components
|
|
9
|
+
* self-hide.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
import type { ColorSample, DensitometerSample } from "../types";
|
|
14
|
+
/**
|
|
15
|
+
* Page-image source. Returns a URL the viewer renders into a canvas
|
|
16
|
+
* / `<img>` tag. The viewer caches results — services should not
|
|
17
|
+
* implement their own cache.
|
|
18
|
+
*
|
|
19
|
+
* URL builders are **synchronous**: hosts that need async signing
|
|
20
|
+
* pre-resolve into a redirect proxy or blob URL upstream. Returning
|
|
21
|
+
* a Promise here would force every consumer through `useEffect` +
|
|
22
|
+
* state, which doesn't fit the `<img src={url}>` rendering pattern.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export interface PageImageService {
|
|
27
|
+
/**
|
|
28
|
+
* Standard page-tile URL. The host resolves whatever path /
|
|
29
|
+
* blob / signed URL is appropriate.
|
|
30
|
+
*/
|
|
31
|
+
getPageImageUrl(args: {
|
|
32
|
+
pageNum: number;
|
|
33
|
+
/** Render DPI; viewer asks for the DPI it needs. */
|
|
34
|
+
dpi: number;
|
|
35
|
+
}): string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* PDF Optional Content Group (OCG / "layer") source.
|
|
39
|
+
*
|
|
40
|
+
* Hosts that don't expose layers should leave the no-op default
|
|
41
|
+
* (returns no layers); the `LayerPanel` then renders an empty-
|
|
42
|
+
* state placeholder.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export interface LayerService {
|
|
47
|
+
/**
|
|
48
|
+
* Synchronous URL for an isolated layer image. The host renders
|
|
49
|
+
* one PNG per OCG with a transparent background; the viewer
|
|
50
|
+
* composites the active subset locally.
|
|
51
|
+
*/
|
|
52
|
+
getLayerImageUrl(args: {
|
|
53
|
+
pageNum: number;
|
|
54
|
+
layerIndex: number;
|
|
55
|
+
dpi: number;
|
|
56
|
+
}): string;
|
|
57
|
+
/** List the OCGs available for the current document. */
|
|
58
|
+
listLayers(): Promise<ReadonlyArray<{
|
|
59
|
+
name: string;
|
|
60
|
+
ocg_index: number;
|
|
61
|
+
default_on: boolean;
|
|
62
|
+
}>>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Per-channel separation source. Hosts that don't expose ink
|
|
66
|
+
* separations leave the no-op default (returns an empty URL); the
|
|
67
|
+
* SeparationCanvas renders blank stock for any unrenderable channel.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export interface SeparationService {
|
|
72
|
+
/**
|
|
73
|
+
* Synchronous URL for an isolated channel image (one PNG per ink
|
|
74
|
+
* with a transparent background). Channel name is process-ink
|
|
75
|
+
* (`"Cyan"`, `"Magenta"`, `"Yellow"`, `"Black"`) or a spot ink
|
|
76
|
+
* (`"Pantone Reflex Blue C"`, etc.). The host is responsible for
|
|
77
|
+
* percent-encoding the channel name in whatever URL it returns.
|
|
78
|
+
*/
|
|
79
|
+
getChannelImageUrl(args: {
|
|
80
|
+
pageNum: number;
|
|
81
|
+
channelName: string;
|
|
82
|
+
dpi: number;
|
|
83
|
+
}): string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Total-Area-Coverage heatmap source. Hosts that don't compute a
|
|
87
|
+
* TAC heatmap leave the no-op default (URL returns empty, runs
|
|
88
|
+
* resolves to []); the overlay renders nothing in that case.
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export interface TACHeatmapService {
|
|
93
|
+
/** Synchronous URL for the heatmap image (per-pixel RGBA tint). */
|
|
94
|
+
getHeatmapImageUrl(args: {
|
|
95
|
+
pageNum: number;
|
|
96
|
+
dpi: number;
|
|
97
|
+
tacLimit: number;
|
|
98
|
+
}): string;
|
|
99
|
+
/**
|
|
100
|
+
* Per-text-run TAC readings used to drive the hover-tooltip layer.
|
|
101
|
+
* Coordinates are PDF points with origin at the **top-left** of the
|
|
102
|
+
* page (matches poppler's ``pdftotext -bbox`` output).
|
|
103
|
+
*/
|
|
104
|
+
listRuns(args: {
|
|
105
|
+
pageNum: number;
|
|
106
|
+
dpi: number;
|
|
107
|
+
tacLimit: number;
|
|
108
|
+
}): Promise<ReadonlyArray<{
|
|
109
|
+
x0: number;
|
|
110
|
+
y0: number;
|
|
111
|
+
x1: number;
|
|
112
|
+
y1: number;
|
|
113
|
+
mean_tac: number;
|
|
114
|
+
limit: number;
|
|
115
|
+
exceeds: boolean;
|
|
116
|
+
}>>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Color-sampler source — picks the rendered colour at a single PDF
|
|
120
|
+
* point and returns RGB + hex + total area coverage. Hosts that
|
|
121
|
+
* don't expose colour sampling leave the no-op default (returns
|
|
122
|
+
* `null`); the `ColorPickerTool` then shows nothing.
|
|
123
|
+
*
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export interface ColorSampleService {
|
|
127
|
+
/**
|
|
128
|
+
* Sample at the given PDF coordinates (origin lower-left). Returns
|
|
129
|
+
* `null` on any failure — the tool deliberately swallows errors so
|
|
130
|
+
* a flaky network doesn't push a popover with a confusing chrome
|
|
131
|
+
* fallback colour.
|
|
132
|
+
*/
|
|
133
|
+
sampleAt(args: {
|
|
134
|
+
pageNum: number;
|
|
135
|
+
pdfX: number;
|
|
136
|
+
pdfY: number;
|
|
137
|
+
/** Optional render DPI override; service decides the default. */
|
|
138
|
+
dpi?: number;
|
|
139
|
+
}): Promise<ColorSample | null>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Densitometer source — reads ink-channel percentages + Total Area
|
|
143
|
+
* Coverage at a PDF point. Hosts that can't split ink channels
|
|
144
|
+
* (RGB-only documents, no Ghostscript) leave the no-op default —
|
|
145
|
+
* `sampleAt` then throws a `"No separations"` error so the tool
|
|
146
|
+
* renders its friendly amber banner.
|
|
147
|
+
*
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
export interface DensitometerService {
|
|
151
|
+
/**
|
|
152
|
+
* Sample at the given PDF coordinates. On success returns the
|
|
153
|
+
* ink-channel readings + TAC. On failure throws an `Error` with
|
|
154
|
+
* a short user-facing message — the tool surfaces `.message`
|
|
155
|
+
* verbatim in its readout panel. Distinct error paths a typical
|
|
156
|
+
* server-side implementation produces:
|
|
157
|
+
* - "No separations available for this page." — backend signals
|
|
158
|
+
* the page can't be split (e.g. RGB-only document, no CMYK)
|
|
159
|
+
* - "Sampling failed (NNN)" — backend non-2xx other than the
|
|
160
|
+
* "no separations" case
|
|
161
|
+
* - "Network error" — fetch rejected
|
|
162
|
+
*/
|
|
163
|
+
sampleAt(args: {
|
|
164
|
+
pageNum: number;
|
|
165
|
+
pdfX: number;
|
|
166
|
+
pdfY: number;
|
|
167
|
+
/** Optional render DPI override; service decides the default. */
|
|
168
|
+
dpi?: number;
|
|
169
|
+
tacLimit: number;
|
|
170
|
+
}): Promise<DensitometerSample>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* One annotation record exposed by `AnnotationService.list()` and
|
|
174
|
+
* `getForPage()`. `fabricJson` is the serialised Fabric.js canvas
|
|
175
|
+
* snapshot — opaque to `core/`, only the host + the canvas component
|
|
176
|
+
* inspect it.
|
|
177
|
+
*
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
export interface AnnotationEntry {
|
|
181
|
+
id: string;
|
|
182
|
+
jobId: string;
|
|
183
|
+
pageNum: number;
|
|
184
|
+
authorEmail: string;
|
|
185
|
+
authorName: string | null;
|
|
186
|
+
createdAt: string;
|
|
187
|
+
updatedAt: string;
|
|
188
|
+
fabricJson?: unknown;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Annotation source. Phase-2 shape replaces the speculative
|
|
192
|
+
* `list/create/update/remove` Protocol with concrete methods that
|
|
193
|
+
* match actual call sites: per-page upsert (canvas autosave),
|
|
194
|
+
* per-page load (canvas init), full list (sidebar thread), delete by
|
|
195
|
+
* id (sidebar thread).
|
|
196
|
+
*
|
|
197
|
+
* Hosts that don't expose annotations leave the no-op default
|
|
198
|
+
* (returns empty list / null). The `<AnnotationCanvas>` and
|
|
199
|
+
* `<AnnotationThread>` components both gracefully render their
|
|
200
|
+
* empty states.
|
|
201
|
+
*
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export interface AnnotationService {
|
|
205
|
+
/** List every annotation for the current job (every page, every author). */
|
|
206
|
+
list(): Promise<ReadonlyArray<AnnotationEntry>>;
|
|
207
|
+
/**
|
|
208
|
+
* Load the active author's saved drawing for one page. Returns
|
|
209
|
+
* `null` when nothing is saved yet (or the author isn't logged in).
|
|
210
|
+
*/
|
|
211
|
+
getForPage(pageNum: number): Promise<AnnotationEntry | null>;
|
|
212
|
+
/**
|
|
213
|
+
* Upsert the active author's drawing for one page. Best-effort —
|
|
214
|
+
* implementations should swallow network errors so flaky
|
|
215
|
+
* connectivity doesn't block the user from continuing to draw.
|
|
216
|
+
*/
|
|
217
|
+
saveForPage(pageNum: number, fabricJson: unknown): Promise<void>;
|
|
218
|
+
/** Delete a single annotation by id. */
|
|
219
|
+
remove(id: string): Promise<void>;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Report-export source — supplies the URLs the drawer / toolbar
|
|
223
|
+
* link to for the HTML report viewer and PDF download. Hosts that
|
|
224
|
+
* don't expose report exports leave the no-op default (returns
|
|
225
|
+
* empty strings); the consuming menu items render but their links
|
|
226
|
+
* resolve to the current page (still inert).
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export interface ReportsService {
|
|
231
|
+
/** URL the "View HTML Report" link points at. */
|
|
232
|
+
getHtmlReportUrl(): string;
|
|
233
|
+
/** URL the "Download PDF" link points at. */
|
|
234
|
+
getPdfDownloadUrl(): string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Telemetry / analytics. No-op default keeps OSS hosts fast.
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
export interface TelemetryService {
|
|
242
|
+
track(event: string, properties?: Record<string, unknown>): void;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Internationalisation. No-op default returns the key unchanged.
|
|
246
|
+
*
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
export interface I18nService {
|
|
250
|
+
t(key: string, params?: Record<string, string | number>): string;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Optional in-browser fallback that pulls "minimum data" directly from
|
|
254
|
+
* a raw PDF blob when a host hasn't wired a richer service. Hosts that
|
|
255
|
+
* supply this — typically by calling ``createPdfJsFallback(pdfUrl)``
|
|
256
|
+
* exported from ``@printwithsynergy/lens-pdf/host`` — let the viewer
|
|
257
|
+
* keep tools like PageCanvas, PageNavigator, MeasureTool, LayerPanel,
|
|
258
|
+
* and ColorPickerTool functional without a server backend.
|
|
259
|
+
*
|
|
260
|
+
* **Capabilities not covered**: true ink separations (CMYK/spot
|
|
261
|
+
* channels), TAC heatmaps, and the densitometer all require server-
|
|
262
|
+
* side rendering (Ghostscript/MuPDF). pdf.js only renders to RGB, so
|
|
263
|
+
* those tools stay hidden when their dedicated services are unwired.
|
|
264
|
+
*
|
|
265
|
+
* Every method returns a Promise so the adapter can lazy-load pdf.js
|
|
266
|
+
* on first use. ``sampleColorAt`` returns ``null`` on failure to match
|
|
267
|
+
* the {@link ColorSampleService} contract.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export interface PdfFallbackAdapter {
|
|
272
|
+
getPageCount(): Promise<number>;
|
|
273
|
+
getPageDimensions(pageNum: number): Promise<{
|
|
274
|
+
widthPts: number;
|
|
275
|
+
heightPts: number;
|
|
276
|
+
}>;
|
|
277
|
+
renderPageToUrl(args: {
|
|
278
|
+
pageNum: number;
|
|
279
|
+
dpi: number;
|
|
280
|
+
}): Promise<string>;
|
|
281
|
+
listLayers(): Promise<ReadonlyArray<{
|
|
282
|
+
name: string;
|
|
283
|
+
ocg_index: number;
|
|
284
|
+
default_on: boolean;
|
|
285
|
+
}>>;
|
|
286
|
+
sampleColorAt(args: {
|
|
287
|
+
pageNum: number;
|
|
288
|
+
pdfX: number;
|
|
289
|
+
pdfY: number;
|
|
290
|
+
dpi?: number;
|
|
291
|
+
}): Promise<ColorSample | null>;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Theme tokens. Plugins that need brand colours read them from here
|
|
295
|
+
* rather than hardcoding hex strings. The optional `logo*` fields let
|
|
296
|
+
* a host bundle its full visual identity (colours + logo + label) into
|
|
297
|
+
* a single object — `<LensPDFDemo>` reads them as a fallback when the
|
|
298
|
+
* equivalent props (`brand`, `brandLogoUrl`) are not set.
|
|
299
|
+
*
|
|
300
|
+
* @public
|
|
301
|
+
*/
|
|
302
|
+
export interface ThemeTokens {
|
|
303
|
+
readonly primary: string;
|
|
304
|
+
readonly accent: string;
|
|
305
|
+
readonly bg: string;
|
|
306
|
+
readonly fg: string;
|
|
307
|
+
readonly border: string;
|
|
308
|
+
/** Optional brand logo image URL shown in the demo top bar. Any URL the browser can fetch — PNG / SVG / `data:` URI. */
|
|
309
|
+
readonly logoUrl?: string;
|
|
310
|
+
/** Optional brand label shown next to the logo. Mirrors the `brand` prop on `<LensPDFDemo>`. Default: `"LensPDF"`. */
|
|
311
|
+
readonly logoText?: string;
|
|
312
|
+
/** Optional pixel cap on the rendered logo height. Width is auto so non-square logos keep their aspect ratio. Default: 24. */
|
|
313
|
+
readonly logoMaxHeight?: number;
|
|
314
|
+
/** Optional alt text for the logo `<img>`. When omitted, the logo is `aria-hidden` and `logoText` carries the meaning. */
|
|
315
|
+
readonly logoAlt?: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Aggregate service surface exposed via `ViewerContext.services`.
|
|
319
|
+
*
|
|
320
|
+
* @public
|
|
321
|
+
*/
|
|
322
|
+
export interface ViewerServices {
|
|
323
|
+
readonly pageImages: PageImageService;
|
|
324
|
+
readonly layers: LayerService;
|
|
325
|
+
readonly separations: SeparationService;
|
|
326
|
+
readonly tacHeatmap: TACHeatmapService;
|
|
327
|
+
readonly colorSample: ColorSampleService;
|
|
328
|
+
readonly densitometer: DensitometerService;
|
|
329
|
+
readonly annotations: AnnotationService;
|
|
330
|
+
readonly reports: ReportsService;
|
|
331
|
+
readonly telemetry: TelemetryService;
|
|
332
|
+
readonly i18n: I18nService;
|
|
333
|
+
readonly tokens: ThemeTokens;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Telemetry stub — drops every event on the floor.
|
|
337
|
+
*
|
|
338
|
+
* @public
|
|
339
|
+
*/
|
|
340
|
+
export declare const noopTelemetry: TelemetryService;
|
|
341
|
+
/**
|
|
342
|
+
* I18n stub — returns the key unchanged. Suitable for English-only
|
|
343
|
+
* environments and tests.
|
|
344
|
+
*
|
|
345
|
+
* @public
|
|
346
|
+
*/
|
|
347
|
+
export declare const noopI18n: I18nService;
|
|
348
|
+
/**
|
|
349
|
+
* Default theme tokens — neutral light palette. Hosts typically
|
|
350
|
+
* override these with their tenant or product branding.
|
|
351
|
+
*
|
|
352
|
+
* @public
|
|
353
|
+
*/
|
|
354
|
+
export declare const defaultThemeTokens: ThemeTokens;
|
|
355
|
+
/**
|
|
356
|
+
* Dark theme tokens — dark-mode palette. Drop-in alternative to
|
|
357
|
+
* {@link defaultThemeTokens} for hosts that want a dark chrome.
|
|
358
|
+
*
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
export declare const darkThemeTokens: ThemeTokens;
|
|
362
|
+
/**
|
|
363
|
+
* Tag a service object as a no-op default. Hosts almost never call
|
|
364
|
+
* this — it's used internally by ``defaultViewerServices`` and
|
|
365
|
+
* exposed only so unit tests / advanced hosts can simulate the
|
|
366
|
+
* unwired state.
|
|
367
|
+
*
|
|
368
|
+
* @public
|
|
369
|
+
*/
|
|
370
|
+
export declare function markUnwired<T extends object>(service: T): T;
|
|
371
|
+
/**
|
|
372
|
+
* Returns ``true`` when the given service is the no-op default — i.e.
|
|
373
|
+
* the host did not wire a real implementation. Components call this
|
|
374
|
+
* to decide between hiding themselves (unwired) and rendering an
|
|
375
|
+
* empty state (wired but returned no data).
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
379
|
+
export declare function isUnwired(service: object | null | undefined): boolean;
|
|
380
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../plugin/services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,oDAAoD;QACpD,GAAG,EAAE,MAAM,CAAC;KACb,GAAG,MAAM,CAAC;CACZ;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,gBAAgB,CAAC,IAAI,EAAE;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU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B,CAAC;AAeF;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAQ3D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAGrE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viewer services — host-supplied data-source protocols.
|
|
3
|
+
*
|
|
4
|
+
* Components reach page images, layers, separations, annotations,
|
|
5
|
+
* telemetry, i18n, and theme tokens through these protocols rather
|
|
6
|
+
* than hardcoding any backend specifics. Hosts implement the
|
|
7
|
+
* protocols their backend supports; the rest fall through to no-op
|
|
8
|
+
* defaults (see `host/index.ts`) and the consuming components
|
|
9
|
+
* self-hide.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// No-op stubs (used by OSS hosts and tests)
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Telemetry stub — drops every event on the floor.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export const noopTelemetry = {
|
|
22
|
+
track: () => { },
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* I18n stub — returns the key unchanged. Suitable for English-only
|
|
26
|
+
* environments and tests.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const noopI18n = {
|
|
31
|
+
t: (key, params) => {
|
|
32
|
+
if (!params)
|
|
33
|
+
return key;
|
|
34
|
+
return Object.entries(params).reduce((acc, [k, v]) => acc.replaceAll(`{${k}}`, String(v)), key);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Default theme tokens — neutral light palette. Hosts typically
|
|
39
|
+
* override these with their tenant or product branding.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export const defaultThemeTokens = {
|
|
44
|
+
primary: "#0f172a",
|
|
45
|
+
accent: "#3b82f6",
|
|
46
|
+
bg: "#ffffff",
|
|
47
|
+
fg: "#0f172a",
|
|
48
|
+
border: "#e2e8f0",
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Dark theme tokens — dark-mode palette. Drop-in alternative to
|
|
52
|
+
* {@link defaultThemeTokens} for hosts that want a dark chrome.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export const darkThemeTokens = {
|
|
57
|
+
primary: "#0f172a",
|
|
58
|
+
accent: "#3b82f6",
|
|
59
|
+
bg: "#0e0a14",
|
|
60
|
+
fg: "#f5f3f7",
|
|
61
|
+
border: "#2b2138",
|
|
62
|
+
};
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Capability detection
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* Non-enumerable marker tagged onto every default no-op service so
|
|
68
|
+
* components can tell "host didn't wire this" apart from "host wired
|
|
69
|
+
* something that returned no data". Components use the former to hide
|
|
70
|
+
* themselves outright; the latter still renders an empty state because
|
|
71
|
+
* the host explicitly opted in.
|
|
72
|
+
*/
|
|
73
|
+
const UNWIRED_MARKER = Symbol.for("@printwithsynergy/lens-pdf:unwired");
|
|
74
|
+
/**
|
|
75
|
+
* Tag a service object as a no-op default. Hosts almost never call
|
|
76
|
+
* this — it's used internally by ``defaultViewerServices`` and
|
|
77
|
+
* exposed only so unit tests / advanced hosts can simulate the
|
|
78
|
+
* unwired state.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export function markUnwired(service) {
|
|
83
|
+
Object.defineProperty(service, UNWIRED_MARKER, {
|
|
84
|
+
value: true,
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: false,
|
|
87
|
+
writable: false,
|
|
88
|
+
});
|
|
89
|
+
return service;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns ``true`` when the given service is the no-op default — i.e.
|
|
93
|
+
* the host did not wire a real implementation. Components call this
|
|
94
|
+
* to decide between hiding themselves (unwired) and rendering an
|
|
95
|
+
* empty state (wired but returned no data).
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export function isUnwired(service) {
|
|
100
|
+
if (!service)
|
|
101
|
+
return true;
|
|
102
|
+
return service[UNWIRED_MARKER] === true;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../plugin/services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkVH,8EAA8E;AAC9E,4CAA4C;AAC5C,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAqB;IAC7C,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAgB;IACnC,CAAC,EAAE,CAAC,GAAW,EAAE,MAAwC,EAAE,EAAE;QAC3D,IAAI,CAAC,MAAM;YAAE,OAAO,GAAG,CAAC;QACxB,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAClC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EACpD,GAAG,CACJ,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,EAAE,EAAE,SAAS;IACb,EAAE,E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