posipaki 0.20.2 → 0.20.3

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.
@@ -18,7 +18,7 @@ function defaultFactory(name) {
18
18
  function debugLogger(opts) {
19
19
  const ignoreSet = new Set(opts?.ignore ?? []);
20
20
  const factory = opts?.factory ?? defaultFactory;
21
- return async (config) => {
21
+ return async function debugLoggerPlugin(config) {
22
22
  const name = config.name ?? "actor";
23
23
  const pats = patterns();
24
24
  const log = factory(name);
@@ -1 +1 @@
1
- {"version":3,"file":"debug-logger.js","names":[],"sources":["../../src/plugins/debug-logger.ts"],"sourcesContent":["import type { ActorPlugin } from \"../hooks\";\nimport { mergeConfigs } from \"../hooks\";\nimport type { Message } from \"../types\";\nimport { pnameMatch } from \"../testing/pname-match\";\n\ndeclare module \"../index\" {\n interface ActorDecorated {\n log: Logger;\n }\n}\n\nexport interface DebugLogFn {\n (message: string, ...args: unknown[]): void;\n}\nexport interface MessageLogFn {\n (message: Message): void;\n}\n\nexport interface Logger {\n debug: DebugLogFn;\n info: DebugLogFn;\n warn: DebugLogFn;\n error: DebugLogFn;\n msg: MessageLogFn;\n}\nexport type LoggerFactory = (name: string) => Logger;\nexport interface DebugLoggerOpts {\n ignore?: string[];\n factory?: LoggerFactory;\n}\n\nfunction patterns(): string[] {\n const raw = (process.env.DEBUG ?? \"\").trim();\n if (!raw) return [];\n return raw\n .split(\",\")\n .map((p) => p.trim())\n .filter(Boolean);\n}\nfunction defaultFactory(name: string): Logger {\n return {\n debug: (...a: unknown[]) => console.debug(`[${name}]`, ...a),\n msg: (msg: Message) => console.debug(`[${name}] ←`, msg),\n info: (...a: unknown[]) => console.info(`[${name}]`, ...a),\n warn: (...a: unknown[]) => console.warn(`[${name}]`, ...a),\n error: (...a: unknown[]) => console.error(`[${name}]`, ...a),\n };\n}\n\nexport function debugLogger(opts?: DebugLoggerOpts): ActorPlugin {\n const ignoreSet = new Set(opts?.ignore ?? []);\n const factory = opts?.factory ?? defaultFactory;\n return async (config) => {\n const name: string = config.name ?? \"actor\";\n const pats = patterns();\n const log = factory(name);\n\n // Always decorate this.log — even when DEBUG is empty\n let result = mergeConfigs(config, {\n methods: { ...config.methods },\n $decorate: { log },\n });\n\n if (pnameMatch(name, pats)) {\n result = mergeConfigs(result, {\n onMessage(msg: Message) {\n if (!ignoreSet.has(msg.type)) log.msg(msg);\n },\n onEmit(msg: Message) {\n log.debug(`${name} → ${msg.type}`, msg);\n },\n onChildExit(childName: string) {\n log.debug(`child ${childName} exited`);\n },\n onError(err: unknown) {\n log.error(`${(err as Error).message ?? err}`);\n },\n });\n }\n\n return result;\n };\n}\n"],"mappings":";;;AA+BA,SAAS,WAAqB;CAC5B,MAAM,OAAO,QAAQ,IAAI,SAAS,IAAI,KAAK;CAC3C,IAAI,CAAC,KAAK,OAAO,CAAC;CAClB,OAAO,IACJ,MAAM,GAAG,EACT,KAAK,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AACnB;AACA,SAAS,eAAe,MAAsB;CAC5C,OAAO;EACL,QAAQ,GAAG,MAAiB,QAAQ,MAAM,IAAI,KAAK,IAAI,GAAG,CAAC;EAC3D,MAAM,QAAiB,QAAQ,MAAM,IAAI,KAAK,MAAM,GAAG;EACvD,OAAO,GAAG,MAAiB,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;EACzD,OAAO,GAAG,MAAiB,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;EACzD,QAAQ,GAAG,MAAiB,QAAQ,MAAM,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7D;AACF;AAEA,SAAgB,YAAY,MAAqC;CAC/D,MAAM,YAAY,IAAI,IAAI,MAAM,UAAU,CAAC,CAAC;CAC5C,MAAM,UAAU,MAAM,WAAW;CACjC,OAAO,OAAO,WAAW;EACvB,MAAM,OAAe,OAAO,QAAQ;EACpC,MAAM,OAAO,SAAS;EACtB,MAAM,MAAM,QAAQ,IAAI;EAGxB,IAAI,SAAS,aAAa,QAAQ;GAChC,SAAS,EAAE,GAAG,OAAO,QAAQ;GAC7B,WAAW,EAAE,IAAI;EACnB,CAAC;EAED,IAAI,WAAW,MAAM,IAAI,GACvB,SAAS,aAAa,QAAQ;GAC5B,UAAU,KAAc;IACtB,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG;GAC3C;GACA,OAAO,KAAc;IACnB,IAAI,MAAM,GAAG,KAAK,KAAK,IAAI,QAAQ,GAAG;GACxC;GACA,YAAY,WAAmB;IAC7B,IAAI,MAAM,SAAS,UAAU,QAAQ;GACvC;GACA,QAAQ,KAAc;IACpB,IAAI,MAAM,GAAI,IAAc,WAAW,KAAK;GAC9C;EACF,CAAC;EAGH,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"debug-logger.js","names":[],"sources":["../../src/plugins/debug-logger.ts"],"sourcesContent":["import type { ActorPlugin } from \"../hooks\";\nimport { mergeConfigs } from \"../hooks\";\nimport type { Message } from \"../types\";\nimport { pnameMatch } from \"../testing/pname-match\";\n\ndeclare module \"../index\" {\n interface ActorDecorated {\n log: Logger;\n }\n}\n\nexport interface DebugLogFn {\n (message: string, ...args: unknown[]): void;\n}\nexport interface MessageLogFn {\n (message: Message): void;\n}\n\nexport interface Logger {\n debug: DebugLogFn;\n info: DebugLogFn;\n warn: DebugLogFn;\n error: DebugLogFn;\n msg: MessageLogFn;\n}\nexport type LoggerFactory = (name: string) => Logger;\nexport interface DebugLoggerOpts {\n ignore?: string[];\n factory?: LoggerFactory;\n}\n\nfunction patterns(): string[] {\n const raw = (process.env.DEBUG ?? \"\").trim();\n if (!raw) return [];\n return raw\n .split(\",\")\n .map((p) => p.trim())\n .filter(Boolean);\n}\nfunction defaultFactory(name: string): Logger {\n return {\n debug: (...a: unknown[]) => console.debug(`[${name}]`, ...a),\n msg: (msg: Message) => console.debug(`[${name}] ←`, msg),\n info: (...a: unknown[]) => console.info(`[${name}]`, ...a),\n warn: (...a: unknown[]) => console.warn(`[${name}]`, ...a),\n error: (...a: unknown[]) => console.error(`[${name}]`, ...a),\n };\n}\n\nexport function debugLogger(opts?: DebugLoggerOpts): ActorPlugin {\n const ignoreSet = new Set(opts?.ignore ?? []);\n const factory = opts?.factory ?? defaultFactory;\n return async function debugLoggerPlugin(config) {\n const name: string = config.name ?? \"actor\";\n const pats = patterns();\n const log = factory(name);\n\n // Always decorate this.log — even when DEBUG is empty\n let result = mergeConfigs(config, {\n methods: { ...config.methods },\n $decorate: { log },\n });\n\n if (pnameMatch(name, pats)) {\n result = mergeConfigs(result, {\n onMessage(msg: Message) {\n if (!ignoreSet.has(msg.type)) log.msg(msg);\n },\n onEmit(msg: Message) {\n log.debug(`${name} → ${msg.type}`, msg);\n },\n onChildExit(childName: string) {\n log.debug(`child ${childName} exited`);\n },\n onError(err: unknown) {\n log.error(`${(err as Error).message ?? err}`);\n },\n });\n }\n\n return result;\n };\n}\n"],"mappings":";;;AA+BA,SAAS,WAAqB;CAC5B,MAAM,OAAO,QAAQ,IAAI,SAAS,IAAI,KAAK;CAC3C,IAAI,CAAC,KAAK,OAAO,CAAC;CAClB,OAAO,IACJ,MAAM,GAAG,EACT,KAAK,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AACnB;AACA,SAAS,eAAe,MAAsB;CAC5C,OAAO;EACL,QAAQ,GAAG,MAAiB,QAAQ,MAAM,IAAI,KAAK,IAAI,GAAG,CAAC;EAC3D,MAAM,QAAiB,QAAQ,MAAM,IAAI,KAAK,MAAM,GAAG;EACvD,OAAO,GAAG,MAAiB,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;EACzD,OAAO,GAAG,MAAiB,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;EACzD,QAAQ,GAAG,MAAiB,QAAQ,MAAM,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7D;AACF;AAEA,SAAgB,YAAY,MAAqC;CAC/D,MAAM,YAAY,IAAI,IAAI,MAAM,UAAU,CAAC,CAAC;CAC5C,MAAM,UAAU,MAAM,WAAW;CACjC,OAAO,eAAe,kBAAkB,QAAQ;EAC9C,MAAM,OAAe,OAAO,QAAQ;EACpC,MAAM,OAAO,SAAS;EACtB,MAAM,MAAM,QAAQ,IAAI;EAGxB,IAAI,SAAS,aAAa,QAAQ;GAChC,SAAS,EAAE,GAAG,OAAO,QAAQ;GAC7B,WAAW,EAAE,IAAI;EACnB,CAAC;EAED,IAAI,WAAW,MAAM,IAAI,GACvB,SAAS,aAAa,QAAQ;GAC5B,UAAU,KAAc;IACtB,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG;GAC3C;GACA,OAAO,KAAc;IACnB,IAAI,MAAM,GAAG,KAAK,KAAK,IAAI,QAAQ,GAAG;GACxC;GACA,YAAY,WAAmB;IAC7B,IAAI,MAAM,SAAS,UAAU,QAAQ;GACvC;GACA,QAAQ,KAAc;IACpB,IAAI,MAAM,GAAI,IAAc,WAAW,KAAK;GAC9C;EACF,CAAC;EAGH,OAAO;CACT;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { r as mergeConfigs } from "../hooks-Q4l5ggDj.js";
2
2
  //#region src/plugins/tree-introspection.ts
3
3
  function inspect() {
4
- return async (config) => {
4
+ return async function inspectPlugin(config) {
5
5
  return mergeConfigs(config, { $reflectionMethods: {
6
6
  ...config.$reflectionMethods,
7
7
  "inspect.getTree": function(prefix) {
@@ -1 +1 @@
1
- {"version":3,"file":"tree-introspection.js","names":[],"sources":["../../src/plugins/tree-introspection.ts"],"sourcesContent":["import { mergeConfigs } from \"../hooks.js\";\nimport type { ActorPlugin, ActorReflection as AR } from \"../hooks.js\";\nimport { AnyProcessCtx } from \"../types.js\";\n\ndeclare module \"../index\" {\n interface ActorReflection {\n \"inspect.getTree\": TreeReflectionMethods[\"inspect.getTree\"];\n \"inspect.getState\": TreeReflectionMethods[\"inspect.getState\"];\n \"inspect.stop\": TreeReflectionMethods[\"inspect.stop\"];\n }\n}\n\ninterface TreeReflectionMethods {\n \"inspect.getTree\": (prefix?: string) => TreeNode;\n \"inspect.getState\": () => unknown;\n \"inspect.stop\": () => void;\n}\n\nexport interface TreeNode {\n pname: string;\n parentName: string | null;\n children: TreeNode[];\n status: \"running\" | \"no introspection\";\n}\n\nexport function inspect(): ActorPlugin {\n return async (config) => {\n return mergeConfigs(config, {\n $reflectionMethods: {\n ...config.$reflectionMethods,\n \"inspect.getTree\": function (prefix?: string) {\n const children: TreeNode[] = [];\n for (const child of Object.values(this.$child)) {\n const cr = child.$reflection as AR;\n if (typeof cr[\"inspect.getTree\"] === \"function\") {\n const sub = cr[\"inspect.getTree\"](prefix) as TreeNode;\n if (!prefix || sub.pname.startsWith(prefix)) children.push(sub);\n } else {\n const n = child.pname;\n if (!prefix || n.startsWith(prefix))\n children.push({\n pname: n,\n parentName: this.name,\n children: [],\n status: \"no introspection\",\n });\n }\n }\n const selfCtx = this.ctx as AnyProcessCtx;\n return {\n pname: selfCtx.pname,\n parentName: selfCtx.parentName,\n children,\n status: \"running\" as const,\n } satisfies TreeNode;\n },\n \"inspect.getState\": function () {\n const state = this.state as unknown;\n return state;\n },\n \"inspect.stop\": function () {\n this.exit(\"inspector\");\n },\n },\n });\n };\n}\n"],"mappings":";;AAyBA,SAAgB,UAAuB;CACrC,OAAO,OAAO,WAAW;EACvB,OAAO,aAAa,QAAQ,EAC1B,oBAAoB;GAClB,GAAG,OAAO;GACV,mBAAmB,SAAU,QAAiB;IAC5C,MAAM,WAAuB,CAAC;IAC9B,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,MAAM,GAAG;KAC9C,MAAM,KAAK,MAAM;KACjB,IAAI,OAAO,GAAG,uBAAuB,YAAY;MAC/C,MAAM,MAAM,GAAG,mBAAmB,MAAM;MACxC,IAAI,CAAC,UAAU,IAAI,MAAM,WAAW,MAAM,GAAG,SAAS,KAAK,GAAG;KAChE,OAAO;MACL,MAAM,IAAI,MAAM;MAChB,IAAI,CAAC,UAAU,EAAE,WAAW,MAAM,GAChC,SAAS,KAAK;OACZ,OAAO;OACP,YAAY,KAAK;OACjB,UAAU,CAAC;OACX,QAAQ;MACV,CAAC;KACL;IACF;IACA,MAAM,UAAU,KAAK;IACrB,OAAO;KACL,OAAO,QAAQ;KACf,YAAY,QAAQ;KACpB;KACA,QAAQ;IACV;GACF;GACA,oBAAoB,WAAY;IAE9B,OADc,KAAK;GAErB;GACA,gBAAgB,WAAY;IAC1B,KAAK,KAAK,WAAW;GACvB;EACF,EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"tree-introspection.js","names":[],"sources":["../../src/plugins/tree-introspection.ts"],"sourcesContent":["import { mergeConfigs } from \"../hooks.js\";\nimport type { ActorPlugin, ActorReflection as AR } from \"../hooks.js\";\nimport { AnyProcessCtx } from \"../types.js\";\n\ndeclare module \"../index\" {\n interface ActorReflection {\n \"inspect.getTree\": TreeReflectionMethods[\"inspect.getTree\"];\n \"inspect.getState\": TreeReflectionMethods[\"inspect.getState\"];\n \"inspect.stop\": TreeReflectionMethods[\"inspect.stop\"];\n }\n}\n\ninterface TreeReflectionMethods {\n \"inspect.getTree\": (prefix?: string) => TreeNode;\n \"inspect.getState\": () => unknown;\n \"inspect.stop\": () => void;\n}\n\nexport interface TreeNode {\n pname: string;\n parentName: string | null;\n children: TreeNode[];\n status: \"running\" | \"no introspection\";\n}\n\nexport function inspect(): ActorPlugin {\n return async function inspectPlugin(config) {\n return mergeConfigs(config, {\n $reflectionMethods: {\n ...config.$reflectionMethods,\n \"inspect.getTree\": function (prefix?: string) {\n const children: TreeNode[] = [];\n for (const child of Object.values(this.$child)) {\n const cr = child.$reflection as AR;\n if (typeof cr[\"inspect.getTree\"] === \"function\") {\n const sub = cr[\"inspect.getTree\"](prefix) as TreeNode;\n if (!prefix || sub.pname.startsWith(prefix)) children.push(sub);\n } else {\n const n = child.pname;\n if (!prefix || n.startsWith(prefix))\n children.push({\n pname: n,\n parentName: this.name,\n children: [],\n status: \"no introspection\",\n });\n }\n }\n const selfCtx = this.ctx as AnyProcessCtx;\n return {\n pname: selfCtx.pname,\n parentName: selfCtx.parentName,\n children,\n status: \"running\" as const,\n } satisfies TreeNode;\n },\n \"inspect.getState\": function () {\n const state = this.state as unknown;\n return state;\n },\n \"inspect.stop\": function () {\n this.exit(\"inspector\");\n },\n },\n });\n };\n}\n"],"mappings":";;AAyBA,SAAgB,UAAuB;CACrC,OAAO,eAAe,cAAc,QAAQ;EAC1C,OAAO,aAAa,QAAQ,EAC1B,oBAAoB;GAClB,GAAG,OAAO;GACV,mBAAmB,SAAU,QAAiB;IAC5C,MAAM,WAAuB,CAAC;IAC9B,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,MAAM,GAAG;KAC9C,MAAM,KAAK,MAAM;KACjB,IAAI,OAAO,GAAG,uBAAuB,YAAY;MAC/C,MAAM,MAAM,GAAG,mBAAmB,MAAM;MACxC,IAAI,CAAC,UAAU,IAAI,MAAM,WAAW,MAAM,GAAG,SAAS,KAAK,GAAG;KAChE,OAAO;MACL,MAAM,IAAI,MAAM;MAChB,IAAI,CAAC,UAAU,EAAE,WAAW,MAAM,GAChC,SAAS,KAAK;OACZ,OAAO;OACP,YAAY,KAAK;OACjB,UAAU,CAAC;OACX,QAAQ;MACV,CAAC;KACL;IACF;IACA,MAAM,UAAU,KAAK;IACrB,OAAO;KACL,OAAO,QAAQ;KACf,YAAY,QAAQ;KACpB;KACA,QAAQ;IACV;GACF;GACA,oBAAoB,WAAY;IAE9B,OADc,KAAK;GAErB;GACA,gBAAgB,WAAY;IAC1B,KAAK,KAAK,WAAW;GACvB;EACF,EACF,CAAC;CACH;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "posipaki",
4
- "version": "0.20.2",
4
+ "version": "0.20.3",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [