swarpc 0.11.0 → 0.13.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/README.md +246 -171
- package/dist/client.d.ts +22 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/localstorage.d.ts.map +1 -1
- package/dist/log.d.ts +9 -3
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +52 -34
- package/dist/nodes.d.ts +12 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +36 -0
- package/dist/polyfills.d.ts +2 -0
- package/dist/polyfills.d.ts.map +1 -0
- package/dist/polyfills.js +20 -0
- package/dist/scopes.d.ts +4 -0
- package/dist/scopes.d.ts.map +1 -0
- package/dist/scopes.js +15 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +20 -29
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/package.json +24 -9
- package/src/client.ts +180 -109
- package/src/index.ts +9 -8
- package/src/localstorage.ts +46 -46
- package/src/log.ts +155 -118
- package/src/nodes.ts +55 -0
- package/src/polyfills.ts +22 -0
- package/src/scopes.ts +35 -0
- package/src/server.ts +275 -299
- package/src/types.ts +264 -239
- package/src/utils.ts +34 -34
package/src/server.ts
CHANGED
|
@@ -1,299 +1,275 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @mergeModuleWith <project>
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/// <reference lib="webworker" />
|
|
7
|
-
import { type } from "arktype"
|
|
8
|
-
import { createLogger, type LogLevel } from "./log.js"
|
|
9
|
-
import {
|
|
10
|
-
ImplementationsMap,
|
|
11
|
-
Payload,
|
|
12
|
-
PayloadCore,
|
|
13
|
-
PayloadHeaderSchema,
|
|
14
|
-
PayloadInitializeSchema,
|
|
15
|
-
PayloadSchema,
|
|
16
|
-
ProcedureImplementation,
|
|
17
|
-
zImplementations,
|
|
18
|
-
zProcedures,
|
|
19
|
-
type ProceduresMap,
|
|
20
|
-
} from "./types.js"
|
|
21
|
-
import { findTransferables } from "./utils.js"
|
|
22
|
-
import { FauxLocalStorage } from "./localstorage.js"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
l.info(requestId, `Error in ${functionName}`, error)
|
|
277
|
-
await postError(error)
|
|
278
|
-
} finally {
|
|
279
|
-
abortedRequests.delete(requestId)
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Listen for messages from the client
|
|
284
|
-
if (scopeIsShared(scope)) {
|
|
285
|
-
if (!port) throw new Error("SharedWorker port not initialized")
|
|
286
|
-
console.log("Listening for shared worker messages on port", port)
|
|
287
|
-
port.addEventListener("message", listener)
|
|
288
|
-
port.start()
|
|
289
|
-
} else if (scopeIsDedicated(scope)) {
|
|
290
|
-
scope.addEventListener("message", listener)
|
|
291
|
-
} else if (scopeIsService(scope)) {
|
|
292
|
-
scope.addEventListener("message", listener)
|
|
293
|
-
} else {
|
|
294
|
-
throw new Error(`Unsupported worker scope ${scope}`)
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return instance
|
|
299
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith <project>
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/// <reference lib="webworker" />
|
|
7
|
+
import { type } from "arktype";
|
|
8
|
+
import { createLogger, injectIntoConsoleGlobal, type LogLevel } from "./log.js";
|
|
9
|
+
import {
|
|
10
|
+
ImplementationsMap,
|
|
11
|
+
Payload,
|
|
12
|
+
PayloadCore,
|
|
13
|
+
PayloadHeaderSchema,
|
|
14
|
+
PayloadInitializeSchema,
|
|
15
|
+
PayloadSchema,
|
|
16
|
+
ProcedureImplementation,
|
|
17
|
+
zImplementations,
|
|
18
|
+
zProcedures,
|
|
19
|
+
type ProceduresMap,
|
|
20
|
+
} from "./types.js";
|
|
21
|
+
import { findTransferables } from "./utils.js";
|
|
22
|
+
import { FauxLocalStorage } from "./localstorage.js";
|
|
23
|
+
import { scopeIsDedicated, scopeIsShared, scopeIsService } from "./scopes.js";
|
|
24
|
+
import { nodeIdFromScope } from "./nodes.js";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The sw&rpc server instance, which provides methods to register {@link ProcedureImplementation | procedure implementations},
|
|
28
|
+
* and listens for incoming messages that call those procedures
|
|
29
|
+
*/
|
|
30
|
+
export type SwarpcServer<Procedures extends ProceduresMap> = {
|
|
31
|
+
[zProcedures]: Procedures;
|
|
32
|
+
[zImplementations]: ImplementationsMap<Procedures>;
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
} & {
|
|
35
|
+
[F in keyof Procedures]: (
|
|
36
|
+
impl: ProcedureImplementation<
|
|
37
|
+
Procedures[F]["input"],
|
|
38
|
+
Procedures[F]["progress"],
|
|
39
|
+
Procedures[F]["success"]
|
|
40
|
+
>,
|
|
41
|
+
) => void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const abortControllers = new Map<string, AbortController>();
|
|
45
|
+
const abortedRequests = new Set<string>();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates a sw&rpc server instance.
|
|
49
|
+
* @param procedures procedures the server will implement, see {@link ProceduresMap}
|
|
50
|
+
* @param options various options
|
|
51
|
+
* @param options.scope The worker scope to use, defaults to the `self` of the file where Server() is called.
|
|
52
|
+
* @param options.loglevel Maximum log level to use, defaults to "debug" (shows everything). "info" will not show debug messages, "warn" will only show warnings and errors, "error" will only show errors.
|
|
53
|
+
* @param options._scopeType @internal Don't touch, this is used in testing environments because the mock is subpar. Manually overrides worker scope type detection.
|
|
54
|
+
* @returns a SwarpcServer instance. Each property of the procedures map will be a method, that accepts a function implementing the procedure (see {@link ProcedureImplementation}). There is also .start(), to be called after implementing all procedures.
|
|
55
|
+
*
|
|
56
|
+
* An example of defining a server:
|
|
57
|
+
* {@includeCode ../example/src/service-worker.ts}
|
|
58
|
+
*/
|
|
59
|
+
export function Server<Procedures extends ProceduresMap>(
|
|
60
|
+
procedures: Procedures,
|
|
61
|
+
{
|
|
62
|
+
loglevel = "debug",
|
|
63
|
+
scope,
|
|
64
|
+
_scopeType,
|
|
65
|
+
}: {
|
|
66
|
+
scope?: WorkerGlobalScope;
|
|
67
|
+
loglevel?: LogLevel;
|
|
68
|
+
_scopeType?: "dedicated" | "shared" | "service";
|
|
69
|
+
} = {},
|
|
70
|
+
): SwarpcServer<Procedures> {
|
|
71
|
+
// If scope is not provided, use the global scope
|
|
72
|
+
// This function is meant to be used in a worker, so `self` is a WorkerGlobalScope
|
|
73
|
+
scope ??= self as WorkerGlobalScope;
|
|
74
|
+
|
|
75
|
+
// Service workers don't have a name, but it's fine anyways cuz we don't have multiple nodes when running with a SW
|
|
76
|
+
const nodeId = nodeIdFromScope(scope, _scopeType);
|
|
77
|
+
|
|
78
|
+
const l = createLogger("server", loglevel, nodeId);
|
|
79
|
+
|
|
80
|
+
// Initialize the instance.
|
|
81
|
+
// Procedures and implementations are stored on properties with symbol keys,
|
|
82
|
+
// to avoid any conflicts with procedure names, and also discourage direct access to them.
|
|
83
|
+
const instance = {
|
|
84
|
+
[zProcedures]: procedures,
|
|
85
|
+
[zImplementations]: {} as ImplementationsMap<Procedures>,
|
|
86
|
+
start: async () => {},
|
|
87
|
+
} as SwarpcServer<Procedures>;
|
|
88
|
+
|
|
89
|
+
// Set all implementation-setter methods
|
|
90
|
+
for (const functionName in procedures) {
|
|
91
|
+
instance[functionName] = ((implementation) => {
|
|
92
|
+
if (!instance[zProcedures][functionName]) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`No procedure found for function name: ${functionName}`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
instance[zImplementations][functionName] = (input, onProgress, tools) => {
|
|
98
|
+
tools.abortSignal?.throwIfAborted();
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
tools.abortSignal?.addEventListener("abort", () => {
|
|
101
|
+
let { requestId, reason } = tools.abortSignal!.reason;
|
|
102
|
+
l.debug(requestId, `Aborted ${functionName} request: ${reason}`);
|
|
103
|
+
reject({ aborted: reason });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
implementation(input, onProgress, tools).then(resolve).catch(reject);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
}) as SwarpcServer<Procedures>[typeof functionName];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
instance.start = async () => {
|
|
113
|
+
const port = await new Promise<MessagePort | undefined>((resolve) => {
|
|
114
|
+
if (!scopeIsShared(scope, _scopeType)) return resolve(undefined);
|
|
115
|
+
l.debug(null, "Awaiting shared worker connection...");
|
|
116
|
+
scope.addEventListener("connect", ({ ports: [port] }) => {
|
|
117
|
+
l.debug(null, "Shared worker connected with port", port);
|
|
118
|
+
resolve(port);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Used to post messages back to the client
|
|
123
|
+
const postMessage = async (
|
|
124
|
+
autotransfer: boolean,
|
|
125
|
+
data: Payload<Procedures>,
|
|
126
|
+
) => {
|
|
127
|
+
const transfer = autotransfer ? [] : findTransferables(data);
|
|
128
|
+
|
|
129
|
+
if (port) {
|
|
130
|
+
port.postMessage(data, { transfer });
|
|
131
|
+
} else if (scopeIsDedicated(scope, _scopeType)) {
|
|
132
|
+
scope.postMessage(data, { transfer });
|
|
133
|
+
} else if (scopeIsService(scope, _scopeType)) {
|
|
134
|
+
await scope.clients.matchAll().then((clients) => {
|
|
135
|
+
clients.forEach((client) => client.postMessage(data, { transfer }));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const listener = async (
|
|
141
|
+
event: MessageEvent<any> | ExtendableMessageEvent,
|
|
142
|
+
): Promise<void> => {
|
|
143
|
+
if (PayloadInitializeSchema.allows(event.data)) {
|
|
144
|
+
const { localStorageData, nodeId } = event.data;
|
|
145
|
+
l.debug(null, "Setting up faux localStorage", localStorageData);
|
|
146
|
+
new FauxLocalStorage(localStorageData).register(scope);
|
|
147
|
+
injectIntoConsoleGlobal(scope, nodeId);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Decode the payload
|
|
152
|
+
const { requestId, functionName } = PayloadHeaderSchema(
|
|
153
|
+
type.enumerated(...Object.keys(procedures)),
|
|
154
|
+
).assert(event.data);
|
|
155
|
+
|
|
156
|
+
l.debug(requestId, `Received request for ${functionName}`, event.data);
|
|
157
|
+
|
|
158
|
+
// Get autotransfer preference from the procedure definition
|
|
159
|
+
const { autotransfer = "output-only", ...schemas } =
|
|
160
|
+
instance[zProcedures][functionName];
|
|
161
|
+
|
|
162
|
+
// Shorthand function with functionName, requestId, etc. set
|
|
163
|
+
const postMsg = async (
|
|
164
|
+
data: PayloadCore<Procedures, typeof functionName>,
|
|
165
|
+
) => {
|
|
166
|
+
if (abortedRequests.has(requestId)) return;
|
|
167
|
+
await postMessage(autotransfer !== "never", {
|
|
168
|
+
by: "sw&rpc",
|
|
169
|
+
functionName,
|
|
170
|
+
requestId,
|
|
171
|
+
...data,
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Prepare a function to post errors back to the client
|
|
176
|
+
const postError = async (error: any) =>
|
|
177
|
+
postMsg({
|
|
178
|
+
error: {
|
|
179
|
+
message: "message" in error ? error.message : String(error),
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Retrieve the implementation for the requested function
|
|
184
|
+
const implementation = instance[zImplementations][functionName];
|
|
185
|
+
if (!implementation) {
|
|
186
|
+
await postError("No implementation found");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Define payload schema for incoming messages
|
|
191
|
+
const payload = PayloadSchema(
|
|
192
|
+
type(`"${functionName}"`),
|
|
193
|
+
schemas.input,
|
|
194
|
+
schemas.progress,
|
|
195
|
+
schemas.success,
|
|
196
|
+
).assert(event.data);
|
|
197
|
+
|
|
198
|
+
if ("isInitializeRequest" in payload)
|
|
199
|
+
throw "Unreachable: #initialize request payload should've been handled already";
|
|
200
|
+
|
|
201
|
+
// Handle abortion requests (pro-choice ftw!!)
|
|
202
|
+
if (payload.abort) {
|
|
203
|
+
const controller = abortControllers.get(requestId);
|
|
204
|
+
|
|
205
|
+
if (!controller)
|
|
206
|
+
await postError("No abort controller found for request");
|
|
207
|
+
|
|
208
|
+
controller?.abort(payload.abort.reason);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Set up the abort controller for this request
|
|
213
|
+
abortControllers.set(requestId, new AbortController());
|
|
214
|
+
|
|
215
|
+
if (!payload.input) {
|
|
216
|
+
await postError("No input provided");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
// Call the implementation with the input and a progress callback
|
|
222
|
+
const result = await implementation(
|
|
223
|
+
payload.input,
|
|
224
|
+
async (progress: any) => {
|
|
225
|
+
// l.debug(requestId, `Progress for ${functionName}`, progress);
|
|
226
|
+
await postMsg({ progress });
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
nodeId,
|
|
230
|
+
abortSignal: abortControllers.get(requestId)?.signal,
|
|
231
|
+
logger: createLogger("server", loglevel, nodeId, requestId),
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
// Send results
|
|
236
|
+
l.debug(requestId, `Result for ${functionName}`, result);
|
|
237
|
+
await postMsg({ result });
|
|
238
|
+
} catch (error: any) {
|
|
239
|
+
// Send errors
|
|
240
|
+
// Handle errors caused by abortions
|
|
241
|
+
if ("aborted" in error) {
|
|
242
|
+
l.debug(
|
|
243
|
+
requestId,
|
|
244
|
+
`Received abort error for ${functionName}`,
|
|
245
|
+
error.aborted,
|
|
246
|
+
);
|
|
247
|
+
abortedRequests.add(requestId);
|
|
248
|
+
abortControllers.delete(requestId);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
l.info(requestId, `Error in ${functionName}`, error);
|
|
253
|
+
await postError(error);
|
|
254
|
+
} finally {
|
|
255
|
+
abortedRequests.delete(requestId);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// Listen for messages from the client
|
|
260
|
+
if (scopeIsShared(scope, _scopeType)) {
|
|
261
|
+
if (!port) throw new Error("SharedWorker port not initialized");
|
|
262
|
+
l.info(null, "Listening for shared worker messages on port", port);
|
|
263
|
+
port.addEventListener("message", listener);
|
|
264
|
+
port.start();
|
|
265
|
+
} else if (scopeIsDedicated(scope, _scopeType)) {
|
|
266
|
+
scope.addEventListener("message", listener);
|
|
267
|
+
} else if (scopeIsService(scope, _scopeType)) {
|
|
268
|
+
scope.addEventListener("message", listener);
|
|
269
|
+
} else {
|
|
270
|
+
throw new Error(`Unsupported worker scope ${scope}`);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
return instance;
|
|
275
|
+
}
|