@livepreso/cdk 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livepreso/cdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Content Development Kit",
5
5
  "bin": {
6
6
  "livepreso-cdk": "./dist/backend/cli.mjs"
@@ -13,7 +13,7 @@
13
13
  "dist/favicon.png",
14
14
  "dist/assets",
15
15
  "dist/backend",
16
- "src/shared/modes.mjs"
16
+ "src/shared"
17
17
  ],
18
18
  "devDependencies": {
19
19
  "html-webpack-plugin": "~5.5.3",
@@ -56,12 +56,12 @@
56
56
  "@rspack/core": "2.2.1",
57
57
  "@rspack/dev-server": "2.2.1",
58
58
  "@rspack/plugin-react-refresh": "2.0.2",
59
- "@livepreso/eslint-config": "1.0.0",
60
- "sp-get-port-by-name": "0.0.1",
61
- "@livepreso/presenter": "2.50.3",
62
59
  "sp-editable-components": "1.7.2",
60
+ "sp-components": "3.1.1",
61
+ "sp-get-port-by-name": "0.0.1",
63
62
  "@livepreso/deck-interface": "0.0.1",
64
- "sp-components": "3.1.1"
63
+ "@livepreso/presenter": "2.50.3",
64
+ "@livepreso/eslint-config": "1.0.0"
65
65
  },
66
66
  "dependencies": {
67
67
  "@modelcontextprotocol/sdk": "~1.29.0",
@@ -0,0 +1,87 @@
1
+ import {
2
+ MODES,
3
+ findModeByIndices,
4
+ findModeByPath,
5
+ PRESENT_STATES,
6
+ } from "./modes.mjs";
7
+
8
+ describe("MODES", () => {
9
+ it("only contains states with no children", () => {
10
+ const leaves = MODES.map((mode) => mode.path);
11
+
12
+ expect(leaves).toContain("app/preso/prep/prepping");
13
+ expect(leaves).not.toContain("app/preso/prep");
14
+ expect(leaves).not.toContain("app");
15
+ });
16
+
17
+ it("indexes each step by its position in PRESENT_STATES", () => {
18
+ const mode = findModeByPath("app/presomanager/edit");
19
+
20
+ expect(mode.indices).toEqual([0, 1, 0]);
21
+ expect(PRESENT_STATES[0].children[1].children[0].key).toBe("edit");
22
+ });
23
+
24
+ it("titles a mode with the states it came through", () => {
25
+ expect(findModeByPath("app/preso/prep/prepping").title).toBe(
26
+ "App > Preso > Prep > Prepping",
27
+ );
28
+ });
29
+
30
+ it("describes a mode with the nearest description above it", () => {
31
+ expect(findModeByPath("app/preso/prep/prepping").description).toBe(
32
+ "Test preparing a preso - contains editables and the like usually",
33
+ );
34
+ });
35
+
36
+ it("reports whether editables are shown", () => {
37
+ expect(findModeByPath("app/preso/prep/prepping").showEditables).toBe(true);
38
+ expect(findModeByPath("app/preso/prep/previewing").showEditables).toBe(
39
+ false,
40
+ );
41
+ });
42
+
43
+ it("offers no editables where a template is only being looked at", () => {
44
+ expect(
45
+ findModeByPath("app/preso/add-slides/template-preview").showEditables,
46
+ ).toBe(false);
47
+ expect(
48
+ findModeByPath("app/presomanager/template-preview").showEditables,
49
+ ).toBe(false);
50
+ });
51
+
52
+ it("inherits flags from the states above the leaf", () => {
53
+ expect(findModeByPath("app/presomanager/edit").isPresomanager).toBe(true);
54
+ expect(findModeByPath("screenshot/pdf").isScreenshot).toBe(true);
55
+ });
56
+
57
+ it("reports the modes rendering with no presentation behind them", () => {
58
+ expect(findModeByPath("app/presomanager/preview").isEmptyPreview).toBe(
59
+ true,
60
+ );
61
+ expect(findModeByPath("app/preset").isEmptyPreview).toBe(true);
62
+ });
63
+
64
+ it("leaves flags off modes outside those states", () => {
65
+ const present = findModeByPath("app/preso/present");
66
+
67
+ expect(present.isPresomanager).toBe(false);
68
+ expect(present.isScreenshot).toBe(false);
69
+ expect(present.isEmptyPreview).toBe(false);
70
+ });
71
+ });
72
+
73
+ describe("finding a mode", () => {
74
+ it("round trips between a path and indices", () => {
75
+ for (const mode of MODES) {
76
+ expect(findModeByIndices(mode.indices).path).toBe(mode.path);
77
+ }
78
+ });
79
+
80
+ it("returns null for an unknown path", () => {
81
+ expect(findModeByPath("app/nope")).toBeNull();
82
+ });
83
+
84
+ it("returns null for indices that stop above a leaf", () => {
85
+ expect(findModeByIndices([0, 0])).toBeNull();
86
+ });
87
+ });
@@ -0,0 +1,95 @@
1
+ import {
2
+ CMS_VALS,
3
+ CONTEXT_OVERRIDES,
4
+ findModeByPath,
5
+ findModesForTab,
6
+ isStateOnTab,
7
+ PRESENT_STATES,
8
+ } from "./modes.mjs";
9
+ import { SLIDES, TEMPLATES } from "./tabs.mjs";
10
+
11
+ function findState(key) {
12
+ return PRESENT_STATES[0].children.find((state) => state.key === key);
13
+ }
14
+
15
+ describe("findModesForTab", () => {
16
+ it("should offer the templates tab one mode per way the app shows a template", () => {
17
+ expect(findModesForTab(TEMPLATES).map((mode) => mode.path)).toEqual([
18
+ "app/preso/add-slides/template-preview",
19
+ "app/preso/add-slides/user-template",
20
+ "app/preso/add-slides/custom-slide",
21
+ "app/preso/add-slides/custom-slide-saved",
22
+ "app/presomanager/template-preview",
23
+ "app/presomanager/placed-template",
24
+ "app/presomanager/placed-template-saved",
25
+ "screenshot/thumbnail",
26
+ "screenshot/pdf",
27
+ ]);
28
+ });
29
+
30
+ it("should keep a template mode off the slides tab", () => {
31
+ const paths = findModesForTab(SLIDES).map((mode) => mode.path);
32
+
33
+ expect(paths).not.toContain("app/presomanager/template-preview");
34
+ });
35
+
36
+ it("should offer a screenshot on both tabs", () => {
37
+ expect(findModeByPath("screenshot/thumbnail").tabs).toEqual([
38
+ SLIDES,
39
+ TEMPLATES,
40
+ ]);
41
+ });
42
+ });
43
+
44
+ describe("isStateOnTab", () => {
45
+ it("should offer a parent wherever a state under it is offered", () => {
46
+ expect(isStateOnTab(findState("presomanager"), TEMPLATES)).toBe(true);
47
+ });
48
+
49
+ it("should hide a parent whose states are all for the other tab", () => {
50
+ expect(isStateOnTab(findState("preso"), TEMPLATES)).toBe(true);
51
+ expect(isStateOnTab(findState("preset"), TEMPLATES)).toBe(false);
52
+ });
53
+
54
+ it("should pass a tab down to states that name none of their own", () => {
55
+ expect(isStateOnTab(findState("preso").children[0], TEMPLATES)).toBe(false);
56
+ });
57
+ });
58
+
59
+ describe("MODES", () => {
60
+ it("should keep a prep edit in the context and a PresoManager one in the cmsvals", () => {
61
+ expect(findModeByPath("app/preso/prep/prepping").editStore).toBe(
62
+ CONTEXT_OVERRIDES,
63
+ );
64
+ expect(findModeByPath("app/presomanager/edit").editStore).toBe(CMS_VALS);
65
+ });
66
+
67
+ it("should call a template preview read only", () => {
68
+ expect(findModeByPath("app/presomanager/template-preview").isReadOnly).toBe(
69
+ true,
70
+ );
71
+ });
72
+
73
+ it("should withhold the cmsvals from a template preview", () => {
74
+ expect(
75
+ findModeByPath("app/presomanager/template-preview").providesCmsVals,
76
+ ).toBe(false);
77
+ expect(
78
+ findModeByPath("app/preso/add-slides/template-preview").providesCmsVals,
79
+ ).toBe(false);
80
+ });
81
+
82
+ it("should pass the cmsvals to every other mode", () => {
83
+ expect(findModeByPath("app/presomanager/edit").providesCmsVals).toBe(true);
84
+ });
85
+
86
+ it("should place a saved instance under an autoadjunct", () => {
87
+ expect(
88
+ findModeByPath("app/presomanager/placed-template-saved").placement,
89
+ ).toEqual({ createdByTemplate: true, autoAdjunctID: 1 });
90
+ });
91
+
92
+ it("should leave a slide the deck declares unplaced", () => {
93
+ expect(findModeByPath("app/presomanager/edit").placement).toBeNull();
94
+ });
95
+ });
@@ -0,0 +1,7 @@
1
+ // Which half of a deck the stage is showing. Shared by the app and the dev
2
+ // server, so this file is .mjs alongside `modes.mjs`.
3
+ export const SLIDES = "slides";
4
+
5
+ export const TEMPLATES = "templates";
6
+
7
+ export const TABS = [SLIDES, TEMPLATES];