@uipath/du-utils 1.0.0-rc.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/CHANGELOG.md +26 -0
- package/LICENSE +9 -0
- package/README.md +191 -0
- package/package.json +30 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +7 -0
- package/src/index.js.map +1 -0
- package/src/lib/load-web-component.d.ts +37 -0
- package/src/lib/load-web-component.js +145 -0
- package/src/lib/load-web-component.js.map +1 -0
- package/src/lib/shared/classification-station-wc.d.ts +181 -0
- package/src/lib/shared/classification-station-wc.js +3 -0
- package/src/lib/shared/classification-station-wc.js.map +1 -0
- package/src/lib/shared/index.d.ts +4 -0
- package/src/lib/shared/index.js +8 -0
- package/src/lib/shared/index.js.map +1 -0
- package/src/lib/shared/types.d.ts +11 -0
- package/src/lib/shared/types.js +10 -0
- package/src/lib/shared/types.js.map +1 -0
- package/src/lib/shared/validation-station-wc.d.ts +487 -0
- package/src/lib/shared/validation-station-wc.js +11 -0
- package/src/lib/shared/validation-station-wc.js.map +1 -0
- package/src/lib/shared/wc-lifecycle.d.ts +84 -0
- package/src/lib/shared/wc-lifecycle.js +81 -0
- package/src/lib/shared/wc-lifecycle.js.map +1 -0
- package/src/lib/url.util.d.ts +7 -0
- package/src/lib/url.util.js +18 -0
- package/src/lib/url.util.js.map +1 -0
- package/src/lib/wc-shared-styles.d.ts +31 -0
- package/src/lib/wc-shared-styles.js +204 -0
- package/src/lib/wc-shared-styles.js.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable consumer-facing changes to `@uipath/du-utils` are documented in this file. The format
|
|
4
|
+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the package follows
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [1.0.0-rc.1] - 2026-07-24
|
|
8
|
+
|
|
9
|
+
First release candidate for `1.0.0`.
|
|
10
|
+
|
|
11
|
+
> 🚀 This is a **release candidate**. The public API (the loader functions, their options, and the
|
|
12
|
+
> web-component type contracts) is considered stable and is not expected to change before `1.0.0`.
|
|
13
|
+
> Please report any issues before the stable release.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`loadValidationStationWebComponent` / `loadClassificationStationWebComponent`** — load a DU web
|
|
18
|
+
component's assets from a deployment URL you host and register its custom element. Supports the
|
|
19
|
+
`includeFonts` option, is idempotent (loaded once per page), and normalizes trailing slashes.
|
|
20
|
+
- **`loadWebComponent`** — the lower-level primitive both loaders build on, accepting an
|
|
21
|
+
async base-URL resolver.
|
|
22
|
+
- **TypeScript contracts** for the registered custom elements — element interfaces, event maps, and
|
|
23
|
+
ambient `HTMLElementTagNameMap` / JSX augmentations so `querySelector`, `viewChild`, and JSX
|
|
24
|
+
return the correct types with no cast.
|
|
25
|
+
- **Shadow-DOM styling helpers** (`adoptWcThemeStyleSheet`, `ensureWcFontsLoaded`,
|
|
26
|
+
`setWcAssetsBaseUrl`) used by the components' own bootstrap.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2026-present UiPath
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# @uipath/du-utils
|
|
2
|
+
|
|
3
|
+
Framework-agnostic utilities for embedding the UiPath **Document Understanding** web components —
|
|
4
|
+
**Validation Station** and **Classification Station** — in any web application.
|
|
5
|
+
|
|
6
|
+
This package lets a host application load a DU web component from a **deployment URL you control**
|
|
7
|
+
(a path or origin you host the built assets on) and interact with it through strongly-typed custom
|
|
8
|
+
elements. It has no Angular/React dependency and works in plain HTML, React, Angular, or any other
|
|
9
|
+
framework.
|
|
10
|
+
|
|
11
|
+
## What's in the box
|
|
12
|
+
|
|
13
|
+
- **`loadValidationStationWebComponent` / `loadClassificationStationWebComponent`** — load a web
|
|
14
|
+
component's assets from a deployment URL and register its custom element.
|
|
15
|
+
- **TypeScript contracts** for the registered custom elements — element interfaces, event maps, and
|
|
16
|
+
ambient `HTMLElementTagNameMap` / JSX augmentations so `querySelector`, `viewChild`, and JSX all
|
|
17
|
+
return the right types.
|
|
18
|
+
- **Shadow-DOM styling helpers** used by the components' own bootstrap (advanced).
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import {
|
|
22
|
+
loadValidationStationWebComponent,
|
|
23
|
+
loadClassificationStationWebComponent,
|
|
24
|
+
type IValidationStationWcElement,
|
|
25
|
+
type IValidationStationWcEventMap,
|
|
26
|
+
} from '@uipath/du-utils';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# npm
|
|
33
|
+
npm install @uipath/du-utils
|
|
34
|
+
|
|
35
|
+
# yarn
|
|
36
|
+
yarn add @uipath/du-utils
|
|
37
|
+
|
|
38
|
+
# pnpm
|
|
39
|
+
pnpm add @uipath/du-utils
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The only runtime dependency is [`@uipath/uipath-typescript`](https://www.npmjs.com/package/@uipath/uipath-typescript)
|
|
43
|
+
(the DU SDK types the Validation Station contract is built on).
|
|
44
|
+
|
|
45
|
+
## Loading a web component
|
|
46
|
+
|
|
47
|
+
Point the loader at the URL where the web component's build artifacts are served. It injects the
|
|
48
|
+
component's `<script type="module">` files (`polyfills.js`, then `main.js`) and a `<link>` to
|
|
49
|
+
cache-warm the theme (`styles.css`), then resolves once the component's custom element is
|
|
50
|
+
registered.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { loadValidationStationWebComponent } from '@uipath/du-utils';
|
|
54
|
+
|
|
55
|
+
await loadValidationStationWebComponent(document, 'https://assets.example.com/du-vs-wc/latest');
|
|
56
|
+
|
|
57
|
+
// The custom element is now registered — create it and set its inputs.
|
|
58
|
+
const el = document.createElement('ui-du-validation-station-wc-element');
|
|
59
|
+
el.theme = 'light';
|
|
60
|
+
el.language = 'en';
|
|
61
|
+
el.platform = { organizationName: 'acme', tenantId: 't1' };
|
|
62
|
+
document.body.appendChild(el);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The deployment URL is the directory that serves the component's assets:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
https://assets.example.com/du-vs-wc/latest/
|
|
69
|
+
├── main.js
|
|
70
|
+
├── polyfills.js
|
|
71
|
+
├── styles.css (theme — preloaded, adopted into the shadow root)
|
|
72
|
+
└── fonts.css (opt-in — see `includeFonts`)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Validation Station assets are produced by the
|
|
76
|
+
[`@uipath/du-validation-station-wc`](https://www.npmjs.com/package/@uipath/du-validation-station-wc)
|
|
77
|
+
build; Classification Station assets by the corresponding Classification Station web-component build.
|
|
78
|
+
|
|
79
|
+
### Options
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
await loadValidationStationWebComponent(document, deploymentUrl, { includeFonts: true });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Option | Default | Description |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `includeFonts` | `false` | Inject a light-DOM `<link rel="stylesheet">` to the component's `fonts.css` (Apollo text fonts + Material Icons). Leave `false` when the host already loads Apollo fonts globally (e.g. Action Center, DU Center) to avoid double-loading. |
|
|
88
|
+
|
|
89
|
+
### Idempotency & caching
|
|
90
|
+
|
|
91
|
+
Each component is loaded **once per page**: the load promise is cached on `window` per component,
|
|
92
|
+
so calling the loader again returns the same promise without re-injecting scripts. A later call
|
|
93
|
+
with `{ includeFonts: true }` still injects the fonts stylesheet against the already-resolved base,
|
|
94
|
+
so opting into fonts after an initial load works.
|
|
95
|
+
|
|
96
|
+
Trailing slashes on the deployment URL are normalized, so `.../latest` and `.../latest/` behave
|
|
97
|
+
identically.
|
|
98
|
+
|
|
99
|
+
## Typed custom elements
|
|
100
|
+
|
|
101
|
+
Once a component is loaded, its custom element is available with full type support. The
|
|
102
|
+
`HTMLElementTagNameMap` and `React.JSX.IntrinsicElements` augmentations are **ambient** — they
|
|
103
|
+
apply as soon as the package is referenced, so `querySelector` / `viewChild` / JSX return the typed
|
|
104
|
+
element with no cast.
|
|
105
|
+
|
|
106
|
+
| Element tag | Interface |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `<ui-du-validation-station-wc-element>` | `IValidationStationWcElement` |
|
|
109
|
+
| `<ui-du-validation-station-wc-persistent-element>` | `IPersistentValidationStationWcElement` |
|
|
110
|
+
| `<ui-du-classification-station-wc-element>` | `IClassificationStationWcElement` |
|
|
111
|
+
|
|
112
|
+
> The **standalone** element variants ship their own type declarations in
|
|
113
|
+
> `@uipath/du-validation-station-wc` — see that package for typed consumption of those.
|
|
114
|
+
|
|
115
|
+
### React
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { useEffect, useRef } from 'react';
|
|
119
|
+
import {
|
|
120
|
+
loadValidationStationWebComponent,
|
|
121
|
+
type IValidationStationWcElement,
|
|
122
|
+
type IValidationStationWcEventMap,
|
|
123
|
+
} from '@uipath/du-utils';
|
|
124
|
+
|
|
125
|
+
function ValidationStation({ deploymentUrl }: { deploymentUrl: string }) {
|
|
126
|
+
const ref = useRef<IValidationStationWcElement | null>(null);
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
void loadValidationStationWebComponent(document, deploymentUrl);
|
|
130
|
+
}, [deploymentUrl]);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const el = ref.current;
|
|
134
|
+
if (!el) return;
|
|
135
|
+
|
|
136
|
+
el.platform = { organizationName: 'acme', tenantId: 't1' };
|
|
137
|
+
|
|
138
|
+
// addEventListener overloads give a typed `event.detail`.
|
|
139
|
+
const onSaveResult = (e: CustomEvent<IValidationStationWcEventMap['saveResult']>) =>
|
|
140
|
+
console.log('saved ok?', e.detail.success);
|
|
141
|
+
|
|
142
|
+
el.addEventListener('saveResult', onSaveResult);
|
|
143
|
+
return () => el.removeEventListener('saveResult', onSaveResult);
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
// React 19: pass inputs directly as JSX props (augmentation is automatic).
|
|
147
|
+
return <ui-du-validation-station-wc-element ref={ref} theme="light" language="en" />;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Angular
|
|
152
|
+
|
|
153
|
+
Angular passes inputs as element properties and listens to outputs as DOM events via `(eventName)`
|
|
154
|
+
binding. The `HTMLElementTagNameMap` augmentation makes `viewChild` / `querySelector` return the
|
|
155
|
+
typed element.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
import { Component, viewChild } from '@angular/core';
|
|
159
|
+
import {
|
|
160
|
+
loadValidationStationWebComponent,
|
|
161
|
+
type IValidationStationWcElement,
|
|
162
|
+
type IValidationStationWcEventMap,
|
|
163
|
+
} from '@uipath/du-utils';
|
|
164
|
+
|
|
165
|
+
@Component({
|
|
166
|
+
template: `
|
|
167
|
+
<ui-du-validation-station-wc-element
|
|
168
|
+
#vsWc
|
|
169
|
+
[theme]="theme"
|
|
170
|
+
[platform]="platform"
|
|
171
|
+
(saveResult)="onSaveResult($event)"
|
|
172
|
+
/>
|
|
173
|
+
`,
|
|
174
|
+
})
|
|
175
|
+
export class ValidationStationComponent {
|
|
176
|
+
readonly vsWc = viewChild.required<IValidationStationWcElement>('vsWc');
|
|
177
|
+
|
|
178
|
+
constructor() {
|
|
179
|
+
void loadValidationStationWebComponent(document, this.deploymentUrl);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onSaveResult(e: CustomEvent<IValidationStationWcEventMap['saveResult']>): void {
|
|
183
|
+
console.log('save ok?', e.detail.success);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The event maps (`IValidationStationWcEventMap`, `IClassificationStationWcEventMap`) map every event
|
|
189
|
+
name to the type carried in `CustomEvent.detail` — e.g. `loaded: boolean`,
|
|
190
|
+
`fieldValueChanged: IFieldValueDetailsDto`, `saveResult: ISaveResult`,
|
|
191
|
+
`actionCenterTaskComplete: number`. Import the detail types you need directly from this package.
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uipath/du-utils",
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"description": "Framework-agnostic loaders and TypeScript contracts for embedding the UiPath Document Understanding web components (Validation Station and Classification Station).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"uipath",
|
|
7
|
+
"document-understanding",
|
|
8
|
+
"validation-station",
|
|
9
|
+
"classification-station",
|
|
10
|
+
"web-component",
|
|
11
|
+
"wc",
|
|
12
|
+
"loader"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://docs.uipath.com/activities/other/latest/document-understanding/compact-validation-station",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "commonjs",
|
|
17
|
+
"main": "./src/index.js",
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"typings": "./src/index.d.ts",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@uipath/uipath-typescript": "1.5.1",
|
|
23
|
+
"tslib": "^2.7.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"registry": "https://registry.npmjs.org/",
|
|
27
|
+
"access": "public",
|
|
28
|
+
"provenance": false
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/shared"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/load-web-component"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/wc-shared-styles"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/du/shared/util/du-utils/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,mEAAyC;AACzC,iEAAuC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Options accepted by the public web-component loaders (Validation Station and Classification Station). */
|
|
2
|
+
export interface LoadWebComponentOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When true, inject a light-DOM `<link rel="stylesheet">` to the WC's `fonts.css` so the
|
|
5
|
+
* component ships its own fonts (Apollo text fonts + Material Icons). Default false —
|
|
6
|
+
* most hosts (Action Center, DU Center) already load Apollo fonts globally and would
|
|
7
|
+
* otherwise double-load them.
|
|
8
|
+
*/
|
|
9
|
+
includeFonts?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the deployment base URL for a web component. Called lazily (and at most once) per
|
|
13
|
+
* cached load, so callers that need to compute the URL asynchronously can pass a resolver instead
|
|
14
|
+
* of a ready string.
|
|
15
|
+
*/
|
|
16
|
+
export type ResolveBaseUrl = () => string | Promise<string>;
|
|
17
|
+
export declare const csAppName = "du-cs-wc";
|
|
18
|
+
export declare const vsAppName = "du-vs-wc";
|
|
19
|
+
/**
|
|
20
|
+
* Load the Classification Station web component from a deployment URL (path-loading variant).
|
|
21
|
+
* @param webComponentDeploymentUrl Base URL the WC assets (`polyfills.js`, `main.js`, `styles.css`,
|
|
22
|
+
* `fonts.css`) are served from.
|
|
23
|
+
*/
|
|
24
|
+
export declare const loadClassificationStationWebComponent: (document: Document, webComponentDeploymentUrl: string, options?: LoadWebComponentOptions) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Load the Validation Station web component from a deployment URL (path-loading variant).
|
|
27
|
+
* @param webComponentDeploymentUrl Base URL the WC assets (`polyfills.js`, `main.js`, `styles.css`,
|
|
28
|
+
* `fonts.css`) are served from.
|
|
29
|
+
*/
|
|
30
|
+
export declare const loadValidationStationWebComponent: (document: Document, webComponentDeploymentUrl: string, options?: LoadWebComponentOptions) => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Core loader: resolves the base URL, loads the WC scripts once (cached per app on `window`), and
|
|
33
|
+
* injects the id-deduped style-asset `<link>`s. The base URL can be a ready string or a (possibly
|
|
34
|
+
* async) resolver, so callers layering their own resolution reuse the same caching, script
|
|
35
|
+
* injection, and style-asset logic.
|
|
36
|
+
*/
|
|
37
|
+
export declare const loadWebComponent: (appName: string, document: Document, baseUrl: string | ResolveBaseUrl, options?: LoadWebComponentOptions) => Promise<void>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadWebComponent = exports.loadValidationStationWebComponent = exports.loadClassificationStationWebComponent = exports.vsAppName = exports.csAppName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const url_util_1 = require("./url.util");
|
|
6
|
+
const themeStylesheetFile = 'styles.css';
|
|
7
|
+
const fontsStylesheetFile = 'fonts.css';
|
|
8
|
+
const getWindowCache = () => window;
|
|
9
|
+
// Resolved deployment base per app, kept so a cached load can still (re)inject the id-deduped
|
|
10
|
+
// style-asset links (e.g. a later `includeFonts: true`) without re-resolving the base.
|
|
11
|
+
const resolvedBaseByApp = new Map();
|
|
12
|
+
exports.csAppName = 'du-cs-wc';
|
|
13
|
+
exports.vsAppName = 'du-vs-wc';
|
|
14
|
+
/**
|
|
15
|
+
* Load the Classification Station web component from a deployment URL (path-loading variant).
|
|
16
|
+
* @param webComponentDeploymentUrl Base URL the WC assets (`polyfills.js`, `main.js`, `styles.css`,
|
|
17
|
+
* `fonts.css`) are served from.
|
|
18
|
+
*/
|
|
19
|
+
const loadClassificationStationWebComponent = (document, webComponentDeploymentUrl, options) => (0, exports.loadWebComponent)(exports.csAppName, document, webComponentDeploymentUrl, options);
|
|
20
|
+
exports.loadClassificationStationWebComponent = loadClassificationStationWebComponent;
|
|
21
|
+
/**
|
|
22
|
+
* Load the Validation Station web component from a deployment URL (path-loading variant).
|
|
23
|
+
* @param webComponentDeploymentUrl Base URL the WC assets (`polyfills.js`, `main.js`, `styles.css`,
|
|
24
|
+
* `fonts.css`) are served from.
|
|
25
|
+
*/
|
|
26
|
+
const loadValidationStationWebComponent = (document, webComponentDeploymentUrl, options) => (0, exports.loadWebComponent)(exports.vsAppName, document, webComponentDeploymentUrl, options);
|
|
27
|
+
exports.loadValidationStationWebComponent = loadValidationStationWebComponent;
|
|
28
|
+
const buildStyleAssets = (options) => ({
|
|
29
|
+
// Cache-warm the theme so the shadow-root theme adopt is instant.
|
|
30
|
+
preload: [themeStylesheetFile],
|
|
31
|
+
// Fonts are opt-in — most hosts already load Apollo fonts globally.
|
|
32
|
+
stylesheets: (options === null || options === void 0 ? void 0 : options.includeFonts) ? [fontsStylesheetFile] : [],
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Core loader: resolves the base URL, loads the WC scripts once (cached per app on `window`), and
|
|
36
|
+
* injects the id-deduped style-asset `<link>`s. The base URL can be a ready string or a (possibly
|
|
37
|
+
* async) resolver, so callers layering their own resolution reuse the same caching, script
|
|
38
|
+
* injection, and style-asset logic.
|
|
39
|
+
*/
|
|
40
|
+
const loadWebComponent = (appName, document, baseUrl, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const styleAssets = buildStyleAssets(options);
|
|
42
|
+
const promiseId = `fe-du-wc-script-load-${appName}`;
|
|
43
|
+
const existing = getWindowCache()[promiseId];
|
|
44
|
+
if (existing) {
|
|
45
|
+
// Scripts are loaded once (cached), but the head <link>s (theme preload + opt-in fonts)
|
|
46
|
+
// are id-deduped and may be newly requested on a later call — e.g. `includeFonts: true`
|
|
47
|
+
// after an earlier load without it. Re-apply them against the resolved base so they
|
|
48
|
+
// aren't silently dropped.
|
|
49
|
+
const resolvedBase = resolvedBaseByApp.get(appName);
|
|
50
|
+
if (resolvedBase) {
|
|
51
|
+
injectStyleAssets(document, `${appName}-script`, resolvedBase, styleAssets);
|
|
52
|
+
}
|
|
53
|
+
return existing;
|
|
54
|
+
}
|
|
55
|
+
const result = loadWebComponentPromise(appName, document, baseUrl, styleAssets);
|
|
56
|
+
getWindowCache()[promiseId] = result;
|
|
57
|
+
try {
|
|
58
|
+
yield result;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
delete getWindowCache()[promiseId];
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
exports.loadWebComponent = loadWebComponent;
|
|
66
|
+
const loadWebComponentPromise = (appName, document, baseUrl, styleAssets) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
// Normalize once (strip any trailing slash) so concatenating `/${file}` for scripts, the
|
|
68
|
+
// theme preload, and fonts never produces `//` — which can cause asset 404s or cache misses.
|
|
69
|
+
const resolved = typeof baseUrl === 'function' ? yield baseUrl() : baseUrl;
|
|
70
|
+
const normalizedBaseUrl = (0, url_util_1.stripTrailingSlashes)(resolved);
|
|
71
|
+
resolvedBaseByApp.set(appName, normalizedBaseUrl);
|
|
72
|
+
const urls = buildWCUrls(normalizedBaseUrl);
|
|
73
|
+
const scriptId = `${appName}-script`;
|
|
74
|
+
const scriptsPromise = loadDUWCScripts(document, scriptId, urls.polyfills, urls.main);
|
|
75
|
+
injectStyleAssets(document, scriptId, normalizedBaseUrl, styleAssets);
|
|
76
|
+
return scriptsPromise;
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Inject the WC's extra stylesheet `<link>`s into `<head>`: a `preload` (cache-warm for the
|
|
80
|
+
* shadow-root adopt fetch) and any opt-in `stylesheet` links (e.g. fonts). Each link is keyed
|
|
81
|
+
* by a stable id so repeat calls don't duplicate it.
|
|
82
|
+
*/
|
|
83
|
+
const injectStyleAssets = (document, scriptId, baseUrl, styleAssets) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
if (!styleAssets) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
for (const file of (_a = styleAssets.preload) !== null && _a !== void 0 ? _a : []) {
|
|
89
|
+
appendHeadLink(document, `${scriptId}_preload_${file}`, link => {
|
|
90
|
+
link.rel = 'preload';
|
|
91
|
+
link.as = 'fetch';
|
|
92
|
+
link.crossOrigin = 'anonymous';
|
|
93
|
+
link.href = `${baseUrl}/${file}`;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
for (const file of (_b = styleAssets.stylesheets) !== null && _b !== void 0 ? _b : []) {
|
|
97
|
+
appendHeadLink(document, `${scriptId}_style_${file}`, link => {
|
|
98
|
+
link.rel = 'stylesheet';
|
|
99
|
+
link.href = `${baseUrl}/${file}`;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const appendHeadLink = (document, id, configure) => {
|
|
104
|
+
if (document.getElementById(id)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const link = document.createElement('link');
|
|
108
|
+
link.id = id;
|
|
109
|
+
configure(link);
|
|
110
|
+
document.head.appendChild(link);
|
|
111
|
+
};
|
|
112
|
+
const loadDUWCScripts = (document, scriptId, polyfills, main) => new Promise((resolve, reject) => {
|
|
113
|
+
const loadMainScript = () => {
|
|
114
|
+
if (document.getElementById(scriptId)) {
|
|
115
|
+
resolve();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const script = document.createElement('script');
|
|
119
|
+
script.id = scriptId;
|
|
120
|
+
script.type = 'module';
|
|
121
|
+
script.async = true;
|
|
122
|
+
script.src = main;
|
|
123
|
+
script.addEventListener('load', () => resolve(), { once: true });
|
|
124
|
+
script.addEventListener('error', () => reject(new Error(`Failed to load script: ${main}`)), { once: true });
|
|
125
|
+
document.head.appendChild(script);
|
|
126
|
+
};
|
|
127
|
+
const polyfillsScriptId = scriptId + '_polyfills';
|
|
128
|
+
if (polyfills && !document.getElementById(polyfillsScriptId)) {
|
|
129
|
+
const polyfillsScript = document.createElement('script');
|
|
130
|
+
polyfillsScript.id = polyfillsScriptId;
|
|
131
|
+
polyfillsScript.type = 'module';
|
|
132
|
+
polyfillsScript.src = polyfills;
|
|
133
|
+
polyfillsScript.addEventListener('load', () => loadMainScript(), { once: true });
|
|
134
|
+
polyfillsScript.addEventListener('error', () => reject(new Error(`Failed to load polyfills script: ${polyfills}`)), { once: true });
|
|
135
|
+
document.head.appendChild(polyfillsScript);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
loadMainScript();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const buildWCUrls = (baseUrl) => ({
|
|
142
|
+
polyfills: `${baseUrl}/polyfills.js`,
|
|
143
|
+
main: `${baseUrl}/main.js`,
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=load-web-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-web-component.js","sourceRoot":"","sources":["../../../../../../../../libs/du/shared/util/du-utils/src/lib/load-web-component.ts"],"names":[],"mappings":";;;;AAAA,yCAAkD;AAiClD,MAAM,mBAAmB,GAAG,YAAY,CAAC;AACzC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAExC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,MAAwC,CAAC;AAEtE,8FAA8F;AAC9F,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEvC,QAAA,SAAS,GAAG,UAAU,CAAC;AACvB,QAAA,SAAS,GAAG,UAAU,CAAC;AAEpC;;;;GAIG;AACI,MAAM,qCAAqC,GAAG,CACjD,QAAkB,EAClB,yBAAiC,EACjC,OAAiC,EACpB,EAAE,CACf,IAAA,wBAAgB,EAAC,iBAAS,EAAE,QAAQ,EAAE,yBAAyB,EAAE,OAAO,CAAC,CAAC;AALjE,QAAA,qCAAqC,yCAK4B;AAE9E;;;;GAIG;AACI,MAAM,iCAAiC,GAAG,CAC7C,QAAkB,EAClB,yBAAiC,EACjC,OAAiC,EACpB,EAAE,CACf,IAAA,wBAAgB,EAAC,iBAAS,EAAE,QAAQ,EAAE,yBAAyB,EAAE,OAAO,CAAC,CAAC;AALjE,QAAA,iCAAiC,qCAKgC;AAE9E,MAAM,gBAAgB,GAAG,CAAC,OAAiC,EAAiB,EAAE,CAAC,CAAC;IAC5E,kEAAkE;IAClE,OAAO,EAAE,CAAE,mBAAmB,CAAE;IAChC,oEAAoE;IACpE,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,EAAC,CAAC,CAAC,CAAE,mBAAmB,CAAE,CAAC,CAAC,CAAC,EAAE;CACpE,CAAC,CAAC;AAEH;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAC5B,OAAe,EACf,QAAkB,EAClB,OAAgC,EA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5G,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAC;IAClD,IAAI,SAAS,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3D,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACzD,eAAe,CAAC,EAAE,GAAG,iBAAiB,CAAC;QACvC,eAAe,CAAC,IAAI,GAAG,QAAQ,CAAC;QAChC,eAAe,CAAC,GAAG,GAAG,SAAS,CAAC;QAEhC,eAAe,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACjF,eAAe,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACJ,cAAc,EAAE,CAAC;IACrB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,OAAe,EAAoB,EAAE,CAAC,CAAC;IACxD,SAAS,EAAE,GAAG,OAAO,eAAe;IACpC,IAAI,EAAE,GAAG,OAAO,UAAU;CAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
export interface CsContentValidationData {
|
|
2
|
+
BucketName: string;
|
|
3
|
+
BucketId: number;
|
|
4
|
+
FolderId: number;
|
|
5
|
+
FolderKey: string;
|
|
6
|
+
DocumentId: string;
|
|
7
|
+
DocumentPath: string;
|
|
8
|
+
EncodedDocumentPath: string;
|
|
9
|
+
TextPath: string;
|
|
10
|
+
DocumentObjectModelPath: string;
|
|
11
|
+
TaxonomyPath: string;
|
|
12
|
+
AutomaticClassificationResultsPath: string;
|
|
13
|
+
ValidatedClassificationResultsPath: string;
|
|
14
|
+
ExtractorPayloadsPath: string;
|
|
15
|
+
ShowOnlyRelevantPageRange: string;
|
|
16
|
+
AdditionalDataPath: string;
|
|
17
|
+
OriginalDocumentFileName: string;
|
|
18
|
+
CustomizationInfoPath: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Maps every custom-event name emitted by the classification-station web component
|
|
22
|
+
* to the type carried in CustomEvent.detail.
|
|
23
|
+
*/
|
|
24
|
+
export interface IClassificationStationWcEventMap {
|
|
25
|
+
/** Fires when the user has unsaved changes (true) or the state is clean (false). */
|
|
26
|
+
dirty: boolean;
|
|
27
|
+
/** Fires when the Action Center task has been submitted successfully. Detail is the task ID. */
|
|
28
|
+
actionCenterTaskComplete: number;
|
|
29
|
+
/** Fires when the Action Center task has been reported as exception. Detail is the task ID. */
|
|
30
|
+
actionCenterTaskReportAsException: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Strongly-typed interface for <ui-du-classification-station-wc-element>.
|
|
34
|
+
*
|
|
35
|
+
* Obtain a reference via document.querySelector or a React/Angular ref, then
|
|
36
|
+
* set properties and attach event listeners through this interface.
|
|
37
|
+
*
|
|
38
|
+
* @example React 18 usage
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const ref = useRef<IClassificationStationWcElement | null>(null);
|
|
41
|
+
*
|
|
42
|
+
* useEffect(() => {
|
|
43
|
+
* const el = ref.current;
|
|
44
|
+
* if (!el) return;
|
|
45
|
+
* el.platform = { organizationName: 'acme', tenantId: 't1' };
|
|
46
|
+
* const onDirty = (e: CustomEvent<boolean>) => setDirty(e.detail);
|
|
47
|
+
* el.addEventListener('dirty', onDirty);
|
|
48
|
+
* return () => el.removeEventListener('dirty', onDirty);
|
|
49
|
+
* }, []);
|
|
50
|
+
*
|
|
51
|
+
* return <ui-du-classification-station-wc-element ref={ref} theme="light" />;
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export interface IClassificationStationWcElement extends HTMLElement {
|
|
55
|
+
/** Bearer token for delegated authentication. */
|
|
56
|
+
authToken: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Platform context — must be set before the component can make API calls.
|
|
59
|
+
* Set as a JS property (not an HTML attribute) for complex object values.
|
|
60
|
+
*/
|
|
61
|
+
platform: {
|
|
62
|
+
organizationName: string;
|
|
63
|
+
tenantId: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Document data contract provided by the UiPath Create Task activity.
|
|
67
|
+
* Set as a JS property (not an HTML attribute) for complex object values.
|
|
68
|
+
*/
|
|
69
|
+
contentValidationData: CsContentValidationData | undefined;
|
|
70
|
+
/** Action Center task ID associated with the document. */
|
|
71
|
+
actionCenterTaskId: number | null;
|
|
72
|
+
/** Organization unit ID for scoped API calls. */
|
|
73
|
+
organizationUnitId: number | null;
|
|
74
|
+
/** Visual theme applied to the component. @default 'light' */
|
|
75
|
+
theme: 'light' | 'dark' | 'light-hc' | 'dark-hc';
|
|
76
|
+
/** BCP-47 language code for the UI. @default 'en' */
|
|
77
|
+
language: string;
|
|
78
|
+
/** When true, the component renders in read-only mode. @default false */
|
|
79
|
+
isReadonly: boolean;
|
|
80
|
+
/** When true, a "Save as draft" action is available. @default false */
|
|
81
|
+
enableSaveAsDraft: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* PDF viewer settings, assigned as a JS property (not an HTML attribute).
|
|
84
|
+
*
|
|
85
|
+
* Deliberately typed as `unknown` — the full settings type is not part of this
|
|
86
|
+
* package's public surface. Pass an object with these properties:
|
|
87
|
+
*
|
|
88
|
+
* - `pages` (**required**) — one entry per page: `pageIndex` (0-based) and `size`
|
|
89
|
+
* (`{ width, height }`, the page's original dimensions), plus optional `uri`
|
|
90
|
+
* (per-page image) and `rotation`
|
|
91
|
+
* - `uri` — URL the viewer fetches the document from
|
|
92
|
+
* - `authHeader` — Authorization header value used for that fetch
|
|
93
|
+
* - `binaryPdf` — `ArrayBuffer` with the document bytes, as an alternative to `uri`
|
|
94
|
+
* - `documentName` — display name for the document
|
|
95
|
+
* - `text` — plain-text rendition of the document
|
|
96
|
+
* - `cMapsFullUrl` / `cMapsRelativeUrl` — location of the PDF.js cMaps folder
|
|
97
|
+
* (include the trailing slash); `cMapsPacked` marks them as compressed `.bcmap`
|
|
98
|
+
* - `wasmFullUrl` / `wasmRelativeUrl` — location of the PDF.js WASM assets
|
|
99
|
+
*/
|
|
100
|
+
pdfSettings: unknown;
|
|
101
|
+
addEventListener<K extends keyof IClassificationStationWcEventMap>(type: K, listener: (event: CustomEvent<IClassificationStationWcEventMap[K]>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
102
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
103
|
+
removeEventListener<K extends keyof IClassificationStationWcEventMap>(type: K, listener: (event: CustomEvent<IClassificationStationWcEventMap[K]>) => void, options?: boolean | EventListenerOptions): void;
|
|
104
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Props for <ui-du-classification-station-wc-element> in React JSX.
|
|
108
|
+
*
|
|
109
|
+
* React 18:
|
|
110
|
+
* - String scalar inputs (`theme`, `language`, `authToken`/`auth-token`) can be
|
|
111
|
+
* passed as JSX attributes directly.
|
|
112
|
+
* - Boolean inputs (`isReadonly`/`is-readonly`, `enableSaveAsDraft`/`enable-save-as-draft`)
|
|
113
|
+
* use `booleanAttribute` transform, so both camelCase JS property and kebab-case
|
|
114
|
+
* attribute forms work correctly.
|
|
115
|
+
* - Numeric inputs (`actionCenterTaskId`/`action-center-task-id`,
|
|
116
|
+
* `organizationUnitId`/`organization-unit-id`) use a number coercion transform,
|
|
117
|
+
* so both camelCase JS property and kebab-case attribute forms work correctly.
|
|
118
|
+
* - Complex object props (`platform`, `contentValidationData`, `pdfSettings`) must
|
|
119
|
+
* be set via a ref as JS properties, because React 18 serialises JSX props as
|
|
120
|
+
* HTML attributes and Angular Elements cannot deserialise JSON strings back into
|
|
121
|
+
* objects.
|
|
122
|
+
*
|
|
123
|
+
* React 19:
|
|
124
|
+
* - Supports passing props as JS properties from JSX. Complex objects can be
|
|
125
|
+
* passed directly without a ref.
|
|
126
|
+
*/
|
|
127
|
+
export interface IClassificationStationWcJsxProps {
|
|
128
|
+
theme?: 'light' | 'dark' | 'light-hc' | 'dark-hc';
|
|
129
|
+
language?: string;
|
|
130
|
+
/** JS property form. */
|
|
131
|
+
authToken?: string;
|
|
132
|
+
/** Attribute form (kebab-case string). */
|
|
133
|
+
'auth-token'?: string;
|
|
134
|
+
/** JS property form. */
|
|
135
|
+
isReadonly?: boolean;
|
|
136
|
+
/** Attribute form (kebab-case). Coerced via `booleanAttribute` transform. */
|
|
137
|
+
'is-readonly'?: boolean;
|
|
138
|
+
/** JS property form. */
|
|
139
|
+
enableSaveAsDraft?: boolean;
|
|
140
|
+
/** Attribute form (kebab-case). Coerced via `booleanAttribute` transform. */
|
|
141
|
+
'enable-save-as-draft'?: boolean;
|
|
142
|
+
/** JS property form. */
|
|
143
|
+
actionCenterTaskId?: number | null;
|
|
144
|
+
/** Attribute form (kebab-case). Coerced via `numberAttribute` transform. */
|
|
145
|
+
'action-center-task-id'?: number | null;
|
|
146
|
+
/** JS property form. */
|
|
147
|
+
organizationUnitId?: number | null;
|
|
148
|
+
/** Attribute form (kebab-case). Coerced via `numberAttribute` transform. */
|
|
149
|
+
'organization-unit-id'?: number | null;
|
|
150
|
+
platform?: {
|
|
151
|
+
organizationName: string;
|
|
152
|
+
tenantId: string;
|
|
153
|
+
};
|
|
154
|
+
contentValidationData?: CsContentValidationData;
|
|
155
|
+
pdfSettings?: unknown;
|
|
156
|
+
id?: string;
|
|
157
|
+
className?: string;
|
|
158
|
+
class?: string;
|
|
159
|
+
style?: string | Record<string, string | number>;
|
|
160
|
+
title?: string;
|
|
161
|
+
role?: string;
|
|
162
|
+
tabIndex?: number;
|
|
163
|
+
part?: string;
|
|
164
|
+
slot?: string;
|
|
165
|
+
draggable?: boolean;
|
|
166
|
+
hidden?: boolean;
|
|
167
|
+
[dataAttr: `data-${string}`]: string | number | boolean | null | undefined;
|
|
168
|
+
[ariaAttr: `aria-${string}`]: string | number | boolean | null | undefined;
|
|
169
|
+
}
|
|
170
|
+
declare global {
|
|
171
|
+
interface HTMLElementTagNameMap {
|
|
172
|
+
'ui-du-classification-station-wc-element': IClassificationStationWcElement;
|
|
173
|
+
}
|
|
174
|
+
namespace React {
|
|
175
|
+
namespace JSX {
|
|
176
|
+
interface IntrinsicElements {
|
|
177
|
+
'ui-du-classification-station-wc-element': IClassificationStationWcJsxProps;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classification-station-wc.js","sourceRoot":"","sources":["../../../../../../../../../libs/du/shared/util/du-utils/src/lib/shared/classification-station-wc.ts"],"names":[],"mappings":""}
|