@pinepaper.studio/mcp-server 1.0.0
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/LICENSE +21 -0
- package/README.md +406 -0
- package/dist/__tests__/fixtures/index.d.ts +8 -0
- package/dist/__tests__/fixtures/index.d.ts.map +1 -0
- package/dist/__tests__/fixtures/index.js +8 -0
- package/dist/__tests__/fixtures/index.js.map +1 -0
- package/dist/__tests__/fixtures/mock-animations.d.ts +213 -0
- package/dist/__tests__/fixtures/mock-animations.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-animations.js +96 -0
- package/dist/__tests__/fixtures/mock-animations.js.map +1 -0
- package/dist/__tests__/fixtures/mock-generators.d.ts +147 -0
- package/dist/__tests__/fixtures/mock-generators.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-generators.js +90 -0
- package/dist/__tests__/fixtures/mock-generators.js.map +1 -0
- package/dist/__tests__/fixtures/mock-items.d.ts +157 -0
- package/dist/__tests__/fixtures/mock-items.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-items.js +74 -0
- package/dist/__tests__/fixtures/mock-items.js.map +1 -0
- package/dist/__tests__/fixtures/mock-relations.d.ts +147 -0
- package/dist/__tests__/fixtures/mock-relations.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-relations.js +90 -0
- package/dist/__tests__/fixtures/mock-relations.js.map +1 -0
- package/dist/browser/bridge.d.ts +127 -0
- package/dist/browser/bridge.d.ts.map +1 -0
- package/dist/browser/bridge.js +320 -0
- package/dist/browser/bridge.js.map +1 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +8 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/puppeteer-controller.d.ts +93 -0
- package/dist/browser/puppeteer-controller.d.ts.map +1 -0
- package/dist/browser/puppeteer-controller.js +280 -0
- package/dist/browser/puppeteer-controller.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +109 -0
- package/dist/cli.js.map +1 -0
- package/dist/i18n/i18n-manager.d.ts +88 -0
- package/dist/i18n/i18n-manager.d.ts.map +1 -0
- package/dist/i18n/i18n-manager.js +209 -0
- package/dist/i18n/i18n-manager.js.map +1 -0
- package/dist/i18n/index.d.ts +10 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +10 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locales/ar.d.ts +6 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -0
- package/dist/i18n/locales/ar.js +106 -0
- package/dist/i18n/locales/ar.js.map +1 -0
- package/dist/i18n/locales/base.d.ts +17 -0
- package/dist/i18n/locales/base.d.ts.map +1 -0
- package/dist/i18n/locales/base.js +213 -0
- package/dist/i18n/locales/base.js.map +1 -0
- package/dist/i18n/locales/bn.d.ts +6 -0
- package/dist/i18n/locales/bn.d.ts.map +1 -0
- package/dist/i18n/locales/bn.js +106 -0
- package/dist/i18n/locales/bn.js.map +1 -0
- package/dist/i18n/locales/chp.d.ts +8 -0
- package/dist/i18n/locales/chp.d.ts.map +1 -0
- package/dist/i18n/locales/chp.js +11 -0
- package/dist/i18n/locales/chp.js.map +1 -0
- package/dist/i18n/locales/cr.d.ts +8 -0
- package/dist/i18n/locales/cr.d.ts.map +1 -0
- package/dist/i18n/locales/cr.js +11 -0
- package/dist/i18n/locales/cr.js.map +1 -0
- package/dist/i18n/locales/crg.d.ts +8 -0
- package/dist/i18n/locales/crg.d.ts.map +1 -0
- package/dist/i18n/locales/crg.js +11 -0
- package/dist/i18n/locales/crg.js.map +1 -0
- package/dist/i18n/locales/cs.d.ts +6 -0
- package/dist/i18n/locales/cs.d.ts.map +1 -0
- package/dist/i18n/locales/cs.js +106 -0
- package/dist/i18n/locales/cs.js.map +1 -0
- package/dist/i18n/locales/da.d.ts +6 -0
- package/dist/i18n/locales/da.d.ts.map +1 -0
- package/dist/i18n/locales/da.js +106 -0
- package/dist/i18n/locales/da.js.map +1 -0
- package/dist/i18n/locales/de.d.ts +6 -0
- package/dist/i18n/locales/de.d.ts.map +1 -0
- package/dist/i18n/locales/de.js +106 -0
- package/dist/i18n/locales/de.js.map +1 -0
- package/dist/i18n/locales/el.d.ts +6 -0
- package/dist/i18n/locales/el.d.ts.map +1 -0
- package/dist/i18n/locales/el.js +106 -0
- package/dist/i18n/locales/el.js.map +1 -0
- package/dist/i18n/locales/en.d.ts +6 -0
- package/dist/i18n/locales/en.d.ts.map +1 -0
- package/dist/i18n/locales/en.js +383 -0
- package/dist/i18n/locales/en.js.map +1 -0
- package/dist/i18n/locales/es.d.ts +6 -0
- package/dist/i18n/locales/es.d.ts.map +1 -0
- package/dist/i18n/locales/es.js +106 -0
- package/dist/i18n/locales/es.js.map +1 -0
- package/dist/i18n/locales/fa.d.ts +6 -0
- package/dist/i18n/locales/fa.d.ts.map +1 -0
- package/dist/i18n/locales/fa.js +106 -0
- package/dist/i18n/locales/fa.js.map +1 -0
- package/dist/i18n/locales/fi.d.ts +6 -0
- package/dist/i18n/locales/fi.d.ts.map +1 -0
- package/dist/i18n/locales/fi.js +106 -0
- package/dist/i18n/locales/fi.js.map +1 -0
- package/dist/i18n/locales/fil.d.ts +6 -0
- package/dist/i18n/locales/fil.d.ts.map +1 -0
- package/dist/i18n/locales/fil.js +383 -0
- package/dist/i18n/locales/fil.js.map +1 -0
- package/dist/i18n/locales/fr.d.ts +6 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -0
- package/dist/i18n/locales/fr.js +106 -0
- package/dist/i18n/locales/fr.js.map +1 -0
- package/dist/i18n/locales/gu.d.ts +6 -0
- package/dist/i18n/locales/gu.d.ts.map +1 -0
- package/dist/i18n/locales/gu.js +106 -0
- package/dist/i18n/locales/gu.js.map +1 -0
- package/dist/i18n/locales/he.d.ts +6 -0
- package/dist/i18n/locales/he.d.ts.map +1 -0
- package/dist/i18n/locales/he.js +106 -0
- package/dist/i18n/locales/he.js.map +1 -0
- package/dist/i18n/locales/hi.d.ts +6 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -0
- package/dist/i18n/locales/hi.js +106 -0
- package/dist/i18n/locales/hi.js.map +1 -0
- package/dist/i18n/locales/hu.d.ts +6 -0
- package/dist/i18n/locales/hu.d.ts.map +1 -0
- package/dist/i18n/locales/hu.js +106 -0
- package/dist/i18n/locales/hu.js.map +1 -0
- package/dist/i18n/locales/id.d.ts +6 -0
- package/dist/i18n/locales/id.d.ts.map +1 -0
- package/dist/i18n/locales/id.js +106 -0
- package/dist/i18n/locales/id.js.map +1 -0
- package/dist/i18n/locales/index.d.ts +110 -0
- package/dist/i18n/locales/index.d.ts.map +1 -0
- package/dist/i18n/locales/index.js +123 -0
- package/dist/i18n/locales/index.js.map +1 -0
- package/dist/i18n/locales/is.d.ts +6 -0
- package/dist/i18n/locales/is.d.ts.map +1 -0
- package/dist/i18n/locales/is.js +383 -0
- package/dist/i18n/locales/is.js.map +1 -0
- package/dist/i18n/locales/it.d.ts +6 -0
- package/dist/i18n/locales/it.d.ts.map +1 -0
- package/dist/i18n/locales/it.js +106 -0
- package/dist/i18n/locales/it.js.map +1 -0
- package/dist/i18n/locales/iu.d.ts +8 -0
- package/dist/i18n/locales/iu.d.ts.map +1 -0
- package/dist/i18n/locales/iu.js +11 -0
- package/dist/i18n/locales/iu.js.map +1 -0
- package/dist/i18n/locales/ja.d.ts +6 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -0
- package/dist/i18n/locales/ja.js +106 -0
- package/dist/i18n/locales/ja.js.map +1 -0
- package/dist/i18n/locales/kn.d.ts +6 -0
- package/dist/i18n/locales/kn.d.ts.map +1 -0
- package/dist/i18n/locales/kn.js +106 -0
- package/dist/i18n/locales/kn.js.map +1 -0
- package/dist/i18n/locales/ko.d.ts +6 -0
- package/dist/i18n/locales/ko.d.ts.map +1 -0
- package/dist/i18n/locales/ko.js +106 -0
- package/dist/i18n/locales/ko.js.map +1 -0
- package/dist/i18n/locales/mic.d.ts +8 -0
- package/dist/i18n/locales/mic.d.ts.map +1 -0
- package/dist/i18n/locales/mic.js +11 -0
- package/dist/i18n/locales/mic.js.map +1 -0
- package/dist/i18n/locales/ml.d.ts +6 -0
- package/dist/i18n/locales/ml.d.ts.map +1 -0
- package/dist/i18n/locales/ml.js +106 -0
- package/dist/i18n/locales/ml.js.map +1 -0
- package/dist/i18n/locales/moh.d.ts +8 -0
- package/dist/i18n/locales/moh.d.ts.map +1 -0
- package/dist/i18n/locales/moh.js +11 -0
- package/dist/i18n/locales/moh.js.map +1 -0
- package/dist/i18n/locales/mr.d.ts +6 -0
- package/dist/i18n/locales/mr.d.ts.map +1 -0
- package/dist/i18n/locales/mr.js +106 -0
- package/dist/i18n/locales/mr.js.map +1 -0
- package/dist/i18n/locales/ms.d.ts +6 -0
- package/dist/i18n/locales/ms.d.ts.map +1 -0
- package/dist/i18n/locales/ms.js +106 -0
- package/dist/i18n/locales/ms.js.map +1 -0
- package/dist/i18n/locales/nl.d.ts +6 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -0
- package/dist/i18n/locales/nl.js +106 -0
- package/dist/i18n/locales/nl.js.map +1 -0
- package/dist/i18n/locales/no.d.ts +6 -0
- package/dist/i18n/locales/no.d.ts.map +1 -0
- package/dist/i18n/locales/no.js +106 -0
- package/dist/i18n/locales/no.js.map +1 -0
- package/dist/i18n/locales/oj.d.ts +8 -0
- package/dist/i18n/locales/oj.d.ts.map +1 -0
- package/dist/i18n/locales/oj.js +11 -0
- package/dist/i18n/locales/oj.js.map +1 -0
- package/dist/i18n/locales/pa.d.ts +6 -0
- package/dist/i18n/locales/pa.d.ts.map +1 -0
- package/dist/i18n/locales/pa.js +106 -0
- package/dist/i18n/locales/pa.js.map +1 -0
- package/dist/i18n/locales/pl.d.ts +6 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -0
- package/dist/i18n/locales/pl.js +106 -0
- package/dist/i18n/locales/pl.js.map +1 -0
- package/dist/i18n/locales/pt-BR.d.ts +6 -0
- package/dist/i18n/locales/pt-BR.d.ts.map +1 -0
- package/dist/i18n/locales/pt-BR.js +106 -0
- package/dist/i18n/locales/pt-BR.js.map +1 -0
- package/dist/i18n/locales/pt.d.ts +6 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -0
- package/dist/i18n/locales/pt.js +106 -0
- package/dist/i18n/locales/pt.js.map +1 -0
- package/dist/i18n/locales/ro.d.ts +6 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -0
- package/dist/i18n/locales/ro.js +106 -0
- package/dist/i18n/locales/ro.js.map +1 -0
- package/dist/i18n/locales/ru.d.ts +6 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -0
- package/dist/i18n/locales/ru.js +106 -0
- package/dist/i18n/locales/ru.js.map +1 -0
- package/dist/i18n/locales/sv.d.ts +6 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -0
- package/dist/i18n/locales/sv.js +106 -0
- package/dist/i18n/locales/sv.js.map +1 -0
- package/dist/i18n/locales/ta.d.ts +6 -0
- package/dist/i18n/locales/ta.d.ts.map +1 -0
- package/dist/i18n/locales/ta.js +106 -0
- package/dist/i18n/locales/ta.js.map +1 -0
- package/dist/i18n/locales/te.d.ts +6 -0
- package/dist/i18n/locales/te.d.ts.map +1 -0
- package/dist/i18n/locales/te.js +106 -0
- package/dist/i18n/locales/te.js.map +1 -0
- package/dist/i18n/locales/th.d.ts +6 -0
- package/dist/i18n/locales/th.d.ts.map +1 -0
- package/dist/i18n/locales/th.js +106 -0
- package/dist/i18n/locales/th.js.map +1 -0
- package/dist/i18n/locales/tl.d.ts +6 -0
- package/dist/i18n/locales/tl.d.ts.map +1 -0
- package/dist/i18n/locales/tl.js +106 -0
- package/dist/i18n/locales/tl.js.map +1 -0
- package/dist/i18n/locales/tr.d.ts +6 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -0
- package/dist/i18n/locales/tr.js +106 -0
- package/dist/i18n/locales/tr.js.map +1 -0
- package/dist/i18n/locales/uk.d.ts +6 -0
- package/dist/i18n/locales/uk.d.ts.map +1 -0
- package/dist/i18n/locales/uk.js +106 -0
- package/dist/i18n/locales/uk.js.map +1 -0
- package/dist/i18n/locales/ur.d.ts +6 -0
- package/dist/i18n/locales/ur.d.ts.map +1 -0
- package/dist/i18n/locales/ur.js +383 -0
- package/dist/i18n/locales/ur.js.map +1 -0
- package/dist/i18n/locales/vi.d.ts +6 -0
- package/dist/i18n/locales/vi.d.ts.map +1 -0
- package/dist/i18n/locales/vi.js +106 -0
- package/dist/i18n/locales/vi.js.map +1 -0
- package/dist/i18n/locales/zh-CN.d.ts +6 -0
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -0
- package/dist/i18n/locales/zh-CN.js +106 -0
- package/dist/i18n/locales/zh-CN.js.map +1 -0
- package/dist/i18n/locales/zh-TW.d.ts +6 -0
- package/dist/i18n/locales/zh-TW.d.ts.map +1 -0
- package/dist/i18n/locales/zh-TW.js +106 -0
- package/dist/i18n/locales/zh-TW.js.map +1 -0
- package/dist/i18n/types.d.ts +101 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +65 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +472 -0
- package/dist/index.js.map +1 -0
- package/dist/server/index.d.ts +39 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +89 -0
- package/dist/server/index.js.map +1 -0
- package/dist/tools/definitions.d.ts +26 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +785 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/handlers.d.ts +19 -0
- package/dist/tools/handlers.d.ts.map +1 -0
- package/dist/tools/handlers.js +477 -0
- package/dist/tools/handlers.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/code-generator.d.ts +97 -0
- package/dist/types/code-generator.d.ts.map +1 -0
- package/dist/types/code-generator.js +545 -0
- package/dist/types/code-generator.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/schemas.d.ts +707 -0
- package/dist/types/schemas.d.ts.map +1 -0
- package/dist/types/schemas.js +341 -0
- package/dist/types/schemas.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Relations for Testing
|
|
3
|
+
*/
|
|
4
|
+
export declare const mockOrbitsRelation: {
|
|
5
|
+
sourceId: string;
|
|
6
|
+
targetId: string;
|
|
7
|
+
relationType: "orbits";
|
|
8
|
+
params: {
|
|
9
|
+
radius: number;
|
|
10
|
+
speed: number;
|
|
11
|
+
direction: "counterclockwise";
|
|
12
|
+
phase: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const mockFollowsRelation: {
|
|
16
|
+
sourceId: string;
|
|
17
|
+
targetId: string;
|
|
18
|
+
relationType: "follows";
|
|
19
|
+
params: {
|
|
20
|
+
offset: [number, number];
|
|
21
|
+
smoothing: number;
|
|
22
|
+
delay: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const mockAttachedToRelation: {
|
|
26
|
+
sourceId: string;
|
|
27
|
+
targetId: string;
|
|
28
|
+
relationType: "attached_to";
|
|
29
|
+
params: {
|
|
30
|
+
offset: [number, number];
|
|
31
|
+
inherit_rotation: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const mockMaintainsDistanceRelation: {
|
|
35
|
+
sourceId: string;
|
|
36
|
+
targetId: string;
|
|
37
|
+
relationType: "maintains_distance";
|
|
38
|
+
params: {
|
|
39
|
+
distance: number;
|
|
40
|
+
strength: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const mockPointsAtRelation: {
|
|
44
|
+
sourceId: string;
|
|
45
|
+
targetId: string;
|
|
46
|
+
relationType: "points_at";
|
|
47
|
+
params: {
|
|
48
|
+
offset_angle: number;
|
|
49
|
+
smoothing: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const mockMirrorsRelation: {
|
|
53
|
+
sourceId: string;
|
|
54
|
+
targetId: string;
|
|
55
|
+
relationType: "mirrors";
|
|
56
|
+
params: {
|
|
57
|
+
axis: "vertical";
|
|
58
|
+
center: [number, number];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare const mockParallaxRelation: {
|
|
62
|
+
sourceId: string;
|
|
63
|
+
targetId: string;
|
|
64
|
+
relationType: "parallax";
|
|
65
|
+
params: {
|
|
66
|
+
depth: number;
|
|
67
|
+
origin: [number, number];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare const mockBoundsToRelation: {
|
|
71
|
+
sourceId: string;
|
|
72
|
+
targetId: string;
|
|
73
|
+
relationType: "bounds_to";
|
|
74
|
+
params: {
|
|
75
|
+
padding: number;
|
|
76
|
+
bounce: boolean;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export declare const allMockRelations: ({
|
|
80
|
+
sourceId: string;
|
|
81
|
+
targetId: string;
|
|
82
|
+
relationType: "orbits";
|
|
83
|
+
params: {
|
|
84
|
+
radius: number;
|
|
85
|
+
speed: number;
|
|
86
|
+
direction: "counterclockwise";
|
|
87
|
+
phase: number;
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
sourceId: string;
|
|
91
|
+
targetId: string;
|
|
92
|
+
relationType: "follows";
|
|
93
|
+
params: {
|
|
94
|
+
offset: [number, number];
|
|
95
|
+
smoothing: number;
|
|
96
|
+
delay: number;
|
|
97
|
+
};
|
|
98
|
+
} | {
|
|
99
|
+
sourceId: string;
|
|
100
|
+
targetId: string;
|
|
101
|
+
relationType: "attached_to";
|
|
102
|
+
params: {
|
|
103
|
+
offset: [number, number];
|
|
104
|
+
inherit_rotation: boolean;
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
sourceId: string;
|
|
108
|
+
targetId: string;
|
|
109
|
+
relationType: "maintains_distance";
|
|
110
|
+
params: {
|
|
111
|
+
distance: number;
|
|
112
|
+
strength: number;
|
|
113
|
+
};
|
|
114
|
+
} | {
|
|
115
|
+
sourceId: string;
|
|
116
|
+
targetId: string;
|
|
117
|
+
relationType: "points_at";
|
|
118
|
+
params: {
|
|
119
|
+
offset_angle: number;
|
|
120
|
+
smoothing: number;
|
|
121
|
+
};
|
|
122
|
+
} | {
|
|
123
|
+
sourceId: string;
|
|
124
|
+
targetId: string;
|
|
125
|
+
relationType: "mirrors";
|
|
126
|
+
params: {
|
|
127
|
+
axis: "vertical";
|
|
128
|
+
center: [number, number];
|
|
129
|
+
};
|
|
130
|
+
} | {
|
|
131
|
+
sourceId: string;
|
|
132
|
+
targetId: string;
|
|
133
|
+
relationType: "parallax";
|
|
134
|
+
params: {
|
|
135
|
+
depth: number;
|
|
136
|
+
origin: [number, number];
|
|
137
|
+
};
|
|
138
|
+
} | {
|
|
139
|
+
sourceId: string;
|
|
140
|
+
targetId: string;
|
|
141
|
+
relationType: "bounds_to";
|
|
142
|
+
params: {
|
|
143
|
+
padding: number;
|
|
144
|
+
bounce: boolean;
|
|
145
|
+
};
|
|
146
|
+
})[];
|
|
147
|
+
//# sourceMappingURL=mock-relations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-relations.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/mock-relations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;CAU9B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;gBAKR,CAAC,MAAM,EAAE,MAAM,CAAC;;;;CAIvC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;gBAKX,CAAC,MAAM,EAAE,MAAM,CAAC;;;CAGvC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;CAQzC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;CAQhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;gBAMN,CAAC,MAAM,EAAE,MAAM,CAAC;;CAEzC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;gBAMP,CAAC,MAAM,EAAE,MAAM,CAAC;;CAEzC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;CAQhC,CAAC;AAGF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;gBAnEL,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;gBAWhB,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;gBA+Bd,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;gBAUhB,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;IAwBzC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Relations for Testing
|
|
3
|
+
*/
|
|
4
|
+
export const mockOrbitsRelation = {
|
|
5
|
+
sourceId: 'item_2',
|
|
6
|
+
targetId: 'item_1',
|
|
7
|
+
relationType: 'orbits',
|
|
8
|
+
params: {
|
|
9
|
+
radius: 150,
|
|
10
|
+
speed: 0.5,
|
|
11
|
+
direction: 'counterclockwise',
|
|
12
|
+
phase: 0,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const mockFollowsRelation = {
|
|
16
|
+
sourceId: 'item_3',
|
|
17
|
+
targetId: 'item_1',
|
|
18
|
+
relationType: 'follows',
|
|
19
|
+
params: {
|
|
20
|
+
offset: [0, -50],
|
|
21
|
+
smoothing: 0.1,
|
|
22
|
+
delay: 0.2,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const mockAttachedToRelation = {
|
|
26
|
+
sourceId: 'label_1',
|
|
27
|
+
targetId: 'item_1',
|
|
28
|
+
relationType: 'attached_to',
|
|
29
|
+
params: {
|
|
30
|
+
offset: [0, -70],
|
|
31
|
+
inherit_rotation: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const mockMaintainsDistanceRelation = {
|
|
35
|
+
sourceId: 'item_4',
|
|
36
|
+
targetId: 'item_1',
|
|
37
|
+
relationType: 'maintains_distance',
|
|
38
|
+
params: {
|
|
39
|
+
distance: 200,
|
|
40
|
+
strength: 0.8,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export const mockPointsAtRelation = {
|
|
44
|
+
sourceId: 'arrow_1',
|
|
45
|
+
targetId: 'target_1',
|
|
46
|
+
relationType: 'points_at',
|
|
47
|
+
params: {
|
|
48
|
+
offset_angle: 0,
|
|
49
|
+
smoothing: 0.2,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const mockMirrorsRelation = {
|
|
53
|
+
sourceId: 'reflection_1',
|
|
54
|
+
targetId: 'original_1',
|
|
55
|
+
relationType: 'mirrors',
|
|
56
|
+
params: {
|
|
57
|
+
axis: 'vertical',
|
|
58
|
+
center: [400, 300],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
export const mockParallaxRelation = {
|
|
62
|
+
sourceId: 'bg_element',
|
|
63
|
+
targetId: 'camera',
|
|
64
|
+
relationType: 'parallax',
|
|
65
|
+
params: {
|
|
66
|
+
depth: 0.5,
|
|
67
|
+
origin: [400, 300],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export const mockBoundsToRelation = {
|
|
71
|
+
sourceId: 'player',
|
|
72
|
+
targetId: 'arena',
|
|
73
|
+
relationType: 'bounds_to',
|
|
74
|
+
params: {
|
|
75
|
+
padding: 20,
|
|
76
|
+
bounce: true,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
// Collection of all mock relations
|
|
80
|
+
export const allMockRelations = [
|
|
81
|
+
mockOrbitsRelation,
|
|
82
|
+
mockFollowsRelation,
|
|
83
|
+
mockAttachedToRelation,
|
|
84
|
+
mockMaintainsDistanceRelation,
|
|
85
|
+
mockPointsAtRelation,
|
|
86
|
+
mockMirrorsRelation,
|
|
87
|
+
mockParallaxRelation,
|
|
88
|
+
mockBoundsToRelation,
|
|
89
|
+
];
|
|
90
|
+
//# sourceMappingURL=mock-relations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-relations.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/mock-relations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,QAAiB;IAC/B,MAAM,EAAE;QACN,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,GAAG;QACV,SAAS,EAAE,kBAA2B;QACtC,KAAK,EAAE,CAAC;KACT;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,SAAkB;IAChC,MAAM,EAAE;QACN,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAqB;QACpC,SAAS,EAAE,GAAG;QACd,KAAK,EAAE,GAAG;KACX;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,aAAsB;IACpC,MAAM,EAAE;QACN,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAqB;QACpC,gBAAgB,EAAE,KAAK;KACxB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,oBAA6B;IAC3C,MAAM,EAAE;QACN,QAAQ,EAAE,GAAG;QACb,QAAQ,EAAE,GAAG;KACd;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,WAAoB;IAClC,MAAM,EAAE;QACN,YAAY,EAAE,CAAC;QACf,SAAS,EAAE,GAAG;KACf;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,YAAY;IACtB,YAAY,EAAE,SAAkB;IAChC,MAAM,EAAE;QACN,IAAI,EAAE,UAAmB;QACzB,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAqB;KACvC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,UAAmB;IACjC,MAAM,EAAE;QACN,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAqB;KACvC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,OAAO;IACjB,YAAY,EAAE,WAAoB;IAClC,MAAM,EAAE;QACN,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,IAAI;KACb;CACF,CAAC;AAEF,mCAAmC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,kBAAkB;IAClB,mBAAmB;IACnB,sBAAsB;IACtB,6BAA6B;IAC7B,oBAAoB;IACpB,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;CACrB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinePaper Browser Bridge
|
|
3
|
+
*
|
|
4
|
+
* postMessage interface for communication between PinePaper Studio (iframe/window)
|
|
5
|
+
* and the MCP server or external clients.
|
|
6
|
+
*
|
|
7
|
+
* This bridge enables:
|
|
8
|
+
* 1. Direct browser-to-PinePaper communication (no MCP required)
|
|
9
|
+
* 2. MCP server to PinePaper communication via postMessage relay
|
|
10
|
+
* 3. Cross-origin iframe communication for embedded PinePaper
|
|
11
|
+
*/
|
|
12
|
+
export interface BridgeMessage {
|
|
13
|
+
type: 'mcp-request' | 'mcp-response' | 'execute-code' | 'code-result' | 'ping' | 'pong';
|
|
14
|
+
id: string;
|
|
15
|
+
payload: unknown;
|
|
16
|
+
source: 'mcp-bridge' | 'pinepaper-studio';
|
|
17
|
+
}
|
|
18
|
+
export interface BridgeConfig {
|
|
19
|
+
targetOrigin: string;
|
|
20
|
+
targetWindow?: Window;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
onReady?: () => void;
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface PendingRequest {
|
|
26
|
+
resolve: (value: unknown) => void;
|
|
27
|
+
reject: (error: Error) => void;
|
|
28
|
+
timeout: ReturnType<typeof setTimeout>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* PinePaper Browser Bridge
|
|
32
|
+
*
|
|
33
|
+
* Provides a postMessage-based interface for communicating with PinePaper Studio.
|
|
34
|
+
* Can be used standalone in the browser or integrated with an MCP server.
|
|
35
|
+
*/
|
|
36
|
+
export declare class PinePaperBridge {
|
|
37
|
+
private config;
|
|
38
|
+
private pendingRequests;
|
|
39
|
+
private isReady;
|
|
40
|
+
private readyPromise;
|
|
41
|
+
private readyResolve;
|
|
42
|
+
private messageHandler;
|
|
43
|
+
constructor(config: BridgeConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Wait for the bridge to be ready
|
|
46
|
+
*/
|
|
47
|
+
waitForReady(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Check if bridge is connected
|
|
50
|
+
*/
|
|
51
|
+
get connected(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Send a ping to establish connection
|
|
54
|
+
*/
|
|
55
|
+
private ping;
|
|
56
|
+
/**
|
|
57
|
+
* Handle incoming messages
|
|
58
|
+
*/
|
|
59
|
+
private handleMessage;
|
|
60
|
+
/**
|
|
61
|
+
* Handle pong response (connection established)
|
|
62
|
+
*/
|
|
63
|
+
private handlePong;
|
|
64
|
+
/**
|
|
65
|
+
* Handle response messages
|
|
66
|
+
*/
|
|
67
|
+
private handleResponse;
|
|
68
|
+
/**
|
|
69
|
+
* Send a message to PinePaper Studio
|
|
70
|
+
*/
|
|
71
|
+
private postMessage;
|
|
72
|
+
/**
|
|
73
|
+
* Generate unique message ID
|
|
74
|
+
*/
|
|
75
|
+
private generateId;
|
|
76
|
+
/**
|
|
77
|
+
* Execute code in PinePaper Studio
|
|
78
|
+
*/
|
|
79
|
+
executeCode(code: string): Promise<unknown>;
|
|
80
|
+
/**
|
|
81
|
+
* Send an MCP tool request to PinePaper Studio
|
|
82
|
+
*/
|
|
83
|
+
sendToolRequest(toolName: string, args: Record<string, unknown>): Promise<unknown>;
|
|
84
|
+
/**
|
|
85
|
+
* Clean up resources
|
|
86
|
+
*/
|
|
87
|
+
destroy(): void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Message handler for PinePaper Studio side
|
|
91
|
+
*
|
|
92
|
+
* Install this in PinePaper Studio to handle incoming bridge messages.
|
|
93
|
+
*/
|
|
94
|
+
export declare class PinePaperStudioHandler {
|
|
95
|
+
private allowedOrigins;
|
|
96
|
+
private messageHandler;
|
|
97
|
+
constructor(allowedOrigins?: string[]);
|
|
98
|
+
/**
|
|
99
|
+
* Handle incoming messages
|
|
100
|
+
*/
|
|
101
|
+
private handleMessage;
|
|
102
|
+
/**
|
|
103
|
+
* Handle ping message
|
|
104
|
+
*/
|
|
105
|
+
private handlePing;
|
|
106
|
+
/**
|
|
107
|
+
* Handle code execution request
|
|
108
|
+
*/
|
|
109
|
+
private handleExecuteCode;
|
|
110
|
+
/**
|
|
111
|
+
* Handle MCP tool request
|
|
112
|
+
*/
|
|
113
|
+
private handleMCPRequest;
|
|
114
|
+
/**
|
|
115
|
+
* Clean up resources
|
|
116
|
+
*/
|
|
117
|
+
destroy(): void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create a bridge to communicate with PinePaper Studio
|
|
121
|
+
*/
|
|
122
|
+
export declare function createBridge(config: BridgeConfig): PinePaperBridge;
|
|
123
|
+
/**
|
|
124
|
+
* Create a handler for PinePaper Studio side
|
|
125
|
+
*/
|
|
126
|
+
export declare function createStudioHandler(allowedOrigins?: string[]): PinePaperStudioHandler;
|
|
127
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/browser/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,aAAa,GAAG,cAAc,GAAG,cAAc,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;IACxF,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,YAAY,GAAG,kBAAkB,CAAC;CAC3C;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;CACxC;AAMD;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,eAAe,CAA0C;IACjE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,cAAc,CAAgC;gBAE1C,MAAM,EAAE,YAAY;IAqBhC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,OAAO,CAAC,IAAI;IASZ;;OAEG;IACH,OAAO,CAAC,aAAa;IA2BrB;;OAEG;IACH,OAAO,CAAC,UAAU;IAQlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAiBtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBjD;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBxF;;OAEG;IACH,OAAO,IAAI,IAAI;CAUhB;AAMD;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,cAAc,CAAgC;gBAE1C,cAAc,GAAE,MAAM,EAAU;IAM5C;;OAEG;IACH,OAAO,CAAC,aAAa;IA6BrB;;OAEG;IACH,OAAO,CAAC,UAAU;IAYlB;;OAEG;YACW,iBAAiB;IAqC/B;;OAEG;YACW,gBAAgB;IAwC9B;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAElE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,sBAAsB,CAErF"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinePaper Browser Bridge
|
|
3
|
+
*
|
|
4
|
+
* postMessage interface for communication between PinePaper Studio (iframe/window)
|
|
5
|
+
* and the MCP server or external clients.
|
|
6
|
+
*
|
|
7
|
+
* This bridge enables:
|
|
8
|
+
* 1. Direct browser-to-PinePaper communication (no MCP required)
|
|
9
|
+
* 2. MCP server to PinePaper communication via postMessage relay
|
|
10
|
+
* 3. Cross-origin iframe communication for embedded PinePaper
|
|
11
|
+
*/
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// BROWSER BRIDGE CLASS
|
|
14
|
+
// =============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* PinePaper Browser Bridge
|
|
17
|
+
*
|
|
18
|
+
* Provides a postMessage-based interface for communicating with PinePaper Studio.
|
|
19
|
+
* Can be used standalone in the browser or integrated with an MCP server.
|
|
20
|
+
*/
|
|
21
|
+
export class PinePaperBridge {
|
|
22
|
+
config;
|
|
23
|
+
pendingRequests = new Map();
|
|
24
|
+
isReady = false;
|
|
25
|
+
readyPromise;
|
|
26
|
+
readyResolve;
|
|
27
|
+
messageHandler;
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.config = {
|
|
30
|
+
targetWindow: window.parent,
|
|
31
|
+
timeout: 30000,
|
|
32
|
+
onReady: () => { },
|
|
33
|
+
onError: () => { },
|
|
34
|
+
...config,
|
|
35
|
+
};
|
|
36
|
+
this.readyPromise = new Promise((resolve) => {
|
|
37
|
+
this.readyResolve = resolve;
|
|
38
|
+
});
|
|
39
|
+
// Bind message handler
|
|
40
|
+
this.messageHandler = this.handleMessage.bind(this);
|
|
41
|
+
window.addEventListener('message', this.messageHandler);
|
|
42
|
+
// Send initial ping
|
|
43
|
+
this.ping();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Wait for the bridge to be ready
|
|
47
|
+
*/
|
|
48
|
+
async waitForReady() {
|
|
49
|
+
return this.readyPromise;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if bridge is connected
|
|
53
|
+
*/
|
|
54
|
+
get connected() {
|
|
55
|
+
return this.isReady;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Send a ping to establish connection
|
|
59
|
+
*/
|
|
60
|
+
ping() {
|
|
61
|
+
this.postMessage({
|
|
62
|
+
type: 'ping',
|
|
63
|
+
id: this.generateId(),
|
|
64
|
+
payload: { timestamp: Date.now() },
|
|
65
|
+
source: 'mcp-bridge',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle incoming messages
|
|
70
|
+
*/
|
|
71
|
+
handleMessage(event) {
|
|
72
|
+
// Validate origin
|
|
73
|
+
if (this.config.targetOrigin !== '*' && event.origin !== this.config.targetOrigin) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const message = event.data;
|
|
77
|
+
if (!message || !message.type || message.source === 'mcp-bridge') {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
switch (message.type) {
|
|
81
|
+
case 'pong':
|
|
82
|
+
this.handlePong();
|
|
83
|
+
break;
|
|
84
|
+
case 'mcp-response':
|
|
85
|
+
case 'code-result':
|
|
86
|
+
this.handleResponse(message);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
// Ignore unknown message types
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Handle pong response (connection established)
|
|
95
|
+
*/
|
|
96
|
+
handlePong() {
|
|
97
|
+
if (!this.isReady) {
|
|
98
|
+
this.isReady = true;
|
|
99
|
+
this.readyResolve();
|
|
100
|
+
this.config.onReady();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle response messages
|
|
105
|
+
*/
|
|
106
|
+
handleResponse(message) {
|
|
107
|
+
const pending = this.pendingRequests.get(message.id);
|
|
108
|
+
if (!pending) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
clearTimeout(pending.timeout);
|
|
112
|
+
this.pendingRequests.delete(message.id);
|
|
113
|
+
const payload = message.payload;
|
|
114
|
+
if (payload.error) {
|
|
115
|
+
pending.reject(new Error(payload.error));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
pending.resolve(payload.result);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Send a message to PinePaper Studio
|
|
123
|
+
*/
|
|
124
|
+
postMessage(message) {
|
|
125
|
+
this.config.targetWindow.postMessage(message, this.config.targetOrigin);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Generate unique message ID
|
|
129
|
+
*/
|
|
130
|
+
generateId() {
|
|
131
|
+
return `msg_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Execute code in PinePaper Studio
|
|
135
|
+
*/
|
|
136
|
+
async executeCode(code) {
|
|
137
|
+
if (!this.isReady) {
|
|
138
|
+
await this.waitForReady();
|
|
139
|
+
}
|
|
140
|
+
const id = this.generateId();
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
const timeout = setTimeout(() => {
|
|
143
|
+
this.pendingRequests.delete(id);
|
|
144
|
+
reject(new Error('Request timeout'));
|
|
145
|
+
}, this.config.timeout);
|
|
146
|
+
this.pendingRequests.set(id, { resolve, reject, timeout });
|
|
147
|
+
this.postMessage({
|
|
148
|
+
type: 'execute-code',
|
|
149
|
+
id,
|
|
150
|
+
payload: { code },
|
|
151
|
+
source: 'mcp-bridge',
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Send an MCP tool request to PinePaper Studio
|
|
157
|
+
*/
|
|
158
|
+
async sendToolRequest(toolName, args) {
|
|
159
|
+
if (!this.isReady) {
|
|
160
|
+
await this.waitForReady();
|
|
161
|
+
}
|
|
162
|
+
const id = this.generateId();
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
const timeout = setTimeout(() => {
|
|
165
|
+
this.pendingRequests.delete(id);
|
|
166
|
+
reject(new Error('Request timeout'));
|
|
167
|
+
}, this.config.timeout);
|
|
168
|
+
this.pendingRequests.set(id, { resolve, reject, timeout });
|
|
169
|
+
this.postMessage({
|
|
170
|
+
type: 'mcp-request',
|
|
171
|
+
id,
|
|
172
|
+
payload: { tool: toolName, arguments: args },
|
|
173
|
+
source: 'mcp-bridge',
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Clean up resources
|
|
179
|
+
*/
|
|
180
|
+
destroy() {
|
|
181
|
+
window.removeEventListener('message', this.messageHandler);
|
|
182
|
+
// Cancel all pending requests
|
|
183
|
+
for (const [id, pending] of this.pendingRequests) {
|
|
184
|
+
clearTimeout(pending.timeout);
|
|
185
|
+
pending.reject(new Error('Bridge destroyed'));
|
|
186
|
+
this.pendingRequests.delete(id);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// =============================================================================
|
|
191
|
+
// PINEPAPER STUDIO HANDLER (runs inside PinePaper)
|
|
192
|
+
// =============================================================================
|
|
193
|
+
/**
|
|
194
|
+
* Message handler for PinePaper Studio side
|
|
195
|
+
*
|
|
196
|
+
* Install this in PinePaper Studio to handle incoming bridge messages.
|
|
197
|
+
*/
|
|
198
|
+
export class PinePaperStudioHandler {
|
|
199
|
+
allowedOrigins;
|
|
200
|
+
messageHandler;
|
|
201
|
+
constructor(allowedOrigins = ['*']) {
|
|
202
|
+
this.allowedOrigins = allowedOrigins;
|
|
203
|
+
this.messageHandler = this.handleMessage.bind(this);
|
|
204
|
+
window.addEventListener('message', this.messageHandler);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Handle incoming messages
|
|
208
|
+
*/
|
|
209
|
+
handleMessage(event) {
|
|
210
|
+
// Validate origin
|
|
211
|
+
if (!this.allowedOrigins.includes('*') &&
|
|
212
|
+
!this.allowedOrigins.includes(event.origin)) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const message = event.data;
|
|
216
|
+
if (!message || !message.type || message.source !== 'mcp-bridge') {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
switch (message.type) {
|
|
220
|
+
case 'ping':
|
|
221
|
+
this.handlePing(event.source, event.origin);
|
|
222
|
+
break;
|
|
223
|
+
case 'execute-code':
|
|
224
|
+
this.handleExecuteCode(message, event.source, event.origin);
|
|
225
|
+
break;
|
|
226
|
+
case 'mcp-request':
|
|
227
|
+
this.handleMCPRequest(message, event.source, event.origin);
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Handle ping message
|
|
233
|
+
*/
|
|
234
|
+
handlePing(source, origin) {
|
|
235
|
+
source.postMessage({
|
|
236
|
+
type: 'pong',
|
|
237
|
+
id: `pong_${Date.now()}`,
|
|
238
|
+
payload: { timestamp: Date.now() },
|
|
239
|
+
source: 'pinepaper-studio',
|
|
240
|
+
}, origin);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Handle code execution request
|
|
244
|
+
*/
|
|
245
|
+
async handleExecuteCode(message, source, origin) {
|
|
246
|
+
const { code } = message.payload;
|
|
247
|
+
try {
|
|
248
|
+
// Execute the code in PinePaper context
|
|
249
|
+
// eslint-disable-next-line no-eval
|
|
250
|
+
const result = await eval(`(async () => { ${code} })()`);
|
|
251
|
+
source.postMessage({
|
|
252
|
+
type: 'code-result',
|
|
253
|
+
id: message.id,
|
|
254
|
+
payload: { success: true, result },
|
|
255
|
+
source: 'pinepaper-studio',
|
|
256
|
+
}, origin);
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
source.postMessage({
|
|
260
|
+
type: 'code-result',
|
|
261
|
+
id: message.id,
|
|
262
|
+
payload: {
|
|
263
|
+
success: false,
|
|
264
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
265
|
+
},
|
|
266
|
+
source: 'pinepaper-studio',
|
|
267
|
+
}, origin);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Handle MCP tool request
|
|
272
|
+
*/
|
|
273
|
+
async handleMCPRequest(message, source, origin) {
|
|
274
|
+
const { tool, arguments: args } = message.payload;
|
|
275
|
+
try {
|
|
276
|
+
// Import and use the handler
|
|
277
|
+
const { handleToolCall } = await import('../tools/handlers.js');
|
|
278
|
+
const result = await handleToolCall(tool, args);
|
|
279
|
+
source.postMessage({
|
|
280
|
+
type: 'mcp-response',
|
|
281
|
+
id: message.id,
|
|
282
|
+
payload: { success: true, result },
|
|
283
|
+
source: 'pinepaper-studio',
|
|
284
|
+
}, origin);
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
source.postMessage({
|
|
288
|
+
type: 'mcp-response',
|
|
289
|
+
id: message.id,
|
|
290
|
+
payload: {
|
|
291
|
+
success: false,
|
|
292
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
293
|
+
},
|
|
294
|
+
source: 'pinepaper-studio',
|
|
295
|
+
}, origin);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Clean up resources
|
|
300
|
+
*/
|
|
301
|
+
destroy() {
|
|
302
|
+
window.removeEventListener('message', this.messageHandler);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// =============================================================================
|
|
306
|
+
// FACTORY FUNCTIONS
|
|
307
|
+
// =============================================================================
|
|
308
|
+
/**
|
|
309
|
+
* Create a bridge to communicate with PinePaper Studio
|
|
310
|
+
*/
|
|
311
|
+
export function createBridge(config) {
|
|
312
|
+
return new PinePaperBridge(config);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Create a handler for PinePaper Studio side
|
|
316
|
+
*/
|
|
317
|
+
export function createStudioHandler(allowedOrigins) {
|
|
318
|
+
return new PinePaperStudioHandler(allowedOrigins);
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=bridge.js.map
|