@ai-matrx/kit 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/LICENSE +21 -0
  3. package/README.md +72 -0
  4. package/dist/autosave.cjs +92 -0
  5. package/dist/autosave.cjs.map +1 -0
  6. package/dist/autosave.d.cts +17 -0
  7. package/dist/autosave.d.ts +17 -0
  8. package/dist/autosave.js +72 -0
  9. package/dist/autosave.js.map +1 -0
  10. package/dist/clipboard.cjs +152 -0
  11. package/dist/clipboard.cjs.map +1 -0
  12. package/dist/clipboard.d.cts +17 -0
  13. package/dist/clipboard.d.ts +17 -0
  14. package/dist/clipboard.js +132 -0
  15. package/dist/clipboard.js.map +1 -0
  16. package/dist/color-util.cjs +790 -0
  17. package/dist/color-util.cjs.map +1 -0
  18. package/dist/color-util.d.cts +235 -0
  19. package/dist/color-util.d.ts +235 -0
  20. package/dist/color-util.js +767 -0
  21. package/dist/color-util.js.map +1 -0
  22. package/dist/concurrency.cjs +59 -0
  23. package/dist/concurrency.cjs.map +1 -0
  24. package/dist/concurrency.d.cts +19 -0
  25. package/dist/concurrency.d.ts +19 -0
  26. package/dist/concurrency.js +38 -0
  27. package/dist/concurrency.js.map +1 -0
  28. package/dist/confirm.cjs +344 -0
  29. package/dist/confirm.cjs.map +1 -0
  30. package/dist/confirm.d.cts +132 -0
  31. package/dist/confirm.d.ts +132 -0
  32. package/dist/confirm.js +312 -0
  33. package/dist/confirm.js.map +1 -0
  34. package/dist/delimiter-guard.cjs +172 -0
  35. package/dist/delimiter-guard.cjs.map +1 -0
  36. package/dist/delimiter-guard.d.cts +119 -0
  37. package/dist/delimiter-guard.d.ts +119 -0
  38. package/dist/delimiter-guard.js +151 -0
  39. package/dist/delimiter-guard.js.map +1 -0
  40. package/dist/drafts.cjs +223 -0
  41. package/dist/drafts.cjs.map +1 -0
  42. package/dist/drafts.d.cts +62 -0
  43. package/dist/drafts.d.ts +62 -0
  44. package/dist/drafts.js +201 -0
  45. package/dist/drafts.js.map +1 -0
  46. package/dist/idb-store.cjs +178 -0
  47. package/dist/idb-store.cjs.map +1 -0
  48. package/dist/idb-store.d.cts +111 -0
  49. package/dist/idb-store.d.ts +111 -0
  50. package/dist/idb-store.js +155 -0
  51. package/dist/idb-store.js.map +1 -0
  52. package/dist/idle-scheduler.cjs +268 -0
  53. package/dist/idle-scheduler.cjs.map +1 -0
  54. package/dist/idle-scheduler.d.cts +185 -0
  55. package/dist/idle-scheduler.d.ts +185 -0
  56. package/dist/idle-scheduler.js +246 -0
  57. package/dist/idle-scheduler.js.map +1 -0
  58. package/dist/index.cjs +3113 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.cts +897 -0
  61. package/dist/index.d.ts +897 -0
  62. package/dist/index.js +3088 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/invalidation.cjs +64 -0
  65. package/dist/invalidation.cjs.map +1 -0
  66. package/dist/invalidation.d.cts +52 -0
  67. package/dist/invalidation.d.ts +52 -0
  68. package/dist/invalidation.js +43 -0
  69. package/dist/invalidation.js.map +1 -0
  70. package/dist/json-format.cjs +319 -0
  71. package/dist/json-format.cjs.map +1 -0
  72. package/dist/json-format.d.cts +148 -0
  73. package/dist/json-format.d.ts +148 -0
  74. package/dist/json-format.js +286 -0
  75. package/dist/json-format.js.map +1 -0
  76. package/dist/latest-request.cjs +36 -0
  77. package/dist/latest-request.cjs.map +1 -0
  78. package/dist/latest-request.d.cts +29 -0
  79. package/dist/latest-request.d.ts +29 -0
  80. package/dist/latest-request.js +16 -0
  81. package/dist/latest-request.js.map +1 -0
  82. package/dist/qr.cjs +109 -0
  83. package/dist/qr.cjs.map +1 -0
  84. package/dist/qr.d.cts +47 -0
  85. package/dist/qr.d.ts +47 -0
  86. package/dist/qr.js +78 -0
  87. package/dist/qr.js.map +1 -0
  88. package/dist/react-tree.cjs +69 -0
  89. package/dist/react-tree.cjs.map +1 -0
  90. package/dist/react-tree.d.cts +38 -0
  91. package/dist/react-tree.d.ts +38 -0
  92. package/dist/react-tree.js +38 -0
  93. package/dist/react-tree.js.map +1 -0
  94. package/dist/search-scoring.cjs +116 -0
  95. package/dist/search-scoring.cjs.map +1 -0
  96. package/dist/search-scoring.d.cts +77 -0
  97. package/dist/search-scoring.d.ts +77 -0
  98. package/dist/search-scoring.js +95 -0
  99. package/dist/search-scoring.js.map +1 -0
  100. package/dist/text-case.cjs +313 -0
  101. package/dist/text-case.cjs.map +1 -0
  102. package/dist/text-case.d.cts +53 -0
  103. package/dist/text-case.d.ts +53 -0
  104. package/dist/text-case.js +292 -0
  105. package/dist/text-case.js.map +1 -0
  106. package/dist/toast.cjs +74 -0
  107. package/dist/toast.cjs.map +1 -0
  108. package/dist/toast.d.cts +92 -0
  109. package/dist/toast.d.ts +92 -0
  110. package/dist/toast.js +54 -0
  111. package/dist/toast.js.map +1 -0
  112. package/dist/url-state.cjs +212 -0
  113. package/dist/url-state.cjs.map +1 -0
  114. package/dist/url-state.d.cts +90 -0
  115. package/dist/url-state.d.ts +90 -0
  116. package/dist/url-state.js +199 -0
  117. package/dist/url-state.js.map +1 -0
  118. package/package.json +286 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/invalidation.ts
21
+ var invalidation_exports = {};
22
+ __export(invalidation_exports, {
23
+ fireInvalidation: () => fireInvalidation,
24
+ registerInvalidationCallback: () => registerInvalidationCallback
25
+ });
26
+ module.exports = __toCommonJS(invalidation_exports);
27
+ var STATE_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.kit.invalidation-registry");
28
+ function getCallbacks() {
29
+ const holder = globalThis;
30
+ let state = holder[STATE_SLOT];
31
+ if (!state) {
32
+ state = /* @__PURE__ */ new Map();
33
+ holder[STATE_SLOT] = state;
34
+ }
35
+ return state;
36
+ }
37
+ function registerInvalidationCallback(name, callback) {
38
+ const callbacks = getCallbacks();
39
+ let set = callbacks.get(name);
40
+ if (!set) {
41
+ set = /* @__PURE__ */ new Set();
42
+ callbacks.set(name, set);
43
+ }
44
+ set.add(callback);
45
+ return () => {
46
+ set.delete(callback);
47
+ };
48
+ }
49
+ function fireInvalidation(name, detail) {
50
+ const set = getCallbacks().get(name);
51
+ if (!set || set.size === 0) return false;
52
+ for (const callback of set) {
53
+ try {
54
+ callback(detail);
55
+ } catch (error) {
56
+ console.error(
57
+ `[invalidation-registry] callback for "${name}" threw`,
58
+ error
59
+ );
60
+ }
61
+ }
62
+ return true;
63
+ }
64
+ //# sourceMappingURL=invalidation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/invalidation.ts"],"sourcesContent":["/**\n * @ai-matrx/kit/invalidation — a tiny name-keyed callback registry that lets a\n * UBIQUITOUS module (a stream processor, an effect runner) trigger cache\n * invalidation inside a HEAVY chunk cluster with ZERO import edge between them.\n *\n * WHY THIS EXISTS (the fragmentation-law incident): a module statically\n * reachable from ~every route context reached a heavy registry cluster with an\n * `await import()` — one line that added +14 GB peak build RSS / +50% compile\n * time and OOM-killed 12 straight production builds. The sanctioned shape is\n * the INVERSION implemented here: the heavy cluster registers a callback at\n * its own module init (it is always initialized wherever its output can\n * render — if the chunk never loaded, nothing stale is mounted), and the\n * ubiquitous module fires the callback by NAME. The only shared code is this\n * module, which imports nothing.\n *\n * RULES:\n * - This module must NEVER grow an import. It is in every chunk that touches\n * it; any dependency it gains is multiplied across all of them.\n * - Firing an unregistered name is a NO-OP by design, not an error — the\n * consumer chunk simply isn't loaded in this tab, so there is nothing\n * stale to invalidate.\n * - Callbacks never break the caller: each runs in its own try/catch and\n * screams to the console on failure.\n * - Key constants live in the HOST app (one shared constants module per app),\n * so producer and consumer agree on the name without importing each other.\n * The registry itself is generic over names — app-specific keys never move\n * into this package.\n *\n * Ported from matrx-frontend `lib/invalidation/invalidation-registry.ts`, with\n * ONE structural inversion: the callback map lives on `globalThis` under a\n * `Symbol.for` slot instead of a module-level variable. With the package built\n * `splitting: false` in dual ESM/CJS format, this module is duplicated into\n * the root bundle and the `./invalidation` bundle, and CJS/ESM each\n * instantiate their own module graph — a module-level Map would silently split\n * the producers from the consumers (the same hazard the confirm opener\n * documents). Behavior is unchanged; never \"clean this up\" into a module\n * local.\n */\n\nexport type InvalidationCallback = (detail?: unknown) => void;\n\nconst STATE_SLOT = Symbol.for(\"ai-matrx.kit.invalidation-registry\");\n\ntype RegistryState = Map<string, Set<InvalidationCallback>>;\n\nfunction getCallbacks(): RegistryState {\n const holder = globalThis as Record<symbol, RegistryState | undefined>;\n let state = holder[STATE_SLOT];\n if (!state) {\n state = new Map();\n holder[STATE_SLOT] = state;\n }\n return state;\n}\n\n/**\n * Register a callback for a name. Idempotent-friendly: returns the\n * unsubscribe. Module-scope registration in the consumer chunk is the\n * intended pattern (register once per chunk load, never unsubscribe).\n */\nexport function registerInvalidationCallback(\n name: string,\n callback: InvalidationCallback,\n): () => void {\n const callbacks = getCallbacks();\n let set = callbacks.get(name);\n if (!set) {\n set = new Set();\n callbacks.set(name, set);\n }\n set.add(callback);\n return () => {\n set.delete(callback);\n };\n}\n\n/**\n * Fire every callback registered under `name`. Returns true when at least one\n * callback ran. Never throws — a failing callback screams and the rest run.\n */\nexport function fireInvalidation(name: string, detail?: unknown): boolean {\n const set = getCallbacks().get(name);\n if (!set || set.size === 0) return false;\n for (const callback of set) {\n try {\n callback(detail);\n } catch (error) {\n console.error(\n `[invalidation-registry] callback for \"${name}\" threw`,\n error,\n );\n }\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCA,IAAM,aAAa,uBAAO,IAAI,oCAAoC;AAIlE,SAAS,eAA8B;AACrC,QAAM,SAAS;AACf,MAAI,QAAQ,OAAO,UAAU;AAC7B,MAAI,CAAC,OAAO;AACV,YAAQ,oBAAI,IAAI;AAChB,WAAO,UAAU,IAAI;AAAA,EACvB;AACA,SAAO;AACT;AAOO,SAAS,6BACd,MACA,UACY;AACZ,QAAM,YAAY,aAAa;AAC/B,MAAI,MAAM,UAAU,IAAI,IAAI;AAC5B,MAAI,CAAC,KAAK;AACR,UAAM,oBAAI,IAAI;AACd,cAAU,IAAI,MAAM,GAAG;AAAA,EACzB;AACA,MAAI,IAAI,QAAQ;AAChB,SAAO,MAAM;AACX,QAAI,OAAO,QAAQ;AAAA,EACrB;AACF;AAMO,SAAS,iBAAiB,MAAc,QAA2B;AACxE,QAAM,MAAM,aAAa,EAAE,IAAI,IAAI;AACnC,MAAI,CAAC,OAAO,IAAI,SAAS,EAAG,QAAO;AACnC,aAAW,YAAY,KAAK;AAC1B,QAAI;AACF,eAAS,MAAM;AAAA,IACjB,SAAS,OAAO;AACd,cAAQ;AAAA,QACN,yCAAyC,IAAI;AAAA,QAC7C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @ai-matrx/kit/invalidation — a tiny name-keyed callback registry that lets a
3
+ * UBIQUITOUS module (a stream processor, an effect runner) trigger cache
4
+ * invalidation inside a HEAVY chunk cluster with ZERO import edge between them.
5
+ *
6
+ * WHY THIS EXISTS (the fragmentation-law incident): a module statically
7
+ * reachable from ~every route context reached a heavy registry cluster with an
8
+ * `await import()` — one line that added +14 GB peak build RSS / +50% compile
9
+ * time and OOM-killed 12 straight production builds. The sanctioned shape is
10
+ * the INVERSION implemented here: the heavy cluster registers a callback at
11
+ * its own module init (it is always initialized wherever its output can
12
+ * render — if the chunk never loaded, nothing stale is mounted), and the
13
+ * ubiquitous module fires the callback by NAME. The only shared code is this
14
+ * module, which imports nothing.
15
+ *
16
+ * RULES:
17
+ * - This module must NEVER grow an import. It is in every chunk that touches
18
+ * it; any dependency it gains is multiplied across all of them.
19
+ * - Firing an unregistered name is a NO-OP by design, not an error — the
20
+ * consumer chunk simply isn't loaded in this tab, so there is nothing
21
+ * stale to invalidate.
22
+ * - Callbacks never break the caller: each runs in its own try/catch and
23
+ * screams to the console on failure.
24
+ * - Key constants live in the HOST app (one shared constants module per app),
25
+ * so producer and consumer agree on the name without importing each other.
26
+ * The registry itself is generic over names — app-specific keys never move
27
+ * into this package.
28
+ *
29
+ * Ported from matrx-frontend `lib/invalidation/invalidation-registry.ts`, with
30
+ * ONE structural inversion: the callback map lives on `globalThis` under a
31
+ * `Symbol.for` slot instead of a module-level variable. With the package built
32
+ * `splitting: false` in dual ESM/CJS format, this module is duplicated into
33
+ * the root bundle and the `./invalidation` bundle, and CJS/ESM each
34
+ * instantiate their own module graph — a module-level Map would silently split
35
+ * the producers from the consumers (the same hazard the confirm opener
36
+ * documents). Behavior is unchanged; never "clean this up" into a module
37
+ * local.
38
+ */
39
+ type InvalidationCallback = (detail?: unknown) => void;
40
+ /**
41
+ * Register a callback for a name. Idempotent-friendly: returns the
42
+ * unsubscribe. Module-scope registration in the consumer chunk is the
43
+ * intended pattern (register once per chunk load, never unsubscribe).
44
+ */
45
+ declare function registerInvalidationCallback(name: string, callback: InvalidationCallback): () => void;
46
+ /**
47
+ * Fire every callback registered under `name`. Returns true when at least one
48
+ * callback ran. Never throws — a failing callback screams and the rest run.
49
+ */
50
+ declare function fireInvalidation(name: string, detail?: unknown): boolean;
51
+
52
+ export { type InvalidationCallback, fireInvalidation, registerInvalidationCallback };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @ai-matrx/kit/invalidation — a tiny name-keyed callback registry that lets a
3
+ * UBIQUITOUS module (a stream processor, an effect runner) trigger cache
4
+ * invalidation inside a HEAVY chunk cluster with ZERO import edge between them.
5
+ *
6
+ * WHY THIS EXISTS (the fragmentation-law incident): a module statically
7
+ * reachable from ~every route context reached a heavy registry cluster with an
8
+ * `await import()` — one line that added +14 GB peak build RSS / +50% compile
9
+ * time and OOM-killed 12 straight production builds. The sanctioned shape is
10
+ * the INVERSION implemented here: the heavy cluster registers a callback at
11
+ * its own module init (it is always initialized wherever its output can
12
+ * render — if the chunk never loaded, nothing stale is mounted), and the
13
+ * ubiquitous module fires the callback by NAME. The only shared code is this
14
+ * module, which imports nothing.
15
+ *
16
+ * RULES:
17
+ * - This module must NEVER grow an import. It is in every chunk that touches
18
+ * it; any dependency it gains is multiplied across all of them.
19
+ * - Firing an unregistered name is a NO-OP by design, not an error — the
20
+ * consumer chunk simply isn't loaded in this tab, so there is nothing
21
+ * stale to invalidate.
22
+ * - Callbacks never break the caller: each runs in its own try/catch and
23
+ * screams to the console on failure.
24
+ * - Key constants live in the HOST app (one shared constants module per app),
25
+ * so producer and consumer agree on the name without importing each other.
26
+ * The registry itself is generic over names — app-specific keys never move
27
+ * into this package.
28
+ *
29
+ * Ported from matrx-frontend `lib/invalidation/invalidation-registry.ts`, with
30
+ * ONE structural inversion: the callback map lives on `globalThis` under a
31
+ * `Symbol.for` slot instead of a module-level variable. With the package built
32
+ * `splitting: false` in dual ESM/CJS format, this module is duplicated into
33
+ * the root bundle and the `./invalidation` bundle, and CJS/ESM each
34
+ * instantiate their own module graph — a module-level Map would silently split
35
+ * the producers from the consumers (the same hazard the confirm opener
36
+ * documents). Behavior is unchanged; never "clean this up" into a module
37
+ * local.
38
+ */
39
+ type InvalidationCallback = (detail?: unknown) => void;
40
+ /**
41
+ * Register a callback for a name. Idempotent-friendly: returns the
42
+ * unsubscribe. Module-scope registration in the consumer chunk is the
43
+ * intended pattern (register once per chunk load, never unsubscribe).
44
+ */
45
+ declare function registerInvalidationCallback(name: string, callback: InvalidationCallback): () => void;
46
+ /**
47
+ * Fire every callback registered under `name`. Returns true when at least one
48
+ * callback ran. Never throws — a failing callback screams and the rest run.
49
+ */
50
+ declare function fireInvalidation(name: string, detail?: unknown): boolean;
51
+
52
+ export { type InvalidationCallback, fireInvalidation, registerInvalidationCallback };
@@ -0,0 +1,43 @@
1
+ // src/invalidation.ts
2
+ var STATE_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.kit.invalidation-registry");
3
+ function getCallbacks() {
4
+ const holder = globalThis;
5
+ let state = holder[STATE_SLOT];
6
+ if (!state) {
7
+ state = /* @__PURE__ */ new Map();
8
+ holder[STATE_SLOT] = state;
9
+ }
10
+ return state;
11
+ }
12
+ function registerInvalidationCallback(name, callback) {
13
+ const callbacks = getCallbacks();
14
+ let set = callbacks.get(name);
15
+ if (!set) {
16
+ set = /* @__PURE__ */ new Set();
17
+ callbacks.set(name, set);
18
+ }
19
+ set.add(callback);
20
+ return () => {
21
+ set.delete(callback);
22
+ };
23
+ }
24
+ function fireInvalidation(name, detail) {
25
+ const set = getCallbacks().get(name);
26
+ if (!set || set.size === 0) return false;
27
+ for (const callback of set) {
28
+ try {
29
+ callback(detail);
30
+ } catch (error) {
31
+ console.error(
32
+ `[invalidation-registry] callback for "${name}" threw`,
33
+ error
34
+ );
35
+ }
36
+ }
37
+ return true;
38
+ }
39
+ export {
40
+ fireInvalidation,
41
+ registerInvalidationCallback
42
+ };
43
+ //# sourceMappingURL=invalidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/invalidation.ts"],"sourcesContent":["/**\n * @ai-matrx/kit/invalidation — a tiny name-keyed callback registry that lets a\n * UBIQUITOUS module (a stream processor, an effect runner) trigger cache\n * invalidation inside a HEAVY chunk cluster with ZERO import edge between them.\n *\n * WHY THIS EXISTS (the fragmentation-law incident): a module statically\n * reachable from ~every route context reached a heavy registry cluster with an\n * `await import()` — one line that added +14 GB peak build RSS / +50% compile\n * time and OOM-killed 12 straight production builds. The sanctioned shape is\n * the INVERSION implemented here: the heavy cluster registers a callback at\n * its own module init (it is always initialized wherever its output can\n * render — if the chunk never loaded, nothing stale is mounted), and the\n * ubiquitous module fires the callback by NAME. The only shared code is this\n * module, which imports nothing.\n *\n * RULES:\n * - This module must NEVER grow an import. It is in every chunk that touches\n * it; any dependency it gains is multiplied across all of them.\n * - Firing an unregistered name is a NO-OP by design, not an error — the\n * consumer chunk simply isn't loaded in this tab, so there is nothing\n * stale to invalidate.\n * - Callbacks never break the caller: each runs in its own try/catch and\n * screams to the console on failure.\n * - Key constants live in the HOST app (one shared constants module per app),\n * so producer and consumer agree on the name without importing each other.\n * The registry itself is generic over names — app-specific keys never move\n * into this package.\n *\n * Ported from matrx-frontend `lib/invalidation/invalidation-registry.ts`, with\n * ONE structural inversion: the callback map lives on `globalThis` under a\n * `Symbol.for` slot instead of a module-level variable. With the package built\n * `splitting: false` in dual ESM/CJS format, this module is duplicated into\n * the root bundle and the `./invalidation` bundle, and CJS/ESM each\n * instantiate their own module graph — a module-level Map would silently split\n * the producers from the consumers (the same hazard the confirm opener\n * documents). Behavior is unchanged; never \"clean this up\" into a module\n * local.\n */\n\nexport type InvalidationCallback = (detail?: unknown) => void;\n\nconst STATE_SLOT = Symbol.for(\"ai-matrx.kit.invalidation-registry\");\n\ntype RegistryState = Map<string, Set<InvalidationCallback>>;\n\nfunction getCallbacks(): RegistryState {\n const holder = globalThis as Record<symbol, RegistryState | undefined>;\n let state = holder[STATE_SLOT];\n if (!state) {\n state = new Map();\n holder[STATE_SLOT] = state;\n }\n return state;\n}\n\n/**\n * Register a callback for a name. Idempotent-friendly: returns the\n * unsubscribe. Module-scope registration in the consumer chunk is the\n * intended pattern (register once per chunk load, never unsubscribe).\n */\nexport function registerInvalidationCallback(\n name: string,\n callback: InvalidationCallback,\n): () => void {\n const callbacks = getCallbacks();\n let set = callbacks.get(name);\n if (!set) {\n set = new Set();\n callbacks.set(name, set);\n }\n set.add(callback);\n return () => {\n set.delete(callback);\n };\n}\n\n/**\n * Fire every callback registered under `name`. Returns true when at least one\n * callback ran. Never throws — a failing callback screams and the rest run.\n */\nexport function fireInvalidation(name: string, detail?: unknown): boolean {\n const set = getCallbacks().get(name);\n if (!set || set.size === 0) return false;\n for (const callback of set) {\n try {\n callback(detail);\n } catch (error) {\n console.error(\n `[invalidation-registry] callback for \"${name}\" threw`,\n error,\n );\n }\n }\n return true;\n}\n"],"mappings":";AAyCA,IAAM,aAAa,uBAAO,IAAI,oCAAoC;AAIlE,SAAS,eAA8B;AACrC,QAAM,SAAS;AACf,MAAI,QAAQ,OAAO,UAAU;AAC7B,MAAI,CAAC,OAAO;AACV,YAAQ,oBAAI,IAAI;AAChB,WAAO,UAAU,IAAI;AAAA,EACvB;AACA,SAAO;AACT;AAOO,SAAS,6BACd,MACA,UACY;AACZ,QAAM,YAAY,aAAa;AAC/B,MAAI,MAAM,UAAU,IAAI,IAAI;AAC5B,MAAI,CAAC,KAAK;AACR,UAAM,oBAAI,IAAI;AACd,cAAU,IAAI,MAAM,GAAG;AAAA,EACzB;AACA,MAAI,IAAI,QAAQ;AAChB,SAAO,MAAM;AACX,QAAI,OAAO,QAAQ;AAAA,EACrB;AACF;AAMO,SAAS,iBAAiB,MAAc,QAA2B;AACxE,QAAM,MAAM,aAAa,EAAE,IAAI,IAAI;AACnC,MAAI,CAAC,OAAO,IAAI,SAAS,EAAG,QAAO;AACnC,aAAW,YAAY,KAAK;AAC1B,QAAI;AACF,eAAS,MAAM;AAAA,IACjB,SAAS,OAAO;AACd,cAAQ;AAAA,QACN,yCAAyC,IAAI;AAAA,QAC7C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/json-format.ts
31
+ var json_format_exports = {};
32
+ __export(json_format_exports, {
33
+ DEFAULT_JSON_INDENT: () => DEFAULT_JSON_INDENT,
34
+ DEFAULT_JSON_WIDTH: () => DEFAULT_JSON_WIDTH,
35
+ detectJson: () => detectJson,
36
+ formatJsonText: () => formatJsonText,
37
+ isJsonArray: () => isJsonArray,
38
+ isJsonObject: () => isJsonObject,
39
+ isJsonPrimitive: () => isJsonPrimitive,
40
+ stringifyJson: () => stringifyJson
41
+ });
42
+ module.exports = __toCommonJS(json_format_exports);
43
+
44
+ // src/json-format/detect.ts
45
+ var import_json5 = __toESM(require("json5"), 1);
46
+ var FENCE_OPEN = /^([ \t]*)(`{3,}|~{3,})[ \t]*([^\s`~]*)[ \t]*$/;
47
+ var JSON_FENCE_LANGS = /* @__PURE__ */ new Set(["json", "jsonc", "json5", "geojson", "jsonl"]);
48
+ function splitFence(text) {
49
+ const lines = text.split("\n");
50
+ const openIdx = lines.findIndex((l) => FENCE_OPEN.test(l));
51
+ if (openIdx === -1) return null;
52
+ const open = FENCE_OPEN.exec(lines[openIdx] ?? "");
53
+ if (!open) return null;
54
+ const [, indent = "", marker = "```", lang = ""] = open;
55
+ const fenceChar = marker[0] ?? "`";
56
+ const closeRe = new RegExp(`^[ \\t]*\\${fenceChar}{${marker.length},}[ \\t]*$`);
57
+ let closeIdx = -1;
58
+ for (let i = openIdx + 1; i < lines.length; i++) {
59
+ if (closeRe.test(lines[i] ?? "")) {
60
+ closeIdx = i;
61
+ break;
62
+ }
63
+ }
64
+ const afterClose = closeIdx === -1 ? [] : lines.slice(closeIdx + 1);
65
+ if (afterClose.some((l) => FENCE_OPEN.test(l))) return null;
66
+ const bodyEnd = closeIdx === -1 ? lines.length : closeIdx;
67
+ return {
68
+ leading: openIdx > 0 ? `${lines.slice(0, openIdx).join("\n")}
69
+ ` : "",
70
+ payload: lines.slice(openIdx + 1, bodyEnd).join("\n"),
71
+ trailing: afterClose.length > 0 ? `
72
+ ${afterClose.join("\n")}` : "",
73
+ fence: {
74
+ marker,
75
+ lang: lang.toLowerCase(),
76
+ indent,
77
+ closed: closeIdx !== -1
78
+ }
79
+ };
80
+ }
81
+ function splitBare(text) {
82
+ const payload = text.trim();
83
+ if (payload === "") {
84
+ return { leading: text, payload: "", trailing: "", fence: null };
85
+ }
86
+ const start = text.indexOf(payload);
87
+ return {
88
+ leading: text.slice(0, start),
89
+ payload,
90
+ trailing: text.slice(start + payload.length),
91
+ fence: null
92
+ };
93
+ }
94
+ function rootKindOf(value) {
95
+ if (Array.isArray(value)) return "array";
96
+ if (typeof value === "object" && value !== null) return "object";
97
+ return "scalar";
98
+ }
99
+ function isBracketShaped(payload) {
100
+ const first = payload[0];
101
+ const last = payload[payload.length - 1];
102
+ if (payload.length < 2) return false;
103
+ return first === "{" && last === "}" || first === "[" && last === "]";
104
+ }
105
+ function errorMessage(err) {
106
+ return err instanceof Error ? err.message : "Invalid JSON";
107
+ }
108
+ function countLines(s) {
109
+ if (s === "") return 0;
110
+ let n = 1;
111
+ for (let i = 0; i < s.length; i++) if (s[i] === "\n") n++;
112
+ return n;
113
+ }
114
+ function detectJson(text) {
115
+ const split = splitFence(text) ?? splitBare(text);
116
+ const payload = split.fence ? split.payload.trim() : split.payload;
117
+ const fenceSaysJson = split.fence !== null && (split.fence.lang === "" || JSON_FENCE_LANGS.has(split.fence.lang));
118
+ const base = {
119
+ fence: split.fence,
120
+ leading: split.leading,
121
+ trailing: split.trailing,
122
+ payload,
123
+ lineCount: countLines(payload),
124
+ charCount: payload.length
125
+ };
126
+ if (payload === "") {
127
+ return { ...base, ok: false, looksLikeJson: false };
128
+ }
129
+ if (split.fence !== null && !fenceSaysJson) {
130
+ return { ...base, ok: false, looksLikeJson: false };
131
+ }
132
+ const shaped = isBracketShaped(payload);
133
+ let value;
134
+ let parser;
135
+ let error;
136
+ try {
137
+ value = JSON.parse(payload);
138
+ parser = "strict";
139
+ } catch (strictErr) {
140
+ try {
141
+ value = import_json5.default.parse(payload);
142
+ parser = "tolerant";
143
+ } catch {
144
+ error = errorMessage(strictErr);
145
+ }
146
+ }
147
+ if (value === void 0 || parser === void 0) {
148
+ return { ...base, ok: false, looksLikeJson: shaped, error };
149
+ }
150
+ const root = rootKindOf(value);
151
+ const worthOffering = root !== "scalar" || fenceSaysJson;
152
+ return { ...base, ok: true, looksLikeJson: worthOffering, value, parser, root };
153
+ }
154
+
155
+ // src/json-format/json-value.ts
156
+ function isJsonObject(value) {
157
+ return typeof value === "object" && value !== null && !Array.isArray(value);
158
+ }
159
+ function isJsonArray(value) {
160
+ return Array.isArray(value);
161
+ }
162
+ function isJsonPrimitive(value) {
163
+ return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
164
+ }
165
+
166
+ // src/json-format/format.ts
167
+ var DEFAULT_JSON_INDENT = 2;
168
+ var DEFAULT_JSON_WIDTH = 100;
169
+ function orderedKeys(obj, sortKeys) {
170
+ const keys = Object.keys(obj).filter((k) => obj[k] !== void 0);
171
+ return sortKeys ? [...keys].sort((a, b) => a.localeCompare(b)) : keys;
172
+ }
173
+ function writeScalar(value) {
174
+ return JSON.stringify(value) ?? "null";
175
+ }
176
+ function flatten(value, cfg) {
177
+ if (isJsonArray(value)) {
178
+ if (value.length === 0) return "[]";
179
+ const parts = value.map((v) => flatten(v ?? null, cfg));
180
+ return cfg.spaced ? `[${parts.join(", ")}]` : `[${parts.join(",")}]`;
181
+ }
182
+ if (isJsonObject(value)) {
183
+ const keys = orderedKeys(value, cfg.sortKeys);
184
+ if (keys.length === 0) return "{}";
185
+ const colon = cfg.spaced ? ": " : ":";
186
+ const parts = keys.map(
187
+ (k) => `${JSON.stringify(k)}${colon}${flatten(value[k] ?? null, cfg)}`
188
+ );
189
+ return cfg.spaced ? `{ ${parts.join(", ")} }` : `{${parts.join(",")}}`;
190
+ }
191
+ return writeScalar(value);
192
+ }
193
+ function layoutEntries(entries, pad, cfg) {
194
+ if (!cfg.pack) return entries.map((e) => pad + e);
195
+ const lines = [];
196
+ let current = "";
197
+ for (let i = 0; i < entries.length; i++) {
198
+ const entry = entries[i] ?? "";
199
+ const isLast = i === entries.length - 1;
200
+ const piece = isLast ? entry : `${entry},`;
201
+ if (entry.includes("\n")) {
202
+ if (current !== "") {
203
+ lines.push(pad + current);
204
+ current = "";
205
+ }
206
+ lines.push(pad + piece);
207
+ continue;
208
+ }
209
+ if (current === "") {
210
+ current = piece;
211
+ continue;
212
+ }
213
+ const merged = `${current} ${piece}`;
214
+ if (pad.length + merged.length <= cfg.width) {
215
+ current = merged;
216
+ } else {
217
+ lines.push(pad + current);
218
+ current = piece;
219
+ }
220
+ }
221
+ if (current !== "") lines.push(pad + current);
222
+ return lines;
223
+ }
224
+ function renderNode(value, level, used, cfg) {
225
+ const isContainer = isJsonArray(value) || isJsonObject(value);
226
+ if (!isContainer) return writeScalar(value);
227
+ const flat = flatten(value, cfg);
228
+ if (flat === "[]" || flat === "{}") return flat;
229
+ if (cfg.width >= 0 && used + flat.length <= cfg.width) return flat;
230
+ const pad = " ".repeat((level + 1) * cfg.indent);
231
+ const closePad = " ".repeat(level * cfg.indent);
232
+ if (isJsonArray(value)) {
233
+ const entries2 = value.map(
234
+ (v) => renderNode(v ?? null, level + 1, pad.length, cfg)
235
+ );
236
+ const body2 = layoutEntries(entries2, pad, cfg);
237
+ const joined2 = cfg.pack ? body2.join("\n") : body2.join(",\n");
238
+ return `[
239
+ ${joined2}
240
+ ${closePad}]`;
241
+ }
242
+ const keys = orderedKeys(value, cfg.sortKeys);
243
+ const entries = keys.map((k) => {
244
+ const prefix = `${JSON.stringify(k)}: `;
245
+ const rendered = renderNode(
246
+ value[k] ?? null,
247
+ level + 1,
248
+ pad.length + prefix.length,
249
+ cfg
250
+ );
251
+ return prefix + rendered;
252
+ });
253
+ const body = layoutEntries(entries, pad, cfg);
254
+ const joined = cfg.pack ? body.join("\n") : body.join(",\n");
255
+ return `{
256
+ ${joined}
257
+ ${closePad}}`;
258
+ }
259
+ function stringifyJson(value, options) {
260
+ const indent = options.indent ?? DEFAULT_JSON_INDENT;
261
+ const sortKeys = options.sortKeys ?? false;
262
+ if (options.style === "minify") {
263
+ return flatten(value, { indent, width: -1, pack: false, spaced: false, sortKeys });
264
+ }
265
+ const cfg = {
266
+ indent,
267
+ width: options.style === "pretty" ? -1 : options.width ?? DEFAULT_JSON_WIDTH,
268
+ pack: options.style === "compact",
269
+ spaced: true,
270
+ sortKeys
271
+ };
272
+ return renderNode(value, 0, 0, cfg);
273
+ }
274
+ function sizeOf(text) {
275
+ let lines = text === "" ? 0 : 1;
276
+ for (let i = 0; i < text.length; i++) if (text[i] === "\n") lines++;
277
+ return { lines, chars: text.length };
278
+ }
279
+ function reassemble(detection, payload, mode) {
280
+ const { fence, leading, trailing } = detection;
281
+ const keepFence = mode === "add" || mode === "preserve" && fence !== null;
282
+ if (!keepFence) {
283
+ return leading + payload + trailing;
284
+ }
285
+ const marker = fence?.marker ?? "```";
286
+ const lang = fence?.lang && fence.lang !== "" ? fence.lang : "json";
287
+ const indent = fence?.indent ?? "";
288
+ const body = indent ? payload.split("\n").map((l) => l === "" ? l : indent + l).join("\n") : payload;
289
+ const close = fence !== null && !fence.closed ? "" : `
290
+ ${indent}${marker}`;
291
+ return `${leading}${indent}${marker}${lang}
292
+ ${body}${close}${trailing}`;
293
+ }
294
+ function formatJsonText(text, options) {
295
+ const detection = detectJson(text);
296
+ const before = sizeOf(text);
297
+ if (!detection.ok || detection.value === void 0) {
298
+ return {
299
+ ok: false,
300
+ text,
301
+ error: detection.error ?? "Selection is not JSON.",
302
+ changed: false,
303
+ detection,
304
+ before,
305
+ after: before
306
+ };
307
+ }
308
+ const payload = stringifyJson(detection.value, options);
309
+ const next = reassemble(detection, payload, options.fence ?? "preserve");
310
+ return {
311
+ ok: true,
312
+ text: next,
313
+ changed: next !== text,
314
+ detection,
315
+ before,
316
+ after: sizeOf(next)
317
+ };
318
+ }
319
+ //# sourceMappingURL=json-format.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/json-format.ts","../src/json-format/detect.ts","../src/json-format/json-value.ts","../src/json-format/format.ts"],"sourcesContent":["/**\n * @ai-matrx/kit/json-format — \"is this text JSON, and what shape should it be\n * in?\" so no surface ever hand-rolls another `JSON.stringify(v, null, 2)` /\n * \"strip the backticks\" / \"does this look like JSON\" helper.\n *\n * Two questions, two entry points:\n * - `detectJson(text)` — finds the JSON (code fences, prose around the\n * payload, tolerant JSON5 input) and says exactly where it starts and stops.\n * `looksLikeJson` gates OFFERING actions; `ok` gates RUNNING them.\n * - `formatJsonText(text, opts)` / `stringifyJson(value, opts)` — re-print in\n * `minify` / `compact` (width-aware fill+pack) / `pretty`, with key sorting\n * and fence add/strip/preserve. Everything around the payload is restored\n * verbatim.\n *\n * Pure (no React / DOM); never throws — non-JSON comes back `ok: false` with\n * the input unchanged. Handles partial/streamed text honestly: bracket-shaped\n * text that does not (yet) parse is `looksLikeJson: true, ok: false`, and an\n * unterminated fence stays unterminated.\n *\n * Runtime dependency of this subpath (and only this subpath's bundles):\n * `json5`, for the tolerant parse tier — the JSON people paste out of logs and\n * code is frequently not legal JSON, and reporting `parser: \"tolerant\"` versus\n * hiding it is a core behavior of the unit.\n */\nexport { detectJson } from \"./json-format/detect\";\nexport {\n DEFAULT_JSON_INDENT,\n DEFAULT_JSON_WIDTH,\n formatJsonText,\n stringifyJson,\n} from \"./json-format/format\";\nexport type {\n JsonDetection,\n JsonFence,\n JsonFenceMode,\n JsonFormatOptions,\n JsonFormatResult,\n JsonFormatStyle,\n JsonParser,\n JsonRootKind,\n JsonTextSize,\n} from \"./json-format/types\";\nexport {\n isJsonArray,\n isJsonObject,\n isJsonPrimitive,\n} from \"./json-format/json-value\";\nexport type {\n JsonArray,\n JsonObject,\n JsonPrimitive,\n JsonValue,\n} from \"./json-format/json-value\";\n","// json-format/detect.ts\n//\n// \"Is this text JSON, and where exactly does the JSON start and stop?\"\n//\n// The answer has to survive real-world selections: a fenced ```json block, a\n// bare pasted object, an object with a stray blank line above it, a fence the\n// user only half-selected. So detection splits the text into three parts —\n// leading / payload / trailing — and only the payload is ever re-formatted.\n// Everything outside it is restored verbatim, because a formatter that eats\n// the prose around the JSON is worse than no formatter at all.\n//\n// Two parse tiers: `JSON.parse` first (strict — what the value really is), then\n// JSON5 (tolerant — trailing commas, comments, unquoted keys, single quotes),\n// because the JSON people paste out of logs and code is frequently not legal\n// JSON. Tolerant parsing is reported, never hidden: a consumer that re-emits a\n// tolerantly-parsed value is normalizing it, and the caller can say so.\n//\n// Pure: no React / DOM. Never throws.\n//\n// Ported verbatim from matrx-frontend `lib/json-format/detect.ts`.\n\nimport JSON5 from \"json5\";\nimport type { JsonValue } from \"./json-value\";\nimport type {\n JsonDetection,\n JsonFence,\n JsonParser,\n JsonRootKind,\n} from \"./types\";\n\n/** Opening fence line: optional indent, 3+ backticks or tildes, optional info. */\nconst FENCE_OPEN = /^([ \\t]*)(`{3,}|~{3,})[ \\t]*([^\\s`~]*)[ \\t]*$/;\n\n/** Languages we treat as \"this fence contains JSON\". */\nconst JSON_FENCE_LANGS = new Set([\"json\", \"jsonc\", \"json5\", \"geojson\", \"jsonl\"]);\n\ninterface Split {\n leading: string;\n payload: string;\n trailing: string;\n fence: JsonFence | null;\n}\n\n/** Peel a markdown code fence off the text, if the text IS a fenced block. */\nfunction splitFence(text: string): Split | null {\n const lines = text.split(\"\\n\");\n\n // The fence may sit anywhere in the selection (a user highlighting a block\n // plus the sentence above it is the common case) — but there must be exactly\n // ONE block. Two fenced blocks in one selection is not a single JSON payload,\n // and spanning them would splice unrelated content together.\n const openIdx = lines.findIndex((l) => FENCE_OPEN.test(l));\n if (openIdx === -1) return null;\n\n const open = FENCE_OPEN.exec(lines[openIdx] ?? \"\");\n if (!open) return null;\n const [, indent = \"\", marker = \"```\", lang = \"\"] = open;\n const fenceChar = marker[0] ?? \"`\";\n const closeRe = new RegExp(`^[ \\\\t]*\\\\${fenceChar}{${marker.length},}[ \\\\t]*$`);\n\n let closeIdx = -1;\n for (let i = openIdx + 1; i < lines.length; i++) {\n if (closeRe.test(lines[i] ?? \"\")) {\n closeIdx = i;\n break;\n }\n }\n\n const afterClose = closeIdx === -1 ? [] : lines.slice(closeIdx + 1);\n if (afterClose.some((l) => FENCE_OPEN.test(l))) return null;\n\n const bodyEnd = closeIdx === -1 ? lines.length : closeIdx;\n // The line separators bordering the fence belong to leading/trailing, so\n // reassembly is a plain concatenation and blank lines survive it.\n return {\n leading: openIdx > 0 ? `${lines.slice(0, openIdx).join(\"\\n\")}\\n` : \"\",\n payload: lines.slice(openIdx + 1, bodyEnd).join(\"\\n\"),\n trailing: afterClose.length > 0 ? `\\n${afterClose.join(\"\\n\")}` : \"\",\n fence: {\n marker,\n lang: lang.toLowerCase(),\n indent,\n closed: closeIdx !== -1,\n },\n };\n}\n\n/** Split bare (unfenced) text into surrounding whitespace + payload. */\nfunction splitBare(text: string): Split {\n const payload = text.trim();\n if (payload === \"\") {\n return { leading: text, payload: \"\", trailing: \"\", fence: null };\n }\n const start = text.indexOf(payload);\n return {\n leading: text.slice(0, start),\n payload,\n trailing: text.slice(start + payload.length),\n fence: null,\n };\n}\n\nfunction rootKindOf(value: JsonValue): JsonRootKind {\n if (Array.isArray(value)) return \"array\";\n if (typeof value === \"object\" && value !== null) return \"object\";\n return \"scalar\";\n}\n\n/** Bracket-shaped: opens and closes with a matching container delimiter. */\nfunction isBracketShaped(payload: string): boolean {\n const first = payload[0];\n const last = payload[payload.length - 1];\n if (payload.length < 2) return false;\n return (first === \"{\" && last === \"}\") || (first === \"[\" && last === \"]\");\n}\n\nfunction errorMessage(err: unknown): string {\n return err instanceof Error ? err.message : \"Invalid JSON\";\n}\n\nfunction countLines(s: string): number {\n if (s === \"\") return 0;\n let n = 1;\n for (let i = 0; i < s.length; i++) if (s[i] === \"\\n\") n++;\n return n;\n}\n\n/**\n * Detect JSON in `text`. Never throws; a non-JSON string comes back with\n * `ok: false` and `looksLikeJson: false`, which is the signal to offer nothing.\n */\nexport function detectJson(text: string): JsonDetection {\n const split = splitFence(text) ?? splitBare(text);\n // A fenced block's body still carries its own indentation/blank lines.\n const payload = split.fence ? split.payload.trim() : split.payload;\n\n const fenceSaysJson =\n split.fence !== null &&\n (split.fence.lang === \"\" || JSON_FENCE_LANGS.has(split.fence.lang));\n\n const base = {\n fence: split.fence,\n leading: split.leading,\n trailing: split.trailing,\n payload,\n lineCount: countLines(payload),\n charCount: payload.length,\n };\n\n if (payload === \"\") {\n return { ...base, ok: false, looksLikeJson: false };\n }\n\n // A fence declaring a NON-JSON language is a hard no, even if the body would\n // parse — reformatting the inside of a ```python block is not our business.\n if (split.fence !== null && !fenceSaysJson) {\n return { ...base, ok: false, looksLikeJson: false };\n }\n\n const shaped = isBracketShaped(payload);\n\n let value: JsonValue | undefined;\n let parser: JsonParser | undefined;\n let error: string | undefined;\n try {\n value = JSON.parse(payload) as JsonValue;\n parser = \"strict\";\n } catch (strictErr) {\n try {\n value = JSON5.parse(payload) as JsonValue;\n parser = \"tolerant\";\n } catch {\n error = errorMessage(strictErr);\n }\n }\n\n if (value === undefined || parser === undefined) {\n // Unparseable. Still \"looks like JSON\" when it is bracket-shaped, so a\n // surface can show the actions and report the parse error on click rather\n // than pretending the selection is ordinary prose.\n return { ...base, ok: false, looksLikeJson: shaped, error };\n }\n\n const root = rootKindOf(value);\n // A bare scalar (\"hello\", 42, true) parses but is not worth offering JSON\n // actions on — every prose word that happens to be a number would qualify.\n const worthOffering = root !== \"scalar\" || fenceSaysJson;\n\n return { ...base, ok: true, looksLikeJson: worthOffering, value, parser, root };\n}\n","/**\n * Canonical JSON value types + narrowing guards.\n *\n * Ported (the subset this subpath needs) from matrx-frontend `types/json.ts` —\n * the honest names for \"this is just JSON\" that are NOT `any` and NOT a bare\n * `unknown`. The package must stand alone, so the types live here; a Matrx\n * host keeps using its own `@/types/json` for app code and the two are\n * structurally identical.\n */\n\nexport type JsonPrimitive = string | number | boolean | null;\n\n/**\n * A JSON object. Values are `JsonValue | undefined` so optional keys read\n * cleanly (mirrors Supabase's original generated `Json` object member).\n */\nexport interface JsonObject {\n [key: string]: JsonValue | undefined;\n}\n\nexport type JsonArray = JsonValue[];\n\nexport type JsonValue = JsonPrimitive | JsonObject | JsonArray;\n\n/**\n * Narrow an `unknown` (e.g. a bare JSONB column) to a `JsonObject`.\n * Plain object only — arrays and `null` return false.\n */\nexport function isJsonObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Narrow an `unknown` to a `JsonArray`. */\nexport function isJsonArray(value: unknown): value is JsonArray {\n return Array.isArray(value);\n}\n\n/** Narrow an `unknown` to a JSON primitive (string | number | boolean | null). */\nexport function isJsonPrimitive(value: unknown): value is JsonPrimitive {\n return (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n );\n}\n","// json-format/format.ts\n//\n// The JSON writer. Three styles over one recursive printer:\n//\n// minify — one line, no optional whitespace.\n// compact — width-aware FILL. Any subtree whose flat form fits the remaining\n// columns is inlined; a subtree that does not fit expands, but its\n// children are then PACKED onto shared lines while they fit. This\n// is what turns an 11-line reference blob into 3 lines without\n// turning it into an unreadable one-liner.\n// pretty — one entry per line (classic 2-space JSON).\n//\n// Why not `JSON.stringify(v, null, 2)`: it cannot inline, cannot pack, and\n// cannot sort keys. All three are the point.\n//\n// Pure: no React / DOM. Never throws — a parse failure comes back as a result\n// with `ok: false` and the input text unchanged.\n//\n// Ported verbatim from matrx-frontend `lib/json-format/format.ts`.\n\nimport type { JsonObject, JsonValue } from \"./json-value\";\nimport { isJsonArray, isJsonObject } from \"./json-value\";\nimport { detectJson } from \"./detect\";\nimport type {\n JsonDetection,\n JsonFormatOptions,\n JsonFormatResult,\n JsonTextSize,\n} from \"./types\";\n\nexport const DEFAULT_JSON_INDENT = 2;\nexport const DEFAULT_JSON_WIDTH = 100;\n\ninterface WriterConfig {\n indent: number;\n /** Target line width; `-1` disables inlining entirely (pretty). */\n width: number;\n /** Pack sibling entries onto shared lines (compact only). */\n pack: boolean;\n /** Spaces inside braces/brackets and after colons/commas. */\n spaced: boolean;\n sortKeys: boolean;\n}\n\nfunction orderedKeys(obj: JsonObject, sortKeys: boolean): string[] {\n // `undefined` values are not JSON — JSON.stringify drops them, so do we.\n const keys = Object.keys(obj).filter((k) => obj[k] !== undefined);\n return sortKeys ? [...keys].sort((a, b) => a.localeCompare(b)) : keys;\n}\n\n/** Serialize a scalar exactly as JSON does. */\nfunction writeScalar(value: JsonValue): string {\n // NaN / Infinity stringify to \"null\", matching JSON.stringify.\n return JSON.stringify(value) ?? \"null\";\n}\n\n/** The whole subtree on one line. */\nfunction flatten(value: JsonValue, cfg: WriterConfig): string {\n if (isJsonArray(value)) {\n if (value.length === 0) return \"[]\";\n const parts = value.map((v) => flatten(v ?? null, cfg));\n return cfg.spaced ? `[${parts.join(\", \")}]` : `[${parts.join(\",\")}]`;\n }\n if (isJsonObject(value)) {\n const keys = orderedKeys(value, cfg.sortKeys);\n if (keys.length === 0) return \"{}\";\n const colon = cfg.spaced ? \": \" : \":\";\n const parts = keys.map(\n (k) => `${JSON.stringify(k)}${colon}${flatten(value[k] ?? null, cfg)}`,\n );\n return cfg.spaced ? `{ ${parts.join(\", \")} }` : `{${parts.join(\",\")}}`;\n }\n return writeScalar(value);\n}\n\n/**\n * Lay out `entries` (already-rendered child texts) inside a container.\n * Single-line entries are packed together while they fit; a multi-line entry\n * always occupies its own line(s). Returns the body lines, unindented-prefixed\n * with `pad` already applied.\n */\nfunction layoutEntries(\n entries: string[],\n pad: string,\n cfg: WriterConfig,\n): string[] {\n if (!cfg.pack) return entries.map((e) => pad + e);\n\n const lines: string[] = [];\n let current = \"\";\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i] ?? \"\";\n const isLast = i === entries.length - 1;\n const piece = isLast ? entry : `${entry},`;\n\n if (entry.includes(\"\\n\")) {\n // Multi-line child: flush whatever is buffered, then stand alone.\n if (current !== \"\") {\n lines.push(pad + current);\n current = \"\";\n }\n lines.push(pad + piece);\n continue;\n }\n\n if (current === \"\") {\n current = piece;\n continue;\n }\n const merged = `${current} ${piece}`;\n if (pad.length + merged.length <= cfg.width) {\n current = merged;\n } else {\n lines.push(pad + current);\n current = piece;\n }\n }\n if (current !== \"\") lines.push(pad + current);\n return lines;\n}\n\n/**\n * Render `value` starting at column `used` on its current line, at nesting\n * `level`. `used` includes the indentation AND any key prefix already written,\n * so the width budget is honest about `\"items\": [` style prefixes.\n */\nfunction renderNode(\n value: JsonValue,\n level: number,\n used: number,\n cfg: WriterConfig,\n): string {\n const isContainer = isJsonArray(value) || isJsonObject(value);\n if (!isContainer) return writeScalar(value);\n\n const flat = flatten(value, cfg);\n if (flat === \"[]\" || flat === \"{}\") return flat;\n if (cfg.width >= 0 && used + flat.length <= cfg.width) return flat;\n\n const pad = \" \".repeat((level + 1) * cfg.indent);\n const closePad = \" \".repeat(level * cfg.indent);\n\n if (isJsonArray(value)) {\n const entries = value.map((v) =>\n renderNode(v ?? null, level + 1, pad.length, cfg),\n );\n const body = layoutEntries(entries, pad, cfg);\n const joined = cfg.pack ? body.join(\"\\n\") : body.join(\",\\n\");\n return `[\\n${joined}\\n${closePad}]`;\n }\n\n const keys = orderedKeys(value, cfg.sortKeys);\n const entries = keys.map((k) => {\n const prefix = `${JSON.stringify(k)}: `;\n const rendered = renderNode(\n value[k] ?? null,\n level + 1,\n pad.length + prefix.length,\n cfg,\n );\n return prefix + rendered;\n });\n const body = layoutEntries(entries, pad, cfg);\n const joined = cfg.pack ? body.join(\"\\n\") : body.join(\",\\n\");\n return `{\\n${joined}\\n${closePad}}`;\n}\n\n/**\n * Serialize a JSON value in one of the three styles. This is the entry point\n * for callers that already HAVE a value (a DB JSONB blob, an API frame) and\n * just want it laid out; text callers want {@link formatJsonText}.\n */\nexport function stringifyJson(\n value: JsonValue,\n options: JsonFormatOptions,\n): string {\n const indent = options.indent ?? DEFAULT_JSON_INDENT;\n const sortKeys = options.sortKeys ?? false;\n\n if (options.style === \"minify\") {\n return flatten(value, { indent, width: -1, pack: false, spaced: false, sortKeys });\n }\n\n const cfg: WriterConfig = {\n indent,\n width: options.style === \"pretty\" ? -1 : (options.width ?? DEFAULT_JSON_WIDTH),\n pack: options.style === \"compact\",\n spaced: true,\n sortKeys,\n };\n return renderNode(value, 0, 0, cfg);\n}\n\nfunction sizeOf(text: string): JsonTextSize {\n let lines = text === \"\" ? 0 : 1;\n for (let i = 0; i < text.length; i++) if (text[i] === \"\\n\") lines++;\n return { lines, chars: text.length };\n}\n\n/** Re-assemble the full text: leading + fence + formatted payload + trailing. */\nfunction reassemble(\n detection: JsonDetection,\n payload: string,\n mode: NonNullable<JsonFormatOptions[\"fence\"]>,\n): string {\n const { fence, leading, trailing } = detection;\n\n const keepFence =\n mode === \"add\" || (mode === \"preserve\" && fence !== null);\n if (!keepFence) {\n return leading + payload + trailing;\n }\n\n const marker = fence?.marker ?? \"```\";\n const lang = fence?.lang && fence.lang !== \"\" ? fence.lang : \"json\";\n const indent = fence?.indent ?? \"\";\n const body = indent\n ? payload\n .split(\"\\n\")\n .map((l) => (l === \"\" ? l : indent + l))\n .join(\"\\n\")\n : payload;\n\n // An unterminated source fence stays unterminated — inventing a closing fence\n // would change the surrounding document's structure, not just this block's.\n const close = fence !== null && !fence.closed ? \"\" : `\\n${indent}${marker}`;\n return `${leading}${indent}${marker}${lang}\\n${body}${close}${trailing}`;\n}\n\n/**\n * Format the JSON found in `text`, preserving everything around it.\n *\n * Never throws. When the text does not parse, the result is `ok: false`,\n * `changed: false`, and `text` is the input verbatim — a formatter that\n * mangles text it did not understand is a data-loss bug.\n */\nexport function formatJsonText(\n text: string,\n options: JsonFormatOptions,\n): JsonFormatResult {\n const detection = detectJson(text);\n const before = sizeOf(text);\n\n if (!detection.ok || detection.value === undefined) {\n return {\n ok: false,\n text,\n error: detection.error ?? \"Selection is not JSON.\",\n changed: false,\n detection,\n before,\n after: before,\n };\n }\n\n const payload = stringifyJson(detection.value, options);\n const next = reassemble(detection, payload, options.fence ?? \"preserve\");\n\n return {\n ok: true,\n text: next,\n changed: next !== text,\n detection,\n before,\n after: sizeOf(next),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqBA,mBAAkB;AAUlB,IAAM,aAAa;AAGnB,IAAM,mBAAmB,oBAAI,IAAI,CAAC,QAAQ,SAAS,SAAS,WAAW,OAAO,CAAC;AAU/E,SAAS,WAAW,MAA4B;AAC9C,QAAM,QAAQ,KAAK,MAAM,IAAI;AAM7B,QAAM,UAAU,MAAM,UAAU,CAAC,MAAM,WAAW,KAAK,CAAC,CA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