@fias/arche-sdk 1.1.5 → 1.1.7
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/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +18 -2
- package/dist/bridge.js.map +1 -1
- package/dist/index.mjs +82 -71
- package/package.json +1 -1
- package/templates/default/AGENTS.md +52 -35
- package/templates/default/CLAUDE.md +52 -35
package/dist/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAkCjB;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,mBAAmB,CAAqC;IAChE,OAAO,CAAC,uBAAuB,CAAuC;IACtE,OAAO,CAAC,SAAS,CAAS;;IAU1B;;;OAGG;IACH,MAAM,IAAI,IAAI;IAOd;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAgB,GAAG,IAAI;IAI5F;;OAEG;IACG,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAoB7E,SAAS,IAAI,MAAM;IAInB,cAAc,IAAI,gBAAgB,EAAE;IAIpC,QAAQ,IAAI,SAAS,GAAG,IAAI;IAI5B,cAAc,IAAI,MAAM;IAIxB,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;IAK/D,kBAAkB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAKhE,sBAAsB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAKtE;;;;;OAKG;IACG,aAAa,CACjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC9B,OAAO,CAAC,sBAAsB,CAAC;IAqBlC;;;OAGG;IACH,OAAO,IAAI,IAAI;IAef,OAAO,CAAC,aAAa,CA4EnB;IAEF,OAAO,CAAC,IAAI;CAcb;AASD,wBAAgB,SAAS,IAAI,UAAU,CAKtC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC"}
|
package/dist/bridge.js
CHANGED
|
@@ -3,10 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FiasBridge = void 0;
|
|
4
4
|
exports.getBridge = getBridge;
|
|
5
5
|
exports.resetBridge = resetBridge;
|
|
6
|
+
const theme_1 = require("./theme");
|
|
6
7
|
let messageCounter = 0;
|
|
7
8
|
function generateMessageId() {
|
|
8
9
|
return `msg_${Date.now()}_${++messageCounter}`;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Merges an incoming theme with defaults to ensure all fields are present.
|
|
13
|
+
* Protects plugins from crashing when the host sends an incomplete theme.
|
|
14
|
+
*/
|
|
15
|
+
function mergeThemeWithDefaults(incoming) {
|
|
16
|
+
const defaults = (0, theme_1.getDefaultTheme)(incoming.mode ?? 'dark');
|
|
17
|
+
return {
|
|
18
|
+
...defaults,
|
|
19
|
+
...incoming,
|
|
20
|
+
colors: { ...defaults.colors, ...(incoming.colors ?? {}) },
|
|
21
|
+
spacing: { ...defaults.spacing, ...(incoming.spacing ?? {}) },
|
|
22
|
+
fonts: { ...defaults.fonts, ...(incoming.fonts ?? {}) },
|
|
23
|
+
components: { ...defaults.components, ...(incoming.components ?? {}) },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
10
26
|
const DEFAULT_TIMEOUT_MS = 30000;
|
|
11
27
|
/**
|
|
12
28
|
* Low-level bridge client for postMessage communication with the FIAS host frame.
|
|
@@ -40,7 +56,7 @@ class FiasBridge {
|
|
|
40
56
|
const initMsg = data;
|
|
41
57
|
this.archId = initMsg.payload.archId;
|
|
42
58
|
this.permissions = initMsg.payload.permissions;
|
|
43
|
-
this.theme = initMsg.payload.theme;
|
|
59
|
+
this.theme = mergeThemeWithDefaults(initMsg.payload.theme);
|
|
44
60
|
this.currentPath = initMsg.payload.currentPath;
|
|
45
61
|
this.initialized = true;
|
|
46
62
|
this.initResolve?.();
|
|
@@ -51,7 +67,7 @@ class FiasBridge {
|
|
|
51
67
|
return;
|
|
52
68
|
// Handle theme updates
|
|
53
69
|
if (data.type === 'theme_update') {
|
|
54
|
-
this.theme = data.payload;
|
|
70
|
+
this.theme = mergeThemeWithDefaults(data.payload);
|
|
55
71
|
for (const listener of this.themeListeners) {
|
|
56
72
|
listener(this.theme);
|
|
57
73
|
}
|
package/dist/bridge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";;;AAyTA,8BAKC;AAKD,kCAGC;AA7TD,mCAA0C;AAE1C,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,SAAS,iBAAiB;IACxB,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAAC,QAA4B;IAC1D,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;IAC1D,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,QAAQ;QACX,MAAM,EAAE,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE;QAC1D,OAAO,EAAE,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;QAC7D,KAAK,EAAE,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE;QACvD,UAAU,EAAE,EAAE,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE;KACvE,CAAC;AACJ,CAAC;AASD,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAElC;;;GAGG;AACH,MAAa,UAAU;IAerB;QAdQ,oBAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;QACpD,gBAAW,GAAG,KAAK,CAAC;QACpB,gBAAW,GAAyB,IAAI,CAAC;QACzC,gBAAW,GAAwB,IAA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IG;AACH,IAAI,cAAc,GAAsB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAEhG,SAAgB,SAAS;IACvB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,UAAU,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,cAAc,EAAE,OAAO,EAAE,CAAC;IAC1B,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -5,11 +5,91 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
5
5
|
import { createContext } from "react";
|
|
6
6
|
var FiasBridgeContext = createContext(null);
|
|
7
7
|
|
|
8
|
+
// src/theme.ts
|
|
9
|
+
var SYSTEM_FONTS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
10
|
+
var MONO_FONTS = '"SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace';
|
|
11
|
+
var SHARED_SPACING = { xs: "4px", sm: "8px", md: "16px", lg: "24px", xl: "32px" };
|
|
12
|
+
var SHARED_FONTS = { body: SYSTEM_FONTS, heading: SYSTEM_FONTS, mono: MONO_FONTS };
|
|
13
|
+
var SHARED_COMPONENTS = {
|
|
14
|
+
borderRadius: "0.5rem",
|
|
15
|
+
buttonRadius: "0.375rem",
|
|
16
|
+
cardRadius: "0.5rem",
|
|
17
|
+
inputRadius: "0.375rem",
|
|
18
|
+
shadowSm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
19
|
+
shadowMd: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
20
|
+
shadowLg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
21
|
+
borderWidth: "1px"
|
|
22
|
+
};
|
|
23
|
+
var DARK_THEME = {
|
|
24
|
+
mode: "dark",
|
|
25
|
+
colors: {
|
|
26
|
+
primary: "#ffffff",
|
|
27
|
+
primaryText: "#0a0a0a",
|
|
28
|
+
secondary: "#1f1f1f",
|
|
29
|
+
accent: "#3b82f6",
|
|
30
|
+
background: "#0a0a0a",
|
|
31
|
+
surface: "#171717",
|
|
32
|
+
card: "#141414",
|
|
33
|
+
cardText: "#ffffff",
|
|
34
|
+
text: "#ffffff",
|
|
35
|
+
textSecondary: "#a6a6a6",
|
|
36
|
+
muted: "#1e1e1e",
|
|
37
|
+
mutedText: "#737373",
|
|
38
|
+
border: "#2e2e2e",
|
|
39
|
+
error: "#ef4444",
|
|
40
|
+
warning: "#f59e0b",
|
|
41
|
+
success: "#22c55e",
|
|
42
|
+
info: "#3b82f6"
|
|
43
|
+
},
|
|
44
|
+
spacing: SHARED_SPACING,
|
|
45
|
+
fonts: SHARED_FONTS,
|
|
46
|
+
components: SHARED_COMPONENTS
|
|
47
|
+
};
|
|
48
|
+
var LIGHT_THEME = {
|
|
49
|
+
mode: "light",
|
|
50
|
+
colors: {
|
|
51
|
+
primary: "#171717",
|
|
52
|
+
primaryText: "#ffffff",
|
|
53
|
+
secondary: "#e5e5e5",
|
|
54
|
+
accent: "#2563eb",
|
|
55
|
+
background: "#ffffff",
|
|
56
|
+
surface: "#fafafa",
|
|
57
|
+
card: "#ffffff",
|
|
58
|
+
cardText: "#0a0a0a",
|
|
59
|
+
text: "#0a0a0a",
|
|
60
|
+
textSecondary: "#737373",
|
|
61
|
+
muted: "#f5f5f5",
|
|
62
|
+
mutedText: "#a3a3a3",
|
|
63
|
+
border: "#e5e5e5",
|
|
64
|
+
error: "#dc2626",
|
|
65
|
+
warning: "#d97706",
|
|
66
|
+
success: "#16a34a",
|
|
67
|
+
info: "#2563eb"
|
|
68
|
+
},
|
|
69
|
+
spacing: SHARED_SPACING,
|
|
70
|
+
fonts: SHARED_FONTS,
|
|
71
|
+
components: SHARED_COMPONENTS
|
|
72
|
+
};
|
|
73
|
+
function getDefaultTheme(mode) {
|
|
74
|
+
return mode === "light" ? LIGHT_THEME : DARK_THEME;
|
|
75
|
+
}
|
|
76
|
+
|
|
8
77
|
// src/bridge.ts
|
|
9
78
|
var messageCounter = 0;
|
|
10
79
|
function generateMessageId() {
|
|
11
80
|
return `msg_${Date.now()}_${++messageCounter}`;
|
|
12
81
|
}
|
|
82
|
+
function mergeThemeWithDefaults(incoming) {
|
|
83
|
+
const defaults = getDefaultTheme(incoming.mode ?? "dark");
|
|
84
|
+
return {
|
|
85
|
+
...defaults,
|
|
86
|
+
...incoming,
|
|
87
|
+
colors: { ...defaults.colors, ...incoming.colors ?? {} },
|
|
88
|
+
spacing: { ...defaults.spacing, ...incoming.spacing ?? {} },
|
|
89
|
+
fonts: { ...defaults.fonts, ...incoming.fonts ?? {} },
|
|
90
|
+
components: { ...defaults.components, ...incoming.components ?? {} }
|
|
91
|
+
};
|
|
92
|
+
}
|
|
13
93
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
14
94
|
var FiasBridge = class {
|
|
15
95
|
constructor() {
|
|
@@ -35,7 +115,7 @@ var FiasBridge = class {
|
|
|
35
115
|
const initMsg = data;
|
|
36
116
|
this.archId = initMsg.payload.archId;
|
|
37
117
|
this.permissions = initMsg.payload.permissions;
|
|
38
|
-
this.theme = initMsg.payload.theme;
|
|
118
|
+
this.theme = mergeThemeWithDefaults(initMsg.payload.theme);
|
|
39
119
|
this.currentPath = initMsg.payload.currentPath;
|
|
40
120
|
this.initialized = true;
|
|
41
121
|
this.initResolve?.();
|
|
@@ -43,7 +123,7 @@ var FiasBridge = class {
|
|
|
43
123
|
}
|
|
44
124
|
if (this.hostOrigin && event.origin !== this.hostOrigin) return;
|
|
45
125
|
if (data.type === "theme_update") {
|
|
46
|
-
this.theme = data.payload;
|
|
126
|
+
this.theme = mergeThemeWithDefaults(data.payload);
|
|
47
127
|
for (const listener of this.themeListeners) {
|
|
48
128
|
listener(this.theme);
|
|
49
129
|
}
|
|
@@ -416,75 +496,6 @@ var fias = {
|
|
|
416
496
|
}
|
|
417
497
|
};
|
|
418
498
|
|
|
419
|
-
// src/theme.ts
|
|
420
|
-
var SYSTEM_FONTS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
421
|
-
var MONO_FONTS = '"SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace';
|
|
422
|
-
var SHARED_SPACING = { xs: "4px", sm: "8px", md: "16px", lg: "24px", xl: "32px" };
|
|
423
|
-
var SHARED_FONTS = { body: SYSTEM_FONTS, heading: SYSTEM_FONTS, mono: MONO_FONTS };
|
|
424
|
-
var SHARED_COMPONENTS = {
|
|
425
|
-
borderRadius: "0.5rem",
|
|
426
|
-
buttonRadius: "0.375rem",
|
|
427
|
-
cardRadius: "0.5rem",
|
|
428
|
-
inputRadius: "0.375rem",
|
|
429
|
-
shadowSm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
430
|
-
shadowMd: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
431
|
-
shadowLg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
432
|
-
borderWidth: "1px"
|
|
433
|
-
};
|
|
434
|
-
var DARK_THEME = {
|
|
435
|
-
mode: "dark",
|
|
436
|
-
colors: {
|
|
437
|
-
primary: "#ffffff",
|
|
438
|
-
primaryText: "#0a0a0a",
|
|
439
|
-
secondary: "#1f1f1f",
|
|
440
|
-
accent: "#3b82f6",
|
|
441
|
-
background: "#0a0a0a",
|
|
442
|
-
surface: "#171717",
|
|
443
|
-
card: "#141414",
|
|
444
|
-
cardText: "#ffffff",
|
|
445
|
-
text: "#ffffff",
|
|
446
|
-
textSecondary: "#a6a6a6",
|
|
447
|
-
muted: "#1e1e1e",
|
|
448
|
-
mutedText: "#737373",
|
|
449
|
-
border: "#2e2e2e",
|
|
450
|
-
error: "#ef4444",
|
|
451
|
-
warning: "#f59e0b",
|
|
452
|
-
success: "#22c55e",
|
|
453
|
-
info: "#3b82f6"
|
|
454
|
-
},
|
|
455
|
-
spacing: SHARED_SPACING,
|
|
456
|
-
fonts: SHARED_FONTS,
|
|
457
|
-
components: SHARED_COMPONENTS
|
|
458
|
-
};
|
|
459
|
-
var LIGHT_THEME = {
|
|
460
|
-
mode: "light",
|
|
461
|
-
colors: {
|
|
462
|
-
primary: "#171717",
|
|
463
|
-
primaryText: "#ffffff",
|
|
464
|
-
secondary: "#e5e5e5",
|
|
465
|
-
accent: "#2563eb",
|
|
466
|
-
background: "#ffffff",
|
|
467
|
-
surface: "#fafafa",
|
|
468
|
-
card: "#ffffff",
|
|
469
|
-
cardText: "#0a0a0a",
|
|
470
|
-
text: "#0a0a0a",
|
|
471
|
-
textSecondary: "#737373",
|
|
472
|
-
muted: "#f5f5f5",
|
|
473
|
-
mutedText: "#a3a3a3",
|
|
474
|
-
border: "#e5e5e5",
|
|
475
|
-
error: "#dc2626",
|
|
476
|
-
warning: "#d97706",
|
|
477
|
-
success: "#16a34a",
|
|
478
|
-
info: "#2563eb"
|
|
479
|
-
},
|
|
480
|
-
spacing: SHARED_SPACING,
|
|
481
|
-
fonts: SHARED_FONTS,
|
|
482
|
-
components: SHARED_COMPONENTS
|
|
483
|
-
};
|
|
484
|
-
function getDefaultTheme(mode) {
|
|
485
|
-
return mode === "light" ? LIGHT_THEME : DARK_THEME;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
499
|
// src/themes/catalog-data.ts
|
|
489
500
|
var DAISY_THEMES = [
|
|
490
501
|
{
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ import { FiasProvider } from '@fias/arche-sdk';
|
|
|
25
25
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
26
26
|
<FiasProvider>
|
|
27
27
|
<App />
|
|
28
|
-
</FiasProvider
|
|
28
|
+
</FiasProvider>,
|
|
29
29
|
);
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -42,13 +42,15 @@ function MyComponent() {
|
|
|
42
42
|
if (!theme) return null;
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<div
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
<div
|
|
46
|
+
style={{
|
|
47
|
+
color: theme.colors.text,
|
|
48
|
+
backgroundColor: theme.colors.background,
|
|
49
|
+
fontFamily: theme.fonts.body,
|
|
50
|
+
padding: theme.spacing.md,
|
|
51
|
+
borderRadius: theme.components.cardRadius,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
52
54
|
{theme.mode === 'dark' ? 'Dark mode' : 'Light mode'}
|
|
53
55
|
</div>
|
|
54
56
|
);
|
|
@@ -56,6 +58,7 @@ function MyComponent() {
|
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
**FiasTheme shape:**
|
|
61
|
+
|
|
59
62
|
- `mode`: `'light' | 'dark'`
|
|
60
63
|
- `colors`: `{ primary, primaryText, secondary, accent, background, surface, card, cardText, text, textSecondary, muted, mutedText, border, error, warning, success, info }`
|
|
61
64
|
- `spacing`: `{ xs, sm, md, lg, xl }` (CSS values like `'8px'`)
|
|
@@ -86,7 +89,7 @@ const { readFile, writeFile, listFiles, deleteFile } = useFiasStorage();
|
|
|
86
89
|
|
|
87
90
|
await writeFile('data/settings.json', JSON.stringify(settings));
|
|
88
91
|
const content = await readFile('data/settings.json'); // string | null
|
|
89
|
-
const files = await listFiles('data/');
|
|
92
|
+
const files = await listFiles('data/'); // string[]
|
|
90
93
|
await deleteFile('data/old.json');
|
|
91
94
|
```
|
|
92
95
|
|
|
@@ -158,8 +161,8 @@ const [count, setCount] = usePersistentState<number>('counter', 0);
|
|
|
158
161
|
```tsx
|
|
159
162
|
import { fias } from '@fias/arche-sdk';
|
|
160
163
|
|
|
161
|
-
fias.resize(800);
|
|
162
|
-
fias.showToast('Saved!', 'success');
|
|
164
|
+
fias.resize(800); // Resize iframe height
|
|
165
|
+
fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' | 'error'
|
|
163
166
|
```
|
|
164
167
|
|
|
165
168
|
## Manifest Reference (`fias-plugin.json`)
|
|
@@ -190,19 +193,19 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'w
|
|
|
190
193
|
|
|
191
194
|
**Fields:**
|
|
192
195
|
|
|
193
|
-
| Field | Required | Description
|
|
194
|
-
|
|
195
|
-
| `name` | Yes | Plugin identifier (lowercase, hyphens)
|
|
196
|
-
| `version` | Yes | Semver (e.g., `"1.0.0"`)
|
|
197
|
-
| `description` | Yes | Short marketplace description
|
|
198
|
-
| `main` | Yes | Entry point source file
|
|
199
|
-
| `archeType` | Yes | `"tool"` or `"site"`
|
|
200
|
-
| `tags` | No | Discovery tags
|
|
201
|
-
| `pricing` | Yes | `{ model: "free"
|
|
202
|
-
| `permissions` | Yes | Array of permission scopes
|
|
203
|
-
| `sdk` | Yes | SDK version range
|
|
196
|
+
| Field | Required | Description |
|
|
197
|
+
| -------------- | -------- | --------------------------------------------- | ------- | --------- | ----------- |
|
|
198
|
+
| `name` | Yes | Plugin identifier (lowercase, hyphens) |
|
|
199
|
+
| `version` | Yes | Semver (e.g., `"1.0.0"`) |
|
|
200
|
+
| `description` | Yes | Short marketplace description |
|
|
201
|
+
| `main` | Yes | Entry point source file |
|
|
202
|
+
| `archeType` | Yes | `"tool"` or `"site"` |
|
|
203
|
+
| `tags` | No | Discovery tags |
|
|
204
|
+
| `pricing` | Yes | `{ model: "free" | "fixed" | "per_use" | "tiered" }` |
|
|
205
|
+
| `permissions` | Yes | Array of permission scopes |
|
|
206
|
+
| `sdk` | Yes | SDK version range |
|
|
204
207
|
| `dependencies` | No | npm packages with **exact** versions (max 20) |
|
|
205
|
-
| `aiConfigs` | No | AI entity configurations (see below)
|
|
208
|
+
| `aiConfigs` | No | AI entity configurations (see below) |
|
|
206
209
|
|
|
207
210
|
**Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `entities:invoke`
|
|
208
211
|
|
|
@@ -213,6 +216,7 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'w
|
|
|
213
216
|
These are hard limits enforced by the platform. Code that violates these will fail review or be blocked at runtime.
|
|
214
217
|
|
|
215
218
|
### Sandboxing
|
|
219
|
+
|
|
216
220
|
- Plugins run in an iframe with `sandbox="allow-scripts allow-forms allow-same-origin"`
|
|
217
221
|
- **No `fetch()` or `XMLHttpRequest`** — all network access is blocked
|
|
218
222
|
- **No access** to parent DOM, cookies, or localStorage
|
|
@@ -220,17 +224,20 @@ These are hard limits enforced by the platform. Code that violates these will fa
|
|
|
220
224
|
- All platform communication goes through the bridge (SDK hooks)
|
|
221
225
|
|
|
222
226
|
### Size and File Limits
|
|
227
|
+
|
|
223
228
|
- **Bundle size:** Max 5 MB compressed
|
|
224
229
|
- **Dependencies:** Max 20, exact semver versions only (e.g., `"4.4.7"`, not `"^4.4.7"`)
|
|
225
230
|
- Platform packages (`react`, `react-dom`, `@fias/arche-sdk`) are provided — do not include in `dependencies`
|
|
226
231
|
|
|
227
232
|
### Rate Limits
|
|
233
|
+
|
|
228
234
|
- `entity_invoke`: 60/minute
|
|
229
235
|
- `storage_write`: 120/minute
|
|
230
236
|
- `storage_read`: 300/minute
|
|
231
237
|
- `storage_list`, `storage_delete`: 60/minute
|
|
232
238
|
|
|
233
239
|
### Security Rules (enforced during review)
|
|
240
|
+
|
|
234
241
|
- No `eval()`, `Function()`, `innerHTML`, or dynamic code execution
|
|
235
242
|
- No attempts to escape the iframe sandbox
|
|
236
243
|
- No credential collection or dark patterns
|
|
@@ -256,11 +263,19 @@ npm run dev:mock
|
|
|
256
263
|
# Open http://localhost:3200 in browser
|
|
257
264
|
```
|
|
258
265
|
|
|
266
|
+
### Authenticating with the FIAS Platform
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
npx fias-dev login # Opens browser to authenticate (recommended)
|
|
270
|
+
npx fias-dev login --key fias_sk_... # Or paste an API key directly
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Running `npx fias-dev login` opens your browser to the FIAS platform. After signing in, an API key is created automatically and saved to `~/.fias/credentials`. No manual key copying needed.
|
|
274
|
+
|
|
259
275
|
### Testing with Real AI Entities (costs credits)
|
|
260
276
|
|
|
261
277
|
```bash
|
|
262
|
-
|
|
263
|
-
npm run dev:harness # Start harness in live mode
|
|
278
|
+
npm run dev:harness # Start harness in live mode (requires login first)
|
|
264
279
|
```
|
|
265
280
|
|
|
266
281
|
### Browsing Available Entities
|
|
@@ -295,14 +310,16 @@ function Card({ children }: { children: React.ReactNode }) {
|
|
|
295
310
|
if (!theme) return null;
|
|
296
311
|
|
|
297
312
|
return (
|
|
298
|
-
<div
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
<div
|
|
314
|
+
style={{
|
|
315
|
+
backgroundColor: theme.colors.card,
|
|
316
|
+
color: theme.colors.cardText,
|
|
317
|
+
borderRadius: theme.components.cardRadius,
|
|
318
|
+
boxShadow: theme.components.shadowMd,
|
|
319
|
+
border: `${theme.components.borderWidth} solid ${theme.colors.border}`,
|
|
320
|
+
padding: theme.spacing.lg,
|
|
321
|
+
}}
|
|
322
|
+
>
|
|
306
323
|
{children}
|
|
307
324
|
</div>
|
|
308
325
|
);
|
|
@@ -318,7 +335,7 @@ function AIChat() {
|
|
|
318
335
|
|
|
319
336
|
return (
|
|
320
337
|
<div>
|
|
321
|
-
<textarea value={input} onChange={e => setInput(e.target.value)} />
|
|
338
|
+
<textarea value={input} onChange={(e) => setInput(e.target.value)} />
|
|
322
339
|
<button onClick={() => invoke({ entityId: 'ent_abc', input })} disabled={isLoading}>
|
|
323
340
|
Send
|
|
324
341
|
</button>
|
|
@@ -342,7 +359,7 @@ function Settings() {
|
|
|
342
359
|
<input
|
|
343
360
|
type="checkbox"
|
|
344
361
|
checked={settings.notifications}
|
|
345
|
-
onChange={e => setSettings({ ...settings, notifications: e.target.checked })}
|
|
362
|
+
onChange={(e) => setSettings({ ...settings, notifications: e.target.checked })}
|
|
346
363
|
/>
|
|
347
364
|
Notifications
|
|
348
365
|
</label>
|
|
@@ -25,7 +25,7 @@ import { FiasProvider } from '@fias/arche-sdk';
|
|
|
25
25
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
26
26
|
<FiasProvider>
|
|
27
27
|
<App />
|
|
28
|
-
</FiasProvider
|
|
28
|
+
</FiasProvider>,
|
|
29
29
|
);
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -42,13 +42,15 @@ function MyComponent() {
|
|
|
42
42
|
if (!theme) return null;
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<div
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
<div
|
|
46
|
+
style={{
|
|
47
|
+
color: theme.colors.text,
|
|
48
|
+
backgroundColor: theme.colors.background,
|
|
49
|
+
fontFamily: theme.fonts.body,
|
|
50
|
+
padding: theme.spacing.md,
|
|
51
|
+
borderRadius: theme.components.cardRadius,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
52
54
|
{theme.mode === 'dark' ? 'Dark mode' : 'Light mode'}
|
|
53
55
|
</div>
|
|
54
56
|
);
|
|
@@ -56,6 +58,7 @@ function MyComponent() {
|
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
**FiasTheme shape:**
|
|
61
|
+
|
|
59
62
|
- `mode`: `'light' | 'dark'`
|
|
60
63
|
- `colors`: `{ primary, primaryText, secondary, accent, background, surface, card, cardText, text, textSecondary, muted, mutedText, border, error, warning, success, info }`
|
|
61
64
|
- `spacing`: `{ xs, sm, md, lg, xl }` (CSS values like `'8px'`)
|
|
@@ -86,7 +89,7 @@ const { readFile, writeFile, listFiles, deleteFile } = useFiasStorage();
|
|
|
86
89
|
|
|
87
90
|
await writeFile('data/settings.json', JSON.stringify(settings));
|
|
88
91
|
const content = await readFile('data/settings.json'); // string | null
|
|
89
|
-
const files = await listFiles('data/');
|
|
92
|
+
const files = await listFiles('data/'); // string[]
|
|
90
93
|
await deleteFile('data/old.json');
|
|
91
94
|
```
|
|
92
95
|
|
|
@@ -158,8 +161,8 @@ const [count, setCount] = usePersistentState<number>('counter', 0);
|
|
|
158
161
|
```tsx
|
|
159
162
|
import { fias } from '@fias/arche-sdk';
|
|
160
163
|
|
|
161
|
-
fias.resize(800);
|
|
162
|
-
fias.showToast('Saved!', 'success');
|
|
164
|
+
fias.resize(800); // Resize iframe height
|
|
165
|
+
fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' | 'error'
|
|
163
166
|
```
|
|
164
167
|
|
|
165
168
|
## Manifest Reference (`fias-plugin.json`)
|
|
@@ -190,19 +193,19 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'w
|
|
|
190
193
|
|
|
191
194
|
**Fields:**
|
|
192
195
|
|
|
193
|
-
| Field | Required | Description
|
|
194
|
-
|
|
195
|
-
| `name` | Yes | Plugin identifier (lowercase, hyphens)
|
|
196
|
-
| `version` | Yes | Semver (e.g., `"1.0.0"`)
|
|
197
|
-
| `description` | Yes | Short marketplace description
|
|
198
|
-
| `main` | Yes | Entry point source file
|
|
199
|
-
| `archeType` | Yes | `"tool"` or `"site"`
|
|
200
|
-
| `tags` | No | Discovery tags
|
|
201
|
-
| `pricing` | Yes | `{ model: "free"
|
|
202
|
-
| `permissions` | Yes | Array of permission scopes
|
|
203
|
-
| `sdk` | Yes | SDK version range
|
|
196
|
+
| Field | Required | Description |
|
|
197
|
+
| -------------- | -------- | --------------------------------------------- | ------- | --------- | ----------- |
|
|
198
|
+
| `name` | Yes | Plugin identifier (lowercase, hyphens) |
|
|
199
|
+
| `version` | Yes | Semver (e.g., `"1.0.0"`) |
|
|
200
|
+
| `description` | Yes | Short marketplace description |
|
|
201
|
+
| `main` | Yes | Entry point source file |
|
|
202
|
+
| `archeType` | Yes | `"tool"` or `"site"` |
|
|
203
|
+
| `tags` | No | Discovery tags |
|
|
204
|
+
| `pricing` | Yes | `{ model: "free" | "fixed" | "per_use" | "tiered" }` |
|
|
205
|
+
| `permissions` | Yes | Array of permission scopes |
|
|
206
|
+
| `sdk` | Yes | SDK version range |
|
|
204
207
|
| `dependencies` | No | npm packages with **exact** versions (max 20) |
|
|
205
|
-
| `aiConfigs` | No | AI entity configurations (see below)
|
|
208
|
+
| `aiConfigs` | No | AI entity configurations (see below) |
|
|
206
209
|
|
|
207
210
|
**Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `entities:invoke`
|
|
208
211
|
|
|
@@ -213,6 +216,7 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'w
|
|
|
213
216
|
These are hard limits enforced by the platform. Code that violates these will fail review or be blocked at runtime.
|
|
214
217
|
|
|
215
218
|
### Sandboxing
|
|
219
|
+
|
|
216
220
|
- Plugins run in an iframe with `sandbox="allow-scripts allow-forms allow-same-origin"`
|
|
217
221
|
- **No `fetch()` or `XMLHttpRequest`** — all network access is blocked
|
|
218
222
|
- **No access** to parent DOM, cookies, or localStorage
|
|
@@ -220,17 +224,20 @@ These are hard limits enforced by the platform. Code that violates these will fa
|
|
|
220
224
|
- All platform communication goes through the bridge (SDK hooks)
|
|
221
225
|
|
|
222
226
|
### Size and File Limits
|
|
227
|
+
|
|
223
228
|
- **Bundle size:** Max 5 MB compressed
|
|
224
229
|
- **Dependencies:** Max 20, exact semver versions only (e.g., `"4.4.7"`, not `"^4.4.7"`)
|
|
225
230
|
- Platform packages (`react`, `react-dom`, `@fias/arche-sdk`) are provided — do not include in `dependencies`
|
|
226
231
|
|
|
227
232
|
### Rate Limits
|
|
233
|
+
|
|
228
234
|
- `entity_invoke`: 60/minute
|
|
229
235
|
- `storage_write`: 120/minute
|
|
230
236
|
- `storage_read`: 300/minute
|
|
231
237
|
- `storage_list`, `storage_delete`: 60/minute
|
|
232
238
|
|
|
233
239
|
### Security Rules (enforced during review)
|
|
240
|
+
|
|
234
241
|
- No `eval()`, `Function()`, `innerHTML`, or dynamic code execution
|
|
235
242
|
- No attempts to escape the iframe sandbox
|
|
236
243
|
- No credential collection or dark patterns
|
|
@@ -256,11 +263,19 @@ npm run dev:mock
|
|
|
256
263
|
# Open http://localhost:3200 in browser
|
|
257
264
|
```
|
|
258
265
|
|
|
266
|
+
### Authenticating with the FIAS Platform
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
npx fias-dev login # Opens browser to authenticate (recommended)
|
|
270
|
+
npx fias-dev login --key fias_sk_... # Or paste an API key directly
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Running `npx fias-dev login` opens your browser to the FIAS platform. After signing in, an API key is created automatically and saved to `~/.fias/credentials`. No manual key copying needed.
|
|
274
|
+
|
|
259
275
|
### Testing with Real AI Entities (costs credits)
|
|
260
276
|
|
|
261
277
|
```bash
|
|
262
|
-
|
|
263
|
-
npm run dev:harness # Start harness in live mode
|
|
278
|
+
npm run dev:harness # Start harness in live mode (requires login first)
|
|
264
279
|
```
|
|
265
280
|
|
|
266
281
|
### Browsing Available Entities
|
|
@@ -295,14 +310,16 @@ function Card({ children }: { children: React.ReactNode }) {
|
|
|
295
310
|
if (!theme) return null;
|
|
296
311
|
|
|
297
312
|
return (
|
|
298
|
-
<div
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
<div
|
|
314
|
+
style={{
|
|
315
|
+
backgroundColor: theme.colors.card,
|
|
316
|
+
color: theme.colors.cardText,
|
|
317
|
+
borderRadius: theme.components.cardRadius,
|
|
318
|
+
boxShadow: theme.components.shadowMd,
|
|
319
|
+
border: `${theme.components.borderWidth} solid ${theme.colors.border}`,
|
|
320
|
+
padding: theme.spacing.lg,
|
|
321
|
+
}}
|
|
322
|
+
>
|
|
306
323
|
{children}
|
|
307
324
|
</div>
|
|
308
325
|
);
|
|
@@ -318,7 +335,7 @@ function AIChat() {
|
|
|
318
335
|
|
|
319
336
|
return (
|
|
320
337
|
<div>
|
|
321
|
-
<textarea value={input} onChange={e => setInput(e.target.value)} />
|
|
338
|
+
<textarea value={input} onChange={(e) => setInput(e.target.value)} />
|
|
322
339
|
<button onClick={() => invoke({ entityId: 'ent_abc', input })} disabled={isLoading}>
|
|
323
340
|
Send
|
|
324
341
|
</button>
|
|
@@ -342,7 +359,7 @@ function Settings() {
|
|
|
342
359
|
<input
|
|
343
360
|
type="checkbox"
|
|
344
361
|
checked={settings.notifications}
|
|
345
|
-
onChange={e => setSettings({ ...settings, notifications: e.target.checked })}
|
|
362
|
+
onChange={(e) => setSettings({ ...settings, notifications: e.target.checked })}
|
|
346
363
|
/>
|
|
347
364
|
Notifications
|
|
348
365
|
</label>
|