@digital-gravy/etch-public-api 0.3.0 → 0.3.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 CHANGED
@@ -112,6 +112,16 @@ interface EtchDynamicElementBlockJson extends EtchBlockCommon {
112
112
  *
113
113
  * The global `styles` applied to the block are **read-only** (see
114
114
  * {@link EtchElementBlockJson}).
115
+ *
116
+ * **Special attributes** (in addition to standard `<img>` attributes):
117
+ * - `mediaId` — WordPress attachment post ID. When set, Etch fetches the media
118
+ * object and uses its URL as `src`, overriding any explicit `src` attribute.
119
+ * Supports dynamic expressions (`{post.featured_image_id}`).
120
+ * - `useSrcSet` — `"true"` to generate a responsive `srcset` from the media
121
+ * (only effective when `mediaId` is set).
122
+ * - `maximumSize` — maximum WordPress image size slug (e.g. `"large"`,
123
+ * `"full"`) used when building `srcset` / resolving the image URL. Defaults
124
+ * to `"full"` when omitted.
115
125
  */
116
126
  interface EtchDynamicImageBlockJson extends EtchBlockCommon {
117
127
  type: "etch/dynamic-image";
@@ -123,6 +133,13 @@ interface EtchDynamicImageBlockJson extends EtchBlockCommon {
123
133
  *
124
134
  * The global `styles` applied to the block are **read-only** (see
125
135
  * {@link EtchElementBlockJson}).
136
+ *
137
+ * **Special attributes** (in addition to standard SVG attributes):
138
+ * - `src` — URL of an external `.svg` file. When set, Etch fetches the file and
139
+ * inlines its contents at render time. Supports dynamic expressions.
140
+ * - `stripColors` — `"true"` to strip `fill` and `stroke` colour declarations
141
+ * from the fetched SVG so CSS can drive its colours instead. Only effective
142
+ * when `src` is set.
126
143
  */
127
144
  interface EtchSvgBlockJson extends EtchBlockCommon {
128
145
  type: "etch/svg";
@@ -636,7 +653,13 @@ interface StringComponentProperty {
636
653
  */
637
654
  selectOptionsString?: SelectOptionsString;
638
655
  }
639
- /** A numeric property. */
656
+ /**
657
+ * A numeric property.
658
+ *
659
+ * Note: number properties are **not implemented in the builder yet** — they are
660
+ * reserved in the contract but you can't create or edit one today. Don't rely
661
+ * on them.
662
+ */
640
663
  interface NumberComponentProperty {
641
664
  type: {
642
665
  primitive: "number";
@@ -730,8 +753,8 @@ interface ConditionComponentProperty {
730
753
  *
731
754
  * - `string` — plain text; or `'image'` | `'wpMediaId'` | `'select'` |
732
755
  * `'array'`; or `'condition'` (a gated group with nested `properties`)
733
- * - `number` — numeric
734
756
  * - `boolean` — boolean
757
+ * - `number` — numeric (reserved; not implemented in the builder yet)
735
758
  * - `object` — generic object; or `'group'` (nested `properties`)
736
759
  * - `array` — generic array; or `'class'` (CSS classes); or `'repeater'`
737
760
  * (repeating group with nested `properties`)
@@ -758,7 +781,11 @@ interface PublicComponentSummary {
758
781
  id: number;
759
782
  /** Display name. */
760
783
  name: string;
761
- /** Stable key used to reference the component in markup. */
784
+ /**
785
+ * Stable key used to reference the component in markup (e.g. `<Card />`).
786
+ * Always **PascalCase**: starts with an uppercase letter, letters and digits
787
+ * only (no dashes, underscores, or spaces).
788
+ */
762
789
  key: string;
763
790
  /** Optional human-readable description. */
764
791
  description?: string;
@@ -774,7 +801,11 @@ interface PublicComponentJson extends PublicComponentSummary {
774
801
  interface ComponentPatch {
775
802
  /** New display name. */
776
803
  name?: string;
777
- /** New reference key. */
804
+ /**
805
+ * New reference key. It is **converted to PascalCase** before it is stored
806
+ * (e.g. `my card` → `MyCard`), so the key actually saved may differ from the
807
+ * string passed here.
808
+ */
778
809
  key?: string;
779
810
  /** New description. */
780
811
  description?: string;
package/dist/index.d.ts CHANGED
@@ -112,6 +112,16 @@ interface EtchDynamicElementBlockJson extends EtchBlockCommon {
112
112
  *
113
113
  * The global `styles` applied to the block are **read-only** (see
114
114
  * {@link EtchElementBlockJson}).
115
+ *
116
+ * **Special attributes** (in addition to standard `<img>` attributes):
117
+ * - `mediaId` — WordPress attachment post ID. When set, Etch fetches the media
118
+ * object and uses its URL as `src`, overriding any explicit `src` attribute.
119
+ * Supports dynamic expressions (`{post.featured_image_id}`).
120
+ * - `useSrcSet` — `"true"` to generate a responsive `srcset` from the media
121
+ * (only effective when `mediaId` is set).
122
+ * - `maximumSize` — maximum WordPress image size slug (e.g. `"large"`,
123
+ * `"full"`) used when building `srcset` / resolving the image URL. Defaults
124
+ * to `"full"` when omitted.
115
125
  */
116
126
  interface EtchDynamicImageBlockJson extends EtchBlockCommon {
117
127
  type: "etch/dynamic-image";
@@ -123,6 +133,13 @@ interface EtchDynamicImageBlockJson extends EtchBlockCommon {
123
133
  *
124
134
  * The global `styles` applied to the block are **read-only** (see
125
135
  * {@link EtchElementBlockJson}).
136
+ *
137
+ * **Special attributes** (in addition to standard SVG attributes):
138
+ * - `src` — URL of an external `.svg` file. When set, Etch fetches the file and
139
+ * inlines its contents at render time. Supports dynamic expressions.
140
+ * - `stripColors` — `"true"` to strip `fill` and `stroke` colour declarations
141
+ * from the fetched SVG so CSS can drive its colours instead. Only effective
142
+ * when `src` is set.
126
143
  */
127
144
  interface EtchSvgBlockJson extends EtchBlockCommon {
128
145
  type: "etch/svg";
@@ -636,7 +653,13 @@ interface StringComponentProperty {
636
653
  */
637
654
  selectOptionsString?: SelectOptionsString;
638
655
  }
639
- /** A numeric property. */
656
+ /**
657
+ * A numeric property.
658
+ *
659
+ * Note: number properties are **not implemented in the builder yet** — they are
660
+ * reserved in the contract but you can't create or edit one today. Don't rely
661
+ * on them.
662
+ */
640
663
  interface NumberComponentProperty {
641
664
  type: {
642
665
  primitive: "number";
@@ -730,8 +753,8 @@ interface ConditionComponentProperty {
730
753
  *
731
754
  * - `string` — plain text; or `'image'` | `'wpMediaId'` | `'select'` |
732
755
  * `'array'`; or `'condition'` (a gated group with nested `properties`)
733
- * - `number` — numeric
734
756
  * - `boolean` — boolean
757
+ * - `number` — numeric (reserved; not implemented in the builder yet)
735
758
  * - `object` — generic object; or `'group'` (nested `properties`)
736
759
  * - `array` — generic array; or `'class'` (CSS classes); or `'repeater'`
737
760
  * (repeating group with nested `properties`)
@@ -758,7 +781,11 @@ interface PublicComponentSummary {
758
781
  id: number;
759
782
  /** Display name. */
760
783
  name: string;
761
- /** Stable key used to reference the component in markup. */
784
+ /**
785
+ * Stable key used to reference the component in markup (e.g. `<Card />`).
786
+ * Always **PascalCase**: starts with an uppercase letter, letters and digits
787
+ * only (no dashes, underscores, or spaces).
788
+ */
762
789
  key: string;
763
790
  /** Optional human-readable description. */
764
791
  description?: string;
@@ -774,7 +801,11 @@ interface PublicComponentJson extends PublicComponentSummary {
774
801
  interface ComponentPatch {
775
802
  /** New display name. */
776
803
  name?: string;
777
- /** New reference key. */
804
+ /**
805
+ * New reference key. It is **converted to PascalCase** before it is stored
806
+ * (e.g. `my card` → `MyCard`), so the key actually saved may differ from the
807
+ * string passed here.
808
+ */
778
809
  key?: string;
779
810
  /** New description. */
780
811
  description?: string;
package/package.json CHANGED
@@ -1,43 +1,46 @@
1
1
  {
2
- "name": "@digital-gravy/etch-public-api",
3
- "version": "0.3.0",
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
- "license": "MIT",
6
- "type": "module",
7
- "main": "./dist/index.cjs",
8
- "module": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
14
- "require": "./dist/index.cjs"
15
- }
16
- },
17
- "files": ["dist", "README.md"],
18
- "sideEffects": false,
19
- "scripts": {
20
- "build": "tsup",
21
- "dev": "tsup --watch",
22
- "test": "vitest run",
23
- "test:watch": "vitest",
24
- "typecheck": "tsc --noEmit",
25
- "prepublishOnly": "bun run build"
26
- },
27
- "keywords": [
28
- "etch",
29
- "etchwp",
30
- "wordpress",
31
- "builder",
32
- "scripting",
33
- "api"
34
- ],
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "devDependencies": {
39
- "tsup": "^8.3.5",
40
- "typescript": "^5.7.2",
41
- "vitest": "^3.0.5"
42
- }
2
+ "name": "@digital-gravy/etch-public-api",
3
+ "version": "0.3.2",
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
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "sideEffects": false,
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "dev": "tsup --watch",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "typecheck": "tsc --noEmit",
28
+ "prepublishOnly": "bun run build"
29
+ },
30
+ "keywords": [
31
+ "etch",
32
+ "etchwp",
33
+ "wordpress",
34
+ "builder",
35
+ "scripting",
36
+ "api"
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "devDependencies": {
42
+ "tsup": "^8.3.5",
43
+ "typescript": "^5.7.2",
44
+ "vitest": "^3.0.5"
45
+ }
43
46
  }