@ldsg/handler 0.1.0-alpha.10
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 +22 -0
- package/README.md +5 -0
- package/dist/handler-resource-settings.d.ts +8 -0
- package/dist/handler-resource-settings.d.ts.map +1 -0
- package/dist/handler-resource-settings.js +18 -0
- package/dist/handler.d.ts +7 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/instantiate-resource.d.ts +5 -0
- package/dist/instantiate-resource.d.ts.map +1 -0
- package/dist/instantiate-resource.js +13 -0
- package/dist/instantiate-resources.d.ts +5 -0
- package/dist/instantiate-resources.d.ts.map +1 -0
- package/dist/instantiate-resources.js +18 -0
- package/dist/resource-definition-resource-settings.d.ts +3 -0
- package/dist/resource-definition-resource-settings.d.ts.map +1 -0
- package/dist/resource-definition-resource-settings.js +9 -0
- package/dist/resource.d.ts +9 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +29 -0
- package/dist/types/handler.d.ts +4 -0
- package/dist/types/handler.d.ts.map +1 -0
- package/dist/types/handler.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/resource-settings.d.ts +29 -0
- package/dist/types/resource-settings.d.ts.map +1 -0
- package/dist/types/resource-settings.js +2 -0
- package/package.json +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HandlerResourceSettings } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Handler Resource Settings
|
|
4
|
+
* 此类型资源的子级处理程序资源的配置
|
|
5
|
+
* 如无或为 undefined,则说明无需子级处理程序。
|
|
6
|
+
*/
|
|
7
|
+
export declare const handlerResourceSettings: HandlerResourceSettings;
|
|
8
|
+
//# sourceMappingURL=handler-resource-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-resource-settings.d.ts","sourceRoot":"","sources":["../src/handler-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBASrC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handlerResourceSettings = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handler Resource Settings
|
|
6
|
+
* 此类型资源的子级处理程序资源的配置
|
|
7
|
+
* 如无或为 undefined,则说明无需子级处理程序。
|
|
8
|
+
*/
|
|
9
|
+
exports.handlerResourceSettings = {
|
|
10
|
+
title: "处理程序类型资源处理程序",
|
|
11
|
+
description: "包含处理程序相应的模块,此模块主要通过",
|
|
12
|
+
code: `export * from "@ldsg/handler";`,
|
|
13
|
+
dependencies: [
|
|
14
|
+
{
|
|
15
|
+
name: "@ldsg/handler",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
|
|
2
|
+
import { HandlerResource } from "./resource";
|
|
3
|
+
import { Handler, HandlerResourceSettings } from "./types";
|
|
4
|
+
export declare const handler: Handler<[
|
|
5
|
+
InstantiateResourceParams<HandlerResourceSettings>
|
|
6
|
+
], InstantiateResourceRes<HandlerResource>>;
|
|
7
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B;IAAC,yBAAyB,CAAC,uBAAuB,CAAC;CAAC,EACpD,sBAAsB,CAAC,eAAe,CAAC,CAClB,CAAC"}
|
package/dist/handler.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./handler";
|
|
2
|
+
export * from "./handler-resource-settings";
|
|
3
|
+
export * from "./instantiate-resource";
|
|
4
|
+
export * from "./instantiate-resources";
|
|
5
|
+
export * from "./resource";
|
|
6
|
+
export * from "./resource-definition-resource-settings";
|
|
7
|
+
export * from "./types";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,yCAAyC,CAAC;AACxD,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./handler"), exports);
|
|
18
|
+
__exportStar(require("./handler-resource-settings"), exports);
|
|
19
|
+
__exportStar(require("./instantiate-resource"), exports);
|
|
20
|
+
__exportStar(require("./instantiate-resources"), exports);
|
|
21
|
+
__exportStar(require("./resource"), exports);
|
|
22
|
+
__exportStar(require("./resource-definition-resource-settings"), exports);
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InstantiateResource } from "@ldsg/resource";
|
|
2
|
+
import { HandlerResource } from "./resource";
|
|
3
|
+
import { HandlerResourceSettings } from "./types";
|
|
4
|
+
export declare const instantiateResource: InstantiateResource<HandlerResourceSettings, HandlerResource>;
|
|
5
|
+
//# sourceMappingURL=instantiate-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantiate-resource.d.ts","sourceRoot":"","sources":["../src/instantiate-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CACnD,uBAAuB,EACvB,eAAe,CAWhB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instantiateResource = void 0;
|
|
4
|
+
const resource_1 = require("./resource");
|
|
5
|
+
const instantiateResource = (params) => {
|
|
6
|
+
const { resourceConstructorParams } = params;
|
|
7
|
+
const resource = new resource_1.HandlerResource(resourceConstructorParams);
|
|
8
|
+
const res = {
|
|
9
|
+
resource,
|
|
10
|
+
};
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
exports.instantiateResource = instantiateResource;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InstantiateResources } from "@ldsg/resource";
|
|
2
|
+
import { HandlerResource } from "./resource";
|
|
3
|
+
import { HandlerResourceSettings } from "./types";
|
|
4
|
+
export declare const instantiateResources: InstantiateResources<HandlerResourceSettings, HandlerResource>;
|
|
5
|
+
//# sourceMappingURL=instantiate-resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantiate-resources.d.ts","sourceRoot":"","sources":["../src/instantiate-resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,oBAAoB,EAAE,oBAAoB,CACrD,uBAAuB,EACvB,eAAe,CAiBhB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instantiateResources = void 0;
|
|
4
|
+
const instantiate_resource_1 = require("./instantiate-resource");
|
|
5
|
+
const instantiateResources = (params) => {
|
|
6
|
+
const { manifestResources } = params;
|
|
7
|
+
const resources = manifestResources.map((manifestResource) => {
|
|
8
|
+
const { resource } = (0, instantiate_resource_1.instantiateResource)({
|
|
9
|
+
resourceConstructorParams: manifestResource,
|
|
10
|
+
});
|
|
11
|
+
return resource;
|
|
12
|
+
});
|
|
13
|
+
const res = {
|
|
14
|
+
resources,
|
|
15
|
+
};
|
|
16
|
+
return res;
|
|
17
|
+
};
|
|
18
|
+
exports.instantiateResources = instantiateResources;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-definition-resource-settings.d.ts","sourceRoot":"","sources":["../src/resource-definition-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAC;AAEpE,eAAO,MAAM,kCAAkC,EAAE,kCAO9C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resourceDefinitionResourceSettings = void 0;
|
|
4
|
+
exports.resourceDefinitionResourceSettings = {
|
|
5
|
+
title: "处理程序类型资源定义",
|
|
6
|
+
description: "主要包含引入模块列表与相应的处理程序代码,处理程序类型资源无子级资源。",
|
|
7
|
+
kind: "HANDLER",
|
|
8
|
+
subKinds: [],
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Resource } from "@ldsg/resource";
|
|
2
|
+
import { DefaultParams, DefaultRes, Handler, HandlerResourceSettings } from "./types";
|
|
3
|
+
type GetHandler<Params extends DefaultParams = DefaultParams, Res extends DefaultRes = DefaultRes> = () => Handler<Params, Res>;
|
|
4
|
+
export declare class HandlerResource extends Resource<HandlerResourceSettings> {
|
|
5
|
+
getModuleId: () => string;
|
|
6
|
+
getHandler: GetHandler;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,aAAa,EACb,UAAU,EACV,OAAO,EACP,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,KAAK,UAAU,CACb,MAAM,SAAS,aAAa,GAAG,aAAa,EAC5C,GAAG,SAAS,UAAU,GAAG,UAAU,IACjC,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE/B,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,uBAAuB,CAAC;IACpE,WAAW,QAAO,MAAM,CAItB;IAEF,UAAU,EAAE,UAAU,CAcpB;CACH"}
|
package/dist/resource.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandlerResource = void 0;
|
|
4
|
+
const resource_1 = require("@ldsg/resource");
|
|
5
|
+
class HandlerResource extends resource_1.Resource {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.getModuleId = () => {
|
|
9
|
+
const { id } = this.settings;
|
|
10
|
+
return id;
|
|
11
|
+
};
|
|
12
|
+
this.getHandler = () => {
|
|
13
|
+
const moduleId = this.getModuleId();
|
|
14
|
+
try {
|
|
15
|
+
const requireRes = require(moduleId);
|
|
16
|
+
if ("handler" in requireRes) {
|
|
17
|
+
return requireRes.handler;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new Error("invalid handler in module");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new Error("require module failed");
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.HandlerResource = HandlerResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/types/handler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC;AAElC,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC;AAE7B,MAAM,MAAM,OAAO,CACjB,MAAM,SAAS,aAAa,GAAG,aAAa,EAC5C,GAAG,SAAS,UAAU,GAAG,UAAU,IACjC,CAAC,GAAG,MAAM,EAAE,MAAM,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./handler"), exports);
|
|
18
|
+
__exportStar(require("./resource-settings"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Manifest } from "@ldsg/resource";
|
|
2
|
+
export interface HandlerResourceDependency {
|
|
3
|
+
/**
|
|
4
|
+
* Name
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* Version
|
|
9
|
+
* pnpm add <name>@<version>
|
|
10
|
+
*/
|
|
11
|
+
version?: string;
|
|
12
|
+
/**
|
|
13
|
+
* URI
|
|
14
|
+
* pnpm add <uri>
|
|
15
|
+
*/
|
|
16
|
+
uri?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HandlerResourceSettings extends Manifest.ResourceSettings {
|
|
19
|
+
/**
|
|
20
|
+
* Code
|
|
21
|
+
* The code must exist to avoid problems caused by different versions resulting from dependencies being installed in the root project.
|
|
22
|
+
*/
|
|
23
|
+
code: string;
|
|
24
|
+
/**
|
|
25
|
+
* Dependencies
|
|
26
|
+
*/
|
|
27
|
+
dependencies: HandlerResourceDependency[];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=resource-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAwB,SAAQ,QAAQ,CAAC,gBAAgB;IACxE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,YAAY,EAAE,yBAAyB,EAAE,CAAC;CAC3C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ldsg/handler",
|
|
3
|
+
"version": "0.1.0-alpha.10",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/"
|
|
8
|
+
],
|
|
9
|
+
"types": "dist",
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "wanxger",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@ldsg/resource": "0.1.0-alpha.10"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^20.13.0"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json"
|
|
24
|
+
}
|
|
25
|
+
}
|