@moxxy/cli 0.0.2 → 0.0.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,37 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ export {
34
+ __require,
35
+ __commonJS,
36
+ __toESM
37
+ };
@@ -0,0 +1,211 @@
1
+ // ../integration-base/dist/index.mjs
2
+ var IntegrationError = class extends Error {
3
+ constructor(message, integration, code, cause) {
4
+ super(message);
5
+ this.integration = integration;
6
+ this.code = code;
7
+ this.cause = cause;
8
+ this.name = "IntegrationError";
9
+ }
10
+ };
11
+ var IntegrationConnectionError = class extends IntegrationError {
12
+ constructor(message, integration, cause) {
13
+ super(message, integration, "CONNECTION_ERROR", cause);
14
+ this.name = "IntegrationConnectionError";
15
+ }
16
+ };
17
+ var IntegrationConfigError = class extends IntegrationError {
18
+ constructor(message, integration, cause) {
19
+ super(message, integration, "CONFIG_ERROR", cause);
20
+ this.name = "IntegrationConfigError";
21
+ }
22
+ };
23
+ var IntegrationNotFoundError = class extends IntegrationError {
24
+ constructor(integration) {
25
+ super(`Integration "${integration}" not found`, integration, "NOT_FOUND");
26
+ this.name = "IntegrationNotFoundError";
27
+ }
28
+ };
29
+ var BaseIntegration = class {
30
+ constructor(name, type) {
31
+ this.name = name;
32
+ this.type = type;
33
+ }
34
+ _status = "disconnected";
35
+ handlers = /* @__PURE__ */ new Map();
36
+ get status() {
37
+ return this._status;
38
+ }
39
+ async connect(config) {
40
+ if (this._status === "connected" || this._status === "watching") {
41
+ return;
42
+ }
43
+ this._status = "connecting";
44
+ try {
45
+ await this.onConnect(config);
46
+ this._status = "connected";
47
+ } catch (error) {
48
+ this._status = "error";
49
+ throw new IntegrationConnectionError(
50
+ `Failed to connect integration "${this.name}": ${error instanceof Error ? error.message : String(error)}`,
51
+ this.name,
52
+ error instanceof Error ? error : void 0
53
+ );
54
+ }
55
+ }
56
+ async disconnect() {
57
+ if (this._status === "disconnected") {
58
+ return;
59
+ }
60
+ try {
61
+ await this.onDisconnect();
62
+ } finally {
63
+ this._status = "disconnected";
64
+ }
65
+ }
66
+ async watch(targets) {
67
+ if (this._status !== "connected" && this._status !== "watching") {
68
+ throw new IntegrationConnectionError(
69
+ `Cannot watch: integration "${this.name}" is not connected`,
70
+ this.name
71
+ );
72
+ }
73
+ await this.onWatch(targets);
74
+ this._status = "watching";
75
+ }
76
+ async unwatch(targets) {
77
+ if (this._status !== "watching") {
78
+ return;
79
+ }
80
+ await this.onUnwatch(targets);
81
+ this._status = "connected";
82
+ }
83
+ async dispose() {
84
+ if (this._status !== "disconnected") {
85
+ await this.disconnect();
86
+ }
87
+ this.handlers.clear();
88
+ }
89
+ on(event, handler) {
90
+ let set = this.handlers.get(event);
91
+ if (!set) {
92
+ set = /* @__PURE__ */ new Set();
93
+ this.handlers.set(event, set);
94
+ }
95
+ set.add(handler);
96
+ }
97
+ off(event, handler) {
98
+ const set = this.handlers.get(event);
99
+ if (set) {
100
+ set.delete(handler);
101
+ if (set.size === 0) {
102
+ this.handlers.delete(event);
103
+ }
104
+ }
105
+ }
106
+ emit(type, data) {
107
+ const event = {
108
+ type,
109
+ integration: this.name,
110
+ data,
111
+ timestamp: Date.now()
112
+ };
113
+ const specificHandlers = this.handlers.get(type);
114
+ if (specificHandlers) {
115
+ for (const handler of specificHandlers) {
116
+ handler(event);
117
+ }
118
+ }
119
+ const wildcardHandlers = this.handlers.get("*");
120
+ if (wildcardHandlers) {
121
+ for (const handler of wildcardHandlers) {
122
+ handler(event);
123
+ }
124
+ }
125
+ }
126
+ };
127
+ var IntegrationManager = class {
128
+ integrations = /* @__PURE__ */ new Map();
129
+ handlers = /* @__PURE__ */ new Map();
130
+ integrationListeners = /* @__PURE__ */ new Map();
131
+ register(integration) {
132
+ this.integrations.set(integration.name, integration);
133
+ const listener = (event) => {
134
+ this.emitToHandlers(event);
135
+ };
136
+ this.integrationListeners.set(integration.name, listener);
137
+ integration.on("*", listener);
138
+ }
139
+ unregister(name) {
140
+ const integration = this.integrations.get(name);
141
+ if (!integration) {
142
+ return;
143
+ }
144
+ const listener = this.integrationListeners.get(name);
145
+ if (listener) {
146
+ integration.off("*", listener);
147
+ this.integrationListeners.delete(name);
148
+ }
149
+ this.integrations.delete(name);
150
+ }
151
+ get(name) {
152
+ return this.integrations.get(name);
153
+ }
154
+ getAll() {
155
+ return Array.from(this.integrations.values());
156
+ }
157
+ async startAll() {
158
+ const promises = [];
159
+ for (const integration of this.integrations.values()) {
160
+ promises.push(integration.connect({}));
161
+ }
162
+ await Promise.all(promises);
163
+ }
164
+ async stopAll() {
165
+ const promises = [];
166
+ for (const integration of this.integrations.values()) {
167
+ promises.push(integration.disconnect());
168
+ }
169
+ await Promise.all(promises);
170
+ }
171
+ on(event, handler) {
172
+ let set = this.handlers.get(event);
173
+ if (!set) {
174
+ set = /* @__PURE__ */ new Set();
175
+ this.handlers.set(event, set);
176
+ }
177
+ set.add(handler);
178
+ }
179
+ off(event, handler) {
180
+ const set = this.handlers.get(event);
181
+ if (set) {
182
+ set.delete(handler);
183
+ if (set.size === 0) {
184
+ this.handlers.delete(event);
185
+ }
186
+ }
187
+ }
188
+ emitToHandlers(event) {
189
+ const specificHandlers = this.handlers.get(event.type);
190
+ if (specificHandlers) {
191
+ for (const handler of specificHandlers) {
192
+ handler(event);
193
+ }
194
+ }
195
+ const wildcardHandlers = this.handlers.get("*");
196
+ if (wildcardHandlers) {
197
+ for (const handler of wildcardHandlers) {
198
+ handler(event);
199
+ }
200
+ }
201
+ }
202
+ };
203
+
204
+ export {
205
+ IntegrationError,
206
+ IntegrationConnectionError,
207
+ IntegrationConfigError,
208
+ IntegrationNotFoundError,
209
+ BaseIntegration,
210
+ IntegrationManager
211
+ };