@kubohiroya/turbowarp-extension-data-editor 0.1.0 → 0.2.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.
- package/README.md +24 -3
- package/dist/build-info.json +7 -2
- package/dist/descendants.js +11 -2
- package/dist/index.d.ts +1 -0
- package/dist/json-value.d.ts +4 -0
- package/dist/json-value.js +12 -0
- package/dist/prepared-save.d.ts +5 -0
- package/dist/prepared-save.js +47 -0
- package/dist/prepared-types.d.ts +13 -0
- package/dist/prepared-types.js +1 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +57 -45
- package/dist/rjsf.d.ts +25 -1
- package/dist/rjsf.js +70 -6
- package/dist/schema-compose.d.ts +6 -0
- package/dist/schema-compose.js +103 -0
- package/dist/schema-engine.d.ts +18 -0
- package/dist/schema-engine.js +298 -0
- package/dist/schema-json.d.ts +10 -0
- package/dist/schema-json.js +68 -0
- package/dist/schema-types.d.ts +161 -0
- package/dist/schema-types.js +2 -0
- package/dist/schema-view.d.ts +7 -0
- package/dist/schema-view.js +102 -0
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +86 -0
- package/dist/session.d.ts +1 -1
- package/dist/session.js +18 -5
- package/dist/source-document.d.ts +3 -0
- package/dist/source-document.js +415 -0
- package/dist/source-editor.d.ts +13 -0
- package/dist/source-editor.js +235 -0
- package/dist/source-schema-hints.d.ts +3 -0
- package/dist/source-schema-hints.js +13 -0
- package/dist/source-types.d.ts +47 -0
- package/dist/source-types.js +1 -0
- package/dist/source-view.d.ts +3 -0
- package/dist/source-view.js +318 -0
- package/dist/types.d.ts +2 -4
- package/dist/webpack4/index.js +4 -2
- package/dist/webpack4/metafile.json +9551 -8644
- package/dist/webpack4/react.js +2 -1
- package/dist/webpack4/react.js.map +1 -1
- package/dist/webpack4/rjsf.js +15014 -20975
- package/dist/webpack4/rjsf.js.map +4 -4
- package/dist/webpack4/schema.js +17 -0
- package/dist/webpack4/schema.js.map +7 -0
- package/dist/webpack4/shared-BKTRZUZH.js +42 -0
- package/dist/webpack4/{shared-KIFRVTSM.js.map → shared-BKTRZUZH.js.map} +1 -1
- package/dist/webpack4/shared-KQOUMWJ4.js +8490 -0
- package/dist/webpack4/shared-KQOUMWJ4.js.map +7 -0
- package/dist/webpack4/shared-MRPGBJIH.js +75 -0
- package/dist/webpack4/shared-MRPGBJIH.js.map +7 -0
- package/dist/webpack4/{shared-WHOAW2VF.js → shared-N6YQE2X6.js} +116 -44
- package/dist/webpack4/shared-N6YQE2X6.js.map +7 -0
- package/dist/webpack4/{shared-KIFRVTSM.js → shared-RN7GOT65.js} +2 -41
- package/dist/webpack4/shared-RN7GOT65.js.map +7 -0
- package/dist/webpack4/turbowarp.js +4 -2
- package/dist/webpack4/turbowarp.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/block-editor-e2e.md +98 -16
- package/docs/ci-success-gate.md +84 -0
- package/docs/editor/issue-12-public-validation/README.md +61 -0
- package/docs/editor/issue-12-public-validation/dark-invalid.png +0 -0
- package/docs/editor/issue-12-public-validation/dark-styles.json +173 -0
- package/docs/editor/issue-12-public-validation/dark-valid.png +0 -0
- package/docs/editor/issue-12-public-validation/deployment-target.json +5 -0
- package/docs/editor/issue-12-public-validation/deployment-wait.json +7 -0
- package/docs/editor/issue-12-public-validation/light-invalid.png +0 -0
- package/docs/editor/issue-12-public-validation/light-styles.json +173 -0
- package/docs/editor/issue-12-public-validation/light-valid.png +0 -0
- package/docs/editor/issue-12-public-validation/provenance.json +88 -0
- package/docs/editor/issue-12-public-validation/results.json +677 -0
- package/docs/editor/issue-12-public-validation/summary.json +206 -0
- package/docs/github-pages.md +48 -41
- package/docs/package-distribution.md +2 -2
- package/docs/schema-stage1-browser.json +10 -0
- package/docs/schema-stage1-contracts.json +242 -0
- package/docs/schema-stage1-dependencies.json +202 -0
- package/docs/schema-stage1-git-artifact-20261018.ja.md +17 -0
- package/docs/schema-stage1-profile-compat.json +30 -0
- package/docs/schema-stage1-review-fixes-20261018.ja.md +36 -0
- package/docs/schema-stage1-verification.json +541 -0
- package/docs/schema-stage1.ja.md +80 -0
- package/docs/schema.md +43 -0
- package/docs/source-forms.ja.md +19 -0
- package/docs/stage-2-publication.ja.md +29 -0
- package/docs/template-fixture-separation.ja.md +43 -0
- package/package.json +11 -3
- package/webpack4.cjs +1 -1
- package/dist/webpack4/shared-WHOAW2VF.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SchemaBundle } from './schema-types.js';
|
|
2
|
+
import type { RJSFSchema, ErrorSchema } from '@rjsf/utils';
|
|
3
|
+
import type { ValidationIssue } from './types.js';
|
|
4
|
+
/** RJSF v5 only resolves fragment pointers; flatten a private, already checked resource graph. */
|
|
5
|
+
export declare function schemaView(input: SchemaBundle): RJSFSchema;
|
|
6
|
+
/** Keep literal property names, including dots and pointer escapes, intact. */
|
|
7
|
+
export declare function fieldErrors(issues: readonly ValidationIssue[]): ErrorSchema;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
3
|
+
import formats from 'ajv-formats';
|
|
4
|
+
import uri from 'fast-uri';
|
|
5
|
+
import { prepare } from './schema-engine.js';
|
|
6
|
+
import { snapshotJson } from './schema-json.js';
|
|
7
|
+
/** RJSF v5 only resolves fragment pointers; flatten a private, already checked resource graph. */
|
|
8
|
+
export function schemaView(input) {
|
|
9
|
+
const bundle = snapshotJson(input);
|
|
10
|
+
const ajv = bundle.dialect === 'draft-07' ? new Ajv({ strict: false }) : new Ajv2020({ strict: false });
|
|
11
|
+
formats.default(ajv);
|
|
12
|
+
const prepared = prepare(bundle, ajv);
|
|
13
|
+
const pointerFor = (reference, base) => {
|
|
14
|
+
const absolute = uri.normalize(uri.resolve(base, reference)).replace(/#$/, '');
|
|
15
|
+
let location = prepared.registry.get(absolute);
|
|
16
|
+
if (location === undefined) {
|
|
17
|
+
const hash = absolute.indexOf('#');
|
|
18
|
+
const resource = prepared.registry.get(hash < 0 ? absolute : absolute.slice(0, hash));
|
|
19
|
+
const fragment = hash < 0 ? '' : decodeURIComponent(absolute.slice(hash + 1));
|
|
20
|
+
if (resource === undefined || (fragment !== '' && !fragment.startsWith('/')))
|
|
21
|
+
throw new TypeError('Unsupported form reference.');
|
|
22
|
+
location = resource + fragment;
|
|
23
|
+
}
|
|
24
|
+
const slash = location.indexOf('/');
|
|
25
|
+
const index = slash < 0 ? location : location.slice(0, slash);
|
|
26
|
+
return `#${encodeURIComponent(`/definitions/__resource${index}${slash < 0 ? '' : location.slice(slash)}`).replace(/%2F/g, '/')}`;
|
|
27
|
+
};
|
|
28
|
+
for (const { node, base } of prepared.nodes) {
|
|
29
|
+
// These constructs cannot be represented faithfully by this RJSF version.
|
|
30
|
+
if ('$dynamicRef' in node || '$recursiveRef' in node || 'prefixItems' in node)
|
|
31
|
+
throw new TypeError('Unsupported form schema keyword.');
|
|
32
|
+
if (typeof node.$ref === 'string')
|
|
33
|
+
node.$ref = pointerFor(node.$ref, base);
|
|
34
|
+
// Every reference is now absolute within the presentation wrapper; canonical documents are untouched.
|
|
35
|
+
delete node.$id;
|
|
36
|
+
delete node.$anchor;
|
|
37
|
+
delete node.$dynamicAnchor;
|
|
38
|
+
}
|
|
39
|
+
if (typeof bundle.root.document === 'boolean')
|
|
40
|
+
throw new TypeError('A form requires an object schema.');
|
|
41
|
+
const view = { $schema: bundle.dialect === 'draft-07' ? 'http://json-schema.org/draft-07/schema#' : 'https://json-schema.org/draft/2020-12/schema',
|
|
42
|
+
definitions: Object.fromEntries(prepared.resources.map((resource, index) => [`__resource${index}`, resource.document])),
|
|
43
|
+
$ref: '#/definitions/__resource0' };
|
|
44
|
+
assertFiniteObjectRendering(view, prepared.nodes.map(({ node }) => node));
|
|
45
|
+
return view;
|
|
46
|
+
}
|
|
47
|
+
// RJSF eagerly expands object defaults even for absent optional properties. Array items
|
|
48
|
+
// are expanded only for actual elements, so recursion through arrays remains supported.
|
|
49
|
+
function assertFiniteObjectRendering(root, seeds) {
|
|
50
|
+
const active = new Set(), done = new Set();
|
|
51
|
+
const visit = (value) => {
|
|
52
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
53
|
+
return;
|
|
54
|
+
if (active.has(value))
|
|
55
|
+
throw new TypeError('Unsupported recursive object form schema.');
|
|
56
|
+
if (done.has(value))
|
|
57
|
+
return;
|
|
58
|
+
active.add(value);
|
|
59
|
+
const node = value;
|
|
60
|
+
if (typeof node.$ref === 'string') {
|
|
61
|
+
let target = root;
|
|
62
|
+
for (const segment of decodeURIComponent(node.$ref.slice(1)).slice(1).split('/')) {
|
|
63
|
+
target = target[segment.replace(/~1/g, '/').replace(/~0/g, '~')];
|
|
64
|
+
}
|
|
65
|
+
visit(target);
|
|
66
|
+
}
|
|
67
|
+
for (const key of ['properties', 'patternProperties', 'dependentSchemas', 'dependencies']) {
|
|
68
|
+
const map = node[key];
|
|
69
|
+
if (map && typeof map === 'object')
|
|
70
|
+
Object.values(map).forEach(visit);
|
|
71
|
+
}
|
|
72
|
+
for (const key of ['allOf', 'anyOf', 'oneOf'])
|
|
73
|
+
if (Array.isArray(node[key]))
|
|
74
|
+
node[key].forEach(visit);
|
|
75
|
+
for (const key of ['additionalProperties', 'if', 'then', 'else'])
|
|
76
|
+
visit(node[key]);
|
|
77
|
+
active.delete(value);
|
|
78
|
+
done.add(value);
|
|
79
|
+
};
|
|
80
|
+
visit(root);
|
|
81
|
+
seeds.forEach(visit);
|
|
82
|
+
}
|
|
83
|
+
/** Keep literal property names, including dots and pointer escapes, intact. */
|
|
84
|
+
export function fieldErrors(issues) {
|
|
85
|
+
const root = Object.create(null);
|
|
86
|
+
for (const issue of issues) {
|
|
87
|
+
let node = root;
|
|
88
|
+
const path = issue.path;
|
|
89
|
+
const segments = (path === null || path === void 0 ? void 0 : path.startsWith('/')) ? path.slice(1).split('/').map(s => s.replace(/~1/g, '/').replace(/~0/g, '~')) : [];
|
|
90
|
+
// RJSF reserves __errors; retain this diagnostic at the root rather than losing it.
|
|
91
|
+
if (!segments.includes('__errors'))
|
|
92
|
+
for (const segment of segments) {
|
|
93
|
+
if (!Object.hasOwn(node, segment))
|
|
94
|
+
Object.defineProperty(node, segment, { value: Object.create(null), enumerable: true });
|
|
95
|
+
node = node[segment];
|
|
96
|
+
}
|
|
97
|
+
if (!Object.hasOwn(node, '__errors'))
|
|
98
|
+
Object.defineProperty(node, '__errors', { value: [], enumerable: true });
|
|
99
|
+
node.__errors.push(issue.message);
|
|
100
|
+
}
|
|
101
|
+
return root;
|
|
102
|
+
}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputDiagnostic, ValidationIssue } from './schema-types.js';
|
|
2
|
+
export type * from './schema-types.js';
|
|
3
|
+
export { compileSchemaBundle } from './schema-engine.js';
|
|
4
|
+
export { validateSchemaInput } from './schema-compose.js';
|
|
5
|
+
/** Convert input diagnostics without copying raw data or changing JSON Pointer paths. */
|
|
6
|
+
export declare function toValidationIssues(diagnostics: readonly InputDiagnostic[]): readonly ValidationIssue[];
|
|
7
|
+
export type * from './source-types.js';
|
|
8
|
+
export { jsonValueSchema, jsonValueSchemaBundle } from './json-value.js';
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export { compileSchemaBundle } from './schema-engine.js';
|
|
2
|
+
export { validateSchemaInput } from './schema-compose.js';
|
|
3
|
+
const messages = {
|
|
4
|
+
'input-format-invalid': 'Input format is invalid.',
|
|
5
|
+
'variant-unrecognized': 'Input variant is not recognized.',
|
|
6
|
+
'input-not-json': 'Input must be a JSON-compatible value.',
|
|
7
|
+
'schema-data-invalid': 'Value does not satisfy the schema.',
|
|
8
|
+
'owner-input-invalid': 'Value does not satisfy the owner input rules.'
|
|
9
|
+
};
|
|
10
|
+
function isRecord(value) {
|
|
11
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
function isPointer(value) {
|
|
14
|
+
return typeof value === 'string' && (value === '' || value.startsWith('/')) && !/~(?:[^01]|$)/u.test(value);
|
|
15
|
+
}
|
|
16
|
+
function readValidationIssue(value) {
|
|
17
|
+
if (!isRecord(value))
|
|
18
|
+
throw new TypeError();
|
|
19
|
+
const scope = value.scope;
|
|
20
|
+
if (!isRecord(scope))
|
|
21
|
+
throw new TypeError();
|
|
22
|
+
const identity = scope.identity;
|
|
23
|
+
if (!isRecord(identity))
|
|
24
|
+
throw new TypeError();
|
|
25
|
+
if (['ownerId', 'contractId', 'revision', 'variantId'].some(key => typeof identity[key] !== 'string')) {
|
|
26
|
+
throw new TypeError();
|
|
27
|
+
}
|
|
28
|
+
if ('consumerId' in scope && typeof scope.consumerId !== 'string')
|
|
29
|
+
throw new TypeError();
|
|
30
|
+
if ('resourceUri' in value && typeof value.resourceUri !== 'string')
|
|
31
|
+
throw new TypeError();
|
|
32
|
+
if ('schemaPath' in value && !isPointer(value.schemaPath))
|
|
33
|
+
throw new TypeError();
|
|
34
|
+
// Keep primitives locally so accessors cannot change them between validation and conversion.
|
|
35
|
+
const dataPath = value.dataPath;
|
|
36
|
+
const phase = value.phase;
|
|
37
|
+
const code = value.code;
|
|
38
|
+
if (!isPointer(dataPath))
|
|
39
|
+
throw new TypeError();
|
|
40
|
+
switch (phase) {
|
|
41
|
+
case 'decode':
|
|
42
|
+
if (code !== 'input-format-invalid' && code !== 'variant-unrecognized')
|
|
43
|
+
throw new TypeError();
|
|
44
|
+
break;
|
|
45
|
+
case 'structure':
|
|
46
|
+
if (code !== 'input-not-json' && code !== 'schema-data-invalid')
|
|
47
|
+
throw new TypeError();
|
|
48
|
+
if ('keyword' in value && typeof value.keyword !== 'string')
|
|
49
|
+
throw new TypeError();
|
|
50
|
+
break;
|
|
51
|
+
case 'semantic':
|
|
52
|
+
if (code !== 'owner-input-invalid' || typeof value.ruleId !== 'string')
|
|
53
|
+
throw new TypeError();
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new TypeError();
|
|
57
|
+
}
|
|
58
|
+
return Object.freeze({ message: messages[code], path: dataPath });
|
|
59
|
+
}
|
|
60
|
+
/** Convert input diagnostics without copying raw data or changing JSON Pointer paths. */
|
|
61
|
+
export function toValidationIssues(diagnostics) {
|
|
62
|
+
try {
|
|
63
|
+
if (!Array.isArray(diagnostics))
|
|
64
|
+
throw new TypeError();
|
|
65
|
+
const length = diagnostics.length;
|
|
66
|
+
if (!Number.isSafeInteger(length) || length < 0)
|
|
67
|
+
throw new TypeError();
|
|
68
|
+
// Snapshot indexed elements before invoking diagnostic getters. Ignore input iterators.
|
|
69
|
+
const snapshot = [];
|
|
70
|
+
for (let index = 0; index < length; index++) {
|
|
71
|
+
if (!Object.hasOwn(diagnostics, index))
|
|
72
|
+
throw new TypeError();
|
|
73
|
+
snapshot.push(diagnostics[index]);
|
|
74
|
+
}
|
|
75
|
+
const issues = [];
|
|
76
|
+
for (let index = 0; index < length; index++) {
|
|
77
|
+
issues.push(readValidationIssue(snapshot[index]));
|
|
78
|
+
}
|
|
79
|
+
return Object.freeze(issues);
|
|
80
|
+
}
|
|
81
|
+
catch (_a) {
|
|
82
|
+
// Never expose an external value or a getter's exception through this boundary.
|
|
83
|
+
throw new TypeError('Invalid input diagnostic.');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export { jsonValueSchema, jsonValueSchemaBundle } from './json-value.js';
|
package/dist/session.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { BlockEditorHost, BlockReference, BlockSnapshot, EditorDefinition,
|
|
|
2
2
|
export declare class EditorSession implements EditorViewContext {
|
|
3
3
|
#private;
|
|
4
4
|
/** Use EditorRegistry.open() to construct sessions from a captured host snapshot. */
|
|
5
|
-
constructor(definition: EditorDefinition, snapshot: BlockSnapshot, host: BlockEditorHost);
|
|
5
|
+
constructor(definition: EditorDefinition, snapshot: BlockSnapshot, host: BlockEditorHost, isRegistered?: () => boolean);
|
|
6
6
|
/** Stable instance identity remains available after the session closes. */
|
|
7
7
|
get reference(): BlockReference;
|
|
8
8
|
getDraft(): JsonObject;
|
package/dist/session.js
CHANGED
|
@@ -9,13 +9,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _EditorSession_instances, _EditorSession_draft, _EditorSession_status, _EditorSession_issues, _EditorSession_error, _EditorSession_listeners, _EditorSession_view, _EditorSession_definition, _EditorSession_snapshot, _EditorSession_host, _EditorSession_prepareChanges, _EditorSession_copyIssues, _EditorSession_copyDraft, _EditorSession_assertOpen, _EditorSession_finish, _EditorSession_notify, _EditorSession_reportObserverError;
|
|
12
|
+
var _EditorSession_instances, _EditorSession_draft, _EditorSession_status, _EditorSession_issues, _EditorSession_error, _EditorSession_listeners, _EditorSession_view, _EditorSession_definition, _EditorSession_snapshot, _EditorSession_host, _EditorSession_isRegistered, _EditorSession_prepareChanges, _EditorSession_copyIssues, _EditorSession_copyDraft, _EditorSession_assertOpen, _EditorSession_finish, _EditorSession_notify, _EditorSession_reportObserverError;
|
|
13
13
|
import { captureReference, captureSnapshot, cloneJson, isLiteral, sameSnapshot } from './data.js';
|
|
14
14
|
import { BlockEditorConflictError } from './types.js';
|
|
15
15
|
import { EditorView } from './view.js';
|
|
16
|
+
import { isPreparedEditor, capturePreparedSave } from './prepared-save.js';
|
|
16
17
|
export class EditorSession {
|
|
17
18
|
/** Use EditorRegistry.open() to construct sessions from a captured host snapshot. */
|
|
18
|
-
constructor(definition, snapshot, host) {
|
|
19
|
+
constructor(definition, snapshot, host, isRegistered) {
|
|
19
20
|
_EditorSession_instances.add(this);
|
|
20
21
|
_EditorSession_draft.set(this, void 0);
|
|
21
22
|
_EditorSession_status.set(this, 'editing');
|
|
@@ -26,6 +27,8 @@ export class EditorSession {
|
|
|
26
27
|
_EditorSession_definition.set(this, void 0);
|
|
27
28
|
_EditorSession_snapshot.set(this, void 0);
|
|
28
29
|
_EditorSession_host.set(this, void 0);
|
|
30
|
+
_EditorSession_isRegistered.set(this, void 0);
|
|
31
|
+
__classPrivateFieldSet(this, _EditorSession_isRegistered, isRegistered, "f");
|
|
29
32
|
__classPrivateFieldSet(this, _EditorSession_definition, definition, "f");
|
|
30
33
|
__classPrivateFieldSet(this, _EditorSession_snapshot, captureSnapshot(snapshot, captureReference(snapshot)), "f");
|
|
31
34
|
__classPrivateFieldSet(this, _EditorSession_host, host, "f");
|
|
@@ -77,18 +80,28 @@ export class EditorSession {
|
|
|
77
80
|
__classPrivateFieldSet(this, _EditorSession_error, undefined, "f");
|
|
78
81
|
__classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_notify).call(this);
|
|
79
82
|
try {
|
|
80
|
-
|
|
83
|
+
if (__classPrivateFieldGet(this, _EditorSession_isRegistered, "f") && !__classPrivateFieldGet(this, _EditorSession_isRegistered, "f").call(this))
|
|
84
|
+
throw new BlockEditorConflictError('The source editor registration expired.');
|
|
85
|
+
const prepared = isPreparedEditor(__classPrivateFieldGet(this, _EditorSession_definition, "f"))
|
|
86
|
+
? capturePreparedSave(__classPrivateFieldGet(this, _EditorSession_definition, "f"), cloneJson(__classPrivateFieldGet(this, _EditorSession_draft, "f")), __classPrivateFieldGet(this, _EditorSession_snapshot, "f")) : undefined;
|
|
87
|
+
const issues = prepared ? (prepared.kind === 'invalid' ? prepared.issues : [])
|
|
88
|
+
: await __classPrivateFieldGet(this, _EditorSession_definition, "f").validate(cloneJson(__classPrivateFieldGet(this, _EditorSession_draft, "f")), __classPrivateFieldGet(this, _EditorSession_snapshot, "f"));
|
|
81
89
|
if (!Array.isArray(issues))
|
|
82
90
|
throw new TypeError('validate() must return an issue array.');
|
|
83
91
|
if (issues.length > 0) {
|
|
84
92
|
__classPrivateFieldSet(this, _EditorSession_issues, __classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_copyIssues).call(this, issues), "f");
|
|
85
93
|
return { status: 'invalid', issues: __classPrivateFieldGet(this, _EditorSession_issues, "f") };
|
|
86
94
|
}
|
|
87
|
-
const changes = __classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_prepareChanges).call(this,
|
|
95
|
+
const changes = __classPrivateFieldGet(this, _EditorSession_instances, "m", _EditorSession_prepareChanges).call(this, (prepared === null || prepared === void 0 ? void 0 : prepared.kind) === 'ready' ? prepared.changes
|
|
96
|
+
: __classPrivateFieldGet(this, _EditorSession_definition, "f").createPatch(cloneJson(__classPrivateFieldGet(this, _EditorSession_draft, "f")), __classPrivateFieldGet(this, _EditorSession_snapshot, "f")));
|
|
97
|
+
if (__classPrivateFieldGet(this, _EditorSession_isRegistered, "f") && !__classPrivateFieldGet(this, _EditorSession_isRegistered, "f").call(this))
|
|
98
|
+
throw new BlockEditorConflictError('The source editor registration expired.');
|
|
88
99
|
const current = __classPrivateFieldGet(this, _EditorSession_host, "f").readBlock(__classPrivateFieldGet(this, _EditorSession_snapshot, "f"));
|
|
89
100
|
if (!current || !sameSnapshot(__classPrivateFieldGet(this, _EditorSession_snapshot, "f"), captureSnapshot(current, __classPrivateFieldGet(this, _EditorSession_snapshot, "f")))) {
|
|
90
101
|
throw new BlockEditorConflictError();
|
|
91
102
|
}
|
|
103
|
+
if (__classPrivateFieldGet(this, _EditorSession_isRegistered, "f") && !__classPrivateFieldGet(this, _EditorSession_isRegistered, "f").call(this))
|
|
104
|
+
throw new BlockEditorConflictError('The source editor registration expired.');
|
|
92
105
|
if (changes.length > 0) {
|
|
93
106
|
await __classPrivateFieldGet(this, _EditorSession_host, "f").commit(Object.freeze({ expected: __classPrivateFieldGet(this, _EditorSession_snapshot, "f"), changes }));
|
|
94
107
|
}
|
|
@@ -122,7 +135,7 @@ export class EditorSession {
|
|
|
122
135
|
return true;
|
|
123
136
|
}
|
|
124
137
|
}
|
|
125
|
-
_EditorSession_draft = new WeakMap(), _EditorSession_status = new WeakMap(), _EditorSession_issues = new WeakMap(), _EditorSession_error = new WeakMap(), _EditorSession_listeners = new WeakMap(), _EditorSession_view = new WeakMap(), _EditorSession_definition = new WeakMap(), _EditorSession_snapshot = new WeakMap(), _EditorSession_host = new WeakMap(), _EditorSession_instances = new WeakSet(), _EditorSession_prepareChanges = function _EditorSession_prepareChanges(patch) {
|
|
138
|
+
_EditorSession_draft = new WeakMap(), _EditorSession_status = new WeakMap(), _EditorSession_issues = new WeakMap(), _EditorSession_error = new WeakMap(), _EditorSession_listeners = new WeakMap(), _EditorSession_view = new WeakMap(), _EditorSession_definition = new WeakMap(), _EditorSession_snapshot = new WeakMap(), _EditorSession_host = new WeakMap(), _EditorSession_isRegistered = new WeakMap(), _EditorSession_instances = new WeakSet(), _EditorSession_prepareChanges = function _EditorSession_prepareChanges(patch) {
|
|
126
139
|
if (!Array.isArray(patch))
|
|
127
140
|
throw new TypeError('createPatch() must return an array.');
|
|
128
141
|
const seen = new Set();
|