@uipath/codedapp-convert-sdk 0.1.0-beta.1 → 0.1.0-beta.2
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.
|
Binary file
|
|
Binary file
|
|
@@ -46,8 +46,10 @@ matches what you were given, and more than one can apply:
|
|
|
46
46
|
`"converter"`. `blame: "source-app"` is the only kind you do NOT fix — not out of
|
|
47
47
|
deference, but because the app itself is broken (an expression naming a control that does
|
|
48
48
|
not exist) and only its author knows what it was meant to say; report those and move on.
|
|
49
|
-
`by-design` needs nothing
|
|
50
|
-
|
|
49
|
+
`by-design` needs nothing — with one exception: `custom-html-verbatim`, which names a
|
|
50
|
+
Custom HTML control that already works and MAY be rewritten as React; follow
|
|
51
|
+
[Custom HTML controls](#custom-html-controls) to decide. `expressionRows` lists
|
|
52
|
+
deliberate, measured approximations — read them for context, act on them only if asked.
|
|
51
53
|
2. Some reports also carry `runtime`-scoped issues and a `runtime` block: those come from the
|
|
52
54
|
converter team driving both apps through the same steps, and they are the most concrete
|
|
53
55
|
issues in the file because each one states what Apps did and what this app did. Treat them
|
|
@@ -73,6 +75,8 @@ matches what you were given, and more than one can apply:
|
|
|
73
75
|
| `property-unmapped` | An authored property reached no component prop. | Add the prop to the component and pass it from the page — unless Apps' own control ignores that property too, in which case log it and change nothing. |
|
|
74
76
|
| `style-unmapped` | An authored style produced no CSS. | Add the rule to the control's class in `src/pages/<Page>.module.css`. |
|
|
75
77
|
| `control-unsupported` | An inert placeholder. | Implement it only if the message gives enough to go on; otherwise leave it and say why. |
|
|
78
|
+
| `custom-html-verbatim` (by-design) | A Custom HTML control whose HTML/CSS/JS runs as authored: the files named in the message under `src/custom-html/<Page>/`, passed as `code={…}` in `<Page>.tsx`. | It already works. Rewrite it as React only where [Custom HTML controls](#custom-html-controls) says it pays off. |
|
|
79
|
+
| `custom-html-document-missing` | The same control, with one of its documents empty because the export does not carry it. | Ask the developer for the document's content from Apps Studio (the control's Code editor); never write one from guesswork. |
|
|
76
80
|
| `emit-inconsistent` | Described in the message. | Fix as described. |
|
|
77
81
|
| `runtime-*` | The app was driven beside the low-code app: `step` is what was done, `expected` what Apps showed or sent, `actual` what this app did. | Make the code produce `expected`. For `runtime-request-differs` compare the bodies field by field. For `runtime-text-differs` find the binding behind the control. For `runtime-request-missing`/`-extra` look at the control's source hook and its handler. |
|
|
78
82
|
|
|
@@ -228,6 +232,7 @@ that is right but formatted differently. Every one of those has happened on a re
|
|
|
228
232
|
| Session values are empty (`CurrentUser.*`) | `src/lib/sdk.ts` | the claims the token actually carries |
|
|
229
233
|
| A validation message differs | `useControlValidation` in `src/lib/runtime.ts` | Apps checks by control KIND, only once a value is filled, and a pattern rule outranks a length rule on the same field |
|
|
230
234
|
| A popup, toast or spinner behaves differently | `src/lib/rules.ts`, `src/lib/overlays.tsx` | the rule's own options (modal, position, seconds) |
|
|
235
|
+
| A Custom HTML control is blank, or its button does nothing | the browser console (the frame logs there too), the control's error icon, `src/custom-html/<Page>/<Control>.*`, `src/custom-html/bridge.ts` | an external script that failed to load, an `App.*` call naming a variable the app does not declare (`invalid-variable-name`), a script relying on `alert` or popups (blocked), or — after a rewrite — a variable write the React version no longer makes |
|
|
231
236
|
|
|
232
237
|
### Differences that are not bugs
|
|
233
238
|
|
|
@@ -294,6 +299,75 @@ the fix.
|
|
|
294
299
|
| Project | The whole app is blank and the console shows an unresolved import | the emitted imports | an import naming a file the project does not contain |
|
|
295
300
|
| Project | The app runs but `npm run build` fails | the pages and components | a prop passed to a component that never declared it, or a name used without importing it |
|
|
296
301
|
|
|
302
|
+
## Custom HTML controls
|
|
303
|
+
|
|
304
|
+
A Custom HTML control is a small web page the app author wrote: an HTML, a CSS and a
|
|
305
|
+
JavaScript document, sometimes external stylesheets and scripts, and an `App` object the
|
|
306
|
+
script uses to talk to the app. The converter does NOT translate it. It keeps the author's
|
|
307
|
+
code verbatim and runs it the way Apps does, so the converted app works on day one:
|
|
308
|
+
|
|
309
|
+
- the documents are `src/custom-html/<Page>/<Control>.html|.css|.js`, imported as text by
|
|
310
|
+
the page and passed as `code={{ html, css, js, cssExternal, jsExternal, bridge }}`;
|
|
311
|
+
- `UiCustomHtml` renders them in an `<iframe sandbox="allow-scripts allow-forms">`, built in
|
|
312
|
+
Apps' order (external CSS, the CSS, the HTML, external JS one by one, the HTML's own
|
|
313
|
+
`<script>`s, the JS document, then a `controlLoad` event);
|
|
314
|
+
- the frame shows a spinner until the control has loaded, and an error icon naming any
|
|
315
|
+
external stylesheet or script that failed to load; a disabled control takes no clicks and
|
|
316
|
+
is out of the tab order, as in Apps;
|
|
317
|
+
- the frame's `App` object is Apps' bridge, and reaches the app's DECLARED variables only:
|
|
318
|
+
|
|
319
|
+
| In the author's script | What it does | The same thing in generated React |
|
|
320
|
+
|---|---|---|
|
|
321
|
+
| `await App.getVariable('v')` | the variable's current value; rejects `{ code: 'invalid-variable-name' }` for a name the app does not declare | `useAppVar('v')` in render, `getAppVar('v')` in a handler |
|
|
322
|
+
| `await App.setVariable('v', x)` | sets it; everything bound to it re-renders, exactly as an assignment in a rule does | `setAppVar('v', x)` |
|
|
323
|
+
| `App.onVariableChange('v', cb)` | `cb(value)` whenever the variable takes a value not deeply equal to the last one it saw — compared as Apps compares, so re-setting an equal value does not fire — from anywhere, including this script's own writes; no initial call; returns an unsubscribe | a component that reads `useAppVar('v')` re-renders — no subscription to write |
|
|
324
|
+
| `App.setHeight(h)` | sets the frame's height: a number or numeric string is px, anything else must be a valid CSS height | the component's own height in its CSS |
|
|
325
|
+
| `localStorage`, `sessionStorage`, `document.cookie` | work as in a browser, shared by every Custom HTML control in this app and no other; the page keeps them in its own storage as `uiapp-custom-html:<app>:<area>:<key>`, `<app>` being `storageScope` in `src/custom-html/bridge.ts` | the app's own `localStorage` / `sessionStorage`, reading and writing the same keys (`uiapp-custom-html:<app>:local:<key>`) so saved values carry over |
|
|
326
|
+
|
|
327
|
+
**Leaving it verbatim is correct.** Rewrite a control as React only when the result is clearly
|
|
328
|
+
simpler to read and keeps every behaviour — it is optional, and the developer can ask for it.
|
|
329
|
+
|
|
330
|
+
Rewrite when ALL of these hold:
|
|
331
|
+
- the HTML is markup for this control (a button, a badge, a small card, a list built from a
|
|
332
|
+
variable), not a whole page with its own `<head>`;
|
|
333
|
+
- the script only reacts to events on that markup and reads or writes app variables through
|
|
334
|
+
`App`;
|
|
335
|
+
- there are no external scripts, no `<canvas>`, no third-party widget, no timers driving
|
|
336
|
+
layout.
|
|
337
|
+
|
|
338
|
+
Keep it verbatim when any of these hold — the rewrite would be a reimplementation, not a
|
|
339
|
+
translation: external libraries (charts, editors, maps), a full HTML document, hundreds of
|
|
340
|
+
lines of DOM code, or behaviour you cannot exercise to compare. Say in the log that you kept
|
|
341
|
+
it and why.
|
|
342
|
+
|
|
343
|
+
**To rewrite one:**
|
|
344
|
+
1. Read all three documents and list every `App.*` call, every DOM event handler, and every
|
|
345
|
+
state the markup shows (loading, disabled, empty).
|
|
346
|
+
2. Write `src/components/custom/<Control>.tsx` and a `<Control>.module.css` beside it. Move the
|
|
347
|
+
CSS in, scoped by the module; keep the class names the markup used so the rules still match.
|
|
348
|
+
Replace `App.getVariable`/`onVariableChange` with `useAppVar`, `App.setVariable` with
|
|
349
|
+
`setAppVar`, `onclick="…"` with `onClick`. Fonts the CSS `@import`s go in
|
|
350
|
+
`src/styles/tokens.css` or the page's `index.html`, not in a module.
|
|
351
|
+
3. In `<Page>.tsx`, replace `<UiCustomHtml ctl="X" className={s.x} code={…} />` with
|
|
352
|
+
`<X ctl="X" className={s.x} />` — keep `ctl` and the class, so provenance, hiding and
|
|
353
|
+
layout still apply — and honour `disabled`/`hidden` the way `UiCustomHtml` does. Remove
|
|
354
|
+
that control's `?raw` imports. Leave `src/custom-html/` files another control still uses.
|
|
355
|
+
4. Verify: `npm run build`; then the same steps in both versions with the browser console
|
|
356
|
+
open. Every variable the original wrote must be written with the same value at the same
|
|
357
|
+
moment — that is what other controls and rules react to — and a screenshot of the two
|
|
358
|
+
(Path C) must agree.
|
|
359
|
+
5. Log it: which controls you rewrote, which you kept, and why.
|
|
360
|
+
|
|
361
|
+
**Never** add `allow-same-origin` to the frame (a `srcdoc` frame would then share the app's
|
|
362
|
+
origin, storage and session with the author's script), hand the frame a token, or widen the
|
|
363
|
+
bridge beyond app variables. Differences from Apps:
|
|
364
|
+
- `alert`/`confirm`/`prompt` and popups are blocked, as Apps blocks them by default. Where the
|
|
365
|
+
app relied on them being allowed, add `allow-modals` or `allow-popups` to the frame's
|
|
366
|
+
`sandbox` in `src/components/ui/ui-custom-html.tsx` — never `allow-same-origin`.
|
|
367
|
+
- `setVariable` does not reject a value of the wrong type (Apps answers `type-mismatch`).
|
|
368
|
+
- A relative URL in the author's HTML (`<img src="logo.png">`) resolves against this app, not
|
|
369
|
+
against Apps; use an absolute URL, or put the file in `public/`.
|
|
370
|
+
|
|
297
371
|
## The generated project
|
|
298
372
|
|
|
299
373
|
| Path | What it is |
|
|
@@ -309,6 +383,7 @@ the fix.
|
|
|
309
383
|
| `src/lib/resource-folders.ts` | which folder each backend resource lives in, and the keys to reach it |
|
|
310
384
|
| `src/store/` | app variables, control state and data sources (Redux Toolkit) |
|
|
311
385
|
| `src/styles/tokens.css` | every colour and font, plus the app-wide layout rules |
|
|
386
|
+
| `src/custom-html/` | Custom HTML controls' own code, verbatim: `<Page>/<Control>.{html,css,js}`, plus `bridge.ts` (the variables a script may reach) and `boot.js` (the `App` object, storage and loading order inside the frame). Only present when the app has such a control |
|
|
312
387
|
|
|
313
388
|
## VB → TypeScript, as the generated code does it
|
|
314
389
|
|
|
@@ -329,5 +404,6 @@ the fix.
|
|
|
329
404
|
- Do not change the report, the log, or the converter.
|
|
330
405
|
- Do not rename generated symbols, reorder files, or reformat code you did not need to touch.
|
|
331
406
|
- Do not remove a `notConverted…` marker without replacing it with a real implementation.
|
|
332
|
-
- Do not fix `source-app` or `by-design` issues
|
|
407
|
+
- Do not fix `source-app` or `by-design` issues — the one exception is the optional rewrite of
|
|
408
|
+
a `custom-html-verbatim` control, under [Custom HTML controls](#custom-html-controls).
|
|
333
409
|
- Do not claim a fix works because it should. Say what you ran and what you saw.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/codedapp-convert-sdk",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
"description": "Convert a UiPath Apps export (.uiapp) into a React + TypeScript coded app. The SDK behind `uip codedapp convert`.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "UiPath",
|