intentx-solid 0.2.2-z1 → 0.2.3

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 CHANGED
@@ -131,14 +131,13 @@ No providers required (unless you want shared context).
131
131
  const counter = useLogic(counterLogic)
132
132
  ```
133
133
 
134
- ```txt
135
- {
136
- runtime,
137
- store,
138
- state,
139
- actions,
140
- emit
141
- }
134
+ ```ts
135
+ {
136
+ store, //
137
+ state, // alias state
138
+ actions, // actions -> emit
139
+ emit // directly
140
+ }
142
141
  ```
143
142
 
144
143
  🔥 Important
@@ -0,0 +1 @@
1
+ "use strict";var e=require("intentx-runtime"),t=require("solid-js/store"),r=require("solid-js");let n=null;const o=new Map;function c(){return n||(n=e.createIntentBus()),n}function s(t){return t?(o.has(t)||o.set(t,e.createIntentBus()),o.get(t)):c()}const i="undefined"!=typeof window;function u(n,o){const c="string"==typeof o?.scope?e.createScope(o.scope):o?.scope,u=o?.bus??(o?.sharedBus?s("string"==typeof o?.scope?o.scope:void 0):void 0),a=u?n.create(c,u):n.create(c),[p,f]=t.createStore(a.getSnapshot());let d=()=>{};return i&&(d=a.subscribe(()=>{f(t.reconcile(a.getSnapshot()))}),r.onCleanup(()=>{d(),a.destroy?.()})),{runtime:a,store:p,state:p,actions:a.actions,emit:a.emit.bind(a)}}const a=r.createContext({});Object.defineProperty(exports,"createIntentBus",{enumerable:!0,get:function(){return e.createIntentBus}}),Object.defineProperty(exports,"createLogic",{enumerable:!0,get:function(){return e.createLogic}}),Object.defineProperty(exports,"effect",{enumerable:!0,get:function(){return e.effect}}),exports.getGlobalBus=c,exports.getScopedBus=s,exports.setLogicContext=function(e,t,r){const n=u(t,r);return{Provider:function(t){return a.Provider({value:{[e]:n},get children(){return t.children}})},store:n}},exports.useLogic=u,exports.useLogicContext=function(e){const t=r.useContext(a);if(!t||!t[e])throw Error(`Logic "${e}" not found in context`);return t[e]};
@@ -0,0 +1,33 @@
1
+ import { createIntentBus, LogicActions, InferComputed, Scope, ComputedDef, LogicFactory } from 'intentx-runtime';
2
+ export { EffectMode, ExtractLogicTypes, IntentContext, LogicActions, LogicFactory, LogicRuntime, createIntentBus, createLogic, effect } from 'intentx-runtime';
3
+ import * as solid_js from 'solid-js';
4
+
5
+ type IntentBus = ReturnType<typeof createIntentBus>;
6
+ declare function getGlobalBus(): IntentBus;
7
+ declare function getScopedBus(scope?: string): IntentBus;
8
+
9
+ type LogicApi<S, C, A extends LogicActions> = {
10
+ runtime: any;
11
+ store: Readonly<S & InferComputed<C>>;
12
+ state: Readonly<S & InferComputed<C>>;
13
+ actions: A;
14
+ emit: (...args: any[]) => Promise<void>;
15
+ };
16
+
17
+ type LogicOptions = {
18
+ scope?: Scope | string;
19
+ sharedBus?: boolean;
20
+ bus?: IntentBus;
21
+ };
22
+ declare function useLogic<S extends object, C extends ComputedDef<S>, A extends LogicActions>(logic: LogicFactory<S, C, A>, options?: LogicOptions): LogicApi<S, C, A>;
23
+
24
+ declare function setLogicContext<S extends object, C extends ComputedDef<S>, A extends LogicActions>(key: string, logic: LogicFactory<S, C, A>, options?: LogicOptions): {
25
+ Provider: (props: {
26
+ children: any;
27
+ }) => solid_js.JSX.Element;
28
+ store: LogicApi<S, C, A>;
29
+ };
30
+ declare function useLogicContext<T>(key: string): T;
31
+
32
+ export { getGlobalBus, getScopedBus, setLogicContext, useLogic, useLogicContext };
33
+ export type { IntentBus, LogicApi, LogicOptions };
package/build/index.js ADDED
@@ -0,0 +1 @@
1
+ import{createIntentBus as t,createScope as e}from"intentx-runtime";export{createIntentBus,createLogic,effect}from"intentx-runtime";import{createStore as n,reconcile as o}from"solid-js/store";import{onCleanup as r,createContext as i,useContext as s}from"solid-js";let c=null;const u=new Map;function f(){return c||(c=t()),c}function p(e){return e?(u.has(e)||u.set(e,t()),u.get(e)):f()}const d="undefined"!=typeof window;function a(t,i){const s="string"==typeof i?.scope?e(i.scope):i?.scope,c=i?.bus??(i?.sharedBus?p("string"==typeof i?.scope?i.scope:void 0):void 0),u=c?t.create(s,c):t.create(s),[f,a]=n(u.getSnapshot());let m=()=>{};return d&&(m=u.subscribe(()=>{a(o(u.getSnapshot()))}),r(()=>{m(),u.destroy?.()})),{runtime:u,store:f,state:f,actions:u.actions,emit:u.emit.bind(u)}}const m=i({});function l(t,e,n){const o=a(e,n);return{Provider:function(e){return m.Provider({value:{[t]:o},get children(){return e.children}})},store:o}}function g(t){const e=s(m);if(!e||!e[t])throw Error(`Logic "${t}" not found in context`);return e[t]}export{f as getGlobalBus,p as getScopedBus,l as setLogicContext,a as useLogic,g as useLogicContext};
@@ -0,0 +1,4 @@
1
+ import { createIntentBus } from "intentx-runtime";
2
+ export type IntentBus = ReturnType<typeof createIntentBus>;
3
+ export declare function getGlobalBus(): IntentBus;
4
+ export declare function getScopedBus(scope?: string): IntentBus;
@@ -0,0 +1,9 @@
1
+ import type { LogicFactory, LogicActions, ComputedDef } from "intentx-runtime";
2
+ import type { LogicOptions } from "./useLogic";
3
+ export declare function setLogicContext<S extends object, C extends ComputedDef<S>, A extends LogicActions>(key: string, logic: LogicFactory<S, C, A>, options?: LogicOptions): {
4
+ Provider: (props: {
5
+ children: any;
6
+ }) => import("solid-js").JSX.Element;
7
+ store: import("./types").LogicApi<S, C, A>;
8
+ };
9
+ export declare function useLogicContext<T>(key: string): T;
@@ -0,0 +1,4 @@
1
+ export * from "./useLogic";
2
+ export * from "./context";
3
+ export * from "./bus";
4
+ export * from "./types";
@@ -0,0 +1,8 @@
1
+ import type { InferComputed, LogicActions } from "intentx-runtime";
2
+ export type LogicApi<S, C, A extends LogicActions> = {
3
+ runtime: any;
4
+ store: Readonly<S & InferComputed<C>>;
5
+ state: Readonly<S & InferComputed<C>>;
6
+ actions: A;
7
+ emit: (...args: any[]) => Promise<void>;
8
+ };
@@ -0,0 +1,9 @@
1
+ import type { Scope, LogicFactory, LogicActions, ComputedDef } from "intentx-runtime";
2
+ import type { IntentBus } from "./bus";
3
+ import type { LogicApi } from "./types";
4
+ export type LogicOptions = {
5
+ scope?: Scope | string;
6
+ sharedBus?: boolean;
7
+ bus?: IntentBus;
8
+ };
9
+ export declare function useLogic<S extends object, C extends ComputedDef<S>, A extends LogicActions>(logic: LogicFactory<S, C, A>, options?: LogicOptions): LogicApi<S, C, A>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intentx-solid",
3
- "version": "0.2.2-z1",
3
+ "version": "0.2.3",
4
4
  "description": "Intent-driven logic adapter for SolidJS. Connects intentx-runtime with Solid's fine-grained reactivity.",
5
5
  "license": "MIT",
6
6
  "author": "Delpi.Kye",