coakka-logger-electron 1.2.1

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/CONSUMING.md ADDED
@@ -0,0 +1,14 @@
1
+ # Consuming CoAkka Logger For Electron
2
+
3
+ Install the published package through your normal application package feed.
4
+ Electron itself remains the application framework dependency; this package owns
5
+ the CoAkka logger intent bridge and consumes the published Node logger package
6
+ from the Electron main process.
7
+
8
+ Use the package only from the Electron main process and preload boundary:
9
+
10
+ - main process: start `ElectronLoggerIntentBridge`
11
+ - preload: expose `createCoAkkaLoggerPreloadApi(ipcRenderer)`
12
+ - renderer: call `window.coakkaLogger.log(...)`
13
+
14
+ Do not import the logger connector directly from renderer code.
package/LICENSE.md ADDED
@@ -0,0 +1,115 @@
1
+ # CoAkka Public Artifact Preview License 1.0
2
+
3
+ Effective: 2026-07-19
4
+
5
+ This repository is the public binary artifact surface for CoAkka. It contains
6
+ headers, native libraries, connector packages, Maven artifacts, checksums, and
7
+ artifact metadata. It is not a source-build repository.
8
+
9
+ Unless a specific release artifact includes different license terms, the
10
+ artifacts in this repository are made available under the following preview
11
+ terms.
12
+
13
+ This is not an OSI-approved open source license. The separate
14
+ `coakka-samples` repository may use a permissive open source license for sample
15
+ code and documentation; that sample license does not change the terms for the
16
+ artifacts distributed from this repository.
17
+
18
+ ## Definitions
19
+
20
+ `Artifacts` means the CoAkka binaries, headers, libraries, connector packages,
21
+ Maven artifacts, container-bundle files, checksums, manifests, and release
22
+ metadata distributed from this repository or from an official release page for
23
+ this repository.
24
+
25
+ `Production` means any environment that serves live end-user traffic, live
26
+ customer data, live operational data, revenue-generating workloads, or
27
+ customer-facing workloads outside development, test, CI, sample execution, or
28
+ proof-of-concept evaluation.
29
+
30
+ `Official sample images` means container images published by the CoAkka
31
+ project or repository owner, including the current
32
+ `docker.io/gabrielgun1983/*` sample image namespace and any future images
33
+ published under an official CoAkka container namespace, that bundle unmodified
34
+ artifacts solely to run official CoAkka samples.
35
+
36
+ ## Allowed Use
37
+
38
+ You may download, copy, and use the artifacts from this repository to:
39
+
40
+ - evaluate CoAkka locally
41
+ - run the official public samples
42
+ - build proof-of-concept integrations
43
+ - run development and test environments for applications that integrate with
44
+ CoAkka
45
+ - run CI jobs, automated tests, and integration verification for
46
+ non-production applications or evaluations
47
+ - run company evaluations, proofs of concept, and integration tests,
48
+ including evaluations inside commercial organizations
49
+ - redistribute unmodified CoAkka artifacts inside local development, test, or
50
+ sample environments, provided this notice and the included checksums or
51
+ manifests remain available
52
+ - pull, cache internally, and run official sample images for local development,
53
+ CI, test, sample execution, proof-of-concept integration, and evaluation
54
+
55
+ ## Reserved Uses
56
+
57
+ The following uses require a separate written license:
58
+
59
+ - selling, hosting, or offering CoAkka artifacts as a managed runtime service
60
+ - running CoAkka artifacts in production systems
61
+ - bundling CoAkka artifacts into a product distributed to customers
62
+ - redistributing CoAkka artifacts as part of a paid product, support package,
63
+ appliance, cloud image, or hosted service
64
+ - offering a product or service that presents modified CoAkka artifacts as
65
+ official CoAkka artifacts
66
+ - removing or obscuring copyright, license, checksum, or provenance notices
67
+ - reverse engineering artifacts except where that restriction is prohibited by
68
+ applicable law
69
+ - using the CoAkka name, package names, artifact names, image names, or other
70
+ project identifiers in a way that implies endorsement of an unofficial fork,
71
+ hosted service, or product
72
+
73
+ ## Official Samples
74
+
75
+ Official sample images may bundle unmodified artifacts solely so users can run
76
+ official CoAkka samples without installing the artifacts manually.
77
+
78
+ This sample-image permission does not grant third parties the right to create,
79
+ publish, sell, host, or distribute derivative images for production, customer
80
+ distribution, hosted services, paid support packages, appliances, or cloud
81
+ marketplace offerings.
82
+
83
+ ## Production Use
84
+
85
+ These preview terms are intended for developer evaluation, sample execution,
86
+ non-production proof-of-concept work, CI, and integration testing. Production
87
+ use, hosted service use, customer distribution, and paid redistribution require
88
+ explicit release terms or a separate written agreement.
89
+
90
+ For production, hosted service, customer distribution, paid redistribution, or
91
+ other commercial rights, contact the project through `SUPPORT.md`.
92
+
93
+ ## No Warranty
94
+
95
+ The artifacts are provided as-is, without warranties or conditions of any kind,
96
+ to the maximum extent permitted by applicable law.
97
+
98
+ ## Limitation Of Liability
99
+
100
+ To the maximum extent permitted by applicable law, the project contributors and
101
+ artifact publishers are not liable for any direct, indirect, incidental,
102
+ special, consequential, exemplary, or other damages arising from use of the
103
+ artifacts.
104
+
105
+ ## No Patent Or Trademark Grant
106
+
107
+ These preview terms do not grant patent rights, trademark rights, or rights to
108
+ use the CoAkka name beyond the limited artifact and sample uses allowed above.
109
+ Trademark use is governed by `TRADEMARKS.md`.
110
+
111
+ ## Legal Notice
112
+
113
+ This file is not legal advice. If your intended use depends on legal
114
+ interpretation of these terms, consult your own counsel or request a separate
115
+ written agreement.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # CoAkka Logger For Electron
2
+
3
+ This package is the Electron main-process intent bridge for CoAkka logger.
4
+
5
+ The boundary is intentionally strict:
6
+
7
+ - renderer JavaScript sends a log intent through `ipcRenderer.invoke`
8
+ - preload exposes only a small `coakkaLogger.log(...)` API
9
+ - the Electron main process owns `ElectronLoggerIntentBridge`
10
+ - the main process submits the log record and projects counters back to the
11
+ renderer
12
+
13
+ Renderer code does not import the logger connector, does not own native logger
14
+ lifecycle, and does not need a native library path in the normal path.
15
+
16
+ ## Main Process
17
+
18
+ ```js
19
+ import { ipcMain } from "electron";
20
+ import {
21
+ ElectronLoggerIntentBridge,
22
+ registerElectronLoggerIpcHandler,
23
+ } from "coakka-logger-electron";
24
+
25
+ const bridge = ElectronLoggerIntentBridge.start({
26
+ systemName: "electron-app-logger",
27
+ });
28
+
29
+ registerElectronLoggerIpcHandler(ipcMain, bridge);
30
+ ```
31
+
32
+ ## Preload
33
+
34
+ ```js
35
+ const { contextBridge, ipcRenderer } = require("electron");
36
+ const { createCoAkkaLoggerPreloadApi } = require("coakka-logger-electron/preload");
37
+
38
+ contextBridge.exposeInMainWorld("coakkaLogger", createCoAkkaLoggerPreloadApi(ipcRenderer));
39
+ ```
40
+
41
+ ## Renderer
42
+
43
+ ```js
44
+ const result = await window.coakkaLogger.log({
45
+ intentId: "log-1",
46
+ source: "electron-renderer",
47
+ level: "info",
48
+ category: "app.orders",
49
+ message: '{"event":"accepted"}',
50
+ awaitDrainMs: 1000,
51
+ });
52
+ ```
53
+
54
+ ## Smoke
55
+
56
+ ```sh
57
+ npm run build
58
+ bash scripts/smoke-packaged-package.sh
59
+ ```
@@ -0,0 +1,40 @@
1
+ import { type LoggerRecordSnapshot, type LoggerSpec, type LoggerStatsSnapshot } from "coakka-logger-node";
2
+ export declare const COAKKA_LOGGER_ELECTRON_VERSION = "1.2.1";
3
+ export declare const COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL = "coakka:logger-intent";
4
+ export type ElectronLoggerLevelName = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
5
+ export interface ElectronLoggerIntent {
6
+ intentId: string;
7
+ source: string;
8
+ level: ElectronLoggerLevelName | number;
9
+ category: string;
10
+ message: string;
11
+ awaitDrainMs?: number;
12
+ }
13
+ export interface ElectronLoggerIntentResult {
14
+ intentId: string;
15
+ source: string;
16
+ accepted: boolean;
17
+ sequence: number | null;
18
+ record: LoggerRecordSnapshot | null;
19
+ stats: LoggerStatsSnapshot;
20
+ }
21
+ export interface ElectronLoggerIntentBridgeOptions extends LoggerSpec {
22
+ loggerLibPath?: string;
23
+ }
24
+ export interface IpcMainLike {
25
+ handle(channel: string, listener: (event: unknown, intent: ElectronLoggerIntent) => Promise<ElectronLoggerIntentResult>): void;
26
+ removeHandler(channel: string): void;
27
+ }
28
+ export declare class ElectronLoggerIntentBridge {
29
+ private readonly logger;
30
+ static start(options?: ElectronLoggerIntentBridgeOptions): ElectronLoggerIntentBridge;
31
+ private closed;
32
+ private constructor();
33
+ handleLogIntent(intent: ElectronLoggerIntent): Promise<ElectronLoggerIntentResult>;
34
+ stats(): LoggerStatsSnapshot;
35
+ close(): void;
36
+ private drainIfRequested;
37
+ private resultFor;
38
+ private requireOpen;
39
+ }
40
+ export declare function registerElectronLoggerIpcHandler(ipcMain: IpcMainLike, bridge: ElectronLoggerIntentBridge, channel?: string): () => void;
package/dist/index.js ADDED
@@ -0,0 +1,130 @@
1
+ import { CoakkaLoggerLevel, Logger, LoggerStatusError, } from "coakka-logger-node";
2
+ export const COAKKA_LOGGER_ELECTRON_VERSION = "1.2.1";
3
+ export const COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL = "coakka:logger-intent";
4
+ export class ElectronLoggerIntentBridge {
5
+ logger;
6
+ static start(options = {}) {
7
+ const logger = Logger.start({
8
+ systemName: options.systemName ?? "electronLogger",
9
+ queueCapacity: options.queueCapacity,
10
+ categoryCapacity: options.categoryCapacity,
11
+ messageCapacity: options.messageCapacity,
12
+ minLevel: options.minLevel,
13
+ }, options.loggerLibPath);
14
+ return new ElectronLoggerIntentBridge(logger);
15
+ }
16
+ closed = false;
17
+ constructor(logger) {
18
+ this.logger = logger;
19
+ }
20
+ async handleLogIntent(intent) {
21
+ this.requireOpen();
22
+ const normalized = normalizeIntent(intent);
23
+ let sequence = null;
24
+ try {
25
+ sequence = this.logger.log(normalized.level, normalized.category, normalized.message);
26
+ }
27
+ catch (error) {
28
+ if (error instanceof LoggerStatusError && error.statusName === "queue_full") {
29
+ return this.resultFor(normalized, null, null);
30
+ }
31
+ throw error;
32
+ }
33
+ const record = sequence == null ? null : this.drainIfRequested(normalized.awaitDrainMs);
34
+ return this.resultFor(normalized, sequence, record);
35
+ }
36
+ stats() {
37
+ this.requireOpen();
38
+ return this.logger.stats();
39
+ }
40
+ close() {
41
+ if (this.closed) {
42
+ return;
43
+ }
44
+ this.closed = true;
45
+ this.logger.close();
46
+ }
47
+ drainIfRequested(awaitDrainMs) {
48
+ if (awaitDrainMs == null) {
49
+ return null;
50
+ }
51
+ return this.logger.awaitNext(awaitDrainMs);
52
+ }
53
+ resultFor(intent, sequence, record) {
54
+ return {
55
+ intentId: intent.intentId,
56
+ source: intent.source,
57
+ accepted: sequence != null,
58
+ sequence,
59
+ record,
60
+ stats: this.logger.stats(),
61
+ };
62
+ }
63
+ requireOpen() {
64
+ if (this.closed) {
65
+ throw new Error("Electron logger intent bridge is closed");
66
+ }
67
+ }
68
+ }
69
+ export function registerElectronLoggerIpcHandler(ipcMain, bridge, channel = COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL) {
70
+ ipcMain.handle(channel, async (_event, intent) => bridge.handleLogIntent(intent));
71
+ return () => ipcMain.removeHandler(channel);
72
+ }
73
+ function normalizeIntent(intent) {
74
+ if (intent == null || typeof intent !== "object") {
75
+ throw new Error("logger intent is required");
76
+ }
77
+ return {
78
+ intentId: requireNonBlank(intent.intentId, "intentId"),
79
+ source: requireNonBlank(intent.source, "source"),
80
+ level: normalizeLevel(intent.level),
81
+ category: requireNonBlank(intent.category, "category"),
82
+ message: requireString(intent.message, "message"),
83
+ awaitDrainMs: normalizeAwaitDrainMs(intent.awaitDrainMs),
84
+ };
85
+ }
86
+ function normalizeLevel(level) {
87
+ if (typeof level === "number") {
88
+ if (!Number.isInteger(level) || level < CoakkaLoggerLevel.TRACE || level > CoakkaLoggerLevel.FATAL) {
89
+ throw new Error("level must be a logger level integer");
90
+ }
91
+ return level;
92
+ }
93
+ switch (level) {
94
+ case "trace":
95
+ return CoakkaLoggerLevel.TRACE;
96
+ case "debug":
97
+ return CoakkaLoggerLevel.DEBUG;
98
+ case "info":
99
+ return CoakkaLoggerLevel.INFO;
100
+ case "warn":
101
+ return CoakkaLoggerLevel.WARN;
102
+ case "error":
103
+ return CoakkaLoggerLevel.ERROR;
104
+ case "fatal":
105
+ return CoakkaLoggerLevel.FATAL;
106
+ default:
107
+ throw new Error("level must be trace, debug, info, warn, error, or fatal");
108
+ }
109
+ }
110
+ function normalizeAwaitDrainMs(value) {
111
+ if (value == null) {
112
+ return undefined;
113
+ }
114
+ if (!Number.isInteger(value) || value < 0) {
115
+ throw new Error("awaitDrainMs must be a non-negative integer");
116
+ }
117
+ return value;
118
+ }
119
+ function requireString(value, what) {
120
+ if (typeof value !== "string") {
121
+ throw new Error(`${what} must be a string`);
122
+ }
123
+ return value;
124
+ }
125
+ function requireNonBlank(value, what) {
126
+ if (typeof value !== "string" || value.trim() === "") {
127
+ throw new Error(`${what} is required`);
128
+ }
129
+ return value;
130
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ const COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL = "coakka:logger-intent";
4
+
5
+ function createCoAkkaLoggerPreloadApi(ipcRenderer, channel = COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL) {
6
+ return {
7
+ log(intent) {
8
+ return ipcRenderer.invoke(channel, intent);
9
+ },
10
+ };
11
+ }
12
+
13
+ module.exports = {
14
+ COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL,
15
+ createCoAkkaLoggerPreloadApi,
16
+ };
@@ -0,0 +1,8 @@
1
+ export declare const COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL = "coakka:logger-intent";
2
+ export interface IpcRendererLike {
3
+ invoke(channel: string, payload: unknown): Promise<unknown>;
4
+ }
5
+ export interface CoAkkaElectronLoggerPreloadApi {
6
+ log(intent: unknown): Promise<unknown>;
7
+ }
8
+ export declare function createCoAkkaLoggerPreloadApi(ipcRenderer: IpcRendererLike, channel?: string): CoAkkaElectronLoggerPreloadApi;
@@ -0,0 +1,8 @@
1
+ export const COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL = "coakka:logger-intent";
2
+ export function createCoAkkaLoggerPreloadApi(ipcRenderer, channel = COAKKA_ELECTRON_LOGGER_INTENT_CHANNEL) {
3
+ return {
4
+ log(intent) {
5
+ return ipcRenderer.invoke(channel, intent);
6
+ },
7
+ };
8
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "coakka-logger-electron",
3
+ "version": "1.2.1",
4
+ "description": "Electron main-process intent bridge for the CoAkka logger",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./preload": {
15
+ "types": "./dist/preload.d.ts",
16
+ "import": "./dist/preload.js",
17
+ "require": "./dist/preload.cjs"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "CONSUMING.md",
23
+ "LICENSE.md",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "node scripts/build-package.mjs",
28
+ "verify": "npm run build",
29
+ "pack:release": "npm run build && node scripts/pack-release.mjs",
30
+ "smoke:packaged": "bash scripts/smoke-packaged-package.sh"
31
+ },
32
+ "dependencies": {
33
+ "coakka-logger-node": "1.2.1"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^24.0.0",
37
+ "typescript": "^5.8.3"
38
+ }
39
+ }