plug-code 1.1.2 → 1.1.4
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.md +2 -2
- package/package.json +1 -1
- package/types/plug-code.d.ts +3 -3
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ import { createPlugAndCode } from 'plug-code';
|
|
|
41
41
|
export const { useSystemPlc, SystemPlcRoot } = createPlugAndCode((api) => {
|
|
42
42
|
|
|
43
43
|
// Define a Sales Feature
|
|
44
|
-
api.
|
|
44
|
+
api.createFuture("sales", (api) => {
|
|
45
45
|
// Register a UI component into a slot
|
|
46
46
|
api.register("header.cart", () => <CartIcon />);
|
|
47
47
|
|
|
@@ -53,7 +53,7 @@ export const { useSystemPlc, SystemPlcRoot } = createPlugAndCode((api) => {
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// Define a Logger Feature that wraps existing logic
|
|
56
|
-
api.
|
|
56
|
+
api.createFuture("logger", (api) => {
|
|
57
57
|
api.wrapCommand("sales.checkout", (next) => async (items) => {
|
|
58
58
|
console.log("Checkout started...");
|
|
59
59
|
const result = await next(items);
|
package/package.json
CHANGED
package/types/plug-code.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
// Tipos Generales
|
|
5
5
|
// ==========================================
|
|
6
6
|
|
|
7
|
-
export type ObjectType = Record<string, any>;
|
|
7
|
+
export declare type ObjectType = Record<string, any>;
|
|
8
8
|
|
|
9
9
|
export type Slot = () => React.ReactNode;
|
|
10
10
|
|
|
@@ -52,12 +52,12 @@ export declare class PlcAPI<S extends ObjectType> {
|
|
|
52
52
|
* @param name Identificador único para debugging y prevención de duplicados.
|
|
53
53
|
* @param setupFn Función de configuración donde registras slots, comandos, etc.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
createFeature(name: string, setupFn: (api: PlcAPI<S>) => void): PlcAPI<S>;
|
|
56
56
|
|
|
57
57
|
// --- Gestión de UI (Slots & Rendering) ---
|
|
58
58
|
|
|
59
59
|
register(slot: string, node: () => React.ReactNode): void;
|
|
60
|
-
register<K extends string>(slot: string, node: (data:
|
|
60
|
+
register<K extends string>(slot: string, node: (data: keyof S) => React.ReactNode, dependencyKey: K): void;
|
|
61
61
|
|
|
62
62
|
/** Envuelve un slot existente (Decorador/Wrapper) */
|
|
63
63
|
wrap(slot: string, fn: (next: () => React.ReactNode) => () => React.ReactNode): void;
|