@blac/core 2.0.22 → 2.1.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.
Files changed (76) hide show
  1. package/dist/StateContainer-BUyuxKb3.cjs +667 -0
  2. package/dist/StateContainer-BUyuxKb3.cjs.map +1 -0
  3. package/dist/StateContainer-B_7UHc3I.js +632 -0
  4. package/dist/StateContainer-B_7UHc3I.js.map +1 -0
  5. package/dist/StateContainer-Bh2ipNYj.js +632 -0
  6. package/dist/StateContainer-Bh2ipNYj.js.map +1 -0
  7. package/dist/StateContainer-ClzwKnQZ.cjs +667 -0
  8. package/dist/StateContainer-ClzwKnQZ.cjs.map +1 -0
  9. package/dist/StateContainer-DiQATvZh.js +632 -0
  10. package/dist/StateContainer-DiQATvZh.js.map +1 -0
  11. package/dist/StateContainer-j16zciex.cjs +667 -0
  12. package/dist/StateContainer-j16zciex.cjs.map +1 -0
  13. package/dist/StateContainerRegistry-BX-DlHXO.js +747 -0
  14. package/dist/StateContainerRegistry-BX-DlHXO.js.map +1 -0
  15. package/dist/StateContainerRegistry-Bf5VuVjm.js +747 -0
  16. package/dist/StateContainerRegistry-Bf5VuVjm.js.map +1 -0
  17. package/dist/StateContainerRegistry-BvSRfhKv.cjs +866 -0
  18. package/dist/StateContainerRegistry-BvSRfhKv.cjs.map +1 -0
  19. package/dist/StateContainerRegistry-C8jxrcqk.cjs +866 -0
  20. package/dist/StateContainerRegistry-C8jxrcqk.cjs.map +1 -0
  21. package/dist/StateContainerRegistry-DjQQtlCW.cjs +870 -0
  22. package/dist/StateContainerRegistry-DjQQtlCW.cjs.map +1 -0
  23. package/dist/StateContainerRegistry-gQbEutkN.js +751 -0
  24. package/dist/StateContainerRegistry-gQbEutkN.js.map +1 -0
  25. package/dist/config.d.cts +10 -6
  26. package/dist/config.d.ts +10 -6
  27. package/dist/constants.d.cts +12 -17
  28. package/dist/constants.d.ts +12 -17
  29. package/dist/core/StateContainer.d.ts +16 -34
  30. package/dist/core/StateContainerRegistry.d.ts +57 -174
  31. package/dist/core/symbols.d.ts +7 -4
  32. package/dist/decorators/blac.d.ts +5 -2
  33. package/dist/ensure-Bi_yXk6f.js +46 -0
  34. package/dist/ensure-Bi_yXk6f.js.map +1 -0
  35. package/dist/ensure-Bx41d-il.cjs +63 -0
  36. package/dist/ensure-Bx41d-il.cjs.map +1 -0
  37. package/dist/ensure-C7UQ_mKM.js +46 -0
  38. package/dist/ensure-C7UQ_mKM.js.map +1 -0
  39. package/dist/ensure-D1D4WjYf.cjs +63 -0
  40. package/dist/ensure-D1D4WjYf.cjs.map +1 -0
  41. package/dist/ensure-DBnuRJ0R.cjs +63 -0
  42. package/dist/ensure-DBnuRJ0R.cjs.map +1 -0
  43. package/dist/ensure-NTB9nnnj.js +46 -0
  44. package/dist/ensure-NTB9nnnj.js.map +1 -0
  45. package/dist/index.cjs +70 -49
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +2 -7
  48. package/dist/index.d.ts +2 -7
  49. package/dist/index.js +53 -26
  50. package/dist/index.js.map +1 -1
  51. package/dist/internal.cjs +10 -0
  52. package/dist/internal.d.cts +8 -0
  53. package/dist/internal.d.ts +8 -0
  54. package/dist/internal.js +3 -0
  55. package/dist/plugin/BlacPlugin.d.ts +8 -24
  56. package/dist/plugin/PluginManager.d.ts +41 -64
  57. package/dist/plugins.cjs +67 -87
  58. package/dist/plugins.cjs.map +1 -1
  59. package/dist/plugins.d.cts +7 -6
  60. package/dist/plugins.d.ts +7 -6
  61. package/dist/plugins.js +67 -87
  62. package/dist/plugins.js.map +1 -1
  63. package/dist/registry/config.d.ts +3 -0
  64. package/dist/testing.cjs +37 -35
  65. package/dist/testing.cjs.map +1 -1
  66. package/dist/testing.d.cts +5 -11
  67. package/dist/testing.d.ts +5 -11
  68. package/dist/testing.js +28 -26
  69. package/dist/testing.js.map +1 -1
  70. package/dist/types/branded.d.ts +3 -10
  71. package/dist/types/utilities.d.ts +0 -18
  72. package/dist/utils/idGenerator.d.ts +6 -13
  73. package/dist/utils/static-props.d.ts +9 -35
  74. package/dist/utils/structural-key.d.ts +0 -5
  75. package/dist/watch/watch.d.ts +4 -9
  76. package/package.json +15 -2
@@ -0,0 +1,63 @@
1
+ const require_StateContainer = require("./StateContainer-j16zciex.cjs");
2
+ //#region src/registry/acquire.ts
3
+ /**
4
+ * Acquire an instance with ref tracking (ownership semantics). Instance
5
+ * identity is derived purely from `args` (via the class's `static key(args)`,
6
+ * a structural hash of `args`, or the default sentinel when there are none).
7
+ *
8
+ * @param BlocClass - The StateContainer class constructor
9
+ * @param opts - `args` derives the instance key; `refId` names the reference
10
+ * for debugging and is auto-generated when omitted.
11
+ */
12
+ function acquire(BlocClass, opts) {
13
+ const registry = require_StateContainer.getRegistry();
14
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
15
+ return registry.acquire(BlocClass, key, {
16
+ canCreate: true,
17
+ countRef: true,
18
+ refId: opts?.refId,
19
+ args: opts?.args
20
+ });
21
+ }
22
+ /**
23
+ * Resolve the storage key an instance would be acquired under, given its
24
+ * construction `args`. This is the canonical key-computation path. Callers that
25
+ * both acquire and release against the `@internal` registry tier (e.g.
26
+ * `@blac/react` `useBloc`) must use this once and pass the same resolved key to
27
+ * both, so the ref is dropped under the key it was taken.
28
+ */
29
+ function resolveInstanceKey(BlocClass, args) {
30
+ return require_StateContainer.getRegistry().resolveKey(BlocClass, void 0, args);
31
+ }
32
+ //#endregion
33
+ //#region src/registry/ensure.ts
34
+ /**
35
+ * Ensure an instance exists without taking ownership (no ref added). Instance
36
+ * identity is derived purely from `args`, matching `acquire`.
37
+ */
38
+ function ensure(BlocClass, opts) {
39
+ const registry = require_StateContainer.getRegistry();
40
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
41
+ return registry.ensure(BlocClass, key, opts?.args);
42
+ }
43
+ //#endregion
44
+ Object.defineProperty(exports, "acquire", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return acquire;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "ensure", {
51
+ enumerable: true,
52
+ get: function() {
53
+ return ensure;
54
+ }
55
+ });
56
+ Object.defineProperty(exports, "resolveInstanceKey", {
57
+ enumerable: true,
58
+ get: function() {
59
+ return resolveInstanceKey;
60
+ }
61
+ });
62
+
63
+ //# sourceMappingURL=ensure-D1D4WjYf.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-D1D4WjYf.cjs","names":["getRegistry","getRegistry"],"sources":["../src/registry/acquire.ts","../src/registry/ensure.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Acquire an instance with ref tracking (ownership semantics). Instance\n * identity is derived purely from `args` (via the class's `static key(args)`,\n * a structural hash of `args`, or the default sentinel when there are none).\n *\n * @param BlocClass - The StateContainer class constructor\n * @param opts - `args` derives the instance key; `refId` names the reference\n * for debugging and is auto-generated when omitted.\n */\nexport function acquire<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.acquire(BlocClass, key, {\n canCreate: true,\n countRef: true,\n refId: opts?.refId,\n args: opts?.args,\n });\n}\n\n/**\n * Resolve the storage key an instance would be acquired under, given its\n * construction `args`. This is the canonical key-computation path. Callers that\n * both acquire and release against the `@internal` registry tier (e.g.\n * `@blac/react` `useBloc`) must use this once and pass the same resolved key to\n * both, so the ref is dropped under the key it was taken.\n */\nexport function resolveInstanceKey<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, args);\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Ensure an instance exists without taking ownership (no ref added). Instance\n * identity is derived purely from `args`, matching `acquire`.\n */\nexport function ensure<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.ensure(BlocClass, key, opts?.args);\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,QACd,WACA,MACiB;CACjB,MAAM,WAAWA,uBAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,QAAQ,WAAW,KAAK;EACtC,WAAW;EACX,UAAU;EACV,OAAO,MAAM;EACb,MAAM,MAAM;CACd,CAAC;AACH;;;;;;;;AASA,SAAgB,mBACd,WACA,MACQ;CACR,OAAOA,uBAAAA,YAAY,EAAE,WAAW,WAAW,KAAA,GAAW,IAAI;AAC5D;;;;;;;AC/BA,SAAgB,OACd,WACA,MACiB;CACjB,MAAM,WAAWC,uBAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,OAAO,WAAW,KAAK,MAAM,IAAI;AACnD"}
@@ -0,0 +1,63 @@
1
+ const require_StateContainer = require("./StateContainer-BUyuxKb3.cjs");
2
+ //#region src/registry/acquire.ts
3
+ /**
4
+ * Acquire an instance with ref tracking (ownership semantics). Instance
5
+ * identity is derived purely from `args` (via the class's `static key(args)`,
6
+ * a structural hash of `args`, or the default sentinel when there are none).
7
+ *
8
+ * @param BlocClass - The StateContainer class constructor
9
+ * @param opts - `args` derives the instance key; `refId` names the reference
10
+ * for debugging and is auto-generated when omitted.
11
+ */
12
+ function acquire(BlocClass, opts) {
13
+ const registry = require_StateContainer.getRegistry();
14
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
15
+ return registry.acquire(BlocClass, key, {
16
+ canCreate: true,
17
+ countRef: true,
18
+ refId: opts?.refId,
19
+ args: opts?.args
20
+ });
21
+ }
22
+ /**
23
+ * Resolve the storage key an instance would be acquired under, given its
24
+ * construction `args`. This is the canonical key-computation path. Callers that
25
+ * both acquire and release against the `@internal` registry tier (e.g.
26
+ * `@blac/react` `useBloc`) must use this once and pass the same resolved key to
27
+ * both, so the ref is dropped under the key it was taken.
28
+ */
29
+ function resolveInstanceKey(BlocClass, args) {
30
+ return require_StateContainer.getRegistry().resolveKey(BlocClass, void 0, args);
31
+ }
32
+ //#endregion
33
+ //#region src/registry/ensure.ts
34
+ /**
35
+ * Ensure an instance exists without taking ownership (no ref added). Instance
36
+ * identity is derived purely from `args`, matching `acquire`.
37
+ */
38
+ function ensure(BlocClass, opts) {
39
+ const registry = require_StateContainer.getRegistry();
40
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
41
+ return registry.ensure(BlocClass, key, opts?.args);
42
+ }
43
+ //#endregion
44
+ Object.defineProperty(exports, "acquire", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return acquire;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "ensure", {
51
+ enumerable: true,
52
+ get: function() {
53
+ return ensure;
54
+ }
55
+ });
56
+ Object.defineProperty(exports, "resolveInstanceKey", {
57
+ enumerable: true,
58
+ get: function() {
59
+ return resolveInstanceKey;
60
+ }
61
+ });
62
+
63
+ //# sourceMappingURL=ensure-DBnuRJ0R.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-DBnuRJ0R.cjs","names":["getRegistry","getRegistry"],"sources":["../src/registry/acquire.ts","../src/registry/ensure.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Acquire an instance with ref tracking (ownership semantics). Instance\n * identity is derived purely from `args` (via the class's `static key(args)`,\n * a structural hash of `args`, or the default sentinel when there are none).\n *\n * @param BlocClass - The StateContainer class constructor\n * @param opts - `args` derives the instance key; `refId` names the reference\n * for debugging and is auto-generated when omitted.\n */\nexport function acquire<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.acquire(BlocClass, key, {\n canCreate: true,\n countRef: true,\n refId: opts?.refId,\n args: opts?.args,\n });\n}\n\n/**\n * Resolve the storage key an instance would be acquired under, given its\n * construction `args`. This is the canonical key-computation path. Callers that\n * both acquire and release against the `@internal` registry tier (e.g.\n * `@blac/react` `useBloc`) must use this once and pass the same resolved key to\n * both, so the ref is dropped under the key it was taken.\n */\nexport function resolveInstanceKey<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, args);\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Ensure an instance exists without taking ownership (no ref added). Instance\n * identity is derived purely from `args`, matching `acquire`.\n */\nexport function ensure<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.ensure(BlocClass, key, opts?.args);\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,QACd,WACA,MACiB;CACjB,MAAM,WAAWA,uBAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,QAAQ,WAAW,KAAK;EACtC,WAAW;EACX,UAAU;EACV,OAAO,MAAM;EACb,MAAM,MAAM;CACd,CAAC;AACH;;;;;;;;AASA,SAAgB,mBACd,WACA,MACQ;CACR,OAAOA,uBAAAA,YAAY,EAAE,WAAW,WAAW,KAAA,GAAW,IAAI;AAC5D;;;;;;;AC/BA,SAAgB,OACd,WACA,MACiB;CACjB,MAAM,WAAWC,uBAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,OAAO,WAAW,KAAK,MAAM,IAAI;AACnD"}
@@ -0,0 +1,46 @@
1
+ import { i as getRegistry } from "./StateContainer-DiQATvZh.js";
2
+ //#region src/registry/acquire.ts
3
+ /**
4
+ * Acquire an instance with ref tracking (ownership semantics). Instance
5
+ * identity is derived purely from `args` (via the class's `static key(args)`,
6
+ * a structural hash of `args`, or the default sentinel when there are none).
7
+ *
8
+ * @param BlocClass - The StateContainer class constructor
9
+ * @param opts - `args` derives the instance key; `refId` names the reference
10
+ * for debugging and is auto-generated when omitted.
11
+ */
12
+ function acquire(BlocClass, opts) {
13
+ const registry = getRegistry();
14
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
15
+ return registry.acquire(BlocClass, key, {
16
+ canCreate: true,
17
+ countRef: true,
18
+ refId: opts?.refId,
19
+ args: opts?.args
20
+ });
21
+ }
22
+ /**
23
+ * Resolve the storage key an instance would be acquired under, given its
24
+ * construction `args`. This is the canonical key-computation path. Callers that
25
+ * both acquire and release against the `@internal` registry tier (e.g.
26
+ * `@blac/react` `useBloc`) must use this once and pass the same resolved key to
27
+ * both, so the ref is dropped under the key it was taken.
28
+ */
29
+ function resolveInstanceKey(BlocClass, args) {
30
+ return getRegistry().resolveKey(BlocClass, void 0, args);
31
+ }
32
+ //#endregion
33
+ //#region src/registry/ensure.ts
34
+ /**
35
+ * Ensure an instance exists without taking ownership (no ref added). Instance
36
+ * identity is derived purely from `args`, matching `acquire`.
37
+ */
38
+ function ensure(BlocClass, opts) {
39
+ const registry = getRegistry();
40
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
41
+ return registry.ensure(BlocClass, key, opts?.args);
42
+ }
43
+ //#endregion
44
+ export { acquire as n, resolveInstanceKey as r, ensure as t };
45
+
46
+ //# sourceMappingURL=ensure-NTB9nnnj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-NTB9nnnj.js","names":[],"sources":["../src/registry/acquire.ts","../src/registry/ensure.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Acquire an instance with ref tracking (ownership semantics). Instance\n * identity is derived purely from `args` (via the class's `static key(args)`,\n * a structural hash of `args`, or the default sentinel when there are none).\n *\n * @param BlocClass - The StateContainer class constructor\n * @param opts - `args` derives the instance key; `refId` names the reference\n * for debugging and is auto-generated when omitted.\n */\nexport function acquire<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.acquire(BlocClass, key, {\n canCreate: true,\n countRef: true,\n refId: opts?.refId,\n args: opts?.args,\n });\n}\n\n/**\n * Resolve the storage key an instance would be acquired under, given its\n * construction `args`. This is the canonical key-computation path. Callers that\n * both acquire and release against the `@internal` registry tier (e.g.\n * `@blac/react` `useBloc`) must use this once and pass the same resolved key to\n * both, so the ref is dropped under the key it was taken.\n */\nexport function resolveInstanceKey<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, args);\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Ensure an instance exists without taking ownership (no ref added). Instance\n * identity is derived purely from `args`, matching `acquire`.\n */\nexport function ensure<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.ensure(BlocClass, key, opts?.args);\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,QACd,WACA,MACiB;CACjB,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,QAAQ,WAAW,KAAK;EACtC,WAAW;EACX,UAAU;EACV,OAAO,MAAM;EACb,MAAM,MAAM;CACd,CAAC;AACH;;;;;;;;AASA,SAAgB,mBACd,WACA,MACQ;CACR,OAAO,YAAY,EAAE,WAAW,WAAW,KAAA,GAAW,IAAI;AAC5D;;;;;;;AC/BA,SAAgB,OACd,WACA,MACiB;CACjB,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,OAAO,WAAW,KAAK,MAAM,IAAI;AACnD"}
package/dist/index.cjs CHANGED
@@ -1,16 +1,43 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_StateContainerRegistry = require("./StateContainerRegistry-CBLeHObO.cjs");
3
- const require_ensure = require("./ensure-D3w6YGp9.cjs");
2
+ const require_StateContainerRegistry = require("./StateContainerRegistry-DjQQtlCW.cjs");
3
+ const require_StateContainer = require("./StateContainer-BUyuxKb3.cjs");
4
+ const require_ensure = require("./ensure-DBnuRJ0R.cjs");
4
5
  let _dirtytalk_structural = require("@dirtytalk/structural");
6
+ //#region src/core/Cubit.ts
7
+ /**
8
+ * `Cubit<S>` is a `StateContainer<S>` that exposes mutation publicly.
9
+ *
10
+ * That is the whole difference, and it is a real one: on `StateContainer`
11
+ * `emit` / `patch` / `update` are `protected`, so a container mutates itself
12
+ * from its own methods and callers go through the API it chooses to publish.
13
+ * `Cubit` re-declares the three as `public` for the cases where a caller
14
+ * legitimately drives state from outside — test helpers, devtools
15
+ * time-travel, benchmarks.
16
+ *
17
+ * Reach for `StateContainer` when business logic should live in the class,
18
+ * and `Cubit` when the caller owns the transitions.
19
+ */
20
+ var Cubit = class extends require_StateContainer.StateContainer {
21
+ emit(next) {
22
+ super.emit(next);
23
+ }
24
+ patch(partial) {
25
+ super.patch(partial);
26
+ }
27
+ update(fn) {
28
+ super.update(fn);
29
+ }
30
+ };
31
+ //#endregion
5
32
  //#region src/registry/borrow.ts
6
33
  function resolveBorrowKey(BlocClass, target) {
7
- return require_ensure.getRegistry().resolveKey(BlocClass, void 0, target?.args);
34
+ return require_StateContainer.getRegistry().resolveKey(BlocClass, void 0, target?.args);
8
35
  }
9
36
  function borrow(BlocClass, target) {
10
- return require_ensure.getRegistry().borrow(BlocClass, resolveBorrowKey(BlocClass, target));
37
+ return require_StateContainer.getRegistry().borrow(BlocClass, resolveBorrowKey(BlocClass, target));
11
38
  }
12
39
  function borrowSafe(BlocClass, target) {
13
- return require_ensure.getRegistry().borrowSafe(BlocClass, resolveBorrowKey(BlocClass, target));
40
+ return require_StateContainer.getRegistry().borrowSafe(BlocClass, resolveBorrowKey(BlocClass, target));
14
41
  }
15
42
  //#endregion
16
43
  //#region src/registry/release.ts
@@ -23,7 +50,7 @@ function borrowSafe(BlocClass, target) {
23
50
  * `forceDispose` disposes immediately regardless of remaining refs.
24
51
  */
25
52
  function release(BlocClass, opts) {
26
- const registry = require_ensure.getRegistry();
53
+ const registry = require_StateContainer.getRegistry();
27
54
  const key = registry.resolveKey(BlocClass, void 0, opts?.args);
28
55
  registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);
29
56
  }
@@ -33,7 +60,7 @@ function release(BlocClass, opts) {
33
60
  * @public
34
61
  */
35
62
  function hasInstance(BlocClass, opts) {
36
- const registry = require_ensure.getRegistry();
63
+ const registry = require_StateContainer.getRegistry();
37
64
  const key = registry.resolveKey(BlocClass, void 0, opts?.args);
38
65
  return registry.hasInstance(BlocClass, key);
39
66
  }
@@ -41,7 +68,7 @@ function hasInstance(BlocClass, opts) {
41
68
  * @public
42
69
  */
43
70
  function getRefCount(BlocClass, opts) {
44
- const registry = require_ensure.getRegistry();
71
+ const registry = require_StateContainer.getRegistry();
45
72
  const key = registry.resolveKey(BlocClass, void 0, opts?.args);
46
73
  return registry.getRefCount(BlocClass, key);
47
74
  }
@@ -49,7 +76,7 @@ function getRefCount(BlocClass, opts) {
49
76
  * @public
50
77
  */
51
78
  function getRefIds(BlocClass, opts) {
52
- const registry = require_ensure.getRegistry();
79
+ const registry = require_StateContainer.getRegistry();
53
80
  const key = registry.resolveKey(BlocClass, void 0, opts?.args);
54
81
  return registry.getRefIds(BlocClass, key);
55
82
  }
@@ -57,27 +84,27 @@ function getRefIds(BlocClass, opts) {
57
84
  * @public
58
85
  */
59
86
  function getAll(BlocClass) {
60
- return require_ensure.getRegistry().getAll(BlocClass);
87
+ return require_StateContainer.getRegistry().getAll(BlocClass);
61
88
  }
62
89
  /**
63
90
  * @public
64
91
  */
65
92
  function forEach(BlocClass, callback) {
66
- require_ensure.getRegistry().forEach(BlocClass, callback);
93
+ require_StateContainer.getRegistry().forEach(BlocClass, callback);
67
94
  }
68
95
  //#endregion
69
96
  //#region src/registry/management.ts
70
97
  function clear(BlocClass) {
71
- require_ensure.getRegistry().clear(BlocClass);
98
+ require_StateContainer.getRegistry().clear(BlocClass);
72
99
  }
73
100
  function clearAll() {
74
- require_ensure.getRegistry().clearAll();
101
+ require_StateContainer.getRegistry().clearAll();
75
102
  }
76
103
  /**
77
104
  * @public
78
105
  */
79
106
  function register(BlocClass) {
80
- require_ensure.getRegistry().register(BlocClass);
107
+ require_StateContainer.getRegistry().register(BlocClass);
81
108
  }
82
109
  //#endregion
83
110
  //#region src/decorators/blac.ts
@@ -105,11 +132,11 @@ function register(BlocClass) {
105
132
  */
106
133
  function blac(options) {
107
134
  return function(target, _context) {
108
- if ("keepAlive" in options && options.keepAlive) target[require_StateContainerRegistry.BLAC_STATIC_PROPS.KEEP_ALIVE] = true;
109
- if ("excludeFromDevTools" in options && options.excludeFromDevTools) target[require_StateContainerRegistry.BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
110
- if ("equality" in options && typeof options.equality === "function") target[require_StateContainerRegistry.BLAC_STATIC_PROPS.EQUALITY] = options.equality;
111
- if ("key" in options && typeof options.key === "function") target[require_StateContainerRegistry.BLAC_STATIC_PROPS.KEY] = options.key;
112
- if ("name" in options && typeof options.name === "string") target[require_StateContainerRegistry.BLAC_STATIC_PROPS.BLAC_NAME] = options.name;
135
+ if (options.keepAlive !== void 0) target[require_StateContainerRegistry.BLAC_STATIC_PROPS.KEEP_ALIVE] = options.keepAlive;
136
+ if (options.excludeFromDevTools) target[require_StateContainerRegistry.BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
137
+ if (typeof options.equality === "function") target[require_StateContainerRegistry.BLAC_STATIC_PROPS.EQUALITY] = options.equality;
138
+ if (typeof options.key === "function") target[require_StateContainerRegistry.BLAC_STATIC_PROPS.KEY] = options.key;
139
+ if (typeof options.name === "string") target[require_StateContainerRegistry.BLAC_STATIC_PROPS.BLAC_NAME] = options.name;
113
140
  return target;
114
141
  };
115
142
  }
@@ -139,8 +166,7 @@ function instance(BlocClass, args) {
139
166
  function isBlocRef(input) {
140
167
  return typeof input === "object" && input !== null && BLOC_REF_MARKER in input;
141
168
  }
142
- function toWatchTarget(input) {
143
- const registry = require_ensure.getRegistry();
169
+ function toWatchTarget(registry, input) {
144
170
  if (isBlocRef(input)) return {
145
171
  blocClass: input.blocClass,
146
172
  key: input.instanceId,
@@ -158,8 +184,8 @@ let watchRefSeq = 0;
158
184
  * through so a not-yet-created instance is initialized correctly. The
159
185
  * caller is responsible for releasing `refId` in cleanup.
160
186
  */
161
- function resolveBloc(target, refId) {
162
- return require_ensure.getRegistry().acquire(target.blocClass, target.key, {
187
+ function resolveBloc(registry, target, refId) {
188
+ return registry.acquire(target.blocClass, target.key, {
163
189
  countRef: true,
164
190
  refId,
165
191
  args: target.args
@@ -169,8 +195,7 @@ function resolveBloc(target, refId) {
169
195
  * Passive lookup for `{ create: false }`: never creates the instance and
170
196
  * never takes a ref. Returns `undefined` when no instance currently exists.
171
197
  */
172
- function resolveBlocPassive(target) {
173
- const registry = require_ensure.getRegistry();
198
+ function resolveBlocPassive(registry, target) {
174
199
  try {
175
200
  return registry.acquire(target.blocClass, target.key, {
176
201
  canCreate: false,
@@ -187,12 +212,13 @@ function isArray(input) {
187
212
  function watchImpl(blocsOrBloc, callback, options) {
188
213
  const isSingle = !isArray(blocsOrBloc);
189
214
  const inputs = isSingle ? [blocsOrBloc] : blocsOrBloc;
190
- const registry = require_ensure.getRegistry();
215
+ const registry = require_StateContainer.getRegistry();
191
216
  const create = options?.create ?? true;
192
- const targets = inputs.map(toWatchTarget);
217
+ const targets = inputs.map((input) => toWatchTarget(registry, input));
193
218
  const refIds = targets.map(() => `_watch_${watchRefSeq++}`);
219
+ const resolveAt = (index) => create ? resolveBloc(registry, targets[index], refIds[index]) : resolveBlocPassive(registry, targets[index]);
194
220
  let disposed = false;
195
- const instances = targets.map((target, i) => create ? resolveBloc(target, refIds[i]) : resolveBlocPassive(target));
221
+ const instances = [];
196
222
  const channelUnsubs = [];
197
223
  const disposedUnsubs = [];
198
224
  const cleanup = () => {
@@ -202,7 +228,7 @@ function watchImpl(blocsOrBloc, callback, options) {
202
228
  for (const unsub of disposedUnsubs) unsub?.();
203
229
  channelUnsubs.length = 0;
204
230
  disposedUnsubs.length = 0;
205
- if (create) for (let i = 0; i < targets.length; i++) registry.release(targets[i].blocClass, targets[i].key, false, refIds[i]);
231
+ if (create) for (let i = 0; i < instances.length; i++) registry.release(targets[i].blocClass, targets[i].key, false, refIds[i]);
206
232
  };
207
233
  const runCallback = () => {
208
234
  if (disposed) return;
@@ -214,7 +240,7 @@ function watchImpl(blocsOrBloc, callback, options) {
214
240
  };
215
241
  const resubscribeAt = (index) => {
216
242
  if (disposed) return;
217
- instances[index] = create ? resolveBloc(targets[index], refIds[index]) : resolveBlocPassive(targets[index]);
243
+ instances[index] = resolveAt(index);
218
244
  subscribeAt(index);
219
245
  subscribeDisposeAt(index);
220
246
  runCallback();
@@ -226,19 +252,20 @@ function watchImpl(blocsOrBloc, callback, options) {
226
252
  queueMicrotask(() => resubscribeAt(index));
227
253
  });
228
254
  };
229
- for (let i = 0; i < instances.length; i++) subscribeAt(i);
230
- for (let i = 0; i < instances.length; i++) subscribeDisposeAt(i);
231
- runCallback();
255
+ try {
256
+ for (let i = 0; i < targets.length; i++) instances.push(resolveAt(i));
257
+ for (let i = 0; i < instances.length; i++) subscribeAt(i);
258
+ for (let i = 0; i < instances.length; i++) subscribeDisposeAt(i);
259
+ runCallback();
260
+ } catch (error) {
261
+ cleanup();
262
+ throw error;
263
+ }
232
264
  return cleanup;
233
265
  }
234
266
  const watch = Object.assign(watchImpl, { STOP });
235
267
  //#endregion
236
268
  //#region src/types/branded.ts
237
- /**
238
- * Create a branded InstanceId from a string
239
- * @param id - The string ID to brand
240
- * @returns Branded InstanceId
241
- */
242
269
  function instanceId(id) {
243
270
  return id;
244
271
  }
@@ -249,15 +276,9 @@ Object.defineProperty(exports, "ALL_PATHS", {
249
276
  return _dirtytalk_structural.ALL_PATHS;
250
277
  }
251
278
  });
252
- exports.APPLY_DEPS = require_StateContainerRegistry.APPLY_DEPS;
253
- exports.Cubit = require_ensure.Cubit;
254
- exports.DEP_BRAND = require_ensure.DEP_BRAND;
255
- exports.INIT_CONFIG = require_StateContainerRegistry.INIT_CONFIG;
256
- exports.ON_DISPOSE = require_StateContainerRegistry.ON_DISPOSE;
257
- exports.REMOVE_DEPS_OWNER = require_StateContainerRegistry.REMOVE_DEPS_OWNER;
258
- exports.StateContainer = require_ensure.StateContainer;
279
+ exports.Cubit = Cubit;
280
+ exports.StateContainer = require_StateContainer.StateContainer;
259
281
  exports.StateContainerRegistry = require_StateContainerRegistry.StateContainerRegistry;
260
- exports.WITH_TRACKED_STATE = require_StateContainerRegistry.WITH_TRACKED_STATE;
261
282
  exports.acquire = require_ensure.acquire;
262
283
  exports.blac = blac;
263
284
  exports.borrow = borrow;
@@ -272,8 +293,8 @@ exports.getBlacConfig = require_StateContainerRegistry.getBlacConfig;
272
293
  exports.getBlacName = require_StateContainerRegistry.getBlacName;
273
294
  exports.getRefCount = getRefCount;
274
295
  exports.getRefIds = getRefIds;
275
- exports.getRegistry = require_ensure.getRegistry;
276
- exports.getStats = require_ensure.getStats;
296
+ exports.getRegistry = require_StateContainer.getRegistry;
297
+ exports.getStats = require_StateContainer.getStats;
277
298
  exports.globalRegistry = require_StateContainerRegistry.globalRegistry;
278
299
  exports.hasInstance = hasInstance;
279
300
  exports.instance = instance;
@@ -284,7 +305,7 @@ exports.register = register;
284
305
  exports.release = release;
285
306
  exports.resetBlacConfig = require_StateContainerRegistry.resetBlacConfig;
286
307
  exports.resolveInstanceKey = require_ensure.resolveInstanceKey;
287
- exports.setRegistry = require_ensure.setRegistry;
308
+ exports.setRegistry = require_StateContainer.setRegistry;
288
309
  exports.shallowEqualState = require_StateContainerRegistry.shallowEqualState;
289
310
  exports.watch = watch;
290
311
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["getRegistry","getRegistry","getRegistry","BLAC_STATIC_PROPS","resolveInstanceKey","getRegistry","ALL_PATHS","ON_DISPOSE"],"sources":["../src/registry/borrow.ts","../src/registry/release.ts","../src/registry/queries.ts","../src/registry/management.ts","../src/decorators/blac.ts","../src/watch/watch.ts","../src/types/branded.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * How to identify the instance to borrow: the same `args` shape `useBloc`\n * accepts, resolved through the class's `static key(args)` so call sites use\n * the *same* shape they pass to `useBloc` instead of hand-deriving the key.\n *\n * `borrowSafe(ChannelBloc, { args: { channelId } })` and\n * `useBloc(ChannelBloc, { args: { channelId } })` therefore always agree.\n */\nexport type BorrowTarget<T extends StateContainerConstructor> = {\n args?: ExtractArgs<T>;\n};\n\nfunction resolveBorrowKey<T extends StateContainerConstructor>(\n BlocClass: T,\n target: BorrowTarget<T> | undefined,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, target?.args);\n}\n\nexport function borrow<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n): InstanceType<T> {\n return getRegistry().borrow(BlocClass, resolveBorrowKey(BlocClass, target));\n}\n\nexport function borrowSafe<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n):\n | { error: Error; instance: null }\n | { error: null; instance: InstanceType<T> } {\n return getRegistry().borrowSafe(\n BlocClass,\n resolveBorrowKey(BlocClass, target),\n );\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Release a reference to an instance. Instance identity is derived purely from\n * `args` (must match the `args` it was acquired with).\n *\n * @param opts - `args` derives the instance key (must match acquire);\n * `refId` picks the ref to drop, otherwise one arbitrary ref goes;\n * `forceDispose` disposes immediately regardless of remaining refs.\n */\nexport function release<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string; forceDispose?: boolean },\n): void {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\n/**\n * @public\n */\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\n/**\n * @public\n */\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\n/**\n * @public\n */\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n","import { BLAC_STATIC_PROPS } from '../constants';\nimport type { EqualityFn } from '../config';\n\n/**\n * Configuration options for the `@blac` decorator. Any combination may be\n * given at once.\n */\nexport interface BlacOptions {\n /** Mark bloc to never be auto-disposed when ref count reaches 0 */\n keepAlive?: true;\n /** Exclude bloc from DevTools tracking (prevents infinite loops) */\n excludeFromDevTools?: true;\n /**\n * Override the global equality check for this bloc.\n * Return `true` to skip the emit (states considered equal).\n */\n equality?: EqualityFn;\n /**\n * Override the default structural-hash identity key.\n * The function receives `args` and returns the instance key string.\n * Distinct return values → distinct instances; identical values → shared instance.\n * Non-identity fields can be excluded so they don't fork new instances.\n */\n key?: (args: any) => string;\n /**\n * Explicit, minification-safe identity for this bloc class. Falls back to\n * `constructor.name` when unset, which collides across classes once a\n * minifier shortens class names.\n */\n name?: string;\n}\n\n/**\n * Decorator to configure StateContainer classes.\n *\n * @example Decorator syntax (requires experimentalDecorators or TC39 decorators)\n * ```ts\n * @blac({ keepAlive: true })\n * class AuthBloc extends Cubit<AuthState> {}\n *\n * @blac({ excludeFromDevTools: true })\n * class InternalBloc extends Cubit<InternalState> {}\n *\n * @blac({ keepAlive: true, key: (args) => args.userId })\n * class UserBloc extends Cubit<UserState> {}\n * ```\n *\n * @example Function syntax (no decorator support needed)\n * ```ts\n * const AuthBloc = blac({ keepAlive: true })(\n * class extends Cubit<AuthState> {}\n * );\n * ```\n */\nexport function blac(options: BlacOptions) {\n return function <T extends new (...args: any[]) => any>(\n target: T,\n _context?: ClassDecoratorContext,\n ): T {\n if ('keepAlive' in options && options.keepAlive) {\n (target as any)[BLAC_STATIC_PROPS.KEEP_ALIVE] = true;\n }\n if ('excludeFromDevTools' in options && options.excludeFromDevTools) {\n (target as any)[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;\n }\n if ('equality' in options && typeof options.equality === 'function') {\n (target as any)[BLAC_STATIC_PROPS.EQUALITY] = options.equality;\n }\n if ('key' in options && typeof options.key === 'function') {\n (target as any)[BLAC_STATIC_PROPS.KEY] = options.key;\n }\n if ('name' in options && typeof options.name === 'string') {\n (target as any)[BLAC_STATIC_PROPS.BLAC_NAME] = options.name;\n }\n return target;\n };\n}\n","import { ALL_PATHS } from '@dirtytalk/structural';\nimport { ON_DISPOSE } from '../core/symbols';\nimport { getRegistry } from '../registry';\nimport { resolveInstanceKey } from '../registry/acquire';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n StateContainerInstance,\n} from '../types/utilities';\n\nconst STOP: unique symbol = Symbol('watch.STOP');\ntype StopSymbol = typeof STOP;\n\nconst BLOC_REF_MARKER = Symbol('BlocRef');\n\n/**\n * Reference to a specific bloc instance, identified by class + the resolved\n * key derived from its `args`.\n */\nexport interface BlocRef<T extends StateContainerConstructor> {\n [BLOC_REF_MARKER]: true;\n blocClass: T;\n /** @internal The resolved instance key (derived from `args`). */\n instanceId: string;\n /**\n * @internal The `args` used to derive `instanceId`. Forwarded to\n * `registry.acquire` so a not-yet-created instance is initialized with\n * these args instead of `undefined`.\n */\n args?: unknown;\n}\n\n/**\n * Create a reference to a specific bloc instance, identified by its `args`.\n * The key is derived the same way `useBloc`/`acquire` derive it.\n *\n * @example\n * ```ts\n * watch(instance(UserBloc, { userId: 'user-123' }), (userBloc) => {\n * console.log(userBloc.state.name);\n * });\n * ```\n */\nexport function instance<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): BlocRef<T> {\n return {\n [BLOC_REF_MARKER]: true,\n blocClass: BlocClass,\n instanceId: resolveInstanceKey(BlocClass, args),\n args,\n };\n}\n\nfunction isBlocRef(\n input: unknown,\n): input is BlocRef<StateContainerConstructor> {\n return (\n typeof input === 'object' && input !== null && BLOC_REF_MARKER in input\n );\n}\n\ntype BlocInput = StateContainerConstructor | BlocRef<StateContainerConstructor>;\n\n/**\n * Options for `watch`.\n */\nexport interface WatchOptions {\n /**\n * When `false`, `watch` observes passively instead of owning the instance:\n * it does not create a missing instance, and it does not take a real\n * ownership ref on an existing one (so it never keeps an otherwise-\n * unreferenced instance alive).\n *\n * If the instance does not exist yet when `watch` is called, the callback\n * simply never fires for it — `watch` does not poll or wait for a later\n * creation. Call `watch` again once the instance is known to exist (e.g.\n * after some other owner has acquired it).\n *\n * Defaults to `true`.\n */\n create?: boolean;\n}\n\ntype ExtractInstance<T> =\n T extends BlocRef<infer C>\n ? InstanceType<C>\n : T extends StateContainerConstructor\n ? InstanceType<T>\n : never;\n\ntype ExtractInstances<T extends readonly BlocInput[]> = {\n [K in keyof T]: ExtractInstance<T[K]>;\n};\n\n/**\n * Watch function signature for single bloc.\n */\nexport interface WatchSingleFn {\n <T extends StateContainerConstructor>(\n bloc: T | BlocRef<T>,\n callback: (bloc: InstanceType<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n\n STOP: StopSymbol;\n}\n\n/**\n * Watch function signature for multiple blocs.\n */\nexport interface WatchMultipleFn {\n <T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n\n STOP: StopSymbol;\n}\n\n/**\n * Combined watch function type.\n */\nexport interface WatchFn extends WatchSingleFn {\n <T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n}\n\n/**\n * Class + resolved key + args needed to (re-)acquire a specific instance.\n * `watch` keeps this around per input so it can re-acquire the same logical\n * instance if the underlying container is disposed elsewhere.\n */\ninterface WatchTarget {\n blocClass: StateContainerConstructor;\n key: string;\n args: unknown;\n}\n\nfunction toWatchTarget(input: BlocInput): WatchTarget {\n const registry = getRegistry();\n if (isBlocRef(input)) {\n return {\n blocClass: input.blocClass,\n key: input.instanceId,\n args: input.args,\n };\n }\n return {\n blocClass: input,\n key: registry.resolveKey(input, undefined, undefined),\n args: undefined,\n };\n}\n\nlet watchRefSeq = 0;\n\n/**\n * Acquire a real ref (countRef: true) for the target, carrying its `args`\n * through so a not-yet-created instance is initialized correctly. The\n * caller is responsible for releasing `refId` in cleanup.\n */\nfunction resolveBloc(\n target: WatchTarget,\n refId: string,\n): StateContainerInstance {\n const registry = getRegistry();\n return registry.acquire(target.blocClass, target.key, {\n countRef: true,\n refId,\n args: target.args,\n });\n}\n\n/**\n * Passive lookup for `{ create: false }`: never creates the instance and\n * never takes a ref. Returns `undefined` when no instance currently exists.\n */\nfunction resolveBlocPassive(\n target: WatchTarget,\n): StateContainerInstance | undefined {\n const registry = getRegistry();\n try {\n return registry.acquire(target.blocClass, target.key, {\n canCreate: false,\n countRef: false,\n args: target.args,\n });\n } catch {\n return undefined;\n }\n}\n\nfunction isArray(input: unknown): input is readonly BlocInput[] {\n return Array.isArray(input);\n}\n\n/**\n * Watch one or more blocs for state changes.\n *\n * Thin wrapper around `container.channel.subscribe(ALL_PATHS, ...)`. The\n * callback fires once immediately, then on every state change of any of the\n * passed blocs. Returning `watch.STOP` from the callback tears down all\n * subscriptions.\n *\n * Note: subscriptions are microtask-deferred (per the DirtyChannel default\n * scheduler), so callbacks land asynchronously after `emit()`.\n *\n * By default `watch` creates the instance if it does not exist and holds a\n * real ownership ref until `unwatch`, matching `acquire`. Pass\n * `{ create: false }` to observe passively instead — see `WatchOptions`.\n *\n * @example Single bloc\n * ```ts\n * const unwatch = watch(UserBloc, (userBloc) => {\n * console.log(userBloc.state.name);\n * });\n * ```\n *\n * @example Multiple blocs\n * ```ts\n * const unwatch = watch(\n * [UserBloc, SettingsBloc] as const,\n * ([userBloc, settingsBloc]) => {\n * console.log(userBloc.state.name, settingsBloc.state.theme);\n * }\n * );\n * ```\n *\n * @example With specific instance\n * ```ts\n * const unwatch = watch(\n * instance(UserBloc, { userId: 'user-123' }),\n * (userBloc) => {\n * console.log(userBloc.state.name);\n * }\n * );\n * ```\n *\n * @example Stop watching from callback\n * ```ts\n * const unwatch = watch(UserBloc, (userBloc) => {\n * if (userBloc.state.done) {\n * return watch.STOP;\n * }\n * });\n * ```\n */\nfunction watchImpl<T extends StateContainerConstructor>(\n bloc: T | BlocRef<T>,\n callback: (bloc: InstanceType<T>) => void | StopSymbol,\n options?: WatchOptions,\n): () => void;\n\nfunction watchImpl<T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n): () => void;\n\nfunction watchImpl(\n blocsOrBloc: BlocInput | readonly BlocInput[],\n callback: (blocsOrBloc: any) => void | StopSymbol,\n options?: WatchOptions,\n): () => void {\n const isSingle = !isArray(blocsOrBloc);\n const inputs = isSingle ? [blocsOrBloc] : blocsOrBloc;\n const registry = getRegistry();\n const create = options?.create ?? true;\n\n const targets = inputs.map(toWatchTarget);\n const refIds = targets.map(() => `_watch_${watchRefSeq++}`);\n\n let disposed = false;\n const instances: Array<StateContainerInstance | undefined> = targets.map(\n (target, i) =>\n create ? resolveBloc(target, refIds[i]) : resolveBlocPassive(target),\n );\n const channelUnsubs: Array<(() => void) | undefined> = [];\n const disposedUnsubs: Array<(() => void) | undefined> = [];\n\n const cleanup = () => {\n if (disposed) return;\n disposed = true;\n for (const unsub of channelUnsubs) unsub?.();\n for (const unsub of disposedUnsubs) unsub?.();\n channelUnsubs.length = 0;\n disposedUnsubs.length = 0;\n if (create) {\n for (let i = 0; i < targets.length; i++) {\n registry.release(\n targets[i].blocClass,\n targets[i].key,\n false,\n refIds[i],\n );\n }\n }\n };\n\n const runCallback = () => {\n if (disposed) return;\n if (instances.some((i) => i === undefined)) return;\n const arg = isSingle ? instances[0] : instances;\n const result = callback(arg);\n if (result === STOP) cleanup();\n };\n\n const subscribeAt = (index: number) => {\n channelUnsubs[index] = instances[index]?.channel.subscribe(\n () => ALL_PATHS,\n runCallback,\n );\n };\n\n // On external dispose, tear down the stale subscription and re-acquire +\n // resubscribe (microtask-deferred, so it never runs mid-mutation of the\n // registry that triggered the dispose, e.g. `clearAll()`), then notify.\n const resubscribeAt = (index: number) => {\n if (disposed) return;\n instances[index] = create\n ? resolveBloc(targets[index], refIds[index])\n : resolveBlocPassive(targets[index]);\n subscribeAt(index);\n subscribeDisposeAt(index);\n runCallback();\n };\n\n const subscribeDisposeAt = (index: number) => {\n disposedUnsubs[index] = instances[index]?.[ON_DISPOSE](() => {\n channelUnsubs[index]?.();\n channelUnsubs[index] = undefined;\n queueMicrotask(() => resubscribeAt(index));\n });\n };\n\n for (let i = 0; i < instances.length; i++) {\n subscribeAt(i);\n }\n\n for (let i = 0; i < instances.length; i++) {\n subscribeDisposeAt(i);\n }\n\n // Fire once immediately so the consumer sees the current state.\n runCallback();\n\n return cleanup;\n}\n\nexport const watch: WatchFn = Object.assign(watchImpl, { STOP }) as WatchFn;\n","declare const brand: unique symbol;\n\n/**\n * Utility type for creating branded/nominal types.\n * Prevents accidental type confusion between similar primitive types.\n * @typeParam T - The base type\n * @typeParam B - The brand identifier\n */\nexport type Brand<T, B> = T & { [brand]: B };\n\n/**\n * Branded string type for type-safe IDs.\n * @typeParam B - The brand identifier\n */\nexport type BrandedId<B> = Brand<string, B>;\n\n/**\n * Branded string type for state container instance IDs\n */\nexport type InstanceId = Brand<string, 'InstanceId'>;\n\n/**\n * Create a branded InstanceId from a string\n * @param id - The string ID to brand\n * @returns Branded InstanceId\n */\nexport function instanceId(id: string): InstanceId {\n return id as InstanceId;\n}\n"],"mappings":";;;;;AAkBA,SAAS,iBACP,WACA,QACQ;CACR,OAAOA,eAAAA,YAAY,EAAE,WAA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AAQ;CAC/B;CAEA,MAAM,eAAe,UAAkB;EACrC,cAAc,SAAS,UAAU,QAAQ,QAAQ,gBACzCC,sBAAAA,WACN,WACF;CACF;CAKA,MAAM,iBAAiB,UAAkB;EACvC,IAAI,UAAU;EACd,UAAU,SAAS,SACf,YAAY,QAAQ,QAAQ,OAAO,MAAM,IACzC,mBAAmB,QAAQ,MAAM;EACrC,YAAY,KAAK;EACjB,mBAAmB,KAAK;EACxB,YAAY;CACd;CAEA,MAAM,sBAAsB,UAAkB;EAC5C,eAAe,SAAS,UAAU,SAASC,+BAAAA,kBAAkB;GAC3D,cAAc,SAAS;GACvB,cAAc,SAAS,KAAA;GACvB,qBAAqB,cAAc,KAAK,CAAC;EAC3C,CAAC;CACH;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,YAAY,CAAC;CAGf,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,mBAAmB,CAAC;CAItB,YAAY;CAEZ,OAAO;AACT;AAEA,MAAa,QAAiB,OAAO,OAAO,WAAW,EAAE,KAAK,CAAC;;;;;;;;ACzU/D,SAAgB,WAAW,IAAwB;CACjD,OAAO;AACT"}
1
+ {"version":3,"file":"index.cjs","names":["StateContainer","getRegistry","getRegistry","getRegistry","BLAC_STATIC_PROPS","resolveInstanceKey","getRegistry","ALL_PATHS","ON_DISPOSE"],"sources":["../src/core/Cubit.ts","../src/registry/borrow.ts","../src/registry/release.ts","../src/registry/queries.ts","../src/registry/management.ts","../src/decorators/blac.ts","../src/watch/watch.ts","../src/types/branded.ts"],"sourcesContent":["import { StateContainer } from './StateContainer';\nimport type { DeepPartial } from '@dirtytalk/structural';\n\n/**\n * `Cubit<S>` is a `StateContainer<S>` that exposes mutation publicly.\n *\n * That is the whole difference, and it is a real one: on `StateContainer`\n * `emit` / `patch` / `update` are `protected`, so a container mutates itself\n * from its own methods and callers go through the API it chooses to publish.\n * `Cubit` re-declares the three as `public` for the cases where a caller\n * legitimately drives state from outside — test helpers, devtools\n * time-travel, benchmarks.\n *\n * Reach for `StateContainer` when business logic should live in the class,\n * and `Cubit` when the caller owns the transitions.\n */\nexport abstract class Cubit<\n S extends object = any,\n Args = void,\n Deps extends object = Record<string, never>,\n> extends StateContainer<S, Args, Deps> {\n override emit(next: S): void {\n super.emit(next);\n }\n\n override patch(partial: DeepPartial<S>): void {\n super.patch(partial);\n }\n\n override update(fn: (state: S) => S): void {\n super.update(fn);\n }\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * How to identify the instance to borrow: the same `args` shape `useBloc`\n * accepts, resolved through the class's `static key(args)` so call sites use\n * the *same* shape they pass to `useBloc` instead of hand-deriving the key.\n *\n * `borrowSafe(ChannelBloc, { args: { channelId } })` and\n * `useBloc(ChannelBloc, { args: { channelId } })` therefore always agree.\n */\nexport type BorrowTarget<T extends StateContainerConstructor> = {\n args?: ExtractArgs<T>;\n};\n\nfunction resolveBorrowKey<T extends StateContainerConstructor>(\n BlocClass: T,\n target: BorrowTarget<T> | undefined,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, target?.args);\n}\n\nexport function borrow<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n): InstanceType<T> {\n return getRegistry().borrow(BlocClass, resolveBorrowKey(BlocClass, target));\n}\n\nexport function borrowSafe<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n):\n | { error: Error; instance: null }\n | { error: null; instance: InstanceType<T> } {\n return getRegistry().borrowSafe(\n BlocClass,\n resolveBorrowKey(BlocClass, target),\n );\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Release a reference to an instance. Instance identity is derived purely from\n * `args` (must match the `args` it was acquired with).\n *\n * @param opts - `args` derives the instance key (must match acquire);\n * `refId` picks the ref to drop, otherwise one arbitrary ref goes;\n * `forceDispose` disposes immediately regardless of remaining refs.\n */\nexport function release<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string; forceDispose?: boolean },\n): void {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\n/**\n * @public\n */\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\n/**\n * @public\n */\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\n/**\n * @public\n */\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n","import { BLAC_STATIC_PROPS } from '../constants';\nimport type { EqualityFn } from '../config';\n\n/**\n * Configuration options for the `@blac` decorator. Any combination may be\n * given at once.\n */\nexport interface BlacOptions {\n /**\n * Keep the bloc alive when its ref count reaches 0. `false` turns off a\n * `keepAlive` inherited from a base class.\n */\n keepAlive?: boolean;\n /** Exclude bloc from DevTools tracking (prevents infinite loops) */\n excludeFromDevTools?: true;\n /**\n * Override the global equality check for this bloc.\n * Return `true` to skip the emit (states considered equal).\n */\n equality?: EqualityFn;\n /**\n * Override the default structural-hash identity key.\n * The function receives `args` and returns the instance key string.\n * Distinct return values → distinct instances; identical values → shared instance.\n * Non-identity fields can be excluded so they don't fork new instances.\n */\n key?: (args: any) => string;\n /**\n * Explicit, minification-safe identity for this bloc class. Falls back to\n * `constructor.name` when unset, which collides across classes once a\n * minifier shortens class names.\n */\n name?: string;\n}\n\n/**\n * Decorator to configure StateContainer classes.\n *\n * @example Decorator syntax (requires experimentalDecorators or TC39 decorators)\n * ```ts\n * @blac({ keepAlive: true })\n * class AuthBloc extends Cubit<AuthState> {}\n *\n * @blac({ excludeFromDevTools: true })\n * class InternalBloc extends Cubit<InternalState> {}\n *\n * @blac({ keepAlive: true, key: (args) => args.userId })\n * class UserBloc extends Cubit<UserState> {}\n * ```\n *\n * @example Function syntax (no decorator support needed)\n * ```ts\n * const AuthBloc = blac({ keepAlive: true })(\n * class extends Cubit<AuthState> {}\n * );\n * ```\n */\nexport function blac(options: BlacOptions) {\n return function <T extends new (...args: any[]) => any>(\n target: T,\n _context?: ClassDecoratorContext,\n ): T {\n if (options.keepAlive !== undefined) {\n (target as any)[BLAC_STATIC_PROPS.KEEP_ALIVE] = options.keepAlive;\n }\n if (options.excludeFromDevTools) {\n (target as any)[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;\n }\n if (typeof options.equality === 'function') {\n (target as any)[BLAC_STATIC_PROPS.EQUALITY] = options.equality;\n }\n if (typeof options.key === 'function') {\n (target as any)[BLAC_STATIC_PROPS.KEY] = options.key;\n }\n if (typeof options.name === 'string') {\n (target as any)[BLAC_STATIC_PROPS.BLAC_NAME] = options.name;\n }\n return target;\n };\n}\n","import { ALL_PATHS } from '@dirtytalk/structural';\nimport { ON_DISPOSE } from '../core/symbols';\nimport { getRegistry } from '../registry';\nimport { resolveInstanceKey } from '../registry/acquire';\nimport type { StateContainerRegistry } from '../core/StateContainerRegistry';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n StateContainerInstance,\n} from '../types/utilities';\n\nconst STOP: unique symbol = Symbol('watch.STOP');\ntype StopSymbol = typeof STOP;\n\nconst BLOC_REF_MARKER = Symbol('BlocRef');\n\n/**\n * Reference to a specific bloc instance, identified by class + the resolved\n * key derived from its `args`.\n */\nexport interface BlocRef<T extends StateContainerConstructor> {\n [BLOC_REF_MARKER]: true;\n blocClass: T;\n /** @internal The resolved instance key (derived from `args`). */\n instanceId: string;\n /**\n * @internal The `args` used to derive `instanceId`. Forwarded to\n * `registry.acquire` so a not-yet-created instance is initialized with\n * these args instead of `undefined`.\n */\n args?: unknown;\n}\n\n/**\n * Create a reference to a specific bloc instance, identified by its `args`.\n * The key is derived the same way `useBloc`/`acquire` derive it.\n *\n * @example\n * ```ts\n * watch(instance(UserBloc, { userId: 'user-123' }), (userBloc) => {\n * console.log(userBloc.state.name);\n * });\n * ```\n */\nexport function instance<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): BlocRef<T> {\n return {\n [BLOC_REF_MARKER]: true,\n blocClass: BlocClass,\n instanceId: resolveInstanceKey(BlocClass, args),\n args,\n };\n}\n\nfunction isBlocRef(\n input: unknown,\n): input is BlocRef<StateContainerConstructor> {\n return (\n typeof input === 'object' && input !== null && BLOC_REF_MARKER in input\n );\n}\n\ntype BlocInput = StateContainerConstructor | BlocRef<StateContainerConstructor>;\n\n/**\n * Options for `watch`.\n */\nexport interface WatchOptions {\n /**\n * When `false`, `watch` observes passively: it neither creates a missing\n * instance nor takes a real ownership ref on an existing one. If the\n * instance does not exist yet, the callback simply never fires — `watch`\n * does not poll; call it again once the instance exists.\n *\n * Defaults to `true`.\n */\n create?: boolean;\n}\n\ntype ExtractInstance<T> =\n T extends BlocRef<infer C>\n ? InstanceType<C>\n : T extends StateContainerConstructor\n ? InstanceType<T>\n : never;\n\ntype ExtractInstances<T extends readonly BlocInput[]> = {\n [K in keyof T]: ExtractInstance<T[K]>;\n};\n\n/**\n * Watch function signature for single bloc.\n */\nexport interface WatchSingleFn {\n <T extends StateContainerConstructor>(\n bloc: T | BlocRef<T>,\n callback: (bloc: InstanceType<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n\n STOP: StopSymbol;\n}\n\n/**\n * Watch function signature for multiple blocs.\n */\nexport interface WatchMultipleFn {\n <T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n\n STOP: StopSymbol;\n}\n\n/**\n * Combined watch function type.\n */\nexport interface WatchFn extends WatchSingleFn {\n <T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n}\n\n/**\n * Class + resolved key + args needed to (re-)acquire a specific instance.\n * `watch` keeps this around per input so it can re-acquire the same logical\n * instance if the underlying container is disposed elsewhere.\n */\ninterface WatchTarget {\n blocClass: StateContainerConstructor;\n key: string;\n args: unknown;\n}\n\nfunction toWatchTarget(\n registry: StateContainerRegistry,\n input: BlocInput,\n): WatchTarget {\n if (isBlocRef(input)) {\n return {\n blocClass: input.blocClass,\n key: input.instanceId,\n args: input.args,\n };\n }\n return {\n blocClass: input,\n key: registry.resolveKey(input, undefined, undefined),\n args: undefined,\n };\n}\n\nlet watchRefSeq = 0;\n\n/**\n * Acquire a real ref (countRef: true) for the target, carrying its `args`\n * through so a not-yet-created instance is initialized correctly. The\n * caller is responsible for releasing `refId` in cleanup.\n */\nfunction resolveBloc(\n registry: StateContainerRegistry,\n target: WatchTarget,\n refId: string,\n): StateContainerInstance {\n return registry.acquire(target.blocClass, target.key, {\n countRef: true,\n refId,\n args: target.args,\n });\n}\n\n/**\n * Passive lookup for `{ create: false }`: never creates the instance and\n * never takes a ref. Returns `undefined` when no instance currently exists.\n */\nfunction resolveBlocPassive(\n registry: StateContainerRegistry,\n target: WatchTarget,\n): StateContainerInstance | undefined {\n try {\n return registry.acquire(target.blocClass, target.key, {\n canCreate: false,\n countRef: false,\n args: target.args,\n });\n } catch {\n return undefined;\n }\n}\n\nfunction isArray(input: unknown): input is readonly BlocInput[] {\n return Array.isArray(input);\n}\n\n/**\n * Watch one or more blocs for state changes.\n *\n * Thin wrapper around `container.channel.subscribe(ALL_PATHS, ...)`. The\n * callback fires once immediately, then on every state change of any of the\n * passed blocs. Returning `watch.STOP` from the callback tears down all\n * subscriptions. Subscriptions are microtask-deferred, so callbacks land\n * asynchronously after `emit()`.\n *\n * By default `watch` creates the instance if it does not exist and holds a\n * real ownership ref until `unwatch`, matching `acquire`. Pass\n * `{ create: false }` to observe passively instead — see `WatchOptions`.\n *\n * @example Single bloc\n * ```ts\n * const unwatch = watch(UserBloc, (userBloc) => {\n * console.log(userBloc.state.name);\n * });\n * ```\n *\n * @example Multiple blocs\n * ```ts\n * const unwatch = watch(\n * [UserBloc, SettingsBloc] as const,\n * ([userBloc, settingsBloc]) => {\n * console.log(userBloc.state.name, settingsBloc.state.theme);\n * }\n * );\n * ```\n *\n * @example With specific instance\n * ```ts\n * const unwatch = watch(\n * instance(UserBloc, { userId: 'user-123' }),\n * (userBloc) => {\n * console.log(userBloc.state.name);\n * }\n * );\n * ```\n *\n * @example Stop watching from callback\n * ```ts\n * const unwatch = watch(UserBloc, (userBloc) => {\n * if (userBloc.state.done) {\n * return watch.STOP;\n * }\n * });\n * ```\n */\nfunction watchImpl<T extends StateContainerConstructor>(\n bloc: T | BlocRef<T>,\n callback: (bloc: InstanceType<T>) => void | StopSymbol,\n options?: WatchOptions,\n): () => void;\n\nfunction watchImpl<T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n): () => void;\n\nfunction watchImpl(\n blocsOrBloc: BlocInput | readonly BlocInput[],\n callback: (blocsOrBloc: any) => void | StopSymbol,\n options?: WatchOptions,\n): () => void {\n const isSingle = !isArray(blocsOrBloc);\n const inputs = isSingle ? [blocsOrBloc] : blocsOrBloc;\n const registry = getRegistry();\n const create = options?.create ?? true;\n\n const targets = inputs.map((input) => toWatchTarget(registry, input));\n const refIds = targets.map(() => `_watch_${watchRefSeq++}`);\n const resolveAt = (index: number) =>\n create\n ? resolveBloc(registry, targets[index], refIds[index])\n : resolveBlocPassive(registry, targets[index]);\n\n let disposed = false;\n const instances: Array<StateContainerInstance | undefined> = [];\n const channelUnsubs: Array<(() => void) | undefined> = [];\n const disposedUnsubs: Array<(() => void) | undefined> = [];\n\n const cleanup = () => {\n if (disposed) return;\n disposed = true;\n for (const unsub of channelUnsubs) unsub?.();\n for (const unsub of disposedUnsubs) unsub?.();\n channelUnsubs.length = 0;\n disposedUnsubs.length = 0;\n if (create) {\n for (let i = 0; i < instances.length; i++) {\n registry.release(\n targets[i].blocClass,\n targets[i].key,\n false,\n refIds[i],\n );\n }\n }\n };\n\n const runCallback = () => {\n if (disposed) return;\n if (instances.some((i) => i === undefined)) return;\n const arg = isSingle ? instances[0] : instances;\n const result = callback(arg);\n if (result === STOP) cleanup();\n };\n\n const subscribeAt = (index: number) => {\n channelUnsubs[index] = instances[index]?.channel.subscribe(\n () => ALL_PATHS,\n runCallback,\n );\n };\n\n // On external dispose, tear down the stale subscription and re-acquire +\n // resubscribe (microtask-deferred, so it never runs mid-mutation of the\n // registry that triggered the dispose, e.g. `clearAll()`), then notify.\n const resubscribeAt = (index: number) => {\n if (disposed) return;\n instances[index] = resolveAt(index);\n subscribeAt(index);\n subscribeDisposeAt(index);\n runCallback();\n };\n\n const subscribeDisposeAt = (index: number) => {\n disposedUnsubs[index] = instances[index]?.[ON_DISPOSE](() => {\n channelUnsubs[index]?.();\n channelUnsubs[index] = undefined;\n queueMicrotask(() => resubscribeAt(index));\n });\n };\n\n try {\n for (let i = 0; i < targets.length; i++) instances.push(resolveAt(i));\n for (let i = 0; i < instances.length; i++) subscribeAt(i);\n for (let i = 0; i < instances.length; i++) subscribeDisposeAt(i);\n // Fire once immediately so the consumer sees the current state.\n runCallback();\n } catch (error) {\n cleanup();\n throw error;\n }\n\n return cleanup;\n}\n\nexport const watch: WatchFn = Object.assign(watchImpl, { STOP }) as WatchFn;\n","declare const brand: unique symbol;\n\n/**\n * Nominal type helper, preventing accidental confusion between similar\n * primitive types.\n * @typeParam T - The base type\n * @typeParam B - The brand identifier\n */\nexport type Brand<T, B> = T & { [brand]: B };\n\n/**\n * Branded string type for type-safe IDs.\n * @typeParam B - The brand identifier\n */\nexport type BrandedId<B> = Brand<string, B>;\n\n/** Branded string type for state container instance IDs. */\nexport type InstanceId = Brand<string, 'InstanceId'>;\n\nexport function instanceId(id: string): InstanceId {\n return id as InstanceId;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,IAAsB,QAAtB,cAIUA,uBAAAA,eAA8B;CACtC,KAAc,MAAe;EAC3B,MAAM,KAAK,IAAI;CACjB;CAEA,MAAe,SAA+B;EAC5C,MAAM,MAAM,OAAO;CACrB;CAEA,OAAgB,IAA2B;EACzC,MAAM,OAAO,EAAE;CACjB;AACF;;;ACdA,SAAS,iBACP,WACA,QACQ;CACR,OAAOC,uBAAAA,YAAY,EAAE,WAAW,WAAW,KAAA,GAAW,QAAQ,IAAI;AACpE;AAEA,SAAgB,OACd,WACA,QACiB;CACjB,OAAOA,uBAAAA,YAAY,EAAE,OAAO,WAAW,iBAAiB,WAAW,MAAM,CAAC;AAC5E;AAEA,SAAgB,WACd,WACA,QAG6C;CAC7C,OAAOA,uBAAAA,YAAY,EAAE,WACnB,WACA,iB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Ae,SAAS,UAAU,SAASC,+BAAAA,kBAAkB;GAC3D,cAAc,SAAS;GACvB,cAAc,SAAS,KAAA;GACvB,qBAAqB,cAAc,KAAK,CAAC;EAC3C,CAAC;CACH;CAEA,IAAI;EACF,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK,UAAU,KAAK,UAAU,CAAC,CAAC;EACpE,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK,YAAY,CAAC;EACxD,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK,mBAAmB,CAAC;EAE/D,YAAY;CACd,SAAS,OAAO;EACd,QAAQ;EACR,MAAM;CACR;CAEA,OAAO;AACT;AAEA,MAAa,QAAiB,OAAO,OAAO,WAAW,EAAE,KAAK,CAAC;;;AC3U/D,SAAgB,WAAW,IAAwB;CACjD,OAAO;AACT"}
package/dist/index.d.cts CHANGED
@@ -1,12 +1,7 @@
1
1
  export { configureBlac, getBlacConfig, resetBlacConfig, shallowEqualState, type BlacConfig, type EqualityFn, } from './config';
2
- export { StateContainer, DEP_BRAND } from './core/StateContainer';
2
+ export { StateContainer } from './core/StateContainer';
3
3
  export type { HydrationStatus, StateContainerConfig, SystemEvent, SystemEventPayloads, DepHandle, } from './core/StateContainer';
4
4
  export { Cubit } from './core/Cubit';
5
- /**
6
- * @internal symbols — read by `@blac/react` (APPLY_DEPS / REMOVE_DEPS_OWNER),
7
- * in-package tests (INIT_CONFIG), and `watch()` (ON_DISPOSE).
8
- */
9
- export { APPLY_DEPS, REMOVE_DEPS_OWNER, INIT_CONFIG, ON_DISPOSE, WITH_TRACKED_STATE, } from './core/symbols';
10
5
  export type { BlacMeta, BlacHydration } from './core/meta';
11
6
  export { ALL_PATHS } from '@dirtytalk/structural';
12
7
  export type { PathSet } from '@dirtytalk/structural';
@@ -18,6 +13,6 @@ export { blac, type BlacOptions } from './decorators';
18
13
  export { isKeepAliveClass, isExcludedFromDevTools, getBlacName, } from './utils/static-props';
19
14
  export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
20
15
  export { watch, instance, type WatchFn, type WatchOptions, type BlocRef, } from './watch';
21
- export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractConstructorArgs, ExtractArgs, ExtractDeps, BlocInstanceType, BlocConstructor, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
16
+ export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractArgs, ExtractDeps, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
22
17
  export type { Brand, BrandedId, InstanceId } from './types/branded';
23
18
  export { instanceId } from './types/branded';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  export { configureBlac, getBlacConfig, resetBlacConfig, shallowEqualState, type BlacConfig, type EqualityFn, } from './config';
2
- export { StateContainer, DEP_BRAND } from './core/StateContainer';
2
+ export { StateContainer } from './core/StateContainer';
3
3
  export type { HydrationStatus, StateContainerConfig, SystemEvent, SystemEventPayloads, DepHandle, } from './core/StateContainer';
4
4
  export { Cubit } from './core/Cubit';
5
- /**
6
- * @internal symbols — read by `@blac/react` (APPLY_DEPS / REMOVE_DEPS_OWNER),
7
- * in-package tests (INIT_CONFIG), and `watch()` (ON_DISPOSE).
8
- */
9
- export { APPLY_DEPS, REMOVE_DEPS_OWNER, INIT_CONFIG, ON_DISPOSE, WITH_TRACKED_STATE, } from './core/symbols';
10
5
  export type { BlacMeta, BlacHydration } from './core/meta';
11
6
  export { ALL_PATHS } from '@dirtytalk/structural';
12
7
  export type { PathSet } from '@dirtytalk/structural';
@@ -18,6 +13,6 @@ export { blac, type BlacOptions } from './decorators';
18
13
  export { isKeepAliveClass, isExcludedFromDevTools, getBlacName, } from './utils/static-props';
19
14
  export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
20
15
  export { watch, instance, type WatchFn, type WatchOptions, type BlocRef, } from './watch';
21
- export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractConstructorArgs, ExtractArgs, ExtractDeps, BlocInstanceType, BlocConstructor, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
16
+ export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractArgs, ExtractDeps, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
22
17
  export type { Brand, BrandedId, InstanceId } from './types/branded';
23
18
  export { instanceId } from './types/branded';