Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codraft/core

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codraft/core - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

8

dist/@typings/codraft.d.ts

@@ -25,4 +25,4 @@ export declare type VariableItem<T> = {

type: 'radio';
default_value: string;
items: VariableItem<string>[];
default_value: SupportedVariableType;
items: VariableItem<SupportedVariableType>[];
}

@@ -37,3 +37,3 @@ export declare type MacroVariable = StringVariable | NumberVariable | RadioVariable;

export declare type Reject = (reason?: Error) => void;
export declare type Fn = (this: Record<string, any>, data: MacroDataTransfer, next: Resolve, stop: Reject) => Resolve | Reject;
export declare type Fn = (this: Record<string, any>, data: MacroDataTransfer, next: Resolve, stop: Reject) => void;
export declare interface Point2 {

@@ -64,3 +64,3 @@ x: number;

command_id: string;
variables: Record<string, SupportedVariableType>;
variables: Record<string, string>;
};

@@ -67,0 +67,0 @@ type MacroBox = {

@@ -11,2 +11,4 @@ import { Codraft } from "../../@typings/codraft";

private static CreateHashMap;
private static ParseVariables;
private static ParseVariable;
private static RunCommand;

@@ -13,0 +15,0 @@ private static RunCommandAsync;

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Codraft=t():n.Codraft=t()}(window,(function(){return function(n){var t={};function e(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return n[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}return e.m=n,e.c=t,e.d=function(n,t,o){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:o})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var r in n)e.d(o,r,function(t){return n[t]}.bind(null,r));return o},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="/dist/",e(e.s=0)}([function(n,t,e){"use strict";e.r(t),e.d(t,"Runner",(function(){return o}));class o{constructor(n,t,e,r,i=!1){this.__events=n,this.__conditions=t,this.__actions=e,this.__boxes=r.boxes,this.__usedCommands=r.used_commands,this.__isDebug=i,this.__commandHashMap=o.CreateHashMap([...this.__events,...this.__conditions,...this.__actions])}static CreateHashMap(n){const t=new Map;return n.forEach(n=>t.set(n.id,n)),t}static RunCommand(n,t,e){return new Promise((o,r)=>{n.fn.call(t,e,o,r)})}static RunCommandAsync(n,t,e,o,r){n.fn.call(t,e,o,r)}static FindBox(n,t){var e;return null!==(e=n.find(n=>n.id===t))&&void 0!==e?e:null}async __runCommand(n,t){var e;const{command_id:r,variables:i}=n,s=null!==(e=this.__commandHashMap.get(r))&&void 0!==e?e:null;if(null!==s)return await o.RunCommand(s,i,t);throw new Error(`The '${r}' command not exists.`)}__runCommandAsync(n,t,e,r){var i;const{command_id:s,variables:a}=n,c=null!==(i=this.__commandHashMap.get(s))&&void 0!==i?i:null;if(null===c)throw new Error(`The '${s}' command not exists.`);o.RunCommandAsync(c,a,t,e,r)}__runCommands(n,t){return new Promise(async(e,o)=>{let r=!1;for(const e of n){if(r)return;await new Promise((n,o)=>this.__runCommand(e,t).then(n).catch(o)).catch(()=>{r=!0,o()})}e()})}__recursiveBox(n,t){const e=n.next_box_ids.filter(n=>o.FindBox(this.__boxes,n)).map(n=>o.FindBox(this.__boxes,n));this.__runCommands(n.conditions,t).then(()=>this.__runCommands(n.actions,t)).then(()=>{e.forEach(n=>this.__recursiveBox(n,t))})}__attachEvent(){this.__boxes.forEach(n=>{n.events.forEach(t=>{this.__runCommandAsync(t,{event:null,local:{},global:globalThis},t=>this.__recursiveBox(n,t),n=>console.error(n))})})}init(){this.__attachEvent()}}}])}));
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Codraft=n():e.Codraft=n()}(window,(function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/dist/",t(t.s=1)}([function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return CodraftRunner}));class CodraftRunner{constructor(e,n,t,r,o=!1){this.__events=e,this.__conditions=n,this.__actions=t,this.__boxes=r.boxes,this.__usedCommands=r.used_commands,this.__isDebug=o,this.__commandHashMap=CodraftRunner.CreateHashMap([...this.__events,...this.__conditions,...this.__actions])}static CreateHashMap(e){const n=new Map;return e.forEach(e=>n.set(e.id,e)),n}static ParseVariables(e,n,t){const r={};for(const o in e)r[o]=CodraftRunner.ParseVariable(e[o],n,t);return r}static ParseVariable(variable,local,global){const regexp=/{{2}\s*(.*?)\s*}{2}/gim,equation=variable.replace(regexp,(e,n)=>{let t=null;return n in local?t=local[n]:n in global&&(t=global[n]),"string"!=typeof t&&(t=JSON.stringify(t)),t});let result;try{result=eval(equation)}catch(e){result=equation}return result}static RunCommand(e,n,t){return new Promise((r,o)=>{const a=CodraftRunner.ParseVariables(n,t.local,t.global);console.log(a,n),e.fn.call(a,t,r,o)})}static RunCommandAsync(e,n,t,r,o){const a=CodraftRunner.ParseVariables(n,t.local,t.global);e.fn.call(a,t,r,o)}static FindBox(e,n){var t;return null!==(t=e.find(e=>e.id===n))&&void 0!==t?t:null}async __runCommand(e,n){var t;const{command_id:r,variables:o}=e,a=null!==(t=this.__commandHashMap.get(r))&&void 0!==t?t:null;if(null!==a)return await CodraftRunner.RunCommand(a,o,n);throw new Error(`The '${r}' command not exists.`)}__runCommandAsync(e,n,t,r){var o;const{command_id:a,variables:s}=e,i=null!==(o=this.__commandHashMap.get(a))&&void 0!==o?o:null;if(null===i)throw new Error(`The '${a}' command not exists.`);CodraftRunner.RunCommandAsync(i,s,n,t,r)}__runCommands(e,n){return new Promise(async(t,r)=>{let o=!1;for(const t of e){if(o)return;await new Promise((e,r)=>this.__runCommand(t,n).then(e).catch(r)).catch(()=>{o=!0,r()})}t()})}__recursiveBox(e,n){const t=e.next_box_ids.filter(e=>CodraftRunner.FindBox(this.__boxes,e)).map(e=>CodraftRunner.FindBox(this.__boxes,e));this.__runCommands(e.conditions,n).then(()=>this.__runCommands(e.actions,n)).then(()=>{t.forEach(e=>this.__recursiveBox(e,n))})}__attachEvent(){this.__boxes.forEach(e=>{e.events.forEach(n=>{this.__runCommandAsync(n,{event:null,local:{},global:globalThis},n=>this.__recursiveBox(e,n),e=>console.error(e))})})}init(){this.__attachEvent()}}},function(e,n,t){"use strict";t.r(n);var r=t(0);t.d(n,"Runner",(function(){return r.a}))}])}));
{
"name": "@codraft/core",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Codraft parser",

@@ -19,3 +19,6 @@ "main": "dist/core/src/index.js",

},
"repository": {
"url": "https://github.com/izure1/Codraft"
},
"license": "MIT"
}
# Codraft/core
`@codraft/canvas`로 작성한 코드를 실행하세요. 브라우저와 Node.js 모든 환경에서 동작합니다.
`@codraft/canvas`로 작성한 코드를 실행하세요. 브라우저와 Node.js 모든 환경에서 작동합니다.

@@ -5,0 +5,0 @@ ## 설치

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc