@invinite-org/chartlang-adapter-kit 1.1.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 (56) hide show
  1. package/CHANGELOG.md +1380 -0
  2. package/LICENSE +21 -0
  3. package/README.md +69 -0
  4. package/dist/base/bufferingAdapter.d.ts +52 -0
  5. package/dist/base/bufferingAdapter.d.ts.map +1 -0
  6. package/dist/base/bufferingAdapter.js +68 -0
  7. package/dist/base/bufferingAdapter.js.map +1 -0
  8. package/dist/base/index.d.ts +3 -0
  9. package/dist/base/index.d.ts.map +1 -0
  10. package/dist/base/index.js +5 -0
  11. package/dist/base/index.js.map +1 -0
  12. package/dist/base/passThroughAdapter.d.ts +49 -0
  13. package/dist/base/passThroughAdapter.d.ts.map +1 -0
  14. package/dist/base/passThroughAdapter.js +61 -0
  15. package/dist/base/passThroughAdapter.js.map +1 -0
  16. package/dist/capabilities/capabilities.d.ts +336 -0
  17. package/dist/capabilities/capabilities.d.ts.map +1 -0
  18. package/dist/capabilities/capabilities.js +616 -0
  19. package/dist/capabilities/capabilities.js.map +1 -0
  20. package/dist/capabilities/index.d.ts +2 -0
  21. package/dist/capabilities/index.d.ts.map +1 -0
  22. package/dist/capabilities/index.js +4 -0
  23. package/dist/capabilities/index.js.map +1 -0
  24. package/dist/defineAdapter.d.ts +74 -0
  25. package/dist/defineAdapter.d.ts.map +1 -0
  26. package/dist/defineAdapter.js +55 -0
  27. package/dist/defineAdapter.js.map +1 -0
  28. package/dist/index.d.ts +12 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +9 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/mocks/index.d.ts +3 -0
  33. package/dist/mocks/index.d.ts.map +1 -0
  34. package/dist/mocks/index.js +4 -0
  35. package/dist/mocks/index.js.map +1 -0
  36. package/dist/mocks/mockCandleSource.d.ts +68 -0
  37. package/dist/mocks/mockCandleSource.d.ts.map +1 -0
  38. package/dist/mocks/mockCandleSource.js +61 -0
  39. package/dist/mocks/mockCandleSource.js.map +1 -0
  40. package/dist/types.d.ts +655 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +4 -0
  43. package/dist/types.js.map +1 -0
  44. package/dist/validation/decodeDrawing.d.ts +29 -0
  45. package/dist/validation/decodeDrawing.d.ts.map +1 -0
  46. package/dist/validation/decodeDrawing.js +35 -0
  47. package/dist/validation/decodeDrawing.js.map +1 -0
  48. package/dist/validation/index.d.ts +4 -0
  49. package/dist/validation/index.d.ts.map +1 -0
  50. package/dist/validation/index.js +5 -0
  51. package/dist/validation/index.js.map +1 -0
  52. package/dist/validation/validateEmission.d.ts +70 -0
  53. package/dist/validation/validateEmission.d.ts.map +1 -0
  54. package/dist/validation/validateEmission.js +1481 -0
  55. package/dist/validation/validateEmission.js.map +1 -0
  56. package/package.json +41 -0
@@ -0,0 +1,29 @@
1
+ import type { DrawingState } from "@invinite-org/chartlang-core";
2
+ import type { DrawingEmission } from "../types.js";
3
+ /**
4
+ * Narrow a {@link DrawingEmission} to its typed {@link DrawingState}.
5
+ * Returns `null` when the emission fails the same validation
6
+ * {@link validateEmission} runs — adapters that want to know WHY call
7
+ * `validateEmission(e)` directly and inspect `.code` / `.message`.
8
+ *
9
+ * Successful narrows return `e.state` typed as `DrawingState`; the
10
+ * caller can switch on `state.kind` for per-kind handling. The
11
+ * validator pins `state.kind === e.drawingKind`, so the discriminator
12
+ * is safe.
13
+ *
14
+ * @since 0.3
15
+ * @stable
16
+ * @example
17
+ * import { decodeDrawing } from "@invinite-org/chartlang-adapter-kit";
18
+ * import type { DrawingEmission } from "@invinite-org/chartlang-adapter-kit";
19
+ *
20
+ * declare const e: DrawingEmission;
21
+ * const state = decodeDrawing(e);
22
+ * if (state !== null && state.kind === "line") {
23
+ * const [from, to] = state.anchors;
24
+ * void from;
25
+ * void to;
26
+ * }
27
+ */
28
+ export declare function decodeDrawing(e: DrawingEmission): DrawingState | null;
29
+ //# sourceMappingURL=decodeDrawing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeDrawing.d.ts","sourceRoot":"","sources":["../../src/validation/decodeDrawing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,IAAI,CAIrE"}
@@ -0,0 +1,35 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ import { validateEmission } from "./validateEmission.js";
4
+ /**
5
+ * Narrow a {@link DrawingEmission} to its typed {@link DrawingState}.
6
+ * Returns `null` when the emission fails the same validation
7
+ * {@link validateEmission} runs — adapters that want to know WHY call
8
+ * `validateEmission(e)` directly and inspect `.code` / `.message`.
9
+ *
10
+ * Successful narrows return `e.state` typed as `DrawingState`; the
11
+ * caller can switch on `state.kind` for per-kind handling. The
12
+ * validator pins `state.kind === e.drawingKind`, so the discriminator
13
+ * is safe.
14
+ *
15
+ * @since 0.3
16
+ * @stable
17
+ * @example
18
+ * import { decodeDrawing } from "@invinite-org/chartlang-adapter-kit";
19
+ * import type { DrawingEmission } from "@invinite-org/chartlang-adapter-kit";
20
+ *
21
+ * declare const e: DrawingEmission;
22
+ * const state = decodeDrawing(e);
23
+ * if (state !== null && state.kind === "line") {
24
+ * const [from, to] = state.anchors;
25
+ * void from;
26
+ * void to;
27
+ * }
28
+ */
29
+ export function decodeDrawing(e) {
30
+ const result = validateEmission(e);
31
+ if (!result.ok)
32
+ return null;
33
+ return e.state;
34
+ }
35
+ //# sourceMappingURL=decodeDrawing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeDrawing.js","sourceRoot":"","sources":["../../src/validation/decodeDrawing.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAK/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,aAAa,CAAC,CAAkB;IAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAY,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO,CAAC,CAAC,KAAK,CAAC;AACnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { decodeDrawing } from "./decodeDrawing.js";
2
+ export { validateEmission } from "./validateEmission.js";
3
+ export type { ValidationFail, ValidationOk, ValidationResult } from "./validateEmission.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ export { decodeDrawing } from "./decodeDrawing.js";
4
+ export { validateEmission } from "./validateEmission.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { DiagnosticCode } from "../types.js";
2
+ /**
3
+ * Successful validation. `e` was a well-formed Phase-1 emission and is
4
+ * safe to forward across the structured-clone boundary.
5
+ *
6
+ * @since 0.1
7
+ * @stable
8
+ * @example
9
+ * const r: ValidationOk = { ok: true };
10
+ */
11
+ export type ValidationOk = {
12
+ readonly ok: true;
13
+ };
14
+ /**
15
+ * Failed validation. `code` is `"malformed-emission"` for shape errors
16
+ * and `"unsupported-drawing-kind"` for the Phase-1 drawing stub.
17
+ *
18
+ * @since 0.1
19
+ * @stable
20
+ * @example
21
+ * const r: ValidationFail = {
22
+ * ok: false,
23
+ * code: "malformed-emission",
24
+ * message: "not an object",
25
+ * };
26
+ */
27
+ export type ValidationFail = {
28
+ readonly ok: false;
29
+ readonly code: DiagnosticCode;
30
+ readonly message: string;
31
+ };
32
+ /**
33
+ * Discriminated union returned by {@link validateEmission}.
34
+ *
35
+ * @since 0.1
36
+ * @stable
37
+ * @example
38
+ * declare const r: ValidationResult;
39
+ * if (r.ok) {
40
+ * // pass through
41
+ * } else {
42
+ * console.error(r.code, r.message);
43
+ * }
44
+ */
45
+ export type ValidationResult = ValidationOk | ValidationFail;
46
+ /**
47
+ * Hand-rolled validator covering every Phase-1 / Phase-2 / Phase-3
48
+ * emission shape. Returns `{ ok: true }` for well-formed payloads and
49
+ * `{ ok: false, code, message }` otherwise. Hosts and adapters call
50
+ * this at every structured-clone boundary (Worker `postMessage`,
51
+ * QuickJS membrane) per PLAN §7.3.
52
+ *
53
+ * Phase 3 widens the drawing dispatch from an unconditional Phase-1
54
+ * stub to a per-kind validator: unknown `drawingKind` returns
55
+ * `unsupported-drawing-kind`; malformed payloads of a known kind
56
+ * return `malformed-emission`. Tasks 6–18 each ADD their kind
57
+ * validators to the dispatch as ports land.
58
+ *
59
+ * @since 0.1
60
+ * @stable
61
+ * @example
62
+ * import { validateEmission } from "@invinite-org/chartlang-adapter-kit";
63
+ *
64
+ * const r = validateEmission({ kind: "plot" });
65
+ * if (!r.ok) {
66
+ * console.error(r.code, r.message);
67
+ * }
68
+ */
69
+ export declare function validateEmission(e: unknown): ValidationResult;
70
+ //# sourceMappingURL=validateEmission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateEmission.d.ts","sourceRoot":"","sources":["../../src/validation/validateEmission.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,cAAc,CAAC;AAm9C7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAwB7D"}