@digital-gravy/etch-public-api 0.7.1 → 0.7.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/dist/index.d.cts +74 -3
- package/dist/index.d.ts +74 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -265,6 +265,50 @@ interface BlockPatch {
|
|
|
265
265
|
/** Replace the text content. Only valid on text blocks. */
|
|
266
266
|
text?: string;
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* A portable, JSON-serializable snapshot of a block subtree produced by
|
|
270
|
+
* {@link EtchBlocksApi.copy} and consumed by {@link EtchBlocksApi.pasteAsync}.
|
|
271
|
+
*
|
|
272
|
+
* Treat it as an **opaque token**: store it, send it over the wire, or hand it
|
|
273
|
+
* straight back to `pasteAsync()`. The fields below are documented so you can
|
|
274
|
+
* inspect a payload, but the bundled `styles` / `loops` / `components` /
|
|
275
|
+
* `customMediaDefinitions` are Etch-internal definitions that `pasteAsync()`
|
|
276
|
+
* re-creates and re-maps to fresh ids — don't depend on their internal shape or
|
|
277
|
+
* mutate them.
|
|
278
|
+
*
|
|
279
|
+
* Unlike the builder's Cmd-C / Cmd-V shortcuts, `copy()` / `pasteAsync()` never
|
|
280
|
+
* touch the system clipboard, so they work for fully programmatic flows (no
|
|
281
|
+
* user gesture or clipboard permission required).
|
|
282
|
+
*/
|
|
283
|
+
interface CopyObject {
|
|
284
|
+
/** Payload kind. Currently always `"block"`. */
|
|
285
|
+
type: 'block';
|
|
286
|
+
/**
|
|
287
|
+
* Payload schema version, derived from the features the copied block uses.
|
|
288
|
+
* `paste()` migrates older payloads forward, so pass it back unchanged.
|
|
289
|
+
*/
|
|
290
|
+
version: number;
|
|
291
|
+
/** The copied block subtree in Gutenberg block grammar. */
|
|
292
|
+
gutenbergBlock: GutenbergBlock;
|
|
293
|
+
/** Global styles referenced by the block, keyed by style id (opaque). */
|
|
294
|
+
styles?: {
|
|
295
|
+
[styleId: string]: unknown;
|
|
296
|
+
};
|
|
297
|
+
/** Loop definitions referenced by the block, keyed by loop id (opaque). */
|
|
298
|
+
loops?: {
|
|
299
|
+
[loopId: string]: unknown;
|
|
300
|
+
};
|
|
301
|
+
/** Component definitions referenced by the block, keyed by component id (opaque). */
|
|
302
|
+
components?: {
|
|
303
|
+
[componentId: number]: unknown;
|
|
304
|
+
};
|
|
305
|
+
/** `@custom-media` definitions referenced by the block's styles (opaque). */
|
|
306
|
+
customMediaDefinitions?: {
|
|
307
|
+
[name: string]: unknown;
|
|
308
|
+
};
|
|
309
|
+
/** ISO 8601 timestamp of when the copy was produced. */
|
|
310
|
+
timestamp?: string;
|
|
311
|
+
}
|
|
268
312
|
/** Block selection, reading, structure and property edits. */
|
|
269
313
|
interface EtchBlocksApi {
|
|
270
314
|
/** Select a block in the canvas by id. */
|
|
@@ -281,9 +325,10 @@ interface EtchBlocksApi {
|
|
|
281
325
|
find(predicate: FindBlocksPredicate): string[];
|
|
282
326
|
/**
|
|
283
327
|
* Build a block from JSON and insert it; returns the new block id.
|
|
284
|
-
* `parentId` defaults to the document root
|
|
328
|
+
* `parentId` defaults to the document root (`null` is treated the same as
|
|
329
|
+
* omitting it, matching {@link move}), `index` to the end of the parent.
|
|
285
330
|
*/
|
|
286
|
-
create(json: EtchBlockJson, parentId?: string, index?: number): string;
|
|
331
|
+
create(json: EtchBlockJson, parentId?: string | null, index?: number): string;
|
|
287
332
|
/** Remove a block and its entire subtree. */
|
|
288
333
|
delete(blockId: string): void;
|
|
289
334
|
/** Deep-copy a block next to the original; returns the new block's id. */
|
|
@@ -297,6 +342,32 @@ interface EtchBlocksApi {
|
|
|
297
342
|
replace(blockId: string, json: EtchBlockJson): string;
|
|
298
343
|
/** Patch a block's common editable properties in place (keeps id/children). */
|
|
299
344
|
update(blockId: string, patch: BlockPatch): void;
|
|
345
|
+
/**
|
|
346
|
+
* Serialize a block and its subtree — along with the global styles, loops and
|
|
347
|
+
* components it references — into a portable {@link CopyObject}. The result is
|
|
348
|
+
* plain JSON: hold it, persist it, or pass it to {@link pasteAsync}. Unlike the
|
|
349
|
+
* Cmd-C shortcut this does **not** write to the system clipboard. Throws
|
|
350
|
+
* `BLOCK_NOT_FOUND` for an unknown id.
|
|
351
|
+
*/
|
|
352
|
+
copy(blockId: string): CopyObject;
|
|
353
|
+
/**
|
|
354
|
+
* Insert a block previously produced by {@link copy}. Any styles, loops and
|
|
355
|
+
* components it carries are re-created and re-mapped to fresh ids. Resolves to
|
|
356
|
+
* the id of the newly inserted block. Throws `INVALID_ARGUMENT` for a
|
|
357
|
+
* malformed payload and `BLOCK_NOT_FOUND` for an unknown `targetId`.
|
|
358
|
+
*
|
|
359
|
+
* Placement (mirrors {@link create}):
|
|
360
|
+
* - **No `targetId`** (omitted or `null`) — appended to the document root, or
|
|
361
|
+
* inserted there at `index` when given.
|
|
362
|
+
* - **`targetId` + `index`** — inserted as a child of the target at `index`.
|
|
363
|
+
* - **`targetId`, no `index`** — inserted into the target when it accepts
|
|
364
|
+
* children, otherwise immediately after it (handy for "paste near this
|
|
365
|
+
* block").
|
|
366
|
+
*
|
|
367
|
+
* `index` is clamped to the valid range; a negative `index` counts from the
|
|
368
|
+
* end (`-1` appends).
|
|
369
|
+
*/
|
|
370
|
+
pasteAsync(payload: CopyObject, targetId?: string | null, index?: number): Promise<string>;
|
|
300
371
|
/** Set the text content of a text block. */
|
|
301
372
|
setText(blockId: string, text: string): void;
|
|
302
373
|
/** Rename a block (sets its label / display name). */
|
|
@@ -1352,4 +1423,4 @@ declare function isEtchApiError(value: unknown): value is EtchApiError;
|
|
|
1352
1423
|
*/
|
|
1353
1424
|
declare const ETCH_API_VERSION = "0.x";
|
|
1354
1425
|
|
|
1355
|
-
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchRawHtmlBlockJson, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, type LoopParamRef, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type NumericParam, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type SelectOptionsString, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
|
|
1426
|
+
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CopyObject, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchRawHtmlBlockJson, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, type LoopParamRef, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type NumericParam, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type SelectOptionsString, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
|
package/dist/index.d.ts
CHANGED
|
@@ -265,6 +265,50 @@ interface BlockPatch {
|
|
|
265
265
|
/** Replace the text content. Only valid on text blocks. */
|
|
266
266
|
text?: string;
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* A portable, JSON-serializable snapshot of a block subtree produced by
|
|
270
|
+
* {@link EtchBlocksApi.copy} and consumed by {@link EtchBlocksApi.pasteAsync}.
|
|
271
|
+
*
|
|
272
|
+
* Treat it as an **opaque token**: store it, send it over the wire, or hand it
|
|
273
|
+
* straight back to `pasteAsync()`. The fields below are documented so you can
|
|
274
|
+
* inspect a payload, but the bundled `styles` / `loops` / `components` /
|
|
275
|
+
* `customMediaDefinitions` are Etch-internal definitions that `pasteAsync()`
|
|
276
|
+
* re-creates and re-maps to fresh ids — don't depend on their internal shape or
|
|
277
|
+
* mutate them.
|
|
278
|
+
*
|
|
279
|
+
* Unlike the builder's Cmd-C / Cmd-V shortcuts, `copy()` / `pasteAsync()` never
|
|
280
|
+
* touch the system clipboard, so they work for fully programmatic flows (no
|
|
281
|
+
* user gesture or clipboard permission required).
|
|
282
|
+
*/
|
|
283
|
+
interface CopyObject {
|
|
284
|
+
/** Payload kind. Currently always `"block"`. */
|
|
285
|
+
type: 'block';
|
|
286
|
+
/**
|
|
287
|
+
* Payload schema version, derived from the features the copied block uses.
|
|
288
|
+
* `paste()` migrates older payloads forward, so pass it back unchanged.
|
|
289
|
+
*/
|
|
290
|
+
version: number;
|
|
291
|
+
/** The copied block subtree in Gutenberg block grammar. */
|
|
292
|
+
gutenbergBlock: GutenbergBlock;
|
|
293
|
+
/** Global styles referenced by the block, keyed by style id (opaque). */
|
|
294
|
+
styles?: {
|
|
295
|
+
[styleId: string]: unknown;
|
|
296
|
+
};
|
|
297
|
+
/** Loop definitions referenced by the block, keyed by loop id (opaque). */
|
|
298
|
+
loops?: {
|
|
299
|
+
[loopId: string]: unknown;
|
|
300
|
+
};
|
|
301
|
+
/** Component definitions referenced by the block, keyed by component id (opaque). */
|
|
302
|
+
components?: {
|
|
303
|
+
[componentId: number]: unknown;
|
|
304
|
+
};
|
|
305
|
+
/** `@custom-media` definitions referenced by the block's styles (opaque). */
|
|
306
|
+
customMediaDefinitions?: {
|
|
307
|
+
[name: string]: unknown;
|
|
308
|
+
};
|
|
309
|
+
/** ISO 8601 timestamp of when the copy was produced. */
|
|
310
|
+
timestamp?: string;
|
|
311
|
+
}
|
|
268
312
|
/** Block selection, reading, structure and property edits. */
|
|
269
313
|
interface EtchBlocksApi {
|
|
270
314
|
/** Select a block in the canvas by id. */
|
|
@@ -281,9 +325,10 @@ interface EtchBlocksApi {
|
|
|
281
325
|
find(predicate: FindBlocksPredicate): string[];
|
|
282
326
|
/**
|
|
283
327
|
* Build a block from JSON and insert it; returns the new block id.
|
|
284
|
-
* `parentId` defaults to the document root
|
|
328
|
+
* `parentId` defaults to the document root (`null` is treated the same as
|
|
329
|
+
* omitting it, matching {@link move}), `index` to the end of the parent.
|
|
285
330
|
*/
|
|
286
|
-
create(json: EtchBlockJson, parentId?: string, index?: number): string;
|
|
331
|
+
create(json: EtchBlockJson, parentId?: string | null, index?: number): string;
|
|
287
332
|
/** Remove a block and its entire subtree. */
|
|
288
333
|
delete(blockId: string): void;
|
|
289
334
|
/** Deep-copy a block next to the original; returns the new block's id. */
|
|
@@ -297,6 +342,32 @@ interface EtchBlocksApi {
|
|
|
297
342
|
replace(blockId: string, json: EtchBlockJson): string;
|
|
298
343
|
/** Patch a block's common editable properties in place (keeps id/children). */
|
|
299
344
|
update(blockId: string, patch: BlockPatch): void;
|
|
345
|
+
/**
|
|
346
|
+
* Serialize a block and its subtree — along with the global styles, loops and
|
|
347
|
+
* components it references — into a portable {@link CopyObject}. The result is
|
|
348
|
+
* plain JSON: hold it, persist it, or pass it to {@link pasteAsync}. Unlike the
|
|
349
|
+
* Cmd-C shortcut this does **not** write to the system clipboard. Throws
|
|
350
|
+
* `BLOCK_NOT_FOUND` for an unknown id.
|
|
351
|
+
*/
|
|
352
|
+
copy(blockId: string): CopyObject;
|
|
353
|
+
/**
|
|
354
|
+
* Insert a block previously produced by {@link copy}. Any styles, loops and
|
|
355
|
+
* components it carries are re-created and re-mapped to fresh ids. Resolves to
|
|
356
|
+
* the id of the newly inserted block. Throws `INVALID_ARGUMENT` for a
|
|
357
|
+
* malformed payload and `BLOCK_NOT_FOUND` for an unknown `targetId`.
|
|
358
|
+
*
|
|
359
|
+
* Placement (mirrors {@link create}):
|
|
360
|
+
* - **No `targetId`** (omitted or `null`) — appended to the document root, or
|
|
361
|
+
* inserted there at `index` when given.
|
|
362
|
+
* - **`targetId` + `index`** — inserted as a child of the target at `index`.
|
|
363
|
+
* - **`targetId`, no `index`** — inserted into the target when it accepts
|
|
364
|
+
* children, otherwise immediately after it (handy for "paste near this
|
|
365
|
+
* block").
|
|
366
|
+
*
|
|
367
|
+
* `index` is clamped to the valid range; a negative `index` counts from the
|
|
368
|
+
* end (`-1` appends).
|
|
369
|
+
*/
|
|
370
|
+
pasteAsync(payload: CopyObject, targetId?: string | null, index?: number): Promise<string>;
|
|
300
371
|
/** Set the text content of a text block. */
|
|
301
372
|
setText(blockId: string, text: string): void;
|
|
302
373
|
/** Rename a block (sets its label / display name). */
|
|
@@ -1352,4 +1423,4 @@ declare function isEtchApiError(value: unknown): value is EtchApiError;
|
|
|
1352
1423
|
*/
|
|
1353
1424
|
declare const ETCH_API_VERSION = "0.x";
|
|
1354
1425
|
|
|
1355
|
-
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchRawHtmlBlockJson, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, type LoopParamRef, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type NumericParam, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type SelectOptionsString, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
|
|
1426
|
+
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CopyObject, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchRawHtmlBlockJson, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, type LoopParamRef, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type NumericParam, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type SelectOptionsString, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-gravy/etch-public-api",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "MIT-licensed typed client and contract for the Etch builder scripting API (window.etch). Etch itself is a separate proprietary product governed by its own commercial terms.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|