@fiodos/web-core 0.1.11 → 0.1.14

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.
Files changed (42) hide show
  1. package/dist/cjs/adapters/webCredentialAutofillAdapter.d.ts +16 -0
  2. package/dist/cjs/adapters/webCredentialAutofillAdapter.js +47 -0
  3. package/dist/cjs/api/backendClient.js +14 -0
  4. package/dist/cjs/config/types.d.ts +21 -2
  5. package/dist/cjs/controller/AgentController.d.ts +35 -1
  6. package/dist/cjs/controller/AgentController.js +123 -3
  7. package/dist/cjs/dropin/createFiodosAgent.d.ts +32 -1
  8. package/dist/cjs/dropin/createFiodosAgent.js +39 -1
  9. package/dist/cjs/embed/dynamics.d.ts +61 -0
  10. package/dist/cjs/embed/dynamics.js +173 -0
  11. package/dist/cjs/embed/global.d.ts +45 -0
  12. package/dist/cjs/embed/global.js +48 -0
  13. package/dist/cjs/index.d.ts +3 -0
  14. package/dist/cjs/index.js +8 -1
  15. package/dist/cjs/orb/mountOrb.js +111 -18
  16. package/dist/cjs/orb/orbView.js +40 -7
  17. package/dist/cjs/orb/publishedConfig.d.ts +4 -2
  18. package/dist/cjs/orb/publishedConfig.js +56 -7
  19. package/dist/cjs/version.d.ts +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/embed/fiodos-embed.js +66 -0
  22. package/dist/esm/adapters/webCredentialAutofillAdapter.d.ts +16 -0
  23. package/dist/esm/adapters/webCredentialAutofillAdapter.js +44 -0
  24. package/dist/esm/api/backendClient.js +14 -0
  25. package/dist/esm/config/types.d.ts +21 -2
  26. package/dist/esm/controller/AgentController.d.ts +35 -1
  27. package/dist/esm/controller/AgentController.js +124 -4
  28. package/dist/esm/dropin/createFiodosAgent.d.ts +32 -1
  29. package/dist/esm/dropin/createFiodosAgent.js +39 -1
  30. package/dist/esm/embed/dynamics.d.ts +61 -0
  31. package/dist/esm/embed/dynamics.js +168 -0
  32. package/dist/esm/embed/global.d.ts +45 -0
  33. package/dist/esm/embed/global.js +46 -0
  34. package/dist/esm/index.d.ts +3 -0
  35. package/dist/esm/index.js +3 -0
  36. package/dist/esm/orb/mountOrb.js +112 -19
  37. package/dist/esm/orb/orbView.js +41 -8
  38. package/dist/esm/orb/publishedConfig.d.ts +4 -2
  39. package/dist/esm/orb/publishedConfig.js +56 -7
  40. package/dist/esm/version.d.ts +1 -1
  41. package/dist/esm/version.js +1 -1
  42. package/package.json +5 -3
@@ -11,6 +11,38 @@
11
11
  */
12
12
  import { mapPublishedConfigToOrbProps, resolveBubbleTheme, } from '@fiodos/core';
13
13
  import { DEFAULT_ORB_APPEARANCE } from './orbView.js';
14
+ /**
15
+ * Last-known-good published config, persisted so the customized orb survives
16
+ * page reloads during a backend outage and shows instantly on the next visit.
17
+ * Best-effort: storage failures (private mode, quota) are ignored.
18
+ */
19
+ const PUBLISHED_CONFIG_CACHE_KEY = 'fyodos:published-config:v1';
20
+ function readCachedPublishedConfig() {
21
+ try {
22
+ if (typeof window === 'undefined' || !window.localStorage)
23
+ return null;
24
+ const raw = window.localStorage.getItem(PUBLISHED_CONFIG_CACHE_KEY);
25
+ return raw ? JSON.parse(raw) : null;
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ function writeCachedPublishedConfig(published) {
32
+ try {
33
+ if (typeof window === 'undefined' || !window.localStorage)
34
+ return;
35
+ if (published) {
36
+ window.localStorage.setItem(PUBLISHED_CONFIG_CACHE_KEY, JSON.stringify(published));
37
+ }
38
+ else {
39
+ window.localStorage.removeItem(PUBLISHED_CONFIG_CACHE_KEY);
40
+ }
41
+ }
42
+ catch {
43
+ /* best-effort cache */
44
+ }
45
+ }
14
46
  function toResolved(props, published) {
15
47
  const enabled = published.orbEnabled !== false;
16
48
  const theme = props.theme;
@@ -45,8 +77,10 @@ function toResolved(props, published) {
45
77
  }
46
78
  /**
47
79
  * Starts watching the published config. Returns an unsubscribe function.
48
- * Best-effort: a failed fetch reports `null` (the orb keeps its current/default
49
- * look) and never throws into the host app.
80
+ * Best-effort: a failed fetch is SILENTLY skipped — the orb keeps its
81
+ * last-known-good (or cached) look instead of reverting to the default — and
82
+ * never throws into the host app. `onChange(null)` is reported ONLY when the
83
+ * backend confirms nothing is published.
50
84
  */
51
85
  export function watchPublishedConfig(controller, options) {
52
86
  const fetcher = controller.config.backend.fetchPublishedConfig;
@@ -55,18 +89,33 @@ export function watchPublishedConfig(controller, options) {
55
89
  return () => { };
56
90
  }
57
91
  let cancelled = false;
92
+ // Hydrate from the local cache so the customized orb shows instantly (and
93
+ // survives page loads while the backend is unreachable). The first network
94
+ // response below overwrites it as the source of truth.
95
+ const cached = readCachedPublishedConfig();
96
+ if (cached) {
97
+ options.onChange(toResolved(mapPublishedConfigToOrbProps(cached), cached));
98
+ }
58
99
  const load = async () => {
59
100
  try {
60
101
  const res = await fetcher.call(controller.config.backend);
61
102
  if (cancelled)
62
103
  return;
63
- options.onChange(res.published
64
- ? toResolved(mapPublishedConfigToOrbProps(res.published), res.published)
65
- : null);
104
+ if (res.published) {
105
+ options.onChange(toResolved(mapPublishedConfigToOrbProps(res.published), res.published));
106
+ writeCachedPublishedConfig(res.published);
107
+ }
108
+ else {
109
+ // A SUCCESSFUL response with nothing published: the project truly has
110
+ // no custom design, so the defaults are correct.
111
+ options.onChange(null);
112
+ writeCachedPublishedConfig(null);
113
+ }
66
114
  }
67
115
  catch {
68
- if (!cancelled)
69
- options.onChange(null);
116
+ // Transient failure (timeout, network blip after hours open, backend
117
+ // redeploy…): keep the current appearance. The next successful poll
118
+ // refreshes it.
70
119
  }
71
120
  };
72
121
  void load();
@@ -5,5 +5,5 @@
5
5
  * Auto-generated by scripts/sync-sdk-version.mjs from package.json. Do not edit
6
6
  * by hand — change package.json `version` and re-run the sync/release script.
7
7
  */
8
- export declare const SDK_VERSION = "0.1.11";
8
+ export declare const SDK_VERSION = "0.1.14";
9
9
  export declare const SDK_PACKAGE = "@fiodos/web-core";
@@ -5,5 +5,5 @@
5
5
  * Auto-generated by scripts/sync-sdk-version.mjs from package.json. Do not edit
6
6
  * by hand — change package.json `version` and re-run the sync/release script.
7
7
  */
8
- export const SDK_VERSION = '0.1.11';
8
+ export const SDK_VERSION = '0.1.14';
9
9
  export const SDK_PACKAGE = '@fiodos/web-core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiodos/web-core",
3
- "version": "0.1.11",
3
+ "version": "0.1.14",
4
4
  "description": "Framework-agnostic browser layer for the Fiodos agent: a vanilla AgentController (orchestrator), DOM adapters (navigation/voice/storage), HTTP client and decision engine over @fiodos/core. Shared base for @fiodos/vue, @fiodos/svelte and @fiodos/angular (no framework imports).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -23,16 +23,18 @@
23
23
  "LICENSE"
24
24
  ],
25
25
  "scripts": {
26
- "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node ../../scripts/fix-esm-extensions.mjs dist/esm && node ../../scripts/mark-dual.mjs",
26
+ "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node ../../scripts/fix-esm-extensions.mjs dist/esm && node ../../scripts/mark-dual.mjs && npm run build:embed",
27
+ "build:embed": "esbuild src/embed/global.ts --bundle --format=iife --target=es2019 --minify --outfile=dist/embed/fiodos-embed.js",
27
28
  "typecheck": "tsc -p tsconfig.json --noEmit",
28
29
  "test": "node --import tsx --test test/*.test.ts",
29
30
  "prepublishOnly": "node ../../scripts/sync-sdk-version.mjs && npm run build"
30
31
  },
31
32
  "dependencies": {
32
- "@fiodos/core": "^0.1.7"
33
+ "@fiodos/core": "^0.1.10"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/node": "^22.0.0",
37
+ "esbuild": "^0.28.1",
36
38
  "tsx": "^4.19.0",
37
39
  "typescript": "^5.6.0"
38
40
  }