@widgetic/ui-sdk 0.1.2 → 0.1.3

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.
@@ -0,0 +1,16 @@
1
+ # Contributing to `@widgetic/ui-sdk`
2
+
3
+ This repository ships the framework-agnostic SDK (`src/`) and the heavy Svelte modules (`modules/`). Partners consume the published npm package and the CDN builds of the modules; do not commit secrets or CDN keys.
4
+
5
+ ## Build and test
6
+
7
+ - **SDK:** from the repo root, `npm run build` (Rollup).
8
+ - **Modules:** `cd modules`, then `npm ci`, `npm run typecheck`, `npm test`, `npm run build`, and `npm run test:e2e` (Playwright against `modules/harness/`; build modules first). `npm run release:check -- --tag modules-v0.1.0` must stay green before a modules release.
9
+
10
+ ## Commits
11
+
12
+ Use `type(scope): summary` in the subject and a short body with the why. Stage explicit paths only. Every module change that partners can see needs an entry under `## Unreleased` in that module's `modules/src/<name>/CHANGELOG.md` (see `modules/README.md`, "Versions and the changelog").
13
+
14
+ ## Locale work
15
+
16
+ Master translation files are in `modules/locales/`. Run `npm run locales:export-english` when message keys change, `npm run locales:import-shopify` to refresh File Browser seeds from the Shopify app (read-only), and `npm run locales:coverage` to see per-module progress.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) Widgetic
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -268,10 +268,15 @@ await creator.unmount();
268
268
  be retried, or the starting points not working: `during: 'presets'`). `reloadRequested` means the creator would have reloaded the page to
269
269
  recover: unmount it and mount a new one.
270
270
  - **Your own files.** Pass `mediaLibrary` (above) and the settings panel's file pickers show your files instead of the
271
- user's Widgetic uploads. Pictures dropped on the canvas and the chat's attachments (up to 10 MB) still go to Widgetic.
271
+ user's Widgetic uploads. When `upload` is given, chat attachments and canvas/prompt images call it with
272
+ `purpose: 'chat'` or `'canvas'` once per file (`{ file, purpose, onProgress?, signal? }`; pickers use `'field'`).
273
+ A file that is attached and then sent with the message is uploaded once, not again when the message is sent. The
274
+ transfer has no time limit of ours. When `upload` is given, a failure does not store the file in Widgetic: the visitor
275
+ is shown the message of your error ("The upload failed." when it has none), so reject with words a visitor can read.
276
+ Without `upload`, chat still uses Widgetic (up to 10 MB) and prompt images stay embedded as before.
272
277
  - **Keyboard.** Its shortcuts work only while the focus is inside it, so your page keeps every key it had; your page's
273
278
  own zoom works everywhere.
274
- - **Size and weight.** The module is about 5.8 MB (1.4 MB gzip), downloaded when you mount it and not before. A user who
279
+ - **Size and weight.** The module is about 6.1 MB (1.4 MB gzip), downloaded when you mount it and not before. A user who
275
280
  previews a PDF downloads two more files then (1.8 MB, 0.5 MB gzip). Call `preload('widget-creator')` on a `WidgeticUI`
276
281
  (below) when the page that will host it opens.
277
282
  - **One creator per page** for now; a second is refused with a clear message. The composition steps (*Edit* with a
@@ -346,8 +351,9 @@ Browser's; the differences of the composition editor and the widget creator are
346
351
 
347
352
  - **`locale`**, a [BCP 47](https://www.rfc-editor.org/info/bcp47) tag such as `de` or `pt-BR`. It sets the plural rules
348
353
  ("1 file", "2 files"; Polish and Arabic have more forms) and how numbers, dates and file sizes are written (`1,5 KB` in
349
- German). It translates nothing by itself. A tag the browser has no data for (`xx`) is reported in the console and
350
- English is used, so two languages never mix on one screen.
354
+ German). When the module has a **translation pack** for that tag (eight languages ship today; see the modules' README),
355
+ it loads the pack from the CDN and applies those words under your `messages`. Tags with no pack keep English for words.
356
+ A tag the browser has no plural data for (`xx`) is reported in the console and English formatting is used.
351
357
  - **`messages`**, the words: an object of message keys and texts. A key you leave out stays English, so a language can be
352
358
  added one screen at a time.
353
359
 
@@ -417,6 +423,7 @@ files.setLanguage({ locale: '', messages: {} }); // back to Englis
417
423
  | `dirty` | `{ dirty: boolean }` | Composition editor: there is, or is no longer, work that is not saved. |
418
424
  | `saved` | `{ composition, savedAt }` | Composition editor: a save went through. |
419
425
  | `canvasChanged` | `{ canvasId }` | Widget creator: it opened a canvas or made one. Keep the id and give it back as `canvasId` next time. |
426
+ | `presetChosen` | `{ key, canvasId, widgetId, widgetName, warnings, automatic }` | Widget creator: a starting point was chosen, before the creator opens on the copy. `key`, `canvasId`, `widgetId` and `widgetName` are `null` when the visitor chose *Start from scratch*; `automatic` is `true` when your `startFromPreset` was copied for them; `warnings` are sentences for you, not the visitor (usually empty). The creator then says `canvasChanged` for the copy. |
420
427
  | `widgetRenamed` | `{ widgetId, name }` | Widget creator: the main widget has this name (said when the canvas opens and each time the user renames it). |
421
428
  | `widgetPublished` | `{ widgetId, version? }` | Widget creator: the user published a version of a widget. |
422
429
  | `limitReached` | `{ message, code? }` | Widget creator: the user ran into a limit (credits, plan, storage, allowance). The creator has told them already. |
@@ -700,7 +707,7 @@ itself — its built output, not its source. The link is made by hand rather tha
700
707
  dev-alias setup the adopting apps use, so a sibling edit stays invisible here until that package rebuilds its `dist/`.
701
708
  Setup is the install script this package ships: it reinstalls and then links the sibling, so `node_modules` keeps
702
709
  resolving the checkout rather than the published package. The dev-alias workflow these packages have not adopted, and
703
- the reasons the adopting apps use it, are described in [the dev-tools README](../dev-tools/README.md).
710
+ the reasons the adopting apps use it, are described in the Widgetic monorepo's dev-tools package (not shipped inside this npm package).
704
711
 
705
712
  The SDK itself no longer imports `@widgetic/api-sdk`; the one sibling linked here is the `api-sdk` checkout, for the
706
713
  local demo app in `demo/`. `npm run i` is the whole setup: it reinstalls `node_modules`, then re-links that checkout.
@@ -712,11 +719,11 @@ npm run lapisdk # re-link only, after a fresh node_modules
712
719
 
713
720
  ## Contributing
714
721
 
715
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
722
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) and [modules/README.md](modules/README.md) for build, test, and changelog rules.
716
723
 
717
724
  ## License
718
725
 
719
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
726
+ This project is licensed under the ISC License (see the `license` field in `package.json`).
720
727
 
721
728
  ## Support
722
729
 
@@ -24,14 +24,16 @@
24
24
  export interface ModuleLanguage {
25
25
  /**
26
26
  * A BCP 47 language tag such as `de` or `pt-BR`. It sets the plural rules ("1 file", "2 files", and the extra forms
27
- * of Polish or Arabic) and how numbers, dates and file sizes are written. It does not translate anything by itself:
28
- * the words come from `messages`. A tag this browser has no data for is reported in the console and English is used.
27
+ * of Polish or Arabic) and how numbers, dates and file sizes are written. When the module has a **translation pack**
28
+ * for the tag (see the modules' README), it loads that pack from the CDN and applies those words under your
29
+ * `messages`. Tags with no pack keep English for words; formatting and text direction still follow `locale`. A tag
30
+ * this browser has no plural data for is reported in the console and English formatting is used.
29
31
  *
30
32
  * It is also the `lang` of the module's elements, so a screen reader says the words in that language. The File
31
33
  * Browser is read the way the language is written: a language written right to left (Arabic, Hebrew, Persian, Urdu
32
34
  * ...) turns the whole screen around, and `setLanguage` turns it around or back while it is on screen. The page's own
33
- * direction does not decide. The composition editor and the widget creator keep a left to right layout in every
34
- * language for now.
35
+ * direction does not decide. The composition editor and the widget creator follow `locale` the same way (panels, toolbars,
36
+ * menus and dialogs mirror); the canvas board, live widget previews and code fields stay left to right on purpose.
35
37
  */
36
38
  locale?: string;
37
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"module-language.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/module-language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,qGAAqG;AACrG,MAAM,WAAW,cAAc;IAC3B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC"}
1
+ {"version":3,"file":"module-language.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/module-language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,qGAAqG;AACrG,MAAM,WAAW,cAAc;IAC3B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC"}
@@ -48,6 +48,10 @@ export interface ModuleThemeColors {
48
48
  accent?: string;
49
49
  /** Errors, warnings about data loss, and delete buttons. */
50
50
  destructive?: string;
51
+ /** Panel and card surfaces (`--background`, `--card`, `--popover`, `--surface-canvas`). */
52
+ surface?: string;
53
+ /** Secondary fills and quiet rows (`--secondary`, `--muted`, `--grey1`). */
54
+ secondary?: string;
51
55
  }
52
56
  /** The typeface of a module. The widgets the visitor builds keep their own fonts. */
53
57
  export interface ModuleThemeFont {
@@ -1 +1 @@
1
- {"version":3,"file":"module-theme.d.ts","sourceRoot":"","sources":["../../../src/sdk/types/module-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAqB;AACrB,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,0FAA0F;AAC1F,MAAM,MAAM,qBAAqB,GAAG,UAA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