@kubohiroya/turbowarp-extension-data-editor 0.4.0 → 0.6.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.ja.md +9 -4
- package/README.md +7 -4
- package/dist/build-info.json +3 -3
- package/dist/descendants.js +1 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +100 -0
- package/dist/registry.d.ts +3 -0
- package/dist/registry.js +38 -9
- package/dist/rjsf.d.ts +2 -1
- package/dist/rjsf.js +10 -0
- package/dist/session.d.ts +1 -0
- package/dist/session.js +6 -0
- package/dist/turbowarp/bridge.js +42 -1
- package/dist/turbowarp/fixed-fields.d.ts +1 -1
- package/dist/turbowarp/fixed-fields.js +7 -2
- package/dist/turbowarp/icon.d.ts +3 -1
- package/dist/turbowarp/icon.js +5 -1
- package/dist/turbowarp.d.ts +2 -0
- package/dist/types.d.ts +8 -0
- package/dist/view.js +1 -0
- package/dist/webpack4/index.js +1 -1
- package/dist/webpack4/metafile.json +40 -27
- package/dist/webpack4/rjsf.js +13 -1
- package/dist/webpack4/rjsf.js.map +2 -2
- package/dist/webpack4/{shared-QIOZ73LT.js → shared-FW4MRLXW.js} +148 -8
- package/dist/webpack4/shared-FW4MRLXW.js.map +7 -0
- package/dist/webpack4/turbowarp.js +55 -5
- package/dist/webpack4/turbowarp.js.map +2 -2
- package/docs/README.md +3 -3
- package/docs/block-editor-descendants.md +1 -1
- package/docs/block-editor-e2e.md +6 -122
- package/docs/block-editor.md +1 -1
- package/docs/block-preview.md +45 -0
- package/docs/ci-success-gate.md +9 -29
- package/docs/fixed-input-contracts.md +3 -1
- package/docs/github-pages.md +21 -57
- package/docs/package-distribution.md +3 -3
- package/docs/shared-extension-security.ja.md +6 -6
- package/package.json +7 -6
- package/dist/webpack4/shared-QIOZ73LT.js.map +0 -7
|
@@ -1057,6 +1057,10 @@ var EditorView = class {
|
|
|
1057
1057
|
subscriptions.clear();
|
|
1058
1058
|
};
|
|
1059
1059
|
const context = Object.freeze({
|
|
1060
|
+
...owner.getSnapshot ? { getSnapshot: () => {
|
|
1061
|
+
assertMounted();
|
|
1062
|
+
return owner.getSnapshot();
|
|
1063
|
+
} } : {},
|
|
1060
1064
|
getDraft: () => owner.getDraft(),
|
|
1061
1065
|
...owner.getFixedInputView ? { getFixedInputView: () => {
|
|
1062
1066
|
assertMounted();
|
|
@@ -1336,6 +1340,10 @@ var EditorSession = class {
|
|
|
1336
1340
|
__classPrivateFieldGet2(this, _EditorSession_listeners, "f").delete(listener);
|
|
1337
1341
|
};
|
|
1338
1342
|
}
|
|
1343
|
+
getSnapshot() {
|
|
1344
|
+
__classPrivateFieldGet2(this, _EditorSession_instances, "m", _EditorSession_assertOpen).call(this);
|
|
1345
|
+
return isFixedInputEditor(__classPrivateFieldGet2(this, _EditorSession_definition, "f")) ? captureFixedSnapshot(__classPrivateFieldGet2(this, _EditorSession_snapshot, "f"), this.reference, __classPrivateFieldGet2(this, _EditorSession_definition, "f")) : captureSnapshot(__classPrivateFieldGet2(this, _EditorSession_snapshot, "f"), this.reference);
|
|
1346
|
+
}
|
|
1339
1347
|
mount(container) {
|
|
1340
1348
|
return __classPrivateFieldGet2(this, _EditorSession_view, "f").mount(container, __classPrivateFieldGet2(this, _EditorSession_definition, "f").mount, this);
|
|
1341
1349
|
}
|
|
@@ -1939,6 +1947,7 @@ _DescendantSession_snapshot = /* @__PURE__ */ new WeakMap(), _DescendantSession_
|
|
|
1939
1947
|
const listeners = /* @__PURE__ */ new Set();
|
|
1940
1948
|
const editor = Object.freeze({
|
|
1941
1949
|
reference: descriptor.reference,
|
|
1950
|
+
getSnapshot: () => snapshot,
|
|
1942
1951
|
getDraft: () => {
|
|
1943
1952
|
__classPrivateFieldGet3(this, _DescendantSession_instances, "m", _DescendantSession_assertOpen).call(this);
|
|
1944
1953
|
return cloneJson(record2.draft);
|
|
@@ -2040,6 +2049,111 @@ _DescendantSession_snapshot = /* @__PURE__ */ new WeakMap(), _DescendantSession_
|
|
|
2040
2049
|
__classPrivateFieldGet3(this, _DescendantSession_listeners, "f").clear();
|
|
2041
2050
|
};
|
|
2042
2051
|
|
|
2052
|
+
// dist/preview.js
|
|
2053
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
2054
|
+
function withBlockPreview(original, preview, opcode) {
|
|
2055
|
+
let entries = cache.get(preview);
|
|
2056
|
+
if (!entries) {
|
|
2057
|
+
entries = /* @__PURE__ */ new Map();
|
|
2058
|
+
cache.set(preview, entries);
|
|
2059
|
+
}
|
|
2060
|
+
const previous = entries.get(opcode);
|
|
2061
|
+
if (previous && previous.original === original)
|
|
2062
|
+
return previous.result;
|
|
2063
|
+
const fallback = {
|
|
2064
|
+
apiVersion: 1,
|
|
2065
|
+
extensionId: preview.extensionId,
|
|
2066
|
+
editorId: "block-preview",
|
|
2067
|
+
opcodes: [opcode],
|
|
2068
|
+
editableArguments: [],
|
|
2069
|
+
read: () => ({}),
|
|
2070
|
+
validate: () => [],
|
|
2071
|
+
createPatch: () => []
|
|
2072
|
+
};
|
|
2073
|
+
const result = Object.freeze({ ...original !== null && original !== void 0 ? original : fallback, mount(container, context) {
|
|
2074
|
+
var _a;
|
|
2075
|
+
const snapshot = (_a = context.getSnapshot) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
2076
|
+
if (!snapshot)
|
|
2077
|
+
throw new TypeError("Block preview requires a captured snapshot.");
|
|
2078
|
+
const document = container.ownerDocument;
|
|
2079
|
+
const layout = document.createElement("div");
|
|
2080
|
+
layout.dataset.blockPreviewLayout = "";
|
|
2081
|
+
layout.dataset.blockPreviewHasForm = String(typeof (original === null || original === void 0 ? void 0 : original.mount) === "function");
|
|
2082
|
+
const style = document.createElement("style");
|
|
2083
|
+
style.textContent = `
|
|
2084
|
+
[data-block-preview-layout] {
|
|
2085
|
+
display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
|
|
2086
|
+
min-width: 0; width: 100%; align-items: start;
|
|
2087
|
+
}
|
|
2088
|
+
[data-block-preview-layout] > [data-block-preview-visual],
|
|
2089
|
+
[data-block-preview-layout] > [data-block-preview-form] {
|
|
2090
|
+
min-width: 0; max-width: 100%; overflow-wrap: anywhere;
|
|
2091
|
+
}
|
|
2092
|
+
@media (min-width: 900px) {
|
|
2093
|
+
[data-block-preview-layout][data-block-preview-has-form="true"] {
|
|
2094
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
2095
|
+
}
|
|
2096
|
+
[data-block-preview-layout][data-block-preview-has-form="true"] > [data-block-preview-visual] {
|
|
2097
|
+
position: sticky; top: 0; align-self: start;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
`;
|
|
2101
|
+
const visual = document.createElement("div");
|
|
2102
|
+
visual.dataset.blockPreviewVisual = "";
|
|
2103
|
+
const form = document.createElement("div");
|
|
2104
|
+
form.dataset.blockPreviewForm = "";
|
|
2105
|
+
form.hidden = typeof (original === null || original === void 0 ? void 0 : original.mount) !== "function";
|
|
2106
|
+
layout.append(visual, form);
|
|
2107
|
+
container.append(style, layout);
|
|
2108
|
+
const removeLayout = () => {
|
|
2109
|
+
layout.remove();
|
|
2110
|
+
style.remove();
|
|
2111
|
+
};
|
|
2112
|
+
let removeForm;
|
|
2113
|
+
let removePreview;
|
|
2114
|
+
try {
|
|
2115
|
+
if (original === null || original === void 0 ? void 0 : original.mount) {
|
|
2116
|
+
const cleanup2 = original.mount(form, context);
|
|
2117
|
+
if (typeof cleanup2 !== "function")
|
|
2118
|
+
throw new TypeError("mount() must return a cleanup function.");
|
|
2119
|
+
removeForm = cleanup2;
|
|
2120
|
+
}
|
|
2121
|
+
const cleanup = preview.mount(visual, context, snapshot);
|
|
2122
|
+
if (typeof cleanup !== "function")
|
|
2123
|
+
throw new TypeError("preview.mount() must return a cleanup function.");
|
|
2124
|
+
removePreview = cleanup;
|
|
2125
|
+
} catch (error) {
|
|
2126
|
+
try {
|
|
2127
|
+
removePreview === null || removePreview === void 0 ? void 0 : removePreview();
|
|
2128
|
+
} finally {
|
|
2129
|
+
try {
|
|
2130
|
+
removeForm === null || removeForm === void 0 ? void 0 : removeForm();
|
|
2131
|
+
} finally {
|
|
2132
|
+
removeLayout();
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
throw error;
|
|
2136
|
+
}
|
|
2137
|
+
let active = true;
|
|
2138
|
+
return () => {
|
|
2139
|
+
if (!active)
|
|
2140
|
+
return;
|
|
2141
|
+
active = false;
|
|
2142
|
+
try {
|
|
2143
|
+
removePreview === null || removePreview === void 0 ? void 0 : removePreview();
|
|
2144
|
+
} finally {
|
|
2145
|
+
try {
|
|
2146
|
+
removeForm === null || removeForm === void 0 ? void 0 : removeForm();
|
|
2147
|
+
} finally {
|
|
2148
|
+
removeLayout();
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
};
|
|
2152
|
+
} });
|
|
2153
|
+
entries.set(opcode, { original, result });
|
|
2154
|
+
return result;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2043
2157
|
// dist/registry.js
|
|
2044
2158
|
var __classPrivateFieldGet4 = function(receiver, state, kind, f) {
|
|
2045
2159
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
@@ -2047,20 +2161,42 @@ var __classPrivateFieldGet4 = function(receiver, state, kind, f) {
|
|
|
2047
2161
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2048
2162
|
};
|
|
2049
2163
|
var _EditorRegistry_instances;
|
|
2164
|
+
var _EditorRegistry_previews;
|
|
2050
2165
|
var _EditorRegistry_editors;
|
|
2051
2166
|
var _EditorRegistry_opcodes;
|
|
2052
2167
|
var _EditorRegistry_fixedDeclarations;
|
|
2053
2168
|
var _EditorRegistry_changes;
|
|
2169
|
+
var _EditorRegistry_definition;
|
|
2054
2170
|
var _EditorRegistry_register;
|
|
2055
2171
|
var _EditorRegistry_notifyChanges;
|
|
2056
2172
|
var EditorRegistry = class {
|
|
2057
2173
|
constructor() {
|
|
2058
2174
|
_EditorRegistry_instances.add(this);
|
|
2175
|
+
_EditorRegistry_previews.set(this, /* @__PURE__ */ new Map());
|
|
2059
2176
|
_EditorRegistry_editors.set(this, /* @__PURE__ */ new Map());
|
|
2060
2177
|
_EditorRegistry_opcodes.set(this, /* @__PURE__ */ new Map());
|
|
2061
2178
|
_EditorRegistry_fixedDeclarations.set(this, /* @__PURE__ */ new Map());
|
|
2062
2179
|
_EditorRegistry_changes.set(this, /* @__PURE__ */ new Set());
|
|
2063
2180
|
}
|
|
2181
|
+
registerPreview(definition) {
|
|
2182
|
+
if (!definition || !/^[a-z0-9]+$/i.test(definition.extensionId) || !Array.isArray(definition.opcodes) || !definition.opcodes.length || new Set(definition.opcodes).size !== definition.opcodes.length || definition.opcodes.some((op) => typeof op !== "string" || !op.startsWith(`${definition.extensionId}_`) || op === `${definition.extensionId}_` || __classPrivateFieldGet4(this, _EditorRegistry_previews, "f").has(op)) || typeof definition.mount !== "function" || definition.hover !== void 0 && typeof definition.hover !== "function") {
|
|
2183
|
+
throw new TypeError("Invalid or duplicate block preview.");
|
|
2184
|
+
}
|
|
2185
|
+
const entry = Object.freeze({ ...definition, opcodes: Object.freeze([...definition.opcodes]) });
|
|
2186
|
+
for (const op of entry.opcodes)
|
|
2187
|
+
__classPrivateFieldGet4(this, _EditorRegistry_previews, "f").set(op, entry);
|
|
2188
|
+
__classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_notifyChanges).call(this);
|
|
2189
|
+
return () => {
|
|
2190
|
+
if (__classPrivateFieldGet4(this, _EditorRegistry_previews, "f").get(entry.opcodes[0]) !== entry)
|
|
2191
|
+
return;
|
|
2192
|
+
for (const op of entry.opcodes)
|
|
2193
|
+
__classPrivateFieldGet4(this, _EditorRegistry_previews, "f").delete(op);
|
|
2194
|
+
__classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_notifyChanges).call(this);
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
resolvePreview(opcode) {
|
|
2198
|
+
return __classPrivateFieldGet4(this, _EditorRegistry_previews, "f").get(opcode);
|
|
2199
|
+
}
|
|
2064
2200
|
register(definition) {
|
|
2065
2201
|
if (isFixedInputEditor(definition))
|
|
2066
2202
|
throw new TypeError("Fixed input editors require registerFixed().");
|
|
@@ -2078,7 +2214,7 @@ var EditorRegistry = class {
|
|
|
2078
2214
|
return __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_register).call(this, captureFixedInputEditorDefinition(definition));
|
|
2079
2215
|
}
|
|
2080
2216
|
resolve(opcode) {
|
|
2081
|
-
const entry = __classPrivateFieldGet4(this,
|
|
2217
|
+
const entry = __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_definition).call(this, opcode);
|
|
2082
2218
|
if (!entry)
|
|
2083
2219
|
return void 0;
|
|
2084
2220
|
return Object.freeze({
|
|
@@ -2099,7 +2235,7 @@ var EditorRegistry = class {
|
|
|
2099
2235
|
const live = host.readBlock(capturedReference);
|
|
2100
2236
|
if (!live)
|
|
2101
2237
|
return void 0;
|
|
2102
|
-
const entry = __classPrivateFieldGet4(this,
|
|
2238
|
+
const entry = __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_definition).call(this, live.opcode);
|
|
2103
2239
|
if (!entry) {
|
|
2104
2240
|
captureSnapshot(live, capturedReference);
|
|
2105
2241
|
return void 0;
|
|
@@ -2111,7 +2247,7 @@ var EditorRegistry = class {
|
|
|
2111
2247
|
if (!fixed || fixed.opcode !== live.opcode)
|
|
2112
2248
|
return void 0;
|
|
2113
2249
|
const snapshot2 = captureFixedSnapshot(fixed, capturedReference, entry);
|
|
2114
|
-
return new EditorSession(entry, snapshot2, host, () => __classPrivateFieldGet4(this,
|
|
2250
|
+
return new EditorSession(entry, snapshot2, host, () => __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_definition).call(this, snapshot2.opcode) === entry, (listener) => {
|
|
2115
2251
|
__classPrivateFieldGet4(this, _EditorRegistry_changes, "f").add(listener);
|
|
2116
2252
|
return () => {
|
|
2117
2253
|
__classPrivateFieldGet4(this, _EditorRegistry_changes, "f").delete(listener);
|
|
@@ -2119,7 +2255,7 @@ var EditorRegistry = class {
|
|
|
2119
2255
|
});
|
|
2120
2256
|
}
|
|
2121
2257
|
const snapshot = captureSnapshot(live, capturedReference);
|
|
2122
|
-
return new EditorSession(entry, snapshot, host, isPreparedEditor(entry) ? () => __classPrivateFieldGet4(this,
|
|
2258
|
+
return new EditorSession(entry, snapshot, host, isPreparedEditor(entry) || __classPrivateFieldGet4(this, _EditorRegistry_previews, "f").has(snapshot.opcode) ? () => __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_definition).call(this, snapshot.opcode) === entry : void 0);
|
|
2123
2259
|
}
|
|
2124
2260
|
openDescendants(reference, host, limits) {
|
|
2125
2261
|
if (!supportsDescendantEditing(host))
|
|
@@ -2131,11 +2267,11 @@ var EditorRegistry = class {
|
|
|
2131
2267
|
if (!live)
|
|
2132
2268
|
return void 0;
|
|
2133
2269
|
const captured = captureSubtree(live, capturedReference, resolvedLimits);
|
|
2134
|
-
const root = __classPrivateFieldGet4(this,
|
|
2270
|
+
const root = __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_definition).call(this, captured.snapshot.nodes[0].block.opcode);
|
|
2135
2271
|
if (!root || isFixedInputEditor(root))
|
|
2136
2272
|
return void 0;
|
|
2137
2273
|
return new DescendantSession(captured, port, (opcode) => {
|
|
2138
|
-
const entry = __classPrivateFieldGet4(this,
|
|
2274
|
+
const entry = __classPrivateFieldGet4(this, _EditorRegistry_instances, "m", _EditorRegistry_definition).call(this, opcode);
|
|
2139
2275
|
return entry && !isFixedInputEditor(entry) ? entry : void 0;
|
|
2140
2276
|
}, (listener) => {
|
|
2141
2277
|
__classPrivateFieldGet4(this, _EditorRegistry_changes, "f").add(listener);
|
|
@@ -2145,7 +2281,11 @@ var EditorRegistry = class {
|
|
|
2145
2281
|
}, resolvedLimits);
|
|
2146
2282
|
}
|
|
2147
2283
|
};
|
|
2148
|
-
_EditorRegistry_editors = /* @__PURE__ */ new WeakMap(), _EditorRegistry_opcodes = /* @__PURE__ */ new WeakMap(), _EditorRegistry_fixedDeclarations = /* @__PURE__ */ new WeakMap(), _EditorRegistry_changes = /* @__PURE__ */ new WeakMap(), _EditorRegistry_instances = /* @__PURE__ */ new WeakSet(),
|
|
2284
|
+
_EditorRegistry_previews = /* @__PURE__ */ new WeakMap(), _EditorRegistry_editors = /* @__PURE__ */ new WeakMap(), _EditorRegistry_opcodes = /* @__PURE__ */ new WeakMap(), _EditorRegistry_fixedDeclarations = /* @__PURE__ */ new WeakMap(), _EditorRegistry_changes = /* @__PURE__ */ new WeakMap(), _EditorRegistry_instances = /* @__PURE__ */ new WeakSet(), _EditorRegistry_definition = function _EditorRegistry_definition2(opcode) {
|
|
2285
|
+
const original = __classPrivateFieldGet4(this, _EditorRegistry_opcodes, "f").get(opcode);
|
|
2286
|
+
const preview = __classPrivateFieldGet4(this, _EditorRegistry_previews, "f").get(opcode);
|
|
2287
|
+
return preview ? withBlockPreview(original, preview, opcode) : original;
|
|
2288
|
+
}, _EditorRegistry_register = function _EditorRegistry_register2(definition) {
|
|
2149
2289
|
if (definition.apiVersion !== EDITOR_API_VERSION)
|
|
2150
2290
|
throw new TypeError("Unsupported editor API version.");
|
|
2151
2291
|
if (!/^[a-z0-9]+$/i.test(definition.extensionId) || !/^[a-z0-9][a-z0-9._-]*$/i.test(definition.editorId)) {
|
|
@@ -2203,4 +2343,4 @@ export {
|
|
|
2203
2343
|
DescendantSession,
|
|
2204
2344
|
EditorRegistry
|
|
2205
2345
|
};
|
|
2206
|
-
//# sourceMappingURL=shared-
|
|
2346
|
+
//# sourceMappingURL=shared-FW4MRLXW.js.map
|