@kubohiroya/turbowarp-extension-data-editor 0.8.2 → 0.9.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.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-data-editor",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "repository": "https://github.com/kubohiroya/turbowarp-extension-data-editor",
5
- "revision": "28d7ca791fb696007ed014ebf3c2d28ba389a33a",
5
+ "revision": "2b78007136ce053b643ba36cad8526b9abb457a0",
6
6
  "sourceState": "commit",
7
- "sourceSha256": "fa5c13abb9fef48ea6c0e79eb01bbedc894927d2ef512fd33c9317d21a5027d6",
7
+ "sourceSha256": "5f500faea5d2ced27b0386d6ff550638f8ef78e2aac24a3ba0ec37c3c0afbc0d",
8
8
  "capabilities": {
9
9
  "preparedSource": 1
10
10
  }
@@ -52,6 +52,17 @@ function describe(context) {
52
52
  throw new TypeError('A fixed form requires a fixed session.');
53
53
  return result;
54
54
  }
55
+ /** Presentation issues plus the save-time check, so Save is disabled as soon as the draft would be rejected. */
56
+ function liveIssues(context) {
57
+ var _a;
58
+ const issues = [...describe(context).issues];
59
+ const checked = typeof context.checkFixedInput === 'function' ? (_a = context.checkFixedInput()) !== null && _a !== void 0 ? _a : [] : [];
60
+ for (const issue of checked) {
61
+ if (!issues.some(item => item.message === issue.message && item.path === issue.path))
62
+ issues.push(issue);
63
+ }
64
+ return issues;
65
+ }
55
66
  let nextFixedViewId = 0;
56
67
  /** The session owns every buffer, including controls temporarily absent from the DOM. */
57
68
  function FixedInputView({ context, messages }) {
@@ -87,7 +98,7 @@ function FixedInputView({ context, messages }) {
87
98
  entry.repair = true;
88
99
  Object.defineProperty(next.inputs, argument, { value: entry, enumerable: true, configurable: true, writable: true });
89
100
  context.setDraft(next);
90
- context.setValidationIssues(describe(context).issues);
101
+ context.setValidationIssues(liveIssues(context));
91
102
  };
92
103
  const hasInactiveEdits = Object.entries(description.inputs).some(([argument, input]) => input.state === 'hidden' && record(inputs[argument]) && inputs[argument].changed === true);
93
104
  return React.createElement("div", { className: "block-editor-fixed-inputs" },
package/dist/session.d.ts CHANGED
@@ -8,6 +8,11 @@ export declare class EditorSession implements EditorViewContext {
8
8
  get reference(): BlockReference;
9
9
  getDraft(): JsonObject;
10
10
  getFixedInputView(): FixedInputViewDescription | undefined;
11
+ /**
12
+ * Run the same synchronous check as save, without committing, so a fixed form can disable Save
13
+ * while the draft is invalid. Owner text is reduced to the editor's coded diagnostics, as on save.
14
+ */
15
+ checkFixedInput(): readonly ValidationIssue[] | undefined;
11
16
  setDraft(draft: JsonObject): void;
12
17
  setValidationIssues(issues: readonly ValidationIssue[]): void;
13
18
  getState(): SessionState;
package/dist/session.js CHANGED
@@ -133,6 +133,23 @@ export class EditorSession {
133
133
  throw new TypeError('Invalid fixed input presentation.');
134
134
  }
135
135
  }
136
+ /**
137
+ * Run the same synchronous check as save, without committing, so a fixed form can disable Save
138
+ * while the draft is invalid. Owner text is reduced to the editor's coded diagnostics, as on save.
139
+ */
140
+ checkFixedInput() {
141
+ __classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_assertOpen).call(this);
142
+ const definition = __classPrivateFieldGet(this, _EditorSession_definition, "f");
143
+ if (!isFixedInputEditor(definition))
144
+ return undefined;
145
+ try {
146
+ const prepared = captureFixedPreparedSave(definition, __classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_copyDraft).call(this, __classPrivateFieldGet(this, _EditorSession_draft, "f")), __classPrivateFieldGet(this, _EditorSession_snapshot, "f"));
147
+ return prepared.kind === 'invalid' ? __classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_copyIssues).call(this, prepared.issues) : Object.freeze([]);
148
+ }
149
+ catch (_a) {
150
+ return Object.freeze([Object.freeze({ message: 'Fixed input validation failed: fixed-check-unavailable.' })]);
151
+ }
152
+ }
136
153
  setDraft(draft) {
137
154
  if (__classPrivateFieldGet(this, _EditorSession_status, "f") !== 'editing')
138
155
  throw new Error('The session is not editable.');
package/dist/types.d.ts CHANGED
@@ -58,6 +58,11 @@ export interface EditorViewContext {
58
58
  getDraft(): JsonObject;
59
59
  /** Fixed views obtain only safe presentation data, never live host objects. */
60
60
  getFixedInputView?(): FixedInputViewDescription | undefined;
61
+ /**
62
+ * Run the save-time fixed check (encode, schema and owner validateCandidate) on the current draft.
63
+ * Unlike getFixedInputView, this calls owner callbacks, so views call it per edit, not per render.
64
+ */
65
+ checkFixedInput?(): readonly ValidationIssue[] | undefined;
61
66
  /** Updates are rejected after this view unmounts, even when its session stays open. */
62
67
  setDraft(draft: JsonObject): void;
63
68
  /** Report live UI validation; save() always independently validates again. */
package/dist/view.js CHANGED
@@ -41,6 +41,10 @@ export class EditorView {
41
41
  assertMounted();
42
42
  return owner.getFixedInputView();
43
43
  } } : {}),
44
+ ...(owner.checkFixedInput ? { checkFixedInput: () => {
45
+ assertMounted();
46
+ return owner.checkFixedInput();
47
+ } } : {}),
44
48
  setDraft: (draft) => { assertMounted(); owner.setDraft(draft); },
45
49
  setValidationIssues: (issues) => {
46
50
  assertMounted();
@@ -10,7 +10,7 @@ import {
10
10
  sameFixedSnapshot,
11
11
  supportsFixedInputEditing,
12
12
  supportsFixedInputs
13
- } from "./shared-FW4MRLXW.js";
13
+ } from "./shared-S623S2PV.js";
14
14
  import {
15
15
  BlockEditorConflictError,
16
16
  BlockEditorStructureError,
@@ -16,7 +16,7 @@
16
16
  "format": "esm"
17
17
  },
18
18
  "dist/view.js": {
19
- "bytes": 4330,
19
+ "bytes": 4513,
20
20
  "imports": [],
21
21
  "format": "esm"
22
22
  },
@@ -1873,7 +1873,7 @@
1873
1873
  "format": "esm"
1874
1874
  },
1875
1875
  "dist/session.js": {
1876
- "bytes": 29156,
1876
+ "bytes": 30322,
1877
1877
  "imports": [
1878
1878
  {
1879
1879
  "path": "dist/data.js",
@@ -3864,7 +3864,7 @@
3864
3864
  "format": "esm"
3865
3865
  },
3866
3866
  "dist/fixed-input-view.js": {
3867
- "bytes": 11471,
3867
+ "bytes": 12003,
3868
3868
  "imports": [
3869
3869
  {
3870
3870
  "path": "react",
@@ -14381,7 +14381,7 @@
14381
14381
  "kind": "import-statement"
14382
14382
  },
14383
14383
  {
14384
- "path": "dist/webpack4/shared-FW4MRLXW.js",
14384
+ "path": "dist/webpack4/shared-S623S2PV.js",
14385
14385
  "kind": "import-statement"
14386
14386
  },
14387
14387
  {
@@ -14425,12 +14425,12 @@
14425
14425
  "imports": [],
14426
14426
  "exports": [],
14427
14427
  "inputs": {},
14428
- "bytes": 1929924
14428
+ "bytes": 1930792
14429
14429
  },
14430
14430
  "dist/webpack4/rjsf.js": {
14431
14431
  "imports": [
14432
14432
  {
14433
- "path": "dist/webpack4/shared-FW4MRLXW.js",
14433
+ "path": "dist/webpack4/shared-S623S2PV.js",
14434
14434
  "kind": "import-statement"
14435
14435
  },
14436
14436
  {
@@ -15749,7 +15749,7 @@
15749
15749
  "bytesInOutput": 11809
15750
15750
  },
15751
15751
  "dist/fixed-input-view.js": {
15752
- "bytesInOutput": 10479
15752
+ "bytesInOutput": 10884
15753
15753
  },
15754
15754
  "node_modules/.pnpm/@rjsf+core@5.24.13_@rjsf+utils@5.24.13_react@16.14.0__react@16.14.0/node_modules/@rjsf/core/lib/index.js": {
15755
15755
  "bytesInOutput": 183
@@ -16829,7 +16829,7 @@
16829
16829
  "bytesInOutput": 11025
16830
16830
  }
16831
16831
  },
16832
- "bytes": 897850
16832
+ "bytes": 898255
16833
16833
  },
16834
16834
  "dist/webpack4/react.js.map": {
16835
16835
  "imports": [],
@@ -16884,7 +16884,7 @@
16884
16884
  "kind": "import-statement"
16885
16885
  },
16886
16886
  {
16887
- "path": "dist/webpack4/shared-FW4MRLXW.js",
16887
+ "path": "dist/webpack4/shared-S623S2PV.js",
16888
16888
  "kind": "import-statement"
16889
16889
  },
16890
16890
  {
@@ -16956,13 +16956,13 @@
16956
16956
  },
16957
16957
  "bytes": 44
16958
16958
  },
16959
- "dist/webpack4/shared-FW4MRLXW.js.map": {
16959
+ "dist/webpack4/shared-S623S2PV.js.map": {
16960
16960
  "imports": [],
16961
16961
  "exports": [],
16962
16962
  "inputs": {},
16963
- "bytes": 216305
16963
+ "bytes": 218331
16964
16964
  },
16965
- "dist/webpack4/shared-FW4MRLXW.js": {
16965
+ "dist/webpack4/shared-S623S2PV.js": {
16966
16966
  "imports": [
16967
16967
  {
16968
16968
  "path": "dist/webpack4/shared-BKTRZUZH.js",
@@ -17004,13 +17004,13 @@
17004
17004
  "bytesInOutput": 795
17005
17005
  },
17006
17006
  "dist/view.js": {
17007
- "bytesInOutput": 3894
17007
+ "bytesInOutput": 4035
17008
17008
  },
17009
17009
  "dist/prepared-save.js": {
17010
17010
  "bytesInOutput": 1886
17011
17011
  },
17012
17012
  "dist/session.js": {
17013
- "bytesInOutput": 26754
17013
+ "bytesInOutput": 27855
17014
17014
  },
17015
17015
  "dist/subtree.js": {
17016
17016
  "bytesInOutput": 4426
@@ -17025,7 +17025,7 @@
17025
17025
  "bytesInOutput": 10668
17026
17026
  }
17027
17027
  },
17028
- "bytes": 122791
17028
+ "bytes": 124033
17029
17029
  },
17030
17030
  "dist/webpack4/shared-BKTRZUZH.js.map": {
17031
17031
  "imports": [],
@@ -2,7 +2,7 @@ import {
2
2
  EditorRegistry,
3
3
  cloneJson,
4
4
  createFixedInputEditor
5
- } from "./shared-FW4MRLXW.js";
5
+ } from "./shared-S623S2PV.js";
6
6
  import {
7
7
  EDITOR_API_VERSION
8
8
  } from "./shared-BKTRZUZH.js";
@@ -13036,6 +13036,16 @@ function describe(context) {
13036
13036
  throw new TypeError("A fixed form requires a fixed session.");
13037
13037
  return result;
13038
13038
  }
13039
+ function liveIssues2(context) {
13040
+ var _a;
13041
+ const issues = [...describe(context).issues];
13042
+ const checked = typeof context.checkFixedInput === "function" ? (_a = context.checkFixedInput()) !== null && _a !== void 0 ? _a : [] : [];
13043
+ for (const issue2 of checked) {
13044
+ if (!issues.some((item) => item.message === issue2.message && item.path === issue2.path))
13045
+ issues.push(issue2);
13046
+ }
13047
+ return issues;
13048
+ }
13039
13049
  var nextFixedViewId = 0;
13040
13050
  function FixedInputView({ context, messages }) {
13041
13051
  const [, redraw] = React4.useState(0);
@@ -13070,7 +13080,7 @@ function FixedInputView({ context, messages }) {
13070
13080
  entry.repair = true;
13071
13081
  Object.defineProperty(next.inputs, argument, { value: entry, enumerable: true, configurable: true, writable: true });
13072
13082
  context.setDraft(next);
13073
- context.setValidationIssues(describe(context).issues);
13083
+ context.setValidationIssues(liveIssues2(context));
13074
13084
  };
13075
13085
  const hasInactiveEdits = Object.entries(description.inputs).some(([argument, input]) => input.state === "hidden" && record4(inputs[argument]) && inputs[argument].changed === true);
13076
13086
  return React4.createElement(