@node-ctypes/comtypes 0.3.1 → 0.4.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 +50 -624
- package/dist/automation/dispatch.js +10 -3
- package/dist/automation/record.js +3 -1
- package/dist/automation/variant.d.ts +4 -4
- package/dist/automation/variant.js +93 -28
- package/dist/client/dynamic.js +7 -8
- package/dist/client/events.js +18 -2
- package/dist/client/index.js +3 -1
- package/dist/commethod.d.ts +1 -1
- package/dist/commethod.js +151 -57
- package/dist/errorinfo.d.ts +10 -3
- package/dist/errorinfo.js +66 -18
- package/dist/errors.d.ts +7 -1
- package/dist/executor/apartment.d.ts +7 -3
- package/dist/executor/apartment.js +65 -29
- package/dist/executor/executor.d.ts +2 -0
- package/dist/executor/executor.js +65 -14
- package/dist/guid.d.ts +1 -1
- package/dist/guid.js +7 -9
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/interfaces/agile.d.ts +52 -0
- package/dist/interfaces/agile.js +59 -0
- package/dist/interfaces/errorinfo.d.ts +8 -0
- package/dist/interfaces/errorinfo.js +10 -0
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/interfaces/index.js +2 -1
- package/dist/low-level/iids.d.ts +14 -0
- package/dist/low-level/iids.js +14 -0
- package/dist/low-level/index.d.ts +2 -2
- package/dist/low-level/index.js +1 -1
- package/dist/low-level/native.d.ts +13 -0
- package/dist/low-level/native.js +33 -0
- package/dist/low-level/registry.js +4 -2
- package/dist/low-level/vtable.d.ts +10 -0
- package/dist/low-level/vtable.js +32 -5
- package/dist/pointer.d.ts +2 -0
- package/dist/pointer.js +154 -84
- package/dist/pump.d.ts +32 -8
- package/dist/pump.js +87 -15
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +15 -1
- package/dist/server/automation.js +3 -3
- package/dist/server/comobject.d.ts +53 -0
- package/dist/server/comobject.js +319 -27
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/marshal.d.ts +1 -0
- package/dist/server/marshal.js +13 -7
- package/dist/server/register.js +8 -6
- package/dist/tracking.d.ts +2 -0
- package/dist/tracking.js +13 -0
- package/package.json +6 -2
package/dist/server/register.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as ctypes from "node-ctypes";
|
|
2
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
3
2
|
import { CLSCTX_LOCAL_SERVER } from "../constants.js";
|
|
4
3
|
import { checkHRESULT } from "../errors.js";
|
|
5
4
|
import { toGUID } from "../guid.js";
|
|
6
5
|
import { ole32 } from "../low-level/native.js";
|
|
7
6
|
import { deleteTree, HKEY_CURRENT_USER, writeString } from "../low-level/registry.js";
|
|
8
|
-
import {
|
|
7
|
+
import { waitAndPumpMessages } from "../pump.js";
|
|
9
8
|
import { CoInitializeEx, CoUninitialize } from "../runtime.js";
|
|
10
9
|
import { ClassFactory, COMObject, classTypeLib, getLiveObjectCount, queryObject } from "./comobject.js";
|
|
11
10
|
import { registerTypeLib, unregisterTypeLib } from "../typelib/load.js";
|
|
@@ -127,21 +126,24 @@ export async function runLocalServer(types, options = {}) {
|
|
|
127
126
|
const locked = () => registrations.some((registration) => registration.factory.locks > 0);
|
|
128
127
|
try {
|
|
129
128
|
const started = performance.now();
|
|
129
|
+
const sliceMs = options.interval ?? 8;
|
|
130
|
+
const idleTimeout = options.idleTimeout ?? 2000;
|
|
131
|
+
const startupTimeout = options.startupTimeout ?? 60_000;
|
|
130
132
|
let served = false;
|
|
131
133
|
let idleSince = performance.now();
|
|
132
134
|
for (;;) {
|
|
133
|
-
|
|
135
|
+
waitAndPumpMessages(sliceMs);
|
|
134
136
|
const busy = live() > 0 || locked();
|
|
135
137
|
if (busy) {
|
|
136
138
|
served = true;
|
|
137
139
|
idleSince = performance.now();
|
|
138
140
|
}
|
|
139
141
|
const now = performance.now();
|
|
140
|
-
if (served && !busy && now - idleSince >=
|
|
142
|
+
if (served && !busy && now - idleSince >= idleTimeout)
|
|
141
143
|
break;
|
|
142
|
-
if (!served && now - started >=
|
|
144
|
+
if (!served && now - started >= startupTimeout)
|
|
143
145
|
break;
|
|
144
|
-
await
|
|
146
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
finally {
|
package/dist/tracking.d.ts
CHANGED
|
@@ -15,5 +15,7 @@ export declare function apartmentGeneration(): number;
|
|
|
15
15
|
export declare function liveCount(): number;
|
|
16
16
|
export declare function initCount(): number;
|
|
17
17
|
export declare function initialized(): void;
|
|
18
|
+
/** Register a cleanup hook invoked right before the apartment is uninitialized. */
|
|
19
|
+
export declare function onApartmentTeardown(hook: () => void): void;
|
|
18
20
|
/** Account for one CoUninitialize; on the last one, release everything and start a new generation. */
|
|
19
21
|
export declare function uninitializing(): void;
|
package/dist/tracking.js
CHANGED
|
@@ -59,11 +59,24 @@ export function initCount() {
|
|
|
59
59
|
export function initialized() {
|
|
60
60
|
state.initCount++;
|
|
61
61
|
}
|
|
62
|
+
const teardownHooks = new Set();
|
|
63
|
+
/** Register a cleanup hook invoked right before the apartment is uninitialized. */
|
|
64
|
+
export function onApartmentTeardown(hook) {
|
|
65
|
+
teardownHooks.add(hook);
|
|
66
|
+
}
|
|
62
67
|
/** Account for one CoUninitialize; on the last one, release everything and start a new generation. */
|
|
63
68
|
export function uninitializing() {
|
|
64
69
|
if (state.initCount === 0)
|
|
65
70
|
return;
|
|
66
71
|
if (state.initCount === 1) {
|
|
72
|
+
for (const hook of teardownHooks) {
|
|
73
|
+
try {
|
|
74
|
+
hook();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Keep tearing down.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
67
80
|
releaseAll();
|
|
68
81
|
state.generation++;
|
|
69
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-ctypes/comtypes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Typed Windows COM client and server support for Node.js powered by node-ctypes, inspired by Python comtypes",
|
|
5
5
|
"author": "Damiano Mazzella",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,15 +76,19 @@
|
|
|
76
76
|
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
77
77
|
"test:types": "tsc -p tests/tsconfig.json && tsc -p tests/types/tsconfig.json",
|
|
78
78
|
"test": "npm run build && npm run test:types && node --test --test-concurrency=1 \"tests/checks/*.test.ts\" \"tests/src/*.test.ts\"",
|
|
79
|
+
"test:mirror": "npm run build && node -e \"const { spawnSync } = require('node:child_process'); const r = spawnSync(process.execPath, ['--test', '--test-concurrency=1', 'tests/checks/*.test.ts', 'tests/src/*.test.ts'], { stdio: 'inherit', env: { ...process.env, NODE_CTYPES_NO_EXTERNAL_BUFFERS: '1' } }); process.exit(r.status ?? 1);\"",
|
|
79
80
|
"test:unit": "npm run build && node --test \"tests/checks/unit.*.test.ts\"",
|
|
81
|
+
"docs": "typedoc",
|
|
82
|
+
"docs:serve": "typedoc && npx serve docs",
|
|
80
83
|
"prepack": "npm run build",
|
|
81
84
|
"prepublishOnly": "npm test"
|
|
82
85
|
},
|
|
83
86
|
"dependencies": {
|
|
84
|
-
"node-ctypes": "^2.
|
|
87
|
+
"node-ctypes": "^2.16.0"
|
|
85
88
|
},
|
|
86
89
|
"devDependencies": {
|
|
87
90
|
"@types/node": "^26.6.6",
|
|
91
|
+
"typedoc": "^0.28.20",
|
|
88
92
|
"typescript": "~6.0.3"
|
|
89
93
|
}
|
|
90
94
|
}
|