@kubohiroya/turbowarp-extension-data-editor 0.8.0 → 0.8.2
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.ja.md +2 -1
- package/README.md +2 -1
- package/dist/build-info.json +3 -3
- package/dist/form-presentation.d.ts +1 -1
- package/dist/form-presentation.js +2 -0
- package/dist/react.js +3 -0
- package/dist/turbowarp/appearance.d.ts +7 -6
- package/dist/turbowarp/bridge.d.ts +14 -19
- package/dist/turbowarp/bridge.js +21 -16
- package/dist/turbowarp/error-session.d.ts +3 -17
- package/dist/turbowarp/error-session.js +2 -2
- package/dist/turbowarp/fixed-fields.d.ts +62 -77
- package/dist/turbowarp/fixed-fields.js +6 -6
- package/dist/turbowarp/fixed-transaction.d.ts +23 -18
- package/dist/turbowarp/fixed-transaction.js +13 -13
- package/dist/turbowarp/host.d.ts +2 -18
- package/dist/turbowarp/host.js +9 -6
- package/dist/turbowarp/icon.d.ts +1 -8
- package/dist/turbowarp/icon.js +6 -6
- package/dist/turbowarp/native-types.d.ts +136 -0
- package/dist/turbowarp/native-types.js +1 -0
- package/dist/turbowarp/subtree.d.ts +12 -9
- package/dist/turbowarp/subtree.js +3 -2
- package/dist/webpack4/metafile.json +22 -22
- package/dist/webpack4/react.js +1 -0
- package/dist/webpack4/react.js.map +2 -2
- package/dist/webpack4/rjsf.js +2 -0
- package/dist/webpack4/rjsf.js.map +2 -2
- package/dist/webpack4/turbowarp.js +36 -29
- package/dist/webpack4/turbowarp.js.map +2 -2
- package/docs/ci-success-gate.md +2 -2
- package/docs/common-layout.ja.md +4 -4
- package/docs/descendants.md +2 -2
- package/docs/dialog-window.md +2 -2
- package/docs/schema-stage1.ja.md +3 -3
- package/docs/template-fixture-separation.ja.md +5 -5
- package/package.json +7 -5
- package/webpack4.cjs +19 -20
|
@@ -24,9 +24,10 @@ var collectBlockEditorSubtree = ({ ScratchBlocks, reference, inspect, generation
|
|
|
24
24
|
const nodes = [];
|
|
25
25
|
const records = /* @__PURE__ */ new Map();
|
|
26
26
|
const pending = {};
|
|
27
|
-
|
|
27
|
+
function invalid(message) {
|
|
28
28
|
throw new BlockEditorStructureError(message, "invalid-structure");
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
|
+
;
|
|
30
31
|
const visit = (id, depth) => {
|
|
31
32
|
if (records.has(id)) {
|
|
32
33
|
throw new BlockEditorStructureError("A statement block is connected more than once.", "cycle");
|
|
@@ -133,7 +134,7 @@ var safeField = (field, Class) => {
|
|
|
133
134
|
if (currentPrototype !== entry.prototype)
|
|
134
135
|
return false;
|
|
135
136
|
for (const [name, expected] of entry.own) {
|
|
136
|
-
const actual = Object.getOwnPropertyDescriptor(
|
|
137
|
+
const actual = Object.getOwnPropertyDescriptor(entry.prototype, name);
|
|
137
138
|
if (Boolean(actual) !== Boolean(expected) || actual && (!("value" in actual) || !expected || !("value" in expected) || actual.value !== expected.value))
|
|
138
139
|
return false;
|
|
139
140
|
}
|
|
@@ -248,7 +249,7 @@ function inspectFixedArgument({ ScratchBlocks, block, vmBlock, target, argument,
|
|
|
248
249
|
signatureParts: sourceIdentity
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
|
-
|
|
252
|
+
const owner = direct ? block : connected;
|
|
252
253
|
if (!owner) {
|
|
253
254
|
if (vmBlock.fields && owns(vmBlock.fields, argument))
|
|
254
255
|
return null;
|
|
@@ -292,7 +293,7 @@ function inspectFixedArgument({ ScratchBlocks, block, vmBlock, target, argument,
|
|
|
292
293
|
}
|
|
293
294
|
if (names.length !== 1)
|
|
294
295
|
return unavailable("unsupported", "The menu shadow does not have one standard field.");
|
|
295
|
-
|
|
296
|
+
name = names[0];
|
|
296
297
|
} else
|
|
297
298
|
return unavailable("unsupported", "The shadow field family is unsupported.");
|
|
298
299
|
const field = direct || owner.getField(name);
|
|
@@ -412,7 +413,7 @@ function restoreFixedField(binding) {
|
|
|
412
413
|
|
|
413
414
|
// dist/turbowarp/fixed-transaction.js
|
|
414
415
|
var own2 = (object, name) => {
|
|
415
|
-
const descriptor = object
|
|
416
|
+
const descriptor = object ? Object.getOwnPropertyDescriptor(object, name) : void 0;
|
|
416
417
|
if (!descriptor || !Object.prototype.hasOwnProperty.call(descriptor, "value")) {
|
|
417
418
|
throw new TypeError("Expected an own data property.");
|
|
418
419
|
}
|
|
@@ -430,7 +431,8 @@ var inheritedData = (object, key) => {
|
|
|
430
431
|
return void 0;
|
|
431
432
|
};
|
|
432
433
|
var ensureNativeHistory = (stack) => {
|
|
433
|
-
|
|
434
|
+
var _a;
|
|
435
|
+
if (!Array.isArray(stack) || !Object.isExtensible(stack) || Object.getOwnPropertySymbols(stack).length || !((_a = Object.getOwnPropertyDescriptor(stack, "length")) === null || _a === void 0 ? void 0 : _a.writable)) {
|
|
434
436
|
throw new TypeError("Unsupported undo history.");
|
|
435
437
|
}
|
|
436
438
|
if (Object.getOwnPropertyNames(stack).length !== stack.length + 1)
|
|
@@ -453,13 +455,13 @@ var replaceHistory = (stack, values) => {
|
|
|
453
455
|
for (const value of values)
|
|
454
456
|
Array.prototype.push.call(stack, value);
|
|
455
457
|
};
|
|
456
|
-
|
|
458
|
+
function conflict() {
|
|
457
459
|
throw new BlockEditorConflictError();
|
|
458
|
-
}
|
|
460
|
+
}
|
|
459
461
|
var aborted = Object.getOwnPropertyDescriptor(AbortSignal.prototype, "aborted").get;
|
|
460
462
|
var isAborted = (signal) => aborted.call(signal);
|
|
461
463
|
var optionalOwn = (object, name) => {
|
|
462
|
-
const descriptor = object
|
|
464
|
+
const descriptor = object ? Object.getOwnPropertyDescriptor(object, name) : void 0;
|
|
463
465
|
if (descriptor && !Object.prototype.hasOwnProperty.call(descriptor, "value")) {
|
|
464
466
|
throw new TypeError("VM state must contain data properties.");
|
|
465
467
|
}
|
|
@@ -656,7 +658,7 @@ function createFixedInputPort({ ScratchBlocks, workspace, vm, registry, identify
|
|
|
656
658
|
ensureNativeHistory(redoStack);
|
|
657
659
|
const configuredMaxUndo = inheritedData(workspace, "MAX_UNDO");
|
|
658
660
|
const maxUndo = configuredMaxUndo === void 0 ? Infinity : configuredMaxUndo;
|
|
659
|
-
if (maxUndo !== Infinity && (!Number.isSafeInteger(maxUndo) || maxUndo < 0)) {
|
|
661
|
+
if (typeof maxUndo !== "number" || maxUndo !== Infinity && (!Number.isSafeInteger(maxUndo) || maxUndo < 0)) {
|
|
660
662
|
throw new TypeError("Unsupported undo configuration.");
|
|
661
663
|
}
|
|
662
664
|
const undo = copyHistory(undoStack);
|
|
@@ -711,7 +713,6 @@ function createFixedInputPort({ ScratchBlocks, workspace, vm, registry, identify
|
|
|
711
713
|
const field = fields && fields[edited.fieldName];
|
|
712
714
|
externalWrites.set(edited.field, {
|
|
713
715
|
binding: captureFixedFieldState(edited),
|
|
714
|
-
fields,
|
|
715
716
|
field,
|
|
716
717
|
descriptors: field && Object.getOwnPropertyDescriptors(field)
|
|
717
718
|
});
|
|
@@ -875,7 +876,10 @@ function createFixedInputPort({ ScratchBlocks, workspace, vm, registry, identify
|
|
|
875
876
|
|
|
876
877
|
// dist/turbowarp/host.js
|
|
877
878
|
var owns2 = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
878
|
-
var createBlockEditorHost = ({ ScratchBlocks, workspace, vm, registry, enableDescendants = false, enableFixedInputs = false, onError = console.error }) => {
|
|
879
|
+
var createBlockEditorHost = ({ ScratchBlocks: nativeBlocks, workspace: nativeWorkspace, vm: nativeVM, registry, enableDescendants = false, enableFixedInputs = false, onError = console.error }) => {
|
|
880
|
+
const ScratchBlocks = nativeBlocks;
|
|
881
|
+
const workspace = nativeWorkspace;
|
|
882
|
+
const vm = nativeVM;
|
|
879
883
|
let disposed = false;
|
|
880
884
|
let committing = false;
|
|
881
885
|
let revision = 0;
|
|
@@ -1039,7 +1043,7 @@ var createBlockEditorHost = ({ ScratchBlocks, workspace, vm, registry, enableDes
|
|
|
1039
1043
|
let matches = false;
|
|
1040
1044
|
try {
|
|
1041
1045
|
const current = collect(item.reference);
|
|
1042
|
-
matches = current && JSON.stringify(current.snapshot) === JSON.stringify(item.snapshot);
|
|
1046
|
+
matches = current !== null && JSON.stringify(current.snapshot) === JSON.stringify(item.snapshot);
|
|
1043
1047
|
} catch (error) {
|
|
1044
1048
|
}
|
|
1045
1049
|
if (!matches)
|
|
@@ -1066,7 +1070,7 @@ var createBlockEditorHost = ({ ScratchBlocks, workspace, vm, registry, enableDes
|
|
|
1066
1070
|
Events.disable();
|
|
1067
1071
|
committing = true;
|
|
1068
1072
|
try {
|
|
1069
|
-
if (signal && signal.aborted)
|
|
1073
|
+
if (!target || signal && signal.aborted)
|
|
1070
1074
|
throw new BlockEditorConflictError();
|
|
1071
1075
|
for (const item of prepared) {
|
|
1072
1076
|
item.field.setValue(item.next);
|
|
@@ -1308,7 +1312,7 @@ var bindBlockEditorIcon = ({ element, label, canOpen, onOpen, onHover = () => {
|
|
|
1308
1312
|
for (const [type, listener] of listeners)
|
|
1309
1313
|
element.removeEventListener(type, listener);
|
|
1310
1314
|
attributes.forEach((name, index) => {
|
|
1311
|
-
if (previous[index]
|
|
1315
|
+
if (previous[index] == null)
|
|
1312
1316
|
element.removeAttribute(name);
|
|
1313
1317
|
else
|
|
1314
1318
|
element.setAttribute(name, previous[index]);
|
|
@@ -1409,7 +1413,10 @@ var openBlockEditorSession = ({ registry, reference, host, descendants }) => {
|
|
|
1409
1413
|
return registry.open(reference, host);
|
|
1410
1414
|
return descendants && supportsDescendantEditing(host) ? registry.openDescendants(reference, host) : registry.open(reference, host);
|
|
1411
1415
|
};
|
|
1412
|
-
var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, canOpen, onOpen, onError, descendants = false, fixedInputs = false }) => {
|
|
1416
|
+
var createBlockEditorBridge = ({ ScratchBlocks: nativeBlocks, workspace: nativeWorkspace, vm: nativeVM, service, label, canOpen, onOpen, onError, descendants = false, fixedInputs = false }) => {
|
|
1417
|
+
const ScratchBlocks = nativeBlocks;
|
|
1418
|
+
const workspace = nativeWorkspace;
|
|
1419
|
+
const vm = nativeVM;
|
|
1413
1420
|
const host = host_default({
|
|
1414
1421
|
ScratchBlocks,
|
|
1415
1422
|
workspace,
|
|
@@ -1433,7 +1440,7 @@ var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, c
|
|
|
1433
1440
|
}
|
|
1434
1441
|
};
|
|
1435
1442
|
let disposed = false;
|
|
1436
|
-
let timer
|
|
1443
|
+
let timer;
|
|
1437
1444
|
let activeSession = null;
|
|
1438
1445
|
let openingSnapshot = null;
|
|
1439
1446
|
let openingFixedDeclaration = null;
|
|
@@ -1442,7 +1449,7 @@ var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, c
|
|
|
1442
1449
|
const session = activeSession;
|
|
1443
1450
|
if (!session)
|
|
1444
1451
|
return;
|
|
1445
|
-
if (typeof session.invalidate === "function") {
|
|
1452
|
+
if ("invalidate" in session && typeof session.invalidate === "function") {
|
|
1446
1453
|
session.invalidate();
|
|
1447
1454
|
return;
|
|
1448
1455
|
}
|
|
@@ -1452,21 +1459,21 @@ var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, c
|
|
|
1452
1459
|
stopWaiting = session.subscribe(() => {
|
|
1453
1460
|
if (session.getState().status === "saving")
|
|
1454
1461
|
return;
|
|
1455
|
-
stopWaiting();
|
|
1462
|
+
stopWaiting === null || stopWaiting === void 0 ? void 0 : stopWaiting();
|
|
1456
1463
|
stopWaiting = null;
|
|
1457
1464
|
session.dispose();
|
|
1458
1465
|
});
|
|
1459
1466
|
}
|
|
1460
1467
|
};
|
|
1461
1468
|
const checkSession = () => {
|
|
1462
|
-
var _a;
|
|
1469
|
+
var _a, _b;
|
|
1463
1470
|
if (host.isCommitting())
|
|
1464
1471
|
return;
|
|
1465
1472
|
if (!activeSession || !openingSnapshot || !["editing", "saving"].includes(activeSession.getState().status))
|
|
1466
1473
|
return;
|
|
1467
|
-
const current =
|
|
1474
|
+
const current = "getNodes" in activeSession ? host.descendants.readSubtree(activeSession.reference) : host.readBlock(activeSession.reference);
|
|
1468
1475
|
if (openingFixedDeclaration) {
|
|
1469
|
-
if (!current || ((_a = current.fixedContext) === null || _a === void 0 ? void 0 : _a.generation) !== openingSnapshot.fixedContext.generation || fixedDeclaration(service.registry, current) !== openingFixedDeclaration)
|
|
1476
|
+
if (!current || (!("fixedContext" in current) || !("fixedContext" in openingSnapshot) || ((_a = current.fixedContext) === null || _a === void 0 ? void 0 : _a.generation) !== ((_b = openingSnapshot.fixedContext) === null || _b === void 0 ? void 0 : _b.generation)) || fixedDeclaration(service.registry, "opcode" in current ? current : null) !== openingFixedDeclaration)
|
|
1470
1477
|
endSession();
|
|
1471
1478
|
return;
|
|
1472
1479
|
}
|
|
@@ -1479,7 +1486,7 @@ var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, c
|
|
|
1479
1486
|
const snapshot = host.readBlock({ targetId: vm.editingTarget.id, blockId: block.id });
|
|
1480
1487
|
if (fixedDeclaration(service.registry, snapshot))
|
|
1481
1488
|
return supportsFixedInputEditing(host);
|
|
1482
|
-
return snapshot && Object.values(snapshot.arguments).every((slot) => slot.kind === "literal");
|
|
1489
|
+
return snapshot !== null && Object.values(snapshot.arguments).every((slot) => slot.kind === "literal");
|
|
1483
1490
|
};
|
|
1484
1491
|
const open = (block) => {
|
|
1485
1492
|
var _a, _b;
|
|
@@ -1494,14 +1501,14 @@ var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, c
|
|
|
1494
1501
|
if (session) {
|
|
1495
1502
|
ScratchBlocks.hideChaff();
|
|
1496
1503
|
activeSession = session;
|
|
1497
|
-
openingSnapshot =
|
|
1498
|
-
openingFixedDeclaration = fixedDeclaration(service.registry, openingSnapshot) || null;
|
|
1504
|
+
openingSnapshot = "getNodes" in session ? host.descendants.readSubtree(session.reference) : host.readBlock(session.reference);
|
|
1505
|
+
openingFixedDeclaration = fixedDeclaration(service.registry, openingSnapshot && "opcode" in openingSnapshot ? openingSnapshot : null) || null;
|
|
1499
1506
|
const labels = {};
|
|
1500
1507
|
const appearances = /* @__PURE__ */ Object.create(null);
|
|
1501
1508
|
const rootAppearance = appearance_default(block, ScratchBlocks, (_a = service.registry.resolve(block.type)) === null || _a === void 0 ? void 0 : _a.editableArguments);
|
|
1502
1509
|
appearances[reference.blockId] = rootAppearance;
|
|
1503
1510
|
labels[reference.blockId] = rootAppearance.name || block.type;
|
|
1504
|
-
if (
|
|
1511
|
+
if ("getNodes" in session) {
|
|
1505
1512
|
for (const node of session.getNodes()) {
|
|
1506
1513
|
const source = workspace.getBlockById(node.reference.blockId);
|
|
1507
1514
|
const appearance = appearance_default(source, ScratchBlocks, (_b = service.registry.resolve(node.opcode)) === null || _b === void 0 ? void 0 : _b.editableArguments);
|
|
@@ -1586,11 +1593,11 @@ var createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label, c
|
|
|
1586
1593
|
};
|
|
1587
1594
|
const unregister = service.subscribe(() => {
|
|
1588
1595
|
if (openingFixedDeclaration && activeSession) {
|
|
1589
|
-
if (service.registry.resolveFixed(openingSnapshot.opcode) !== openingFixedDeclaration) {
|
|
1596
|
+
if (openingSnapshot && "opcode" in openingSnapshot && service.registry.resolveFixed(openingSnapshot.opcode) !== openingFixedDeclaration) {
|
|
1590
1597
|
host.invalidate();
|
|
1591
1598
|
endSession();
|
|
1592
1599
|
}
|
|
1593
|
-
} else if (!activeSession ||
|
|
1600
|
+
} else if (!activeSession || !("getNodes" in activeSession)) {
|
|
1594
1601
|
host.invalidate();
|
|
1595
1602
|
endSession();
|
|
1596
1603
|
}
|