@genetik/patches 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eugene Michasiw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @genetik/patches
2
+
3
+ Structured mutations over Genetik content: add node, remove node, update config, reorder slot. Used by revisions (drafts/published, history), undo/redo, and LLM edit-in-place.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @genetik/patches
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ - **applyPatch(content, patch)** — Apply one or more operations and return new content. Does not mutate input. Does not validate the result.
14
+
15
+ See the [docs](/docs/packages/patches) for API and examples.
package/dist/index.cjs ADDED
@@ -0,0 +1,95 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/apply.ts
4
+ /**
5
+ * Applies a patch to content and returns new content. Does not mutate the input.
6
+ * Operations are applied in order. Does not validate the result (e.g. link integrity).
7
+ */
8
+ function applyPatch(content, patch) {
9
+ const ops = Array.isArray(patch) ? patch : [patch];
10
+ let result = content;
11
+ for (const op of ops) result = applyOp(result, op);
12
+ return result;
13
+ }
14
+ function applyOp(content, op) {
15
+ switch (op.type) {
16
+ case "addNode": return applyAddNode(content, op);
17
+ case "removeNode": return applyRemoveNode(content, op);
18
+ case "updateConfig": return applyUpdateConfig(content, op);
19
+ case "reorderSlot": return applyReorderSlot(content, op);
20
+ }
21
+ }
22
+ function applyAddNode(content, op) {
23
+ const nodes = {
24
+ ...content.nodes,
25
+ [op.id]: { ...op.node }
26
+ };
27
+ return {
28
+ ...content,
29
+ nodes
30
+ };
31
+ }
32
+ function applyRemoveNode(content, op) {
33
+ const nodes = {};
34
+ for (const [id, node] of Object.entries(content.nodes)) {
35
+ if (id === op.id) continue;
36
+ const updated = removeIdFromNodeSlots(node, op.id);
37
+ if (updated !== null) nodes[id] = updated;
38
+ }
39
+ return {
40
+ ...content,
41
+ nodes
42
+ };
43
+ }
44
+ function removeIdFromNodeSlots(node, removeId) {
45
+ let changed = false;
46
+ const out = {
47
+ id: node.id,
48
+ block: node.block,
49
+ config: node.config
50
+ };
51
+ for (const [key, value] of Object.entries(node)) {
52
+ if (key === "id" || key === "block" || key === "config") continue;
53
+ if (Array.isArray(value)) {
54
+ const filtered = value.filter((id) => id !== removeId);
55
+ if (filtered.length !== value.length) changed = true;
56
+ out[key] = filtered;
57
+ } else if (value === removeId) changed = true;
58
+ else out[key] = value;
59
+ }
60
+ return changed ? out : node;
61
+ }
62
+ function applyUpdateConfig(content, op) {
63
+ const node = content.nodes[op.id];
64
+ if (!node) return content;
65
+ const nodes = {
66
+ ...content.nodes,
67
+ [op.id]: {
68
+ ...node,
69
+ config: { ...op.config }
70
+ }
71
+ };
72
+ return {
73
+ ...content,
74
+ nodes
75
+ };
76
+ }
77
+ function applyReorderSlot(content, op) {
78
+ const node = content.nodes[op.id];
79
+ if (!node) return content;
80
+ const nodes = {
81
+ ...content.nodes,
82
+ [op.id]: {
83
+ ...node,
84
+ [op.slotName]: [...op.order]
85
+ }
86
+ };
87
+ return {
88
+ ...content,
89
+ nodes
90
+ };
91
+ }
92
+
93
+ //#endregion
94
+ exports.applyPatch = applyPatch;
95
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/apply.ts"],"sourcesContent":["import type { ContentNode, GenetikContent } from \"@genetik/content\";\nimport type { Patch, PatchOp } from \"./types.js\";\n\n/**\n * Applies a patch to content and returns new content. Does not mutate the input.\n * Operations are applied in order. Does not validate the result (e.g. link integrity).\n */\nexport function applyPatch(content: GenetikContent, patch: Patch): GenetikContent {\n const ops = Array.isArray(patch) ? patch : [patch];\n let result = content;\n for (const op of ops) {\n result = applyOp(result, op);\n }\n return result;\n}\n\nfunction applyOp(content: GenetikContent, op: PatchOp): GenetikContent {\n switch (op.type) {\n case \"addNode\":\n return applyAddNode(content, op);\n case \"removeNode\":\n return applyRemoveNode(content, op);\n case \"updateConfig\":\n return applyUpdateConfig(content, op);\n case \"reorderSlot\":\n return applyReorderSlot(content, op);\n }\n}\n\nfunction applyAddNode(content: GenetikContent, op: { id: string; node: ContentNode }): GenetikContent {\n const nodes = { ...content.nodes, [op.id]: { ...op.node } };\n return { ...content, nodes };\n}\n\nfunction applyRemoveNode(content: GenetikContent, op: { id: string }): GenetikContent {\n const nodes: Record<string, ContentNode> = {};\n for (const [id, node] of Object.entries(content.nodes)) {\n if (id === op.id) continue;\n const updated = removeIdFromNodeSlots(node, op.id);\n if (updated !== null) nodes[id] = updated;\n }\n return { ...content, nodes };\n}\n\nfunction removeIdFromNodeSlots(node: ContentNode, removeId: string): ContentNode | null {\n let changed = false;\n const out: ContentNode = { id: node.id, block: node.block, config: node.config };\n for (const [key, value] of Object.entries(node)) {\n if (key === \"id\" || key === \"block\" || key === \"config\") continue;\n if (Array.isArray(value)) {\n const filtered = value.filter((id) => id !== removeId);\n if (filtered.length !== value.length) changed = true;\n out[key] = filtered;\n } else if (value === removeId) {\n changed = true;\n // omit this slot (undefined)\n } else {\n out[key] = value;\n }\n }\n return changed ? out : node;\n}\n\nfunction applyUpdateConfig(\n content: GenetikContent,\n op: { id: string; config: Record<string, unknown> }\n): GenetikContent {\n const node = content.nodes[op.id];\n if (!node) return content;\n const nodes = {\n ...content.nodes,\n [op.id]: { ...node, config: { ...op.config } },\n };\n return { ...content, nodes };\n}\n\nfunction applyReorderSlot(\n content: GenetikContent,\n op: { id: string; slotName: string; order: string[] }\n): GenetikContent {\n const node = content.nodes[op.id];\n if (!node) return content;\n const nodes = {\n ...content.nodes,\n [op.id]: { ...node, [op.slotName]: [...op.order] },\n };\n return { ...content, nodes };\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,WAAW,SAAyB,OAA8B;CAChF,MAAM,MAAM,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CAClD,IAAI,SAAS;AACb,MAAK,MAAM,MAAM,IACf,UAAS,QAAQ,QAAQ,GAAG;AAE9B,QAAO;;AAGT,SAAS,QAAQ,SAAyB,IAA6B;AACrE,SAAQ,GAAG,MAAX;EACE,KAAK,UACH,QAAO,aAAa,SAAS,GAAG;EAClC,KAAK,aACH,QAAO,gBAAgB,SAAS,GAAG;EACrC,KAAK,eACH,QAAO,kBAAkB,SAAS,GAAG;EACvC,KAAK,cACH,QAAO,iBAAiB,SAAS,GAAG;;;AAI1C,SAAS,aAAa,SAAyB,IAAuD;CACpG,MAAM,QAAQ;EAAE,GAAG,QAAQ;GAAQ,GAAG,KAAK,EAAE,GAAG,GAAG,MAAM;EAAE;AAC3D,QAAO;EAAE,GAAG;EAAS;EAAO;;AAG9B,SAAS,gBAAgB,SAAyB,IAAoC;CACpF,MAAM,QAAqC,EAAE;AAC7C,MAAK,MAAM,CAAC,IAAI,SAAS,OAAO,QAAQ,QAAQ,MAAM,EAAE;AACtD,MAAI,OAAO,GAAG,GAAI;EAClB,MAAM,UAAU,sBAAsB,MAAM,GAAG,GAAG;AAClD,MAAI,YAAY,KAAM,OAAM,MAAM;;AAEpC,QAAO;EAAE,GAAG;EAAS;EAAO;;AAG9B,SAAS,sBAAsB,MAAmB,UAAsC;CACtF,IAAI,UAAU;CACd,MAAM,MAAmB;EAAE,IAAI,KAAK;EAAI,OAAO,KAAK;EAAO,QAAQ,KAAK;EAAQ;AAChF,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;AAC/C,MAAI,QAAQ,QAAQ,QAAQ,WAAW,QAAQ,SAAU;AACzD,MAAI,MAAM,QAAQ,MAAM,EAAE;GACxB,MAAM,WAAW,MAAM,QAAQ,OAAO,OAAO,SAAS;AACtD,OAAI,SAAS,WAAW,MAAM,OAAQ,WAAU;AAChD,OAAI,OAAO;aACF,UAAU,SACnB,WAAU;MAGV,KAAI,OAAO;;AAGf,QAAO,UAAU,MAAM;;AAGzB,SAAS,kBACP,SACA,IACgB;CAChB,MAAM,OAAO,QAAQ,MAAM,GAAG;AAC9B,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ;EACZ,GAAG,QAAQ;GACV,GAAG,KAAK;GAAE,GAAG;GAAM,QAAQ,EAAE,GAAG,GAAG,QAAQ;GAAE;EAC/C;AACD,QAAO;EAAE,GAAG;EAAS;EAAO;;AAG9B,SAAS,iBACP,SACA,IACgB;CAChB,MAAM,OAAO,QAAQ,MAAM,GAAG;AAC9B,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ;EACZ,GAAG,QAAQ;GACV,GAAG,KAAK;GAAE,GAAG;IAAO,GAAG,WAAW,CAAC,GAAG,GAAG,MAAM;GAAE;EACnD;AACD,QAAO;EAAE,GAAG;EAAS;EAAO"}
@@ -0,0 +1,58 @@
1
+ import { ContentNode, GenetikContent, GenetikContent as GenetikContent$1 } from "@genetik/content";
2
+
3
+ //#region src/types.d.ts
4
+ /**
5
+ * Add a node to the content. The node must have a unique id.
6
+ * Does not attach it to any slot; use reorderSlot to place it.
7
+ */
8
+ interface AddNodeOp {
9
+ type: "addNode";
10
+ /** Id for the new node (must not already exist in content). */
11
+ id: string;
12
+ /** The node to add. */
13
+ node: ContentNode;
14
+ }
15
+ /**
16
+ * Remove a node and remove its id from any slot that references it.
17
+ */
18
+ interface RemoveNodeOp {
19
+ type: "removeNode";
20
+ id: string;
21
+ }
22
+ /**
23
+ * Replace a node's config.
24
+ */
25
+ interface UpdateConfigOp {
26
+ type: "updateConfig";
27
+ id: string;
28
+ config: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Set a slot to an ordered list of node ids.
32
+ */
33
+ interface ReorderSlotOp {
34
+ type: "reorderSlot";
35
+ /** Node whose slot to update. */
36
+ id: string;
37
+ slotName: string;
38
+ /** New ordered list of node ids for this slot. */
39
+ order: string[];
40
+ }
41
+ /**
42
+ * A single patch operation.
43
+ */
44
+ type PatchOp = AddNodeOp | RemoveNodeOp | UpdateConfigOp | ReorderSlotOp;
45
+ /**
46
+ * A patch is one operation or a sequence of operations applied in order.
47
+ */
48
+ type Patch = PatchOp | PatchOp[];
49
+ //#endregion
50
+ //#region src/apply.d.ts
51
+ /**
52
+ * Applies a patch to content and returns new content. Does not mutate the input.
53
+ * Operations are applied in order. Does not validate the result (e.g. link integrity).
54
+ */
55
+ declare function applyPatch(content: GenetikContent$1, patch: Patch): GenetikContent$1;
56
+ //#endregion
57
+ export { type AddNodeOp, type ContentNode, type GenetikContent, type Patch, type PatchOp, type RemoveNodeOp, type ReorderSlotOp, type UpdateConfigOp, applyPatch };
58
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/apply.ts"],"mappings":";;;;;AAMA;;UAAiB,SAAA;EACf,IAAA;EAAA;EAEA,EAAA;EAEA;EAAA,IAAA,EAAM,WAAA;AAAA;;AAMR;;UAAiB,YAAA;EACf,IAAA;EACA,EAAA;AAAA;;;;UAMe,cAAA;EACf,IAAA;EACA,EAAA;EACA,MAAA,EAAQ,MAAA;AAAA;;AAMV;;UAAiB,aAAA;EACf,IAAA;EAAA;EAEA,EAAA;EACA,QAAA;EAEA;EAAA,KAAA;AAAA;AAMF;;;AAAA,KAAY,OAAA,GAAU,SAAA,GAAY,YAAA,GAAe,cAAA,GAAiB,aAAA;;;;KAKtD,KAAA,GAAQ,OAAA,GAAU,OAAA;;;;AA7C9B;;;iBCCgB,UAAA,CAAW,OAAA,EAAS,gBAAA,EAAgB,KAAA,EAAO,KAAA,GAAQ,gBAAA"}
@@ -0,0 +1,58 @@
1
+ import { ContentNode, GenetikContent, GenetikContent as GenetikContent$1 } from "@genetik/content";
2
+
3
+ //#region src/types.d.ts
4
+ /**
5
+ * Add a node to the content. The node must have a unique id.
6
+ * Does not attach it to any slot; use reorderSlot to place it.
7
+ */
8
+ interface AddNodeOp {
9
+ type: "addNode";
10
+ /** Id for the new node (must not already exist in content). */
11
+ id: string;
12
+ /** The node to add. */
13
+ node: ContentNode;
14
+ }
15
+ /**
16
+ * Remove a node and remove its id from any slot that references it.
17
+ */
18
+ interface RemoveNodeOp {
19
+ type: "removeNode";
20
+ id: string;
21
+ }
22
+ /**
23
+ * Replace a node's config.
24
+ */
25
+ interface UpdateConfigOp {
26
+ type: "updateConfig";
27
+ id: string;
28
+ config: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Set a slot to an ordered list of node ids.
32
+ */
33
+ interface ReorderSlotOp {
34
+ type: "reorderSlot";
35
+ /** Node whose slot to update. */
36
+ id: string;
37
+ slotName: string;
38
+ /** New ordered list of node ids for this slot. */
39
+ order: string[];
40
+ }
41
+ /**
42
+ * A single patch operation.
43
+ */
44
+ type PatchOp = AddNodeOp | RemoveNodeOp | UpdateConfigOp | ReorderSlotOp;
45
+ /**
46
+ * A patch is one operation or a sequence of operations applied in order.
47
+ */
48
+ type Patch = PatchOp | PatchOp[];
49
+ //#endregion
50
+ //#region src/apply.d.ts
51
+ /**
52
+ * Applies a patch to content and returns new content. Does not mutate the input.
53
+ * Operations are applied in order. Does not validate the result (e.g. link integrity).
54
+ */
55
+ declare function applyPatch(content: GenetikContent$1, patch: Patch): GenetikContent$1;
56
+ //#endregion
57
+ export { type AddNodeOp, type ContentNode, type GenetikContent, type Patch, type PatchOp, type RemoveNodeOp, type ReorderSlotOp, type UpdateConfigOp, applyPatch };
58
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/apply.ts"],"mappings":";;;;;AAMA;;UAAiB,SAAA;EACf,IAAA;EAAA;EAEA,EAAA;EAEA;EAAA,IAAA,EAAM,WAAA;AAAA;;AAMR;;UAAiB,YAAA;EACf,IAAA;EACA,EAAA;AAAA;;;;UAMe,cAAA;EACf,IAAA;EACA,EAAA;EACA,MAAA,EAAQ,MAAA;AAAA;;AAMV;;UAAiB,aAAA;EACf,IAAA;EAAA;EAEA,EAAA;EACA,QAAA;EAEA;EAAA,KAAA;AAAA;AAMF;;;AAAA,KAAY,OAAA,GAAU,SAAA,GAAY,YAAA,GAAe,cAAA,GAAiB,aAAA;;;;KAKtD,KAAA,GAAQ,OAAA,GAAU,OAAA;;;;AA7C9B;;;iBCCgB,UAAA,CAAW,OAAA,EAAS,gBAAA,EAAgB,KAAA,EAAO,KAAA,GAAQ,gBAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,93 @@
1
+ //#region src/apply.ts
2
+ /**
3
+ * Applies a patch to content and returns new content. Does not mutate the input.
4
+ * Operations are applied in order. Does not validate the result (e.g. link integrity).
5
+ */
6
+ function applyPatch(content, patch) {
7
+ const ops = Array.isArray(patch) ? patch : [patch];
8
+ let result = content;
9
+ for (const op of ops) result = applyOp(result, op);
10
+ return result;
11
+ }
12
+ function applyOp(content, op) {
13
+ switch (op.type) {
14
+ case "addNode": return applyAddNode(content, op);
15
+ case "removeNode": return applyRemoveNode(content, op);
16
+ case "updateConfig": return applyUpdateConfig(content, op);
17
+ case "reorderSlot": return applyReorderSlot(content, op);
18
+ }
19
+ }
20
+ function applyAddNode(content, op) {
21
+ const nodes = {
22
+ ...content.nodes,
23
+ [op.id]: { ...op.node }
24
+ };
25
+ return {
26
+ ...content,
27
+ nodes
28
+ };
29
+ }
30
+ function applyRemoveNode(content, op) {
31
+ const nodes = {};
32
+ for (const [id, node] of Object.entries(content.nodes)) {
33
+ if (id === op.id) continue;
34
+ const updated = removeIdFromNodeSlots(node, op.id);
35
+ if (updated !== null) nodes[id] = updated;
36
+ }
37
+ return {
38
+ ...content,
39
+ nodes
40
+ };
41
+ }
42
+ function removeIdFromNodeSlots(node, removeId) {
43
+ let changed = false;
44
+ const out = {
45
+ id: node.id,
46
+ block: node.block,
47
+ config: node.config
48
+ };
49
+ for (const [key, value] of Object.entries(node)) {
50
+ if (key === "id" || key === "block" || key === "config") continue;
51
+ if (Array.isArray(value)) {
52
+ const filtered = value.filter((id) => id !== removeId);
53
+ if (filtered.length !== value.length) changed = true;
54
+ out[key] = filtered;
55
+ } else if (value === removeId) changed = true;
56
+ else out[key] = value;
57
+ }
58
+ return changed ? out : node;
59
+ }
60
+ function applyUpdateConfig(content, op) {
61
+ const node = content.nodes[op.id];
62
+ if (!node) return content;
63
+ const nodes = {
64
+ ...content.nodes,
65
+ [op.id]: {
66
+ ...node,
67
+ config: { ...op.config }
68
+ }
69
+ };
70
+ return {
71
+ ...content,
72
+ nodes
73
+ };
74
+ }
75
+ function applyReorderSlot(content, op) {
76
+ const node = content.nodes[op.id];
77
+ if (!node) return content;
78
+ const nodes = {
79
+ ...content.nodes,
80
+ [op.id]: {
81
+ ...node,
82
+ [op.slotName]: [...op.order]
83
+ }
84
+ };
85
+ return {
86
+ ...content,
87
+ nodes
88
+ };
89
+ }
90
+
91
+ //#endregion
92
+ export { applyPatch };
93
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/apply.ts"],"sourcesContent":["import type { ContentNode, GenetikContent } from \"@genetik/content\";\nimport type { Patch, PatchOp } from \"./types.js\";\n\n/**\n * Applies a patch to content and returns new content. Does not mutate the input.\n * Operations are applied in order. Does not validate the result (e.g. link integrity).\n */\nexport function applyPatch(content: GenetikContent, patch: Patch): GenetikContent {\n const ops = Array.isArray(patch) ? patch : [patch];\n let result = content;\n for (const op of ops) {\n result = applyOp(result, op);\n }\n return result;\n}\n\nfunction applyOp(content: GenetikContent, op: PatchOp): GenetikContent {\n switch (op.type) {\n case \"addNode\":\n return applyAddNode(content, op);\n case \"removeNode\":\n return applyRemoveNode(content, op);\n case \"updateConfig\":\n return applyUpdateConfig(content, op);\n case \"reorderSlot\":\n return applyReorderSlot(content, op);\n }\n}\n\nfunction applyAddNode(content: GenetikContent, op: { id: string; node: ContentNode }): GenetikContent {\n const nodes = { ...content.nodes, [op.id]: { ...op.node } };\n return { ...content, nodes };\n}\n\nfunction applyRemoveNode(content: GenetikContent, op: { id: string }): GenetikContent {\n const nodes: Record<string, ContentNode> = {};\n for (const [id, node] of Object.entries(content.nodes)) {\n if (id === op.id) continue;\n const updated = removeIdFromNodeSlots(node, op.id);\n if (updated !== null) nodes[id] = updated;\n }\n return { ...content, nodes };\n}\n\nfunction removeIdFromNodeSlots(node: ContentNode, removeId: string): ContentNode | null {\n let changed = false;\n const out: ContentNode = { id: node.id, block: node.block, config: node.config };\n for (const [key, value] of Object.entries(node)) {\n if (key === \"id\" || key === \"block\" || key === \"config\") continue;\n if (Array.isArray(value)) {\n const filtered = value.filter((id) => id !== removeId);\n if (filtered.length !== value.length) changed = true;\n out[key] = filtered;\n } else if (value === removeId) {\n changed = true;\n // omit this slot (undefined)\n } else {\n out[key] = value;\n }\n }\n return changed ? out : node;\n}\n\nfunction applyUpdateConfig(\n content: GenetikContent,\n op: { id: string; config: Record<string, unknown> }\n): GenetikContent {\n const node = content.nodes[op.id];\n if (!node) return content;\n const nodes = {\n ...content.nodes,\n [op.id]: { ...node, config: { ...op.config } },\n };\n return { ...content, nodes };\n}\n\nfunction applyReorderSlot(\n content: GenetikContent,\n op: { id: string; slotName: string; order: string[] }\n): GenetikContent {\n const node = content.nodes[op.id];\n if (!node) return content;\n const nodes = {\n ...content.nodes,\n [op.id]: { ...node, [op.slotName]: [...op.order] },\n };\n return { ...content, nodes };\n}\n"],"mappings":";;;;;AAOA,SAAgB,WAAW,SAAyB,OAA8B;CAChF,MAAM,MAAM,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CAClD,IAAI,SAAS;AACb,MAAK,MAAM,MAAM,IACf,UAAS,QAAQ,QAAQ,GAAG;AAE9B,QAAO;;AAGT,SAAS,QAAQ,SAAyB,IAA6B;AACrE,SAAQ,GAAG,MAAX;EACE,KAAK,UACH,QAAO,aAAa,SAAS,GAAG;EAClC,KAAK,aACH,QAAO,gBAAgB,SAAS,GAAG;EACrC,KAAK,eACH,QAAO,kBAAkB,SAAS,GAAG;EACvC,KAAK,cACH,QAAO,iBAAiB,SAAS,GAAG;;;AAI1C,SAAS,aAAa,SAAyB,IAAuD;CACpG,MAAM,QAAQ;EAAE,GAAG,QAAQ;GAAQ,GAAG,KAAK,EAAE,GAAG,GAAG,MAAM;EAAE;AAC3D,QAAO;EAAE,GAAG;EAAS;EAAO;;AAG9B,SAAS,gBAAgB,SAAyB,IAAoC;CACpF,MAAM,QAAqC,EAAE;AAC7C,MAAK,MAAM,CAAC,IAAI,SAAS,OAAO,QAAQ,QAAQ,MAAM,EAAE;AACtD,MAAI,OAAO,GAAG,GAAI;EAClB,MAAM,UAAU,sBAAsB,MAAM,GAAG,GAAG;AAClD,MAAI,YAAY,KAAM,OAAM,MAAM;;AAEpC,QAAO;EAAE,GAAG;EAAS;EAAO;;AAG9B,SAAS,sBAAsB,MAAmB,UAAsC;CACtF,IAAI,UAAU;CACd,MAAM,MAAmB;EAAE,IAAI,KAAK;EAAI,OAAO,KAAK;EAAO,QAAQ,KAAK;EAAQ;AAChF,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;AAC/C,MAAI,QAAQ,QAAQ,QAAQ,WAAW,QAAQ,SAAU;AACzD,MAAI,MAAM,QAAQ,MAAM,EAAE;GACxB,MAAM,WAAW,MAAM,QAAQ,OAAO,OAAO,SAAS;AACtD,OAAI,SAAS,WAAW,MAAM,OAAQ,WAAU;AAChD,OAAI,OAAO;aACF,UAAU,SACnB,WAAU;MAGV,KAAI,OAAO;;AAGf,QAAO,UAAU,MAAM;;AAGzB,SAAS,kBACP,SACA,IACgB;CAChB,MAAM,OAAO,QAAQ,MAAM,GAAG;AAC9B,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ;EACZ,GAAG,QAAQ;GACV,GAAG,KAAK;GAAE,GAAG;GAAM,QAAQ,EAAE,GAAG,GAAG,QAAQ;GAAE;EAC/C;AACD,QAAO;EAAE,GAAG;EAAS;EAAO;;AAG9B,SAAS,iBACP,SACA,IACgB;CAChB,MAAM,OAAO,QAAQ,MAAM,GAAG;AAC9B,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ;EACZ,GAAG,QAAQ;GACV,GAAG,KAAK;GAAE,GAAG;IAAO,GAAG,WAAW,CAAC,GAAG,GAAG,MAAM;GAAE;EACnD;AACD,QAAO;EAAE,GAAG;EAAS;EAAO"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@genetik/patches",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.mjs",
10
+ "types": "./dist/index.d.mts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.cjs",
15
+ "types": "./dist/index.d.mts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "dependencies": {
22
+ "@genetik/content": "0.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "eslint": "^9.39.1",
26
+ "tsdown": "0.20.3",
27
+ "typescript": "5.9.2",
28
+ "vitest": "^2.1.8",
29
+ "@genetik/eslint-config": "0.0.0",
30
+ "@genetik/typescript-config": "0.0.0"
31
+ },
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "license": "MIT",
36
+ "scripts": {
37
+ "build": "tsdown",
38
+ "dev": "tsdown --watch",
39
+ "lint": "eslint . --max-warnings 0",
40
+ "check-types": "tsc --noEmit",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest"
43
+ }
44
+ }