{"_id":"@ash9g/redu","_rev":"4-f9bb92f409d3e0c22f71e74b765a2e2f","name":"@ash9g/redu","description":"Strongly typed typescript  helpers for redux","dist-tags":{"latest":"1.0.1"},"versions":{"0.0.1":{"name":"@ash9g/redu","version":"0.0.1","description":"Strongly typed typescript  helpers for redux","keywords":["redux","ash9g","typescript"],"main":"index.js","author":{"name":"benjaminjackman"},"license":"MIT","private":false,"dependencies":{"clone":"^2.1.1"},"devDependencies":{"@types/clone":"^0.1.30"},"_id":"@ash9g/redu@0.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"benjaminjackman","email":"ben@jackman.biz"},"dist":{"integrity":"sha512-E4L9a/K+7LuLjtQWR8DSls0QXeDsXy91ZQSuOoCrVSUGFIYC8eRezj9PEX/x/MrRqrdkbTlO5RE4kXpvmoxLjw==","shasum":"4ca99fa3da67ceb20bb11c4a64ed68f22ccdc31d","tarball":"https://registry.npmjs.org/@ash9g/redu/-/redu-0.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCUYqNf/y/KcRe/a2iu55aMdTwHgWbCb5d5sUZ2hn6tRgIgXEfvtDrNuzJDgL9ysC/9lN39HiV5LvMjOOmlTLciukw="}]},"maintainers":[{"name":"benjaminjackman","email":"ben@jackman.biz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redu-0.0.1.tgz_1517778998901_0.46293196780607104"},"directories":{}},"1.0.0":{"name":"@ash9g/redu","version":"1.0.0","description":"Strongly typed typescript  helpers for redux","keywords":["redux","ash9g","typescript"],"main":"dist/index.js","types":"dist/index.d.ts","author":{"name":"benjaminjackman"},"license":"MIT","private":false,"dependencies":{"clone":"^2.1.1"},"devDependencies":{"@types/clone":"^0.1.30"},"_id":"@ash9g/redu@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"benjaminjackman","email":"ben@jackman.biz"},"dist":{"integrity":"sha512-Lo3a5I7XYrcAjT3WcsM4paUprumZkLkI2IVCMpuKYv2nwiGr/RCd7LAAEsrjYctMAel0QAJpnSykbsON6Xz1JQ==","shasum":"160bee9d108563ad72be250d55a7a903cbc382f2","tarball":"https://registry.npmjs.org/@ash9g/redu/-/redu-1.0.0.tgz","fileCount":7,"unpackedSize":14116,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID/gYNIDvWYaf26CWANEjqyvSmiP5hKpq2nkzJwe3OIfAiBu8gT3ISF3B5gshx46vx26zwVZk9/6tTLi6OUOalQM/A=="}]},"maintainers":[{"name":"benjaminjackman","email":"ben@jackman.biz"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redu_1.0.0_1518218493039_0.0007382171458212294"},"_hasShrinkwrap":false},"1.0.1":{"name":"@ash9g/redu","version":"1.0.1","description":"Strongly typed typescript  helpers for redux","keywords":["redux","ash9g","typescript"],"scripts":{"prepublish":"tsc"},"main":"dist/index.js","types":"dist/index.d.ts","author":{"name":"benjaminjackman"},"license":"MIT","private":false,"dependencies":{"clone":"^2.1.1"},"devDependencies":{"@types/clone":"^0.1.30","typescript":"2.7.1"},"_id":"@ash9g/redu@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"benjaminjackman","email":"ben@jackman.biz"},"dist":{"integrity":"sha512-AgY3t7lqVFr2nBMtFQ0bc/fRuXSb/22PKaO2BE4RVU/zp0C0yRoB7OxhjZdirtDJjKPIU7H0JSX9e5VYqQlBtA==","shasum":"50f5c24901aafbcf25d86dab5ed27f8ee17fc29c","tarball":"https://registry.npmjs.org/@ash9g/redu/-/redu-1.0.1.tgz","fileCount":7,"unpackedSize":14346,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCa1cEdJBzzFn+p2NbtvjyxmkNEyUlqAwgcessl2rm/ngIhAI/7xnGFrXfG6pxfWAhcjHSthiqHaMKETgyViN3+VeNR"}]},"maintainers":[{"name":"benjaminjackman","email":"ben@jackman.biz"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redu_1.0.1_1518218574998_0.183793570939216"},"_hasShrinkwrap":false}},"readme":"\n\nSome examples:\n\n```\nimport {createActionFactory} from \"@ash9g/redu\";\nimport {LocDim, DskState, WndState} from \"./DskState\";\nimport {AppDescriptor, AppHook} from \"./App\"\n\nexport interface XY {\n  x: number\n  y: number\n}\n\nexport const DskActions = {\n  SetState: createActionFactory(\"SetState\").payload<{ state: DskState, }>(),\n\n  DskMouseMove: createActionFactory(\"DskMouseMove\").payload<{ xy: XY, }>(),\n  DskMouseUp: createActionFactory(\"DskMouseUp\").payload(),\n\n  WndTitleDown: createActionFactory(\"WndTitleDown\").payload<{ wndId: number, xy: XY, }>(),\n\n  WndBorderDown: createActionFactory(\"WndBorderDown\").payload<{ wndId: number, xy: XY, direction: string, }>(),\n  WndMouseDown: createActionFactory(\"WndMouseDown\").payload<{ wndId: number }>(),\n\n  WndClose: createActionFactory(\"WndClose\").payload<{ wndId: number }>(),\n  WndMax: createActionFactory(\"WndMax\").payload<{ wndId: number }>(),\n  WndMin: createActionFactory(\"WndMin\").payload<{ wndId: number }>(),\n\n  IcnRun: createActionFactory(\"IcnRun\").payload<{ appId: string, appProps: any }>(),\n\n  AppStart: createActionFactory(\"AppStart\").payload<{ wnd: WndState,  hook: AppHook}>(),\n  AppStop: createActionFactory(\"AppStop\").payload<{ wnd: WndState,  hook: AppHook}>(),\n  SetAppProps: createActionFactory(\"SetAppProps\").payload<{wndId: number, appProps: any}>(),\n\n  //TODO ADD TYPE TO ONE OF BELOW\n}\n\nexport type DskAction =\n  typeof DskActions.DskMouseMove.at |\n  typeof DskActions.DskMouseUp.at |\n  typeof DskActions.WndTitleDown.at |\n  typeof DskActions.WndBorderDown.at |\n  typeof DskActions.WndMouseDown.at |\n  typeof DskActions.WndClose.at |\n  // typeof DskActions.WndOpen.at |\n  typeof DskActions.WndMax.at |\n  typeof DskActions.WndMin.at |\n  typeof DskActions.IcnRun.at |\n  typeof DskActions.SetState.at |\n  typeof DskActions.AppStart.at |\n  typeof DskActions.AppStop.at |\n  typeof DskActions.SetAppProps.at\n```\n\n\n```\nimport {DskAction, DskActions} from \"./DskActions\";\nimport {DskState, DskStateHelp, WndState, LocDim, XY} from \"./DskState\";\nimport {createReducerSet} from \"ash9g/redu\";\n\n\nconst DskReducers = {\n\n  SetStateReducer: DskActions.SetState.reducer<DskState>((s, a) => {\n    return a.state\n  }),\n\n  DskMouseMoveReducer: DskActions.DskMouseMove.reducer<DskState>((s, a) => {\n    if (s.ops.moveeWid != -1) {\n      const dx = a.xy.x - s.ops.startPageXY.x\n      const dy = a.xy.y - s.ops.startPageXY.y\n\n      const wid = s.ops.moveeWid\n      const wnd = s.wnds.wnds.get(wid)\n      s = s.setIn([\"wnds\", \"wnds\"], s.wnds.wnds.updateIn([wid, \"nextLoc\"], nl => {\n        const x = Math.max(wnd.loc.x + dx, 0)\n        const y = Math.max(wnd.loc.y + dy, 0)\n        return nl.merge({x, y})\n      }))\n\n      return s\n    }\n\n    if (s.ops.resizeeWid != -1) {\n      const dir = s.ops.resizeDir\n      const wid = s.ops.resizeeWid\n      const wnd = DskStateHelp.getWndOrNull(s, wid)\n\n      if (dir != \"\") {\n        let mdx = 0\n        if (dir != \"N\" && dir != \"S\") {\n          mdx = a.xy.x - s.ops.startPageXY.x\n        }\n\n        let mdy = 0\n        if (dir != \"E\" && dir != \"W\") {\n          mdy = a.xy.y - s.ops.startPageXY.y\n        }\n\n        let width: any\n        let height: any\n        let top: any\n        let left: any\n\n        if (dir == \"N\" || dir == \"NE\" || dir == \"NW\") {\n          top = (mdy + wnd.loc.y)\n          if (top < 0) {\n            //If the top goes off the top of screen while resizing \n            //just cap it & height\n            top = 0\n            height = wnd.loc.y + wnd.loc.height\n          } else {\n            height = (-mdy + wnd.loc.height)\n          }\n        } else if (dir == \"S\" || dir == \"SE\" || dir == \"SW\") {\n          height = (mdy + wnd.loc.height)\n        }\n\n        if (dir == \"E\" || dir == \"NE\" || dir == \"SE\") {\n          width = (mdx + wnd.loc.width)\n        } else if (dir == \"W\" || dir == \"NW\" || dir == \"SW\") {\n          left = (mdx + wnd.loc.x)\n          if (left < 0) {\n            left = 0\n            width = wnd.loc.x + wnd.loc.width\n          } else {\n            width = (-mdx + wnd.loc.width)\n          }\n\n        }\n\n        const heightOk = height != null && !isNaN(height) && height >= 0\n        const widthOk = width != null && !isNaN(width) && width >= 0\n        const topOk = top != null && !isNaN(top)\n        const leftOk = left != null && !isNaN(left)\n\n        let nextLoc = wnd.nextLoc\n\n        if (heightOk) {\n          nextLoc = nextLoc.set(\"height\", height)\n        }\n        if (widthOk) {\n          nextLoc = nextLoc.set(\"width\", width)\n        }\n        if (topOk) {\n          nextLoc = nextLoc.set(\"y\", top)\n        }\n        if (leftOk) {\n          nextLoc = nextLoc.set(\"x\", left)\n        }\n\n        s = s.setIn([\"wnds\", \"wnds\"], s.wnds.wnds.set(wid, wnd.set(\"nextLoc\", nextLoc)))\n\n        return s\n      }\n    }\n    return null\n  }),\n\n\n  DskMouseUpReducer: DskActions.DskMouseUp.reducer<DskState>((s, a) => {\n\n    let ops = s.ops.set(\"allowSelect\", true)\n\n    if (s.ops.moveeWid != -1) {\n      const wid = s.ops.moveeWid\n      const wnd = DskStateHelp.getWndOrNull(s, wid)\n\n      s = s.setIn([\"wnds\", \"wnds\"], s.wnds.wnds.set(wid, wnd.merge({\n        moving: false,\n        loc: wnd.nextLoc || wnd.loc,\n        nextLoc: null,\n      })))\n\n      s = s.set(\"ops\", ops.merge({\n        moveeWid: -1,\n        startPageXY: null,\n      }))\n    }\n\n    if (s.ops.resizeeWid != -1) {\n      const wid = s.ops.resizeeWid\n      const wnd = DskStateHelp.getWndOrNull(s, wid)\n\n      s = s.setIn([\"wnds\", \"wnds\"], s.wnds.wnds.set(wid, wnd.merge({\n        loc: wnd.nextLoc || wnd.loc,\n        nextLoc: null,\n      })))\n\n      s = s.set(\"ops\", ops.merge({\n        resizeeWid: -1,\n        resizeDir: \"\",\n        startPageXY: null,\n      }))\n\n    }\n\n\n    return s\n  }),\n\n  WndTitleDownReducer: DskActions.WndTitleDown.reducer<DskState>((s, a) => {\n    const wid = a.wndId\n    const wnd = DskStateHelp.getWndOrNull(s, wid)\n    if (wnd != null) {\n      let ops = s.ops.set(\"allowSelect\", false)\n      s = s.set(\"ops\", ops)\n\n      s = DskStateHelp.raiseWnd(s, wid)\n\n      s = s.setIn([\"wnds\", \"wnds\"], s.wnds.wnds.update(wid, w => w.merge({\n        moving: true,\n        nextLoc: wnd.loc,\n      })))\n\n      s = s.set(\"ops\", s.ops.merge({\n        moveeWid: wid,\n        startPageXY: new XY(a.xy),\n      }))\n    }\n    return s\n  }),\n\n  WndBorderDownReducer: DskActions.WndBorderDown.reducer<DskState>((s, a) => {\n    const wid = a.wndId\n    const wnd = DskStateHelp.getWndOrNull(s, wid)\n    if (wnd != null) {\n      let ops = s.ops.set(\"allowSelect\", false)\n      s = s.set(\"ops\", ops)\n\n      s = DskStateHelp.raiseWnd(s, wid)\n\n      s = s.setIn([\"wnds\", \"wnds\"], s.wnds.wnds.update(wid, w => w.merge({\n        nextLoc: wnd.loc,\n      })))\n\n      s = s.set(\"ops\", s.ops.merge({\n        resizeeWid: wid,\n        startPageXY: new XY(a.xy),\n        resizeDir: a.direction,\n      }))\n    }\n    return s\n  }),\n\n  WndDownReducer: DskActions.WndMouseDown.reducer<DskState>((s, a) => {\n    return DskStateHelp.raiseWnd(s, a.wndId)\n  }),\n\n  WndCloseReducer: DskActions.WndClose.reducer<DskState>((s, a) => {\n    return s.set(\"wnds\", s.wnds.set(\"wnds\", s.wnds.wnds.remove(a.wndId)))\n  }),\n\n  // WndOpenReducer: DskActions.WndOpen.reducer<DskState>((s, a) => {\n  //   console.error(\"Wndopen no longer supported\")\n  //   return s\n  // }),\n\n\n  IcnRunReducer: DskActions.IcnRun.reducer<DskState>((s, a) => {\n    const app = s.appRegistry.get(a.appId)\n    if (app) {\n      const appDescriptor = app\n      const appProps = a.appProps\n      const wndId = s.ops.nextWndId\n      const x = 100 + (wndId * 20) % 200\n      const y = x\n      s = s.setIn([\"ops\", \"nextWndId\"], wndId + 1)\n\n      const wnd = new WndState({\n        wndId,\n        appDescriptor,\n        appProps,\n        wndTitle: appDescriptor.title,\n        loc: new LocDim({\n          x, y,\n          height: 480,\n          width: 640,\n        }),\n      })\n      s = s.setIn([\"wnds\", \"wnds\", wndId], wnd)\n\n      s = DskStateHelp.raiseWnd(s, wndId)\n    } else {\n      console.error(`Unable to locate cmd[${a.appId}] for icn click`)\n    }\n    return s;\n  }),\n\n  SetAppPropsReducer: DskActions.SetAppProps.reducer<DskState>((s, a) => {\n    s = DskStateHelp.updateWnd(s, a.wndId, wnd => wnd.set(\"appProps\", a.appProps))\n    return s\n  })\n}\n\n\nexport const DskReducerSet = createReducerSet<DskState, DskAction>(DskReducers)\n\n```","maintainers":[{"name":"benjaminjackman","email":"ben@jackman.biz"}],"time":{"modified":"2022-04-04T15:45:16.640Z","created":"2018-02-04T21:16:39.893Z","0.0.1":"2018-02-04T21:16:39.893Z","1.0.0":"2018-02-09T23:21:33.788Z","1.0.1":"2018-02-09T23:22:55.779Z"},"keywords":["redux","ash9g","typescript"],"author":{"name":"benjaminjackman"},"license":"MIT","readmeFilename":"README.md"}