@widgetic/ui-sdk 0.1.10 → 0.1.12

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/modules/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @widgetic/ui-sdk-modules
2
2
 
3
- The heavy UI modules a partner mounts into its own page: the **File Browser**, the **composition editor** and the AI
4
- **widget creator**. Each module is **one self-contained ES module file** (`dist/<name>/index.js`) that brings its own Svelte,
3
+ The UI modules a partner mounts into its own page: the **File Browser**, the **composition editor**, the AI
4
+ **widget creator** and **Workflows**. Each module is **one self-contained ES module file** (`dist/<name>/index.js`) that brings its own Svelte,
5
5
  design system and CSS, and draws inside a **shadow root**, so the partner's CSS cannot restyle it and its CSS cannot
6
6
  touch the partner's page. The only other files are a few **lazy files** next to it (`dist/<name>/chunks/`): pdf.js and
7
7
  its worker, which only a visitor who previews a PDF needs (see "One file, and the parts that are not in it").
@@ -205,17 +205,35 @@ Without the SDK it is the same class as the File Browser's (`new CompositionEdit
205
205
  | `apiUrl` | As for the File Browser. |
206
206
 
207
207
  Events: `ready` `{ name, widgetId }` (the composition has loaded and is on screen), `dirty` `{ dirty }` (there is, or is
208
- no longer, work that is not saved), `saved` `{ composition, savedAt }` (a save went through), and `error`
208
+ no longer, work that is not saved), `saved` `{ composition, savedAt }` (a save went through), `conflict`
209
+ `{ currentVersion, lastEditedBy, lastEditedAt, correlationId? }` and `conflictResolved` `{ resolution }` (see "When somebody
210
+ else saved first" below), and `error`
209
211
  `{ message, code?, fatal, during?, status?, retryable?, sessionEnded?, correlationId? }`. The editor shows a problem to the
210
212
  visitor itself (with "Try again" where that helps); `error` is for your page. `fatal: true` means the editor cannot go on
211
213
  by itself: the composition cannot be opened, or the session is over (`sessionEnded`), so give it a new session or take it
212
214
  away. `correlationId` is what Widgetic's support needs to find the request.
213
215
 
216
+ **When somebody else saved first.** Every save carries the version of the content the editor loaded (an `If-Match` header
217
+ of the composition's `contentVersion`). When another tab, another person or your own server saved the composition in the
218
+ meantime, the API refuses the save (412 `CONTENT_VERSION_MISMATCH`): nothing is overwritten and nothing more is sent. The
219
+ editor stops saving by itself, keeps the visitor's
220
+ edits and shows a card with two choices: *Keep my changes* (it reads the newer version again and saves the edits on top,
221
+ a deliberate overwrite; when somebody saved a third time meanwhile it asks again instead of replacing that unseen) and
222
+ *Use the latest version* (the composition is read again and the edits are dropped). Your page hears `conflict` when the
223
+ save is refused and `conflictResolved` (`{ resolution: 'keepMine' | 'loadLatest' }`) once somebody chose. It is not an
224
+ `error`, so `error` is not sent for it. A page that wants its own buttons calls `keepMyChanges()` or `loadLatestVersion()`
225
+ on the module. The API names who saved only to a member of a team (it never tells an editor session), so `lastEditedBy`
226
+ and `lastEditedAt` are `null` here; `currentVersion` is the version the API holds now, when the refusal said so. The
227
+ editor's *presence* notice ("Anna is editing", take over, read only) is not offered by the module: it runs on routes an
228
+ editor session may not call, and the module keeps the `presence` option of the editor off.
229
+
214
230
  Methods (on `editor.module` when you mounted it with the SDK): `save()` saves what is unsaved now, `flush()` saves
215
231
  everything and waits, both resolving `true` when nothing is left unsaved; `isDirty()`; `reload()` loads the composition
216
232
  again (unsaved edits are lost); `adoptEmbedSettings(settings)` for a page that saves the composition's `embedSettings` itself
217
233
  (call it after `await flush()`, with the settings the API now holds, so a later save of the editor does not put the old ones
218
- back; nothing becomes unsaved); `adoptName(name)` for a page that renames the composition itself (same use); `setTheme(theme)` (see "Looking like your product"); `setLanguage({ locale?, messages? })`, and
234
+ back; nothing becomes unsaved); `adoptName(name)` for a page that renames the composition itself (same use); `keepMyChanges()`
235
+ (resolves `true` when nothing is left unsaved) and `loadLatestVersion()`, the two answers to a `conflict` for a page with buttons of its own (both do nothing, and
236
+ `keepMyChanges()` resolves `false`, when there is no conflict); `setTheme(theme)` (see "Looking like your product"); `setLanguage({ locale?, messages? })`, and
219
237
  `CompositionEditorModule.defaultMessages` and `checkMessages(messages)`, which are also on the instance (see "Speaking your
220
238
  visitors' language").
221
239
 
@@ -380,11 +398,109 @@ only the API's origin (connections, pictures and frames), `data:` fonts and `dat
380
398
  **One creator per page.** Its chat, its file lists and its user are stores of the whole page, so a second `mount()` is
381
399
  refused with a message that says so; unmount the first one before mounting another.
382
400
 
401
+ ## Using the Workflows module
402
+
403
+ The page where a team builds **workflows**: a set of compositions, and the filters between them that decide which
404
+ composition an embed shows next. It is for team accounts and partners (the API refuses any other workspace and the screen
405
+ says so). What an embed does on its own page (how and when it appears) belongs to the Embed SDK and stays there: a
406
+ workflow only decides **which composition** the embed shows, and the Embed SDK follows it from the tag
407
+ (`<widgetic workflow-id="..." composition-id="...">`). The screen is the package `@widgetic/workflows` (its own repository,
408
+ `widgeticai/Frontend/workflows`, which has the screen's README and `__docs/concepts.md`: what a workflow is and why); the
409
+ module gives it a shadow root, a theme, a language, a session and a way to tell your page what happened.
410
+
411
+ **What the screen does.** The list of the workspace's workflows (search by name, show or hide the archived ones, order by
412
+ name, date created, last published or visitors, new workflow, duplicate, delete) and, when one is opened, the editor: a
413
+ canvas of Composition, Trigger and Condition blocks that go forward only (up to 25), a side panel for the selected block,
414
+ a draft that is saved while you work, publish and discard, a history of versions that never change, a Test run that plays a
415
+ visitor through the draft, a Runs tab with how many visitors went through each block, and a Settings tab (time zone, embed
416
+ code, pause, archive, duplicate, delete). A trigger is enabled for a composition only when its widget can supply it (values a
417
+ visitor adds need a Pro widget that keeps data); the reason is told next to the choice. The package's README lists it all.
418
+
419
+ ```js
420
+ import { mountModule } from '@widgetic/ui-sdk';
421
+
422
+ const workflows = await mountModule('workflows', {
423
+ container: '#workflows', // give it a height: it fills its container, and scrolls inside it when that is short
424
+ workspaceId: 'personal', // or the id of an organization
425
+ getToken: async ({ reason }) => (await fetch(`/my-server/widgetic-token?reason=${reason}`)).text(),
426
+ workflowId: workflowOfTheAddress(), // optional: the workflow to open first; leave it out for the list
427
+ theme: 'light',
428
+ on: {
429
+ ready: () => {},
430
+ openWorkflow: ({ workflowId }) => history.pushState(null, '', workflowId ? `/workflows/${workflowId}` : '/workflows'),
431
+ showEmbedCode: ({ workflowId }) => showMyEmbedCodeDialog(workflowId),
432
+ error: ({ message, code, fatal }) => report(code, message),
433
+ },
434
+ });
435
+
436
+ // The page owns where the person is: when it moves (the back button), tell the screen
437
+ window.addEventListener('popstate', () => workflows.module.setWorkflow(workflowOfTheAddress()));
438
+ ```
439
+
440
+ | Option | What it does |
441
+ | --- | --- |
442
+ | `container` | The element the screen fills (it needs a height). |
443
+ | `workspaceId` | **Required.** `personal`, or the id of the organization whose workflows are shown and edited. |
444
+ | `getToken` | **Required**, and the same as for the other modules: `getToken({ reason })` resolves with a token the API accepts for the workspace's workflows, bare or as `{ token, expiresAt }`. It must be the token of a **signed-in person who may work in that workspace** (a member of the team, or the partner's own account), the way the Widgetic site calls the API: an *editor session* minted for one of a partner's customers is refused on these routes (`403`), because an editor session may call only what its allow-list names and workflows are not on it. It is called once before the screen appears (a `getToken` that fails fails the mount), and again when the token is about to run out or the API refuses it (`reason: 'expired'`, once per refusal). |
445
+ | `apiUrl` | The API origin (`https://api.widgetic.com` unless you run your own). |
446
+ | `workflowId` | The workflow to open first. Leave it out for the list. After mounting the screen moves by itself (and says so with `openWorkflow`); `setWorkflow` moves it from the page. |
447
+ | `presence` | `true` tells the people of a team who else has the workflow open: "Anna is editing", with a choice to take over or to only look (default `false`, read once when the module mounts). It is for an organization's workspace and a person who may change the workflow; for `personal`, or for a token the edit-lease routes refuse (an editor session), the screen carries on as if it were off, without asking again. It is presence, never a lock: nobody is shut out, and a save that finds the draft changed by somebody else asks the person what to do (*Keep my changes as a copy* first, if they like, then *Load the latest version*) whether `presence` is on or not. A value that is not `true` or `false` is ignored, with one warning in the console. |
448
+ | `theme`, `themeFromHost` | The colours, the corners and the typeface ("Looking like your product"). |
449
+ | `locale`, `messages` | The language ("Speaking your visitors' language"). |
450
+
451
+ **What it tells the page.** `ready`, with no payload, once the screen is drawn. `openWorkflow` `{ workflowId }`: the person
452
+ opened a workflow, or went back to the list (`workflowId: null`), so the page can keep its address in step.
453
+ `showEmbedCode` `{ workflowId }`: the person asked for the tag of a workflow. The page shows it, because it knows how the tag
454
+ is built for its Embed SDK; the screen has the button **only when something listens for this event at the moment it
455
+ mounts**. `error` `{ message, code?, fatal }`: `fatal: true` when it could not start (`mount()` rejects as well, and the
456
+ console says `[widgetic-ui] Workflows failed to start:` with the cause), and `fatal: false` for `RENDER_FAILED` (a part of
457
+ the screen could not be drawn: the rest stays and the visitor is offered "Try again" in its place), `REQUEST_FAILED` (a
458
+ request to the API failed: the screen tells the person by itself), `SESSION_ENDED` (the API no longer accepts the token
459
+ `getToken` gives) and `TOKEN_REFRESH_FAILED`. The events are not typed in the SDK yet (see "Known gaps of Workflows").
460
+
461
+ **What it puts on your page.** What every module does, and nothing else: one `<widgetic-ui-module>` in your container and
462
+ the namespaced `<style>` of font rules in `<head>`. Its menus, dialogs and the canvas's own pieces stay inside the shadow
463
+ root (nothing is appended to your `<body>`). It adds nothing to your `window` but Svelte's own version marker (`__svelte`,
464
+ as in every module), and writes nothing to your storage, cookies or address bar.
465
+
466
+ **What it needs from your page.** A container with a height, a `getToken`, and a workspace. Under a strict
467
+ Content-Security-Policy: **scripts from the CDN, inline styles and `data:` fonts, the API for requests, and the CDN for the
468
+ thumbnails of compositions**, nothing else: `default-src 'none'; script-src 'self' https://cdn.widgetic.com;
469
+ connect-src https://api.widgetic.com; style-src 'unsafe-inline'; font-src data:; img-src https://cdn.widgetic.com` (see the
470
+ policy in the SDK's README). No `frame-src`, `worker-src`, inline script or `eval`. The pictures come from where the API's
471
+ answer says (`thumbnailUrl`), which is the CDN. `e2e/workflowsModule.spec.ts` opens the screen under this policy with the
472
+ harness's own origins in place of the CDN and the API, and `e2e/workflowsEditor.spec.ts` draws the canvas and its pictures
473
+ under a strict one: both fail on a violation.
474
+
475
+ **How it is built.** `src/workflows/` has `index.ts` (the module), `WorkflowsHost.svelte` (what the module mounts),
476
+ `language.ts`, `localePackLoad.ts`, `module.css` and `CHANGELOG.md`. The screen is the package `@widgetic/workflows`
477
+ (which bundles `@widgetic/workflows-engine` and the canvas library `kaykay`, pinned to one exact version). It bundles
478
+ neither pdf.js nor the rich text editor, so it needs none of the patches the other modules apply to those packages
479
+ (`packagePatches: []`), and the swaps of the design system's files that work inside a shadow root apply to whatever it
480
+ imports (`MODULES` says `overridesMayGoUnused: true`, so the build does not fail when a swap goes unused). Its `module.css`
481
+ imports `FileBrowser.css` for the theme tokens a module has to own (`--primary`, `--radius` ...): without them a page that
482
+ sets `:root { --primary: yellow }` repaints the module. It also reads the text colour of a main button from the theme
483
+ (`--wg-on-primary`), so a light brand colour keeps dark words.
484
+
485
+ **What the tests check.** `tests/workflowsModule.test.ts` for the module's logic. On the hostile page
486
+ (`harness/workflows.html`, with the mock API of `harness/mockWorkflows.mjs`; `?theme=`, `?themeFromHost=1`, `?height=`,
487
+ `?mount=no`, `?locale=`, `?messages=`, `?pseudo=1`, `?workflow=`, `?workspace=`, `?embedCode=yes`, `?lifetime=`):
488
+ `e2e/workflowsModule.spec.ts` (the page is not touched and nothing is left behind, the requests it makes, the
489
+ Content-Security-Policies, how well the text reads in four looks), `e2e/workflowsEditor.spec.ts` (the list and its
490
+ questions to the API, opening and making a workflow, the canvas drawn among the page's own CSS, adding and connecting
491
+ blocks with a real mouse drag, publishing with its `Idempotency-Key` and revision, the Runs counts, the version history,
492
+ and that taking the screen away in the middle of an edit leaves nothing behind),
493
+ `e2e/workflowsLanguage.spec.ts` (the pseudo language: every word a visitor can read is a message; `messages`,
494
+ `setLanguage`, `checkMessages`) and `e2e/workflowsRtl.spec.ts` (the screen, its list and its editor mirrored for
495
+ `locale: 'ar'` without a word of Arabic, and not decided by the page's own direction). The themes matrix
496
+ (`e2e/themes.spec.ts`) and the React page (`e2e/reactPage.spec.ts`) run it too, and `e2e/sdkLoader.spec.ts` checks that the
497
+ theme the page sets through the SDK reaches it.
498
+
383
499
  ## Looking like your product (themes)
384
500
 
385
501
  Every module takes a `theme`. It changes **colours, the roundness of corners and the typeface**, never the layout or the
386
502
  controls, so a page with a design system of its own can have the modules match it. Each module has its own theme: the File
387
- Browser, the composition editor and the widget creator can look the same or different.
503
+ Browser, the composition editor, the widget creator and Workflows can look the same or different.
388
504
 
389
505
  ```js
390
506
  const editor = await mountModule('composition-editor', {
@@ -497,17 +613,17 @@ editor.setTheme({ radius: 'none' }); // one module alone
497
613
  theme the creator's greys are Tailwind's own, never more than 4 of 255 from what they were in a colour channel. The
498
614
  console says what stays light when a creator gets a dark theme. The File Browser and the composition editor follow a dark
499
615
  theme.
500
- - **No layout and no icons.** Components and spacing are Widgetic's. The words of the File Browser, the composition editor and the widget creator can be changed (see "Speaking your visitors' language").
616
+ - **No layout and no icons.** Components and spacing are Widgetic's. The words of the File Browser, the composition editor, the widget creator and Workflows can be changed (see "Speaking your visitors' language").
501
617
  - **Only colours the module can read as they are** (see "Writing a colour"): no CSS variables, and no gradient or image for a colour.
502
618
  - The old `ThemeConfig` object (`{ mode, colors: { secondary, surface, text }, spacing }`) is no longer accepted by `theme`: it never
503
619
  changed anything in a module. Use the settings above.
504
620
 
505
621
  ## Speaking your visitors' language
506
622
 
507
- The **File Browser**, the **composition editor** and the **widget creator** can speak your visitors' language. Every word
508
- they show is a *message* with a key: your page hands over the words it wants to change and every key it leaves out stays
509
- English, so a language can be added one screen at a time. The examples below are the File Browser's; "The composition
510
- editor" and "The widget creator" say what is different.
623
+ The **File Browser**, the **composition editor**, the **widget creator** and **Workflows** can speak your visitors'
624
+ language. Every word they show is a *message* with a key: your page hands over the words it wants to change and every key
625
+ it leaves out stays English, so a language can be added one screen at a time. The examples below are the File Browser's;
626
+ "The composition editor", "The widget creator" and "Workflows" say what is different.
511
627
 
512
628
  ```js
513
629
  const files = await mountModule('file-browser', {
@@ -526,12 +642,12 @@ files.setLanguage({ locale: 'de', messages: germanMessages }); // later, while i
526
642
 
527
643
  | Option | |
528
644
  | --- | --- |
529
- | `locale` | A BCP 47 language tag (`de`, `pt-BR`). It decides the plural rules and how numbers, dates ("2 days ago") and file sizes are written, through `Intl`. When a **translation pack** exists for the tag (see below), the module loads it as a lazy file next to `index.js` and applies those words before your `messages`. A tag with no pack keeps English for words; plural rules and direction still follow `locale`. Blank or left out is English. It is also the `lang` of the module's elements (a screen reader says the words in that language), and a language that is written right to left (`ar`, `he`, `fa`, `ur` ...) turns the whole screen of the File Browser, the composition editor and the widget creator around: see "Right to left". `new WidgeticUI({ locale })` hands it to every module of the page. |
645
+ | `locale` | A BCP 47 language tag (`de`, `pt-BR`). It decides the plural rules and how numbers, dates ("2 days ago") and file sizes are written, through `Intl`. When a **translation pack** exists for the tag (see below), the module loads it as a lazy file next to `index.js` and applies those words before your `messages`. A tag with no pack keeps English for words; plural rules and direction still follow `locale`. Blank or left out is English. It is also the `lang` of the module's elements (a screen reader says the words in that language), and a language that is written right to left (`ar`, `he`, `fa`, `ur` ...) turns the whole screen of the File Browser, the composition editor, the widget creator and Workflows around: see "Right to left". `new WidgeticUI({ locale })` hands it to every module of the page. |
530
646
  | `messages` | The words you want to change, `{ 'action.cancel': 'Anuluj', ... }`. A key you leave out stays English. |
531
647
  | `selectLabel` | The text of the button that hands the pick to your page, for a page that only wants to rename that one button (default "Select"). `messages['action.addToEditor']` does the same and wins when both are given. |
532
648
  | `setLanguage({ locale?, messages? })` | On the handle (`files.setLanguage`) and on a module you made yourself. Changes the language at once, while the module is on screen or before `mount()`. A value the call leaves out keeps what it was. `messages` it gives **replace** all the earlier ones: a page that switches from German to French passes the French only, and `setLanguage({ locale: '', messages: {} })` goes back to English. `null` counts as "not said". When `locale` changes, the module loads the matching pack (if any) and applies it in one step; two quick calls end in the language of the last call. |
533
649
 
534
- **Translation packs (shipped languages).** Each pack is one lazy file next to `index.js` (gzip budget per pack: File Browser **5 kB**, composition editor **9 kB**, widget creator **28 kB**; the build fails when a pack grows past its module's budget). **Twelve** languages ship today as lazy JSON packs on the CDN: the eight left-to-right ones (`fr`, `de`, `es`, `pt-BR`, `nl`, `da`, `sv`, `zh-CN`) and four right-to-left ones (`ar`, `he`, `fa`, `ur`; Hebrew also answers to the legacy tag `iw`). Every pack is **provisional** until a native speaker has reviewed it. Each module exposes `Module.supportedLocales` (the list above) and `Module.localePackStatus(tag)` (`'provisional' | 'reviewed' | null`). Master files for translators live in `modules/locales/<tag>.json` (union of all keys); the build splits them into one pack per module. Missing keys in a pack fall back to English. **Merge order:** pack → module English shortcuts (`selectLabel`, `presetLabels`, the File Browser's "Select" / "Files selected" toasts) → your `messages` (your page always wins). **Fallback examples:** `pt-PT` and `pt` → `pt-BR` pack; `fr-CA` → `fr`; `zh` / `zh-Hans` / `zh-SG` → `zh-CN`; `zh-TW` / `zh-Hant` → no pack (English words, Simplified is not used); `ar-SA`, `ar-EG` → `ar`; `he-IL` and `iw` → `he`; `fa-IR`, `fa-AF` → `fa`; `ur-PK`, `ur-IN` → `ur`; `en*` → no pack; unknown tag → English (no console line). A pack file that fails to load is reported once in the console; the module keeps working in English. On `mount()`, the module waits for the pack in parallel with its session token so the first paint can be in the pack language when the file arrives in time. Commands: `npm run locales:export-english`, `locales:import-shopify`, `locales:coverage`. Report a wrong translation to Widgetic support with the module name, `locale`, message key and what you expected.
650
+ **Translation packs (shipped languages).** Each pack is one lazy file next to `index.js` (gzip budget per pack: File Browser **5 kB**, composition editor **9 kB**, widget creator **28 kB**, Workflows **9 kB**; the build fails when a pack grows past its module's budget). **Twelve** languages ship today as lazy JSON packs on the CDN: the eight left-to-right ones (`fr`, `de`, `es`, `pt-BR`, `nl`, `da`, `sv`, `zh-CN`) and four right-to-left ones (`ar`, `he`, `fa`, `ur`; Hebrew also answers to the legacy tag `iw`). Every pack is **provisional** until a native speaker has reviewed it. Each module exposes `Module.supportedLocales` (the list above) and `Module.localePackStatus(tag)` (`'provisional' | 'reviewed' | null`). Master files for translators live in `modules/locales/<tag>.json` (union of all keys, with the 416 of Workflows); the build splits them into one pack per module. Missing keys in a pack fall back to English. **Merge order:** pack → module English shortcuts (`selectLabel`, `presetLabels`, the File Browser's "Select" / "Files selected" toasts) → your `messages` (your page always wins). **Fallback examples:** `pt-PT` and `pt` → `pt-BR` pack; `fr-CA` → `fr`; `zh` / `zh-Hans` / `zh-SG` → `zh-CN`; `zh-TW` / `zh-Hant` → no pack (English words, Simplified is not used); `ar-SA`, `ar-EG` → `ar`; `he-IL` and `iw` → `he`; `fa-IR`, `fa-AF` → `fa`; `ur-PK`, `ur-IN` → `ur`; `en*` → no pack; unknown tag → English (no console line). A pack file that fails to load is reported once in the console; the module keeps working in English. On `mount()`, the module waits for the pack in parallel with its session token so the first paint can be in the pack language when the file arrives in time (Workflows waits for the token and the pack both before it draws anything, so its first paint is always in the language). Commands: `npm run locales:export-english`, `locales:import-shopify`, `locales:coverage`. Report a wrong translation to Widgetic support with the module name, `locale`, message key and what you expected.
535
651
 
536
652
  **`action.addToEditor` vs Shopify.** The confirm button of the file picker is the message `action.addToEditor`. In these modules its English text is **Select** (`selectLabel` is a shortcut for the same key; `messages` wins over both). Packs seeded from the Shopify app's File Browser used Shopify's wording ("Add to Editor") for that key; the import script replaces it with Select in each language. There is no separate `action.select` key in the module catalogs (Shopify's JSON may list `action.select` for another button).
537
653
 
@@ -572,7 +688,7 @@ the module's English), not "Added 2 files to the editor", which is a sentence ab
572
688
  `locale: 5` throws a `TypeError` that names the option. `setLanguage` throws it itself and changes nothing; in
573
689
  `mountModule` it comes as a `ModuleMountError` (`MOUNT_FAILED`) with the `TypeError` as its `cause`.
574
690
 
575
- **Right to left.** Each of the three modules is read the way its `locale` is. For a language that is written right to left
691
+ **Right to left.** Each of the four modules is read the way its `locale` is. For a language that is written right to left
576
692
  (Arabic, Hebrew, Persian, Urdu and the others: the script of the language decides, not a list, so `ar-Latn` stays left to
577
693
  right) the whole screen turns around and starts a line on the right. `setLanguage({ locale: 'ar' })` turns a module that is
578
694
  on screen around, and `setLanguage({ locale: 'de' })` turns it back, with no new mount.
@@ -598,6 +714,14 @@ await mountModule('file-browser', { container: '#media', getToken, locale: 'ar'
598
714
  start, the title of a widget in its panel keeps the room it needs, and the pop-up of the brand kit hangs from the
599
715
  start edge of its button. The composition editor and the File Browser inside the creator are turned around the same
600
716
  way.
717
+ - **Workflows:** everything is placed by the start and the end of the line (the package's `tests/workflows-direction.test.mjs`
718
+ fails on a physical side), so the list, the top bar of the editor, the tabs, the side panel, the menus and the dialogs
719
+ mirror as a whole. **The canvas is the exception:** a workflow is read from its first block forward, so it is drawn left to
720
+ right in every language (`dir="ltr"` on it) and the lines run from the block on the left to the next one on its right.
721
+ Every element that names a direction says `rtl` outside the canvas (a library's own `dir` cannot put the screen back). A
722
+ page that calls `setLanguage` turns it around and back with no new mount, and `e2e/workflowsRtl.spec.ts` checks all of
723
+ this with `locale: 'ar'` and the English words as `messages` (they win over the Arabic pack, so the same text is laid out
724
+ both ways and a box can be compared to its mirror), because `locale` decides.
601
725
  - **What a visitor types** (a text field or the tags of the editor, the chat, a text in the quick edit of the creator) is
602
726
  read by its own first letter on a right to left screen: a sentence in Latin letters is set from the left and one in
603
727
  Arabic from the right, side by side. A field with nothing in it yet has no first letter, so it takes the direction of
@@ -645,6 +769,11 @@ and it splits what you give between them, so you never need to know which part s
645
769
  - the rich text editor of its text fields, the `shadEditor.` keys. The editor draws its own text toolbar (`editor.` keys),
646
770
  so these words are not on screen today, and a translation can leave them out.
647
771
 
772
+ Among the `editor.` keys, the nineteen `editor.presence.` ones ("Anna is editing", take over, look only) are on no screen
773
+ either: the module keeps the editor's `presence` off, because it runs on routes an editor session may not use. The language
774
+ packs leave them out (`npm run locales:coverage` counts them as missing for that reason); the nine `editor.conflict.` ones,
775
+ which the card of a refused save shows, are translated.
776
+
648
777
  `CompositionEditorModule.defaultMessages` lists all of them, with their English text: more than 500. A key that is in none
649
778
  of the three parts is said once in the console as `[Editor] ...`, with the nearest real key, and ignored.
650
779
 
@@ -741,8 +870,34 @@ creator.setLanguage({ locale: 'de', messages: germanMessages }); // every screen
741
870
  right to left, as the composition editor's is (see "Right to left" above); the canvas board, the live previews and the
742
871
  code stay left to right.
743
872
 
873
+ **Workflows.** It takes the same `locale`, `messages`, `setLanguage`, `defaultMessages` and `checkMessages`, with **one**
874
+ `messages` object for all of it: its 416 `workflows.` keys (the list, the editor and its panels, the names of blocks,
875
+ operators and units, what the engine finds wrong with a workflow, what a failed request means, and the words of the screen
876
+ that says a part could not be drawn). The words of a block are made of parts the screen puts together (`{field} {value}`,
877
+ `{count, plural, ...}`), so a language that puts them in another order can say so in its own message.
878
+
879
+ - **It speaks the twelve languages of the other modules.** `Workflows.supportedLocales` lists them (`fr`, `de`, `es`,
880
+ `pt-BR`, `nl`, `da`, `sv`, `zh-CN`, `ar`, `he`, `fa`, `ur`) and `Workflows.localePackStatus(tag)` is `'provisional'` for
881
+ each: a `locale` that has a pack fetches one lazy file of 416 messages (27 to 39 kB, 7 to 8 kB gzipped; the budget is
882
+ 9 kB gzipped), and `mount()` waits for it, so the first paint is already in that language. A `locale` with no pack
883
+ (English, `zh-TW`, an unknown tag) downloads nothing and says nothing in the console: the words stay English, while the
884
+ plural rules and the direction follow `locale` either way. Your `messages` win over the pack, key by key. The packs are
885
+ machine translations written from the English words (Workflows has no Shopify base to start from) and no native speaker
886
+ has read them yet; Arabic, Hebrew, Persian and Urdu put the technical words of a rule (a table, a column) between
887
+ left-to-right marks so they read in order, and Urdu puts a rule's parts in the order its sentence needs. They are built
888
+ like the other modules': `workflows` is in `MODULES` of `scripts/locales/lib/constants.mjs`, its keys are in
889
+ `locales/module-keys.json`, `src/workflows/localePackLoad.ts` fetches them and its budget is in
890
+ `LOCALE_PACK_MAX_GZIP_BYTES` in `scripts/lib/bundleBudget.mjs`. When the words of the screen change: change them in
891
+ `@widgetic/workflows`, run `npm run locales:export-english`, give the new keys a text in each of the twelve
892
+ `locales/<tag>.json` (`npm run locales:coverage` shows what is missing), and run `npm run locales:prepare-packs`.
893
+ - **A mistake never breaks the screen.** A key that does not exist (the console says which one you probably meant), a text
894
+ that is not a string or cannot be read: each is said once in the console as `[Workflows] ...` and the English text is
895
+ used. Only a *wrong shape* throws, naming the option (`messages: 'Abbrechen'`, `locale: 5`).
896
+ - **What stays as it is.** The `message` of its `error` events (use `code`).
897
+
744
898
  The page that makes sure of the first point is `harness/hostile.html?library=host&pseudo=1` (for the composition editor,
745
- `harness/composition-editor.html?pseudo=1`, for the widget creator `harness/widget-creator.html?pseudo=1`), which gives the module a `messages` object holding **every** default message
899
+ `harness/composition-editor.html?pseudo=1`, for the widget creator `harness/widget-creator.html?pseudo=1`, for Workflows
900
+ `harness/workflows.html?pseudo=1`), which gives the module a `messages` object holding **every** default message
746
901
  wrapped in marks (`Delete` becomes `⟦Delete⟧`): anything a visitor can read that has no marks is English the module wrote
747
902
  itself, which no `messages` could ever translate. The same trick works on your own page.
748
903
 
@@ -751,14 +906,15 @@ itself, which no `messages` could ever translate. The same trick works on your o
751
906
  | Command | What it does |
752
907
  | --- | --- |
753
908
  | `npm install` | Installs, then `patch-package` applies each file in `patches/` (none at the moment: see "Workarounds, and when to delete each"). A patch that no longer applies stops the install in the pipeline, where `patch-package` turns `--error-on-fail` on by itself; on your machine it prints the error and exits 0 |
754
- | `npm run build` / `npm run build:file-browser` / `npm run build:composition-editor` / `npm run build:widget-creator` | Builds `dist/<name>/index.js` and the lazy files in `dist/<name>/chunks/` (+ hidden source maps: no file points at them), prints the size, and fails when a file imports another to start, when it is over its budget or holds a script in a `data:` URL (see "Size budget" and "One file, and the parts that are not in it"). `npm run build` builds the three modules **one process each** (`scripts/lib/buildPlan.mjs`): the CSS compiler keeps what it learned in one build for the next, so the third module of a single process (widget-creator) came out with rules for the composition editor's classes and in another order than the file that is live, which a hand publish builds alone. Every process gets the flags of the first, the 6 GB heap that `npm run build` sets (`--max-old-space-size=6144`, the same as the pipeline's build job): at Node's default of about 4 GB the third module of one process used to stop with `JavaScript heap out of memory`, and one module alone fits (peak about 3.2 GB), so the `build:<name>` scripts need no flag |
755
- | `npm test` | Unit tests (vitest): token source, session token provider, emitter, picked files, shadow mount, the composition editor and widget creator modules, the creator's route list, CSS transforms, fonts, the publishing rules, the R2 store, the release plan and the two scripts of the release pipeline |
756
- | `npm run harness` | Serves `harness/hostile.html`, `harness/composition-editor.html`, `harness/widget-creator.html` and a mock Widgetic API on http://localhost:5290 |
909
+ | `npm run build` / `npm run build:file-browser` / `npm run build:composition-editor` / `npm run build:widget-creator` / `npm run build:workflows` | Builds `dist/<name>/index.js` and the lazy files in `dist/<name>/chunks/` (+ hidden source maps: no file points at them), prints the size, and fails when a file imports another to start, when it is over its budget or holds a script in a `data:` URL (see "Size budget" and "One file, and the parts that are not in it"). `npm run build` builds the four modules **one process each** (`scripts/lib/buildPlan.mjs`): the CSS compiler keeps what it learned in one build for the next, so the third module of a single process (widget-creator) came out with rules for the composition editor's classes and in another order than the file that is live, which a hand publish builds alone. Every process gets the flags of the first, the 6 GB heap that `npm run build` sets (`--max-old-space-size=6144`, the same as the pipeline's build job): at Node's default of about 4 GB the third module of one process used to stop with `JavaScript heap out of memory`, and one module alone fits (peak about 3.2 GB), so the `build:<name>` scripts need no flag |
910
+ | `npm test` | Unit tests (vitest): token source, session token provider, emitter, picked files, shadow mount, the composition editor, widget creator and Workflows modules, the creator's route list, CSS transforms, fonts, the publishing rules, the R2 store, the release plan and the two scripts of the release pipeline |
911
+ | `npm run harness` | Serves `harness/hostile.html`, `harness/composition-editor.html`, `harness/widget-creator.html`, `harness/workflows.html` and a mock Widgetic API on http://localhost:5290 |
757
912
  | `npm run test:e2e` | Playwright against the harness (`PLAYWRIGHT_CHANNEL=chrome` uses the installed Google Chrome instead of Playwright's download) |
758
913
  | `npm run check:creator-routes` | Reads the packages the creator is made of and checks that every route they can call is on the gateway's list for a creator session, or is listed with the reason a visitor can never reach it (`-- --inventory` prints it as JSON, see "What the end-to-end tests check") |
759
914
  | `npm run publish:cdn -- <module> [options]` | Releases a module to the CDN: see "Publishing". `--help` lists every option |
760
915
  | `npm run release:check -- --tag modules-v<x.y.z>` | The checks a release starts with (the tag against `package.json`, a lockfile the pipeline can install), on your machine: no keys, nothing written, no package needed |
761
- | `npm run release:publish` | Releases every built module from the tag in `CI_COMMIT_TAG` (or `-- --tag modules-v<x.y.z>`), in three passes. This is what the pipeline's `publish` job runs; it needs the R2 settings. See "Releasing from a tag" |
916
+ | `npm run release:publish` | Releases every built module from the tag in `CI_COMMIT_TAG` (or `-- --tag modules-v<x.y.z>`), in three passes. This is what the pipeline's `publish` job runs; it needs the R2 settings (read from Doppler once, when you run it). See "Releasing from a tag" |
917
+ | `npm run release:settings` | Checks that a release can reach the CDN's bucket: reads the R2 settings (from Doppler, or the environment), reads one object that is not there, writes nothing, prints no key. `npm run publish-to-npm` in `Frontend/ui-sdk` runs it before it raises the version |
762
918
  | `npm run typecheck` | `tsc --noEmit` over `src`, `tests`, `e2e` |
763
919
 
764
920
  Run `npm run build` (or the `build:<module>` of the one you test) before `npm run harness` / `npm run test:e2e`: the
@@ -822,7 +978,7 @@ SDK's README), and fails if the module needs anything more. `e2e/examplePage.spe
822
978
  `harness/react-page.html` is a page built with React 18 (its browser builds come from this workspace's `node_modules`, so
823
979
  the page needs no build) with the component of the SDK's README, for any module. `e2e/reactPage.spec.ts` runs it in
824
980
  `<React.StrictMode>` (React runs the effect, cleans it up and runs it again) and out of it, for the File Browser, the
825
- composition editor and the widget creator. The first run is cancelled before it counts as an instance, so the one-instance
981
+ composition editor, the widget creator and Workflows. The first run is cancelled before it counts as an instance, so the one-instance
826
982
  guards do not refuse the second; the module is downloaded once; nothing reaches the console; a component that React
827
983
  removes (its container leaves the page *before* the clean-up runs, and the module is taken down from it) leaves nothing
828
984
  behind; one that comes back mounts a fresh module; and a pick goes to the newest `onPick` without mounting again. Taking
@@ -923,6 +1079,14 @@ button is pressed (and that ordinary rate limiting is not reported as a limit).
923
1079
  one for each managed user, to check that the two work at once on their own canvases without refusing, telling or showing
924
1080
  each other anything.
925
1081
 
1082
+ Two rules of the gateway decide whether a call reaches these mocks at all, and `harness/gatewayRequestRules.mjs` holds both.
1083
+ The first is the request headers a page on another origin may send (the gateway's `ALLOWED_REQUEST_HEADERS`, in its
1084
+ `src/middleware/editorSessionCors.ts`, plus the File Browser's upload headers): the browser enforces it at the preflight, so a
1085
+ module that sends a header the list lacks never reaches the mock, and a test that waits for the answer times out without
1086
+ saying why. The second is the compression of a body: the creator gzips any JSON request of 4 KB or more (`Content-Encoding:
1087
+ gzip`: a canvas, a composition, a message with attachments), and the mocks read it inflated, as the gateway does. When the
1088
+ gateway changes either rule, change it there the same day; `tests/gatewayRequestRules.test.mjs` pins them.
1089
+
926
1090
  `e2e/widgetCreatorDarkMode.spec.ts` checks that the creator can be read in a dark look. It reads every text of the creator
927
1091
  the way the browser paints it (`e2e/support/contrastProbe.ts`: the colour of the text over what is behind it, through the
928
1092
  creator's shadow root and the chat's inside it, with an element's opacity and the translucent surfaces in between) and fails,
@@ -1084,8 +1248,9 @@ These are known, tracked for the File Browser work, and not hidden by the module
1084
1248
  from or written to `localStorage`: the module turns that off.)
1085
1249
  - **Files on another website need CORS for some previews.** Pictures, audio and video are shown without it; the text,
1086
1250
  PDF and font previews read the file with a script and need `Access-Control-Allow-Origin` on the file's host.
1087
- - **Words you can change.** The File Browser, the composition editor and the widget creator take `locale` and `messages`
1088
- (see "Speaking your visitors' language"); what each leaves in English is listed there and under its own known gaps.
1251
+ - **Words you can change.** The File Browser, the composition editor, the widget creator and Workflows take `locale` and
1252
+ `messages` (see "Speaking your visitors' language"); what each leaves in English is listed there and under its own
1253
+ known gaps.
1089
1254
  - **Right to left: what is left out.** The canvas board, the live previews and the code of the widget creator stay left to
1090
1255
  right on purpose (see "Right to left"), and two small things are open: the weekday names of an Urdu calendar are the
1091
1256
  short ones, which are whole words (the browser has no one-letter names for Urdu), and the panel of a widget in the
@@ -1186,6 +1351,36 @@ What is left:
1186
1351
  - **Publishing is covered by the gateway's tests, not by the end-to-end ones.** The harness answers 501 for publishing a
1187
1352
  widget, setting a version live and previewing a version.
1188
1353
 
1354
+ ### Known gaps of Workflows
1355
+
1356
+ What is open:
1357
+
1358
+ - **A touch screen reads the canvas only.** The canvas needs a pointer to move blocks and to drag a line from one point to
1359
+ another, so on a touch screen it is read-only: the side panel still changes the selected block, and a banner says so.
1360
+ - **No copy, cut or paste on the canvas.** A pasted block would bring ids and rules from somewhere else. Use Add block, or
1361
+ duplicate the whole workflow in Settings.
1362
+ - **The embed-code button needs a listener at mount time.** The page shows the code (it knows how its tag is built), so the
1363
+ screen has the button only when something listens for `showEmbedCode` when it mounts; a listener added later is not seen.
1364
+ - **The Runs tab counts in UTC days**, whatever the time zone of the workflow, which only decides when a scheduled trigger fires.
1365
+ - **There is no list of visitors.** Where a visitor is in a workflow is kept in that visitor's own browser, and the Runs tab
1366
+ counts how many went through each block, never who.
1367
+ - **Twelve languages, as lazy packs.** The same twelve as the other modules, provisional until a native speaker has read
1368
+ them: `supportedLocales` lists them (see "Speaking your visitors' language").
1369
+ - **Its events are not typed in the SDK.** The SDK types the events of three modules by name; a fourth typed overload makes
1370
+ TypeScript report a mistake against the wrong module, so Workflows is open, like a module the SDK knows nothing about:
1371
+ `on` takes any name and a handler is given what the module sent, unchecked. The reasoning is in `src/sdk/loader/ui.ts`.
1372
+ The form with one type argument (`mountModule<MyModule>('workflows', ...)`) does not compile for it: give both,
1373
+ `mountModule<MyModule, 'workflows'>(...)`. `tests/unit/fixtures/typedEvents.fixture.ts` pins both.
1374
+ - **The end-to-end tests cannot make the screen fail.** A part of the screen that cannot be drawn (`RENDER_FAILED`, the
1375
+ "Try again" button) is covered by the module's unit tests and the package's, not by a browser test, because a page has
1376
+ no way to make a Svelte component throw.
1377
+ - **Two listeners of Svelte's own on `document`.** While the screen is mounted Svelte's runtime listens to `click` on
1378
+ `document` (it delegates the events of its components) and takes it off again on unmount; its `reset` listener stays.
1379
+ The tests name both (`LISTENERS_OF_SVELTE_WHILE_MOUNTED`, `LISTENERS_LEFT_BY_SVELTE`), so a listener of the module's own
1380
+ is not hidden among them.
1381
+ - **The Arabic in the samples is not reviewed.** The Arabic sentence of the package's dev page and the one of
1382
+ `e2e/workflowsRtl.spec.ts` are samples to see the layout turn around, not translations a native speaker has read.
1383
+
1189
1384
  ## Publishing
1190
1385
 
1191
1386
  Partners' pages load three kinds of file from the CDN (`https://cdn.widgetic.com`, the `widgets` bucket on Cloudflare R2,
@@ -1214,7 +1409,7 @@ released. To release them:
1214
1409
 
1215
1410
  ```bash
1216
1411
  cd Frontend/ui-sdk/modules
1217
- # first, add the entry for <x.y.z> to src/file-browser/, src/composition-editor/ and src/widget-creator/CHANGELOG.md
1412
+ # first, add the entry for <x.y.z> to src/file-browser/, src/composition-editor/, src/widget-creator/ and src/workflows/CHANGELOG.md
1218
1413
  npm version <x.y.z> --no-git-tag-version # the version in package.json is the version that gets published
1219
1414
  git commit -am "Modules <x.y.z>" # merged into main the way every change is
1220
1415
  git switch main && git pull
@@ -1331,20 +1526,23 @@ module that needs a first release.
1331
1526
 
1332
1527
  1. **Put the work on `main`.** `publish:cdn` refuses a `modules/` with uncommitted changes, and a release has to come
1333
1528
  from a commit that is on the default branch.
1334
- 2. **Give the command the R2 keys.** The four names are the API gateway's own, so the values are in its Doppler config.
1335
- Use an R2 token of its own, limited to the `widgets` bucket with object read and write, and keep the file out of git
1336
- (`modules/.env` is ignored):
1529
+ 2. **Check that the command can reach the R2 keys.** The four names are the API gateway's own (`CLOUDFLARE_PUBLIC_ENDPOINT`,
1530
+ `R2_WIDGETS_NAME`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`), and the command reads them **from Doppler, every time it
1531
+ runs**: the gateway's production config (project `api-gateway-service`, config `prd`), with the Doppler CLI you are
1532
+ logged in to (`brew install dopplerhq/cli/doppler`, then `doppler login`). There is no `.env` file to make, copy or keep
1533
+ in step, and a key rotated in Doppler is the key the next release uses. This reads one object that is not there, writes
1534
+ nothing and prints no key:
1337
1535
 
1338
1536
  ```bash
1339
1537
  cd Frontend/ui-sdk/modules
1340
- cat > .env <<'EOF'
1341
- CLOUDFLARE_PUBLIC_ENDPOINT=...
1342
- R2_WIDGETS_NAME=...
1343
- R2_ACCESS_KEY_ID=...
1344
- R2_SECRET_ACCESS_KEY=...
1345
- EOF
1538
+ npm run release:settings
1346
1539
  ```
1347
1540
 
1541
+ It prints `R2 settings from Doppler (project api-gateway-service, config prd); the bucket "widgets" answers a read.` When it
1542
+ stops instead, it says why: the CLI is not installed, you are not logged in, you cannot read the project, or the bucket
1543
+ refuses the key. To release with a token of its own (limited to the `widgets` bucket, object read and write) put it in
1544
+ Doppler under the same four names and change `R2_SETTINGS_DOPPLER` in `scripts/lib/publishModule.mjs`.
1545
+
1348
1546
  3. **Look at CORS before you write anything.** A page on another origin `import()`s the module and `fetch`es its manifest,
1349
1547
  so the CDN must answer `Access-Control-Allow-Origin: *` for `modules/*`. On 2026-10-09 it already does, even for the
1350
1548
  404 of a manifest that does not exist yet, and for `sdks/browser/embed-sdk.js`:
@@ -1407,15 +1605,15 @@ module that needs a first release.
1407
1605
  export PROJECT='widgeticai%2FFrontend%2Fui-sdk'
1408
1606
  curl --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
1409
1607
  "https://gitlab.com/api/v4/projects/$PROJECT/protected_tags" --form 'name=modules-v*' --form 'create_access_level=40'
1410
- set -a; . ./.env; set +a
1411
1608
  for name in CLOUDFLARE_PUBLIC_ENDPOINT R2_WIDGETS_NAME R2_ACCESS_KEY_ID R2_SECRET_ACCESS_KEY; do
1609
+ value=$(doppler secrets get "$name" --plain --project api-gateway-service --config prd --no-check-version)
1412
1610
  masked=false; case "$name" in R2_ACCESS_KEY_ID|R2_SECRET_ACCESS_KEY) masked=true;; esac
1413
1611
  curl --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/$PROJECT/variables" \
1414
- --form "key=$name" --form "value=${!name}" --form 'protected=true' --form "masked=$masked" --form 'environment_scope=cdn'
1612
+ --form "key=$name" --form "value=$value" --form 'protected=true' --form "masked=$masked" --form 'environment_scope=cdn'
1415
1613
  done
1416
1614
  ```
1417
1615
 
1418
- (`${!name}` is bash. In zsh write `${(P)name}`.)
1616
+ (The values are read from Doppler into the loop and never printed. This works in bash and zsh alike.)
1419
1617
 
1420
1618
  8. **The next release goes by tag and proves the pipeline:** `npm version 0.1.1 --no-git-tag-version`, commit, merge,
1421
1619
  `git tag modules-v0.1.1 && git push origin modules-v0.1.1`.
@@ -1423,6 +1621,40 @@ module that needs a first release.
1423
1621
  Publish the modules **before** a `@widgetic/ui-sdk` version whose defaults point at them: `@widgetic/ui-sdk` 0.1.1 was on
1424
1622
  npm before step 5 was done, and until then its `mountModule` failed with `MODULE_NOT_FOUND`.
1425
1623
 
1624
+ ### The first release of a module added later
1625
+
1626
+ `workflows` was added after the three above, and the way it was released is the way the next module added later will be:
1627
+ **by a person, with steps 2 to 6 above**, and **before the next release of the loader** (a `version` bump pushed to `main`,
1628
+ or a `modules-v<x.y.z>` tag). That release builds every module in `MODULES`, and the first pass of the publishing job
1629
+ (`modules-publish` for `main`, `publish` for a tag) refuses a module that has no manifest. Nothing is written when it
1630
+ refuses, and the job can be run again once the module has its manifest, but nobody gets the release until then. `workflows`
1631
+ was released this way at 0.1.5 on 2026-10-26. In order, for a module that has no manifest yet:
1632
+
1633
+ 1. **Release `@widgetic/workflows` to npm** (the module bundles the package, and `npm ci` has to find it). The first
1634
+ publish of a package is made by hand, then the package is given a Trusted Publisher so that every later one is made by
1635
+ its pipeline: "Publish @widgetic packages to npm" in the Releases and deployments doc has the steps.
1636
+ 2. **In `modules/`, run `npm install` once and commit the lockfile.** Until `@widgetic/workflows` is on npm the lockfile
1637
+ cannot list it, and `npm run release:check` says so; this is the only time the lockfile is made by hand.
1638
+ 3. **Merge to `main`.** The merge releases nothing while the loader's `version` is unchanged.
1639
+ 4. **Build from that commit and publish `workflows` by hand**, as in steps 4 and 5 above, for this one module:
1640
+
1641
+ ```bash
1642
+ cd Frontend/ui-sdk/modules
1643
+ npm ci
1644
+ npm run build
1645
+ npm run publish:cdn -- workflows --skip-build --allow-create --dry-run
1646
+ npm run publish:cdn -- workflows --skip-build --allow-create
1647
+ ```
1648
+
1649
+ It is published at the version in `package.json`, and needs an entry for that version in
1650
+ `src/workflows/CHANGELOG.md`: the file starts with the entry the module was added under, so if the version has moved on
1651
+ by then, change that heading to the version and the date of the release before you publish.
1652
+ 5. **Look at what a page gets** (step 6 above): `https://cdn.widgetic.com/modules/workflows/manifest.json` answers with the
1653
+ version, and a page that calls `mountModule('workflows', ...)` with no `version` no longer fails with `MODULE_NOT_FOUND`.
1654
+
1655
+ From then on the module is released with the others: the next release raises the patch, writes its changelog sentence and
1656
+ publishes all of them, `workflows` included.
1657
+
1426
1658
  ### By hand
1427
1659
 
1428
1660
  ```bash
@@ -1467,9 +1699,16 @@ stays until the next release.) `build-module.mjs` refuses a build in which any f
1467
1699
  still publishes the maps, but nothing points at them, so whoever wants one loads it by its address in DevTools. A map
1468
1700
  carries the text of every source file it was made from, so publishing it is a decision about who may read the code.
1469
1701
 
1470
- The settings are the API gateway's own names, so the same values work: `CLOUDFLARE_PUBLIC_ENDPOINT`, `R2_WIDGETS_NAME`,
1471
- `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY` (and `CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ZONE_ID` for `--purge`). The real
1472
- environment wins over `modules/.env` (git-ignored, or `--env-file <path>`). Nothing prints them.
1702
+ The settings are the API gateway's own, with its names: `CLOUDFLARE_PUBLIC_ENDPOINT`, `R2_WIDGETS_NAME`,
1703
+ `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY` (and `CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ZONE_ID` for `--purge`, asked for only
1704
+ then). **They are read from Doppler every time the command runs**: the gateway's production config (project
1705
+ `api-gateway-service`, config `prd`, named once, as `R2_SETTINGS_DOPPLER` in `scripts/lib/publishModule.mjs`), with the
1706
+ Doppler CLI you are logged in to, asking for exactly those names and nothing else of the config. There is no `.env` for
1707
+ them and no `--env-file`. One exception: an environment that already holds all of them (the pipeline's runner, where they
1708
+ are variables of the `cdn` environment, or a shell started with `doppler run`) is used as it is, and Doppler is not asked;
1709
+ an environment that holds only some is not mixed with Doppler's, all of them come from the one place. `npm run
1710
+ release:settings` checks the settings and the bucket without publishing anything. Nothing prints a value: when Doppler
1711
+ cannot be read, the message says what the CLI said (not logged in, not installed, no access) and never a key.
1473
1712
 
1474
1713
  | I want to | Run (after `npm run publish:cdn --`) |
1475
1714
  | --- | --- |
@@ -1504,13 +1743,38 @@ Publish a module **before** the `@widgetic/ui-sdk` version whose defaults point
1504
1743
 
1505
1744
  ## Adding a module
1506
1745
 
1507
- 1. Create `src/<name>/` with `index.ts` (a class extending `ModuleEmitter`, using `TokenSource` and `createShadowMount`),
1508
- a host `.svelte` file and a `module.css` that imports the design-system styles and sets `@source` for the package's
1509
- components.
1746
+ 1. Create `src/<name>/` with `index.ts` (a class extending `ModuleEmitter`, using `TokenSource` when it talks to the API,
1747
+ and `createShadowMount`), a host `.svelte` file and a `module.css` that imports the design-system styles **and the
1748
+ theme tokens** (`@import '../../node_modules/@widgetic/file-browser/dist/components/core/FileBrowser.css'`, as the other
1749
+ modules do) and sets `@source` for the package's components. A module has to own the tokens it draws with
1750
+ (`--primary`, `--radius` ...): without them it takes whatever the partner's page defines, and a page that sets
1751
+ `:root { --primary: yellow }` repaints it. `e2e/themes.spec.ts` found this in Workflows.
1510
1752
  2. Register it in `MODULES` in `scripts/build-module.mjs`, build it, and give it a size budget in
1511
1753
  `scripts/lib/bundleBudget.mjs` a little above what it weighs, for the first load and for the module with its lazy files
1512
1754
  (see "Size budget"): a module with no budget fails the build. If it has a heavy part that few visitors need, see
1513
- "One file, and the parts that are not in it" before adding it to `LAZY_IMPORTS`.
1514
- 3. Add a harness page, an end-to-end spec on the hostile page, and unit tests for anything with logic.
1755
+ "One file, and the parts that are not in it" before adding it to `LAZY_IMPORTS`. The build swaps some files of the
1756
+ design system for ones that work inside a shadow root (`PACKAGE_FILE_OVERRIDES`) and **fails when one of them is not
1757
+ used**, which is how a renamed file is noticed. A module that has no use for some of them (a screen with no modal, menu
1758
+ or popover imports no `Portal.svelte`) says `overridesMayGoUnused: true` in its entry: the swaps still apply to whatever
1759
+ it does import, so a dialog added later is not left with the file that cannot work; only the check is waived. Say it
1760
+ only when that is the reason.
1761
+ 3. Add a harness page, an end-to-end spec on the hostile page, and unit tests for anything with logic. Add the module to
1762
+ the lists that run on every module: the `MODULES` of `e2e/themes.spec.ts` (with `componentsAddTheirOwnStyles: false`
1763
+ when its screen has no component `<style>` of its own, as Workflows' is made of Tailwind classes only: the test then
1764
+ expects none, and says so when that stops being true) and `e2e/reactPage.spec.ts`. Every module also needs an entry for
1765
+ the current version in its `src/<name>/CHANGELOG.md`: `tests/changelogFiles.test.mjs` fails without one.
1515
1766
  4. Anything a package does that cannot work inside a shadow root goes into "Workarounds" above with its removal
1516
1767
  condition, never into the partner's page.
1768
+ 5. Words: if the module has messages, give it `supportedLocales` and `localePackStatus` (a module with no packs says `[]`
1769
+ and `null`) so that a page can ask any module the same question. Packs are a separate step: "Workflows" under
1770
+ "Speaking your visitors' language" lists the files a module's packs are made of, and Workflows is the newest module
1771
+ that has them.
1772
+ 6. The loader (the root of this repository) has to know its name: `ComponentType` in `src/sdk/types/component.ts`,
1773
+ `types/index.d.ts` and `demo/svelte/routes/sdk/types/component.ts`, and `getComponentMinHeight` in
1774
+ `src/sdk/core/lifecycle.ts` (the height of the placeholder while the module downloads). Typed events are
1775
+ optional and limited: the SDK types the events of three modules by name, and a fourth overload makes TypeScript report
1776
+ a mistake against the wrong module, so a new module is open (`on` takes any name) until the overloads are
1777
+ restructured. Say so in `src/sdk/loader/ui.ts` and keep `tests/unit/fixtures/typedEvents.fixture.ts` honest.
1778
+ 7. Its package goes into the list of packages that are published (`Frontend/dev-tools`: the publish walk, the package
1779
+ list and the changelog paths of this repository) before the first release of the module, and `modules/package.json`
1780
+ asks for it. The first release of the module is made by hand ("The first release of a module added later").
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/ui-sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Framework-agnostic UI components for building Widgetic integrations",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "main": "dist/index.cjs",