@antelopejs/interface-core 0.0.3 → 0.0.5
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/dist/config.d.ts +2 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/responsible-module.js +1 -3
- package/dist/responsible-module.js.map +1 -1
- package/dist/runtime.d.ts +85 -0
- package/dist/runtime.js +26 -0
- package/dist/runtime.js.map +1 -0
- package/dist/tests/runtime.test.d.ts +1 -0
- package/dist/tests/runtime.test.js +100 -0
- package/dist/tests/runtime.test.js.map +1 -0
- package/package.json +4 -1
package/dist/config.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface ModuleSourceLocal extends ModuleSource {
|
|
|
11
11
|
main?: string;
|
|
12
12
|
watchDir?: ModuleWatchDir;
|
|
13
13
|
installCommand?: ModuleInstallCommand;
|
|
14
|
+
reloadCommand?: ModuleInstallCommand;
|
|
14
15
|
}
|
|
15
16
|
export interface ModuleSourceGit extends ModuleSource {
|
|
16
17
|
type: "git";
|
|
@@ -29,6 +30,7 @@ export interface ModuleSourceLocalFolder extends ModuleSource {
|
|
|
29
30
|
path: string;
|
|
30
31
|
watchDir?: ModuleWatchDir;
|
|
31
32
|
installCommand?: ModuleInstallCommand;
|
|
33
|
+
reloadCommand?: ModuleInstallCommand;
|
|
32
34
|
}
|
|
33
35
|
export interface AntelopeTestConfig {
|
|
34
36
|
folder?: string;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;AAuGtB,oCAEC;AAFD,SAAgB,YAAY,CAAC,KAAkB;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA4CA,kCAuBC;AAYD,8CAQC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA4CA,kCAuBC;AAYD,8CAQC;AAgED,gDAmBC;AAeD,sDAOC;AAWD,oDAUC;AArND,4BAA0B;AAE1B,yCAAsC;AACtC,uCAAoC;AACpC,uCAKmB;AAEnB,qCAKmB;AAJjB,qGAAA,UAAU,OAAA;AACV,qGAAA,UAAU,OAAA;AACV,+GAAA,oBAAoB,OAAA;AACpB,2GAAA,gBAAgB,OAAA;AAGlB,mBAAQ,CAAC,oBAAoB,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,IAAI,QAAQ,EAAE,WAAW,EAAE,KAAK,sBAAsB,EAAE,CAAC;QACvD,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK;SACnB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;SACnE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SAC9B,IAAI,CAAC,UAAU,CAAC,CAAC;IACpB,iBAAO,CAAC,KAAK,CACX,kGAAkG;QAChG,QAAQ,CACX,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CAGzB,MAAS,EAAE,IAAqC,EAAE,OAAO,GAAG,IAAI;IAChE,IAAI,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAM,CAAC;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,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,CAAC,CAAC;IACtB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAU,EAAE,CAAC;AAC3D,CAAC;AAOD;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,WAAmB;IAEnB,MAAM,MAAM,GAAG,IAAA,8BAAoB,GAAE,CAAC;IACtC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,mBAAQ,CAAC,oBAAoB,CAAC;QAAE,OAAO,EAAE,CAAC;IACrE,MAAM,WAAW,GAAG,mBAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,WAAmB,EACnB,YAAoB;IAEpB,MAAM,MAAM,GAAG,IAAA,8BAAoB,GAAE,CAAC;IACtC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,mBAAQ,CAAC,oBAAoB,CAAC;QAAE,OAAO;IAClE,MAAM,WAAW,GAAG,mBAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC1C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,YAAY,CAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -46,9 +46,7 @@ function findResponsibleFile(trace, entries = internal_1.internal.moduleByFolder
|
|
|
46
46
|
if (!match.isImplementor) {
|
|
47
47
|
return { module: match.id, lastInterface };
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
implementorMatch = match.id;
|
|
51
|
-
}
|
|
49
|
+
implementorMatch = match.id;
|
|
52
50
|
}
|
|
53
51
|
if (implementorMatch) {
|
|
54
52
|
return { module: implementorMatch, lastInterface };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsible-module.js","sourceRoot":"","sources":["../src/responsible-module.ts"],"names":[],"mappings":";;AAyCA,
|
|
1
|
+
{"version":3,"file":"responsible-module.js","sourceRoot":"","sources":["../src/responsible-module.ts"],"names":[],"mappings":";;AAyCA,kDAiCC;AA1ED,yCAAsC;AAatC,SAAS,iBAAiB,CACxB,QAAgB,EAChB,OAA4B;IAE5B,IAAI,IAAmC,CAAC;IACxC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;YACjE,IAAI,GAAG,KAAK,CAAC;YACb,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,mBAAmB,CACjC,KAAwB,EACxB,UAA+B,mBAAQ,CAAC,cAAc;IAEtD,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,IAAI,gBAAoC,CAAC;IAEzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,QAAQ,EAAE,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;YACnD,MAAM;QACR,CAAC;QACD,IACE,CAAC,QAAQ;YACT,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC;YACrC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,EACxC,CAAC;YACD,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,aAAa,EAAE,CAAC;QAC7C,CAAC;QACD,gBAAgB,GAAG,KAAK,CAAC,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,aAAa,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information about the runtime environment of the running Antelope project.
|
|
3
|
+
*/
|
|
4
|
+
export interface RuntimeInfo {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the project is running in development mode (`ajs project dev`).
|
|
7
|
+
* False for `ajs project start` and `ajs project run`.
|
|
8
|
+
*/
|
|
9
|
+
dev: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Absolute path to the root of the running project.
|
|
12
|
+
*/
|
|
13
|
+
projectPath: string;
|
|
14
|
+
/**
|
|
15
|
+
* Name of the active configuration environment.
|
|
16
|
+
*/
|
|
17
|
+
env: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Network endpoint exposed by a development server.
|
|
21
|
+
*/
|
|
22
|
+
export interface DevServerEndpoint {
|
|
23
|
+
/**
|
|
24
|
+
* Protocol of the endpoint (e.g. 'http', 'https').
|
|
25
|
+
*/
|
|
26
|
+
protocol: string;
|
|
27
|
+
/**
|
|
28
|
+
* Host the endpoint is bound to (e.g. 'localhost').
|
|
29
|
+
*/
|
|
30
|
+
host: string;
|
|
31
|
+
/**
|
|
32
|
+
* Port the endpoint is listening on.
|
|
33
|
+
*/
|
|
34
|
+
port: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Entry for a single registered development server in the dev registry file.
|
|
38
|
+
*/
|
|
39
|
+
export interface DevServerEntry {
|
|
40
|
+
/**
|
|
41
|
+
* Endpoints the server is listening on.
|
|
42
|
+
*/
|
|
43
|
+
endpoints: DevServerEndpoint[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Shape of the dev registry file written at {@link DEV_REGISTRY_PATH}.
|
|
47
|
+
*
|
|
48
|
+
* The file is only valid while the process identified by `pid` exists.
|
|
49
|
+
* If that process is gone, the file is orphaned and must be ignored or overwritten.
|
|
50
|
+
*/
|
|
51
|
+
export interface DevServerRegistry {
|
|
52
|
+
/**
|
|
53
|
+
* PID of the process that owns the registry file.
|
|
54
|
+
*/
|
|
55
|
+
pid: number;
|
|
56
|
+
/**
|
|
57
|
+
* ISO 8601 timestamp of when the process started.
|
|
58
|
+
*/
|
|
59
|
+
startedAt: string;
|
|
60
|
+
/**
|
|
61
|
+
* Registered development servers, keyed by server name.
|
|
62
|
+
*/
|
|
63
|
+
servers: Record<string, DevServerEntry>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Project-relative path of the dev registry file.
|
|
67
|
+
*/
|
|
68
|
+
export declare const DEV_REGISTRY_PATH = ".antelope/dev.json";
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve information about the runtime environment of the running project.
|
|
71
|
+
*
|
|
72
|
+
* @returns Runtime information including dev mode, project path and environment
|
|
73
|
+
*/
|
|
74
|
+
export declare const GetRuntimeInfo: () => Promise<RuntimeInfo>;
|
|
75
|
+
/**
|
|
76
|
+
* Register a development server and the endpoints it is listening on.
|
|
77
|
+
*
|
|
78
|
+
* In development mode, the registration is merged into the dev registry file
|
|
79
|
+
* at {@link DEV_REGISTRY_PATH} in the project root, and the file is removed
|
|
80
|
+
* when the project shuts down. Outside development mode, this is a no-op.
|
|
81
|
+
*
|
|
82
|
+
* @param name Unique name of the server (e.g. 'api')
|
|
83
|
+
* @param endpoints Endpoints the server is listening on
|
|
84
|
+
*/
|
|
85
|
+
export declare const RegisterDevServer: (name: string, endpoints: DevServerEndpoint[]) => Promise<void>;
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegisterDevServer = exports.GetRuntimeInfo = exports.DEV_REGISTRY_PATH = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
/**
|
|
6
|
+
* Project-relative path of the dev registry file.
|
|
7
|
+
*/
|
|
8
|
+
exports.DEV_REGISTRY_PATH = ".antelope/dev.json";
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve information about the runtime environment of the running project.
|
|
11
|
+
*
|
|
12
|
+
* @returns Runtime information including dev mode, project path and environment
|
|
13
|
+
*/
|
|
14
|
+
exports.GetRuntimeInfo = (0, _1.InterfaceFunction)();
|
|
15
|
+
/**
|
|
16
|
+
* Register a development server and the endpoints it is listening on.
|
|
17
|
+
*
|
|
18
|
+
* In development mode, the registration is merged into the dev registry file
|
|
19
|
+
* at {@link DEV_REGISTRY_PATH} in the project root, and the file is removed
|
|
20
|
+
* when the project shuts down. Outside development mode, this is a no-op.
|
|
21
|
+
*
|
|
22
|
+
* @param name Unique name of the server (e.g. 'api')
|
|
23
|
+
* @param endpoints Endpoints the server is listening on
|
|
24
|
+
*/
|
|
25
|
+
exports.RegisterDevServer = (0, _1.InterfaceFunction)();
|
|
26
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;AAAA,wBAAsC;AA4EtC;;GAEG;AACU,QAAA,iBAAiB,GAAG,oBAAoB,CAAC;AAEtD;;;;GAIG;AACU,QAAA,cAAc,GAAG,IAAA,oBAAiB,GAAqB,CAAC;AAErE;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAC5B,IAAA,oBAAiB,GAA0D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const chai_1 = require("chai");
|
|
37
|
+
const __1 = require("..");
|
|
38
|
+
const runtime = __importStar(require("../runtime"));
|
|
39
|
+
const runtime_1 = require("../runtime");
|
|
40
|
+
function drainQueuedCalls() {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
function resetProxy(func) {
|
|
44
|
+
const proxy = func.proxy;
|
|
45
|
+
proxy.onCall(drainQueuedCalls, true);
|
|
46
|
+
proxy.detach();
|
|
47
|
+
}
|
|
48
|
+
describe("runtime interface", () => {
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
resetProxy(runtime_1.GetRuntimeInfo);
|
|
51
|
+
resetProxy(runtime_1.RegisterDevServer);
|
|
52
|
+
});
|
|
53
|
+
it("resolves GetRuntimeInfo with the implementation result", async () => {
|
|
54
|
+
const info = {
|
|
55
|
+
dev: true,
|
|
56
|
+
projectPath: "/tmp/project",
|
|
57
|
+
env: "default",
|
|
58
|
+
};
|
|
59
|
+
(0, __1.ImplementInterface)(runtime, { GetRuntimeInfo: () => info });
|
|
60
|
+
(0, chai_1.expect)(await (0, runtime_1.GetRuntimeInfo)()).to.deep.equal(info);
|
|
61
|
+
});
|
|
62
|
+
it("passes name and endpoints to the RegisterDevServer implementation", async () => {
|
|
63
|
+
const received = [];
|
|
64
|
+
(0, __1.ImplementInterface)(runtime, {
|
|
65
|
+
RegisterDevServer: (name, endpoints) => {
|
|
66
|
+
received.push([name, endpoints]);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const endpoints = [
|
|
70
|
+
{ protocol: "http", host: "localhost", port: 5011 },
|
|
71
|
+
];
|
|
72
|
+
await (0, runtime_1.RegisterDevServer)("api", endpoints);
|
|
73
|
+
(0, chai_1.expect)(received).to.deep.equal([["api", endpoints]]);
|
|
74
|
+
});
|
|
75
|
+
it("replays calls queued before the implementation is attached", async () => {
|
|
76
|
+
const pending = (0, runtime_1.GetRuntimeInfo)();
|
|
77
|
+
const info = {
|
|
78
|
+
dev: false,
|
|
79
|
+
projectPath: "/tmp/project",
|
|
80
|
+
env: "production",
|
|
81
|
+
};
|
|
82
|
+
(0, __1.ImplementInterface)(runtime, { GetRuntimeInfo: () => info });
|
|
83
|
+
(0, chai_1.expect)(await pending).to.deep.equal(info);
|
|
84
|
+
});
|
|
85
|
+
it("replays RegisterDevServer calls queued before the implementation is attached", async () => {
|
|
86
|
+
const endpoints = [
|
|
87
|
+
{ protocol: "http", host: "localhost", port: 5011 },
|
|
88
|
+
];
|
|
89
|
+
const pending = (0, runtime_1.RegisterDevServer)("api", endpoints);
|
|
90
|
+
const received = [];
|
|
91
|
+
(0, __1.ImplementInterface)(runtime, {
|
|
92
|
+
RegisterDevServer: (name, registered) => {
|
|
93
|
+
received.push([name, registered]);
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
await pending;
|
|
97
|
+
(0, chai_1.expect)(received).to.deep.equal([["api", endpoints]]);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=runtime.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.test.js","sourceRoot":"","sources":["../../src/tests/runtime.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,0BAAyD;AACzD,oDAAsC;AACtC,wCAKoB;AAMpB,SAAS,gBAAgB;IACvB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,IAAa;IAC/B,MAAM,KAAK,GAAI,IAAwB,CAAC,KAAK,CAAC;IAC9C,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACrC,KAAK,CAAC,MAAM,EAAE,CAAC;AACjB,CAAC;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,wBAAc,CAAC,CAAC;QAC3B,UAAU,CAAC,2BAAiB,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,IAAI,GAAgB;Y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AAC,IAAI,EAAE,CAAC,CAAC;QAE5D,IAAA,aAAM,EAAC,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,KAAK,IAAI,EAAE;QAC5F,MAAM,SAAS,GAAwB;YACrC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE;SACpD,CAAC;QACF,MAAM,OAAO,GAAG,IAAA,2BAAiB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAEpD,MAAM,QAAQ,GAAyC,EAAE,CAAC;QAC1D,IAAA,sBAAkB,EAAC,OAAO,EAAE;YAC1B,iBAAiB,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;gBACtC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;YACpC,CAAC;SACF,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC;QACd,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "AntelopeJS core interface primitives - proxies, decorators, interface functions, and logging",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -52,6 +52,9 @@
|
|
|
52
52
|
"proxies": [
|
|
53
53
|
"dist/proxies.d.ts"
|
|
54
54
|
],
|
|
55
|
+
"runtime": [
|
|
56
|
+
"dist/runtime.d.ts"
|
|
57
|
+
],
|
|
55
58
|
"internal": [
|
|
56
59
|
"dist/internal.d.ts"
|
|
57
60
|
],
|