@faasjs/func 0.0.3-beta.8 → 0.0.3-beta.81

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 CHANGED
@@ -261,13 +261,13 @@ ___
261
261
 
262
262
  ### UseifyPlugin
263
263
 
264
- Ƭ **UseifyPlugin**: `Object`
264
+ Ƭ **UseifyPlugin**<`T`\>: `T` & { `mount?`: (`data?`: { `config?`: [`Config`](#config) }) => `Promise`<`T`\> }
265
265
 
266
- #### Type declaration
266
+ #### Type parameters
267
267
 
268
- | Name | Type |
269
- | :------ | :------ |
270
- | `mount?` | (`data`: { `config`: [`Config`](#config) }) => `Promise`<`void`\> |
268
+ | Name |
269
+ | :------ |
270
+ | `T` |
271
271
 
272
272
  ## Functions
273
273
 
@@ -317,7 +317,7 @@ ___
317
317
 
318
318
  ### usePlugin
319
319
 
320
- ▸ **usePlugin**<`T`\>(`plugin`): `T` & [`UseifyPlugin`](#useifyplugin)
320
+ ▸ **usePlugin**<`T`\>(`plugin`): [`UseifyPlugin`](#useifyplugin)<`T`\>
321
321
 
322
322
  #### Type parameters
323
323
 
@@ -329,8 +329,8 @@ ___
329
329
 
330
330
  | Name | Type |
331
331
  | :------ | :------ |
332
- | `plugin` | `T` & [`UseifyPlugin`](#useifyplugin) |
332
+ | `plugin` | [`UseifyPlugin`](#useifyplugin)<`T`\> |
333
333
 
334
334
  #### Returns
335
335
 
336
- `T` & [`UseifyPlugin`](#useifyplugin)
336
+ [`UseifyPlugin`](#useifyplugin)<`T`\>
package/dist/index.d.ts CHANGED
@@ -124,12 +124,12 @@ declare class Func<TEvent = any, TContext = any, TResult = any> {
124
124
  handler: ExportedHandler<TEvent, TContext, TResult>;
125
125
  };
126
126
  }
127
- type UseifyPlugin = {
128
- mount?: (data: {
129
- config: Config;
130
- }) => Promise<void>;
127
+ type UseifyPlugin<T> = T & {
128
+ mount?: (data?: {
129
+ config?: Config;
130
+ }) => Promise<T>;
131
131
  };
132
- declare function usePlugin<T extends Plugin>(plugin: T & UseifyPlugin): T & UseifyPlugin;
132
+ declare function usePlugin<T extends Plugin>(plugin: UseifyPlugin<T>): UseifyPlugin<T>;
133
133
  /**
134
134
  * ```ts
135
135
  * // pure function
package/dist/index.js CHANGED
@@ -196,14 +196,15 @@ function usePlugin(plugin) {
196
196
  if (!plugins.find((p) => p.name === plugin.name))
197
197
  plugins.push(plugin);
198
198
  if (!plugin.mount)
199
- plugin.mount = async function({ config }) {
199
+ plugin.mount = async function(data) {
200
200
  if (plugin.onMount)
201
201
  await plugin.onMount({
202
- config,
203
- event: {},
204
- context: {},
202
+ config: (data == null ? void 0 : data.config) || /* @__PURE__ */ Object.create(null),
203
+ event: /* @__PURE__ */ Object.create(null),
204
+ context: /* @__PURE__ */ Object.create(null),
205
205
  logger: new import_logger.Logger(plugin.name)
206
206
  }, async () => Promise.resolve());
207
+ return plugin;
207
208
  };
208
209
  return plugin;
209
210
  }
package/dist/index.mjs CHANGED
@@ -170,14 +170,15 @@ function usePlugin(plugin) {
170
170
  if (!plugins.find((p) => p.name === plugin.name))
171
171
  plugins.push(plugin);
172
172
  if (!plugin.mount)
173
- plugin.mount = async function({ config }) {
173
+ plugin.mount = async function(data) {
174
174
  if (plugin.onMount)
175
175
  await plugin.onMount({
176
- config,
177
- event: {},
178
- context: {},
176
+ config: (data == null ? void 0 : data.config) || /* @__PURE__ */ Object.create(null),
177
+ event: /* @__PURE__ */ Object.create(null),
178
+ context: /* @__PURE__ */ Object.create(null),
179
179
  logger: new Logger(plugin.name)
180
180
  }, async () => Promise.resolve());
181
+ return plugin;
181
182
  };
182
183
  return plugin;
183
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/func",
3
- "version": "0.0.3-beta.8",
3
+ "version": "0.0.3-beta.81",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,15 +15,14 @@
15
15
  },
16
16
  "funding": "https://github.com/sponsors/faasjs",
17
17
  "scripts": {
18
- "build": "tsup-node src/index.ts --format esm,cjs",
19
- "build:types": "tsup-node src/index.ts --dts-only"
18
+ "build": "tsup-node src/index.ts --format esm,cjs --dts --clean"
20
19
  },
21
20
  "files": [
22
21
  "dist"
23
22
  ],
24
23
  "dependencies": {
25
- "@faasjs/deep_merge": "^0.0.3-beta.8",
26
- "@faasjs/logger": "^0.0.3-beta.8"
24
+ "@faasjs/deep_merge": "^0.0.3-beta.81",
25
+ "@faasjs/logger": "^0.0.3-beta.81"
27
26
  },
28
27
  "engines": {
29
28
  "npm": ">=8.0.0",