Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@cloudos/core

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudos/core - npm Package Compare versions

Comparing version
1.0.24
to
1.0.25
+1
lib/appman/db.d.ts
export function taffy(d: any): (...args: any[]) => any;

Sorry, the diff of this file is too big to display

declare type AppDescriptor = {
name?: string;
icon?: any;
desciption?: string;
start: Function;
pause?: Function;
exit: Function;
[key: string]: any;
};
declare type AppDescriptorProxy = {
name?: string;
icon?: any;
description?: string;
start: Function;
exit: Function;
[key: string]: any;
};
declare const defineApp: (creator: () => AppDescriptor) => void;
declare const loadAppFromWorker: (woker: Worker) => Promise<AppDescriptorProxy>;
declare const loadApp: (url: string) => Promise<AppDescriptorProxy>;
declare const loadAppFromString: (s: string) => Promise<AppDescriptorProxy>;
declare const getAppByName: (name: string) => any;
declare const getAllAppInfo: () => any[];
export { defineApp, loadApp, loadAppFromString, loadAppFromWorker, getAppByName, getAllAppInfo, };
import * as comlink from 'comlink';
import { stringToURL } from './utils';
import { taffy } from './db';
const useJsonDB = (db = []) => {
const registry = taffy(db);
return {
getData: () => {
let data = [];
registry().each((item) => { data.push(item); });
return data;
},
...registry,
each: (f) => {
return registry().each(f);
},
filter: (condition) => {
return registry(condition);
}
};
};
const registry = useJsonDB();
const defineApp = (creator) => {
comlink.expose(creator);
};
const useApp = async (descriptor) => {
const name = await descriptor.name;
const icon = await descriptor.icon;
const description = await descriptor.description;
const start = async (x) => {
return await descriptor.start(x);
};
const exit = async (x) => {
return await descriptor.exit(x);
};
return {
name,
icon,
description,
start,
exit,
};
};
const loadAppFromWorker = async (woker) => {
let descriptor = await useApp(comlink.wrap(woker));
// check is a valid descriptor or not
// let descriptor=await creator();
// console.log(descriptor);
registry.insert(descriptor);
return descriptor;
};
const loadApp = (url) => {
let woker = new Worker(url);
return loadAppFromWorker(woker);
};
const loadAppFromString = (s) => {
return loadApp(stringToURL(s));
};
const getAppByName = (name) => {
return registry.filter({ name }).first();
};
const getAllAppInfo = () => {
let info = [];
registry.each((item) => {
let { name, description } = item;
info.push({ name, description });
});
return info;
};
export { defineApp, loadApp, loadAppFromString, loadAppFromWorker, getAppByName, getAllAppInfo, };
export declare const stringToURL: (s: string) => string;
export const stringToURL = (s) => {
const URL = window.URL || window.webkitURL;
let blob;
try {
blob = new Blob([s], { type: 'application/javascript' });
}
catch (e) { // Backwards-compatibility
const BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
blob = new BlobBuilder();
blob.append(s);
blob = blob.getBlob();
}
return URL.createObjectURL(blob);
};
export declare const useCoder: () => {
start: () => void;
};
import Coder from './pages/Coder';
import { rnd, box } from './reusable';
import { createUI, render } from '../../gui';
export const useCoder = () => {
const docRoot = document.getElementById('root');
const useContainer = (docRoot) => {
let c;
return {
createEl: () => {
c = document.createElement('div');
docRoot.appendChild(c);
},
removeEl: () => {
docRoot.removeChild(c);
},
getEl: () => c,
};
};
const container = useContainer(docRoot);
const create = () => {
container.createEl();
const demo = box({
top: 0,
right: 0,
bottom: 0,
left: 0,
}, [
rnd({
// default:{
// width:"100%",
// height:"100%"
// },
// disableDragging:false,
// enableResizing:false,
}, [
Coder
])
]);
let ui = createUI(demo);
render(ui, container.getEl());
};
const destroy = () => {
container.removeEl();
};
const start = () => {
create();
};
return {
start
};
};
declare const _default: {
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
flexShrink: number;
};
export default _default;
export default {
name: "activityBar",
flow: "column",
span: "55px",
backgroundColor: "#2c2c2c",
boxShadow: "0 1px 5px 0 #8c8c8c91",
flexShrink: 0,
};
declare const _default: {
name: string;
description: string;
span: string;
flow: string;
backgroundColor: string;
boxShadow: string;
children: never[];
};
export default _default;
export default {
name: "appBox",
description: "where app ui is displayed",
span: "100%",
flow: "row",
backgroundColor: "white",
boxShadow: "0 1px 5px 0 #8c8c8c91",
children: [
// {
// type:"div",
// children: [
// {
// type: "text-view",
// onClick: () => {
// alert("hi");
// },
// style: {
// backgroundColor: "green",
// },
// children: [
// "Hello World !"
// ]
// }
// ]
// }
]
};
declare const _default: {
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
className: string;
children: (((props?: object | undefined, children?: any[] | undefined) => any) | {
name: string;
minWidth: string;
span?: undefined;
} | {
name: string;
span: string;
minWidth?: undefined;
})[];
};
export default _default;
import windowControl from './windowControl';
export default {
name: "header",
flow: "row",
backgroundColor: "#e5e5e5",
boxShadow: "0 1px 5px 0 #8c8c8c91",
span: "35px",
flexShrink: 0,
className: "drag-handle",
children: [
{
name: "menuBar",
// backgroundColor: "#16488d",
minWidth: "100px",
},
{
name: "blank",
span: "100%",
},
windowControl,
]
};
declare const _default: {
name: string;
flow: string;
width: string;
height: string;
children: (BarProp | {
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
className: string;
children: (((props?: object | undefined, children?: any[] | undefined) => any) | {
name: string;
minWidth: string;
span?: undefined;
} | {
name: string;
span: string;
minWidth?: undefined;
})[];
} | {
flow: string;
span: string;
children: ({
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
} | {
description: string;
flow: string;
span: string;
children: ({
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
flexShrink: number;
} | {
name: string;
description: string;
span: string;
flow: string;
backgroundColor: string;
boxShadow: string;
children: never[];
} | {
name: string;
flow: string;
span: string;
flexShrink: number;
boxShadow: string;
children: {
description: string;
flow: string;
}[];
})[];
})[];
})[];
};
export default _default;
import header from "./header";
import activityBar from "./activityBar";
import sidebar from "./sidebar";
import taskbar from "./taskbar";
import infoBar from "./infoBar";
import panel from "./panel";
import appBox from "./appBox";
export default {
name: "page",
flow: "column",
width: "100%",
height: "100%",
children: [
header,
{
flow: "row",
span: "100%",
children: [
activityBar,
sidebar,
{
description: "right area",
flow: "column",
span: "100%",
children: [
taskbar,
infoBar,
appBox,
panel,
]
}
]
},
statusbar,
]
};
declare const _default: {
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
flexShrink: number;
};
export default _default;
export default {
name: "infoBar",
flow: "row",
span: "20px",
backgroundColor: "#fffeee",
boxShadow: "0 1px 5px 0 #8c8c8c91",
flexShrink: 0,
};
declare const _default: {
name: string;
flow: string;
span: string;
flexShrink: number;
boxShadow: string;
children: {
description: string;
flow: string;
}[];
};
export default _default;
export default {
// type:"resizable"
name: "panel",
flow: "column",
span: "50px",
flexShrink: 1,
boxShadow: "0 1px 5px 0 #8c8c8c91",
children: [
{
description: "problems|output|terminal|console---other operations",
flow: "row",
},
{
description: "iostream",
flow: "column",
}
]
};
declare const _default: {
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
};
export default _default;
export default {
name: "sidebar",
flow: "column",
span: "200px",
backgroundColor: "#f3f3f3",
boxShadow: "0 1px 5px 0 #8c8c8c91",
};
declare const _default: {
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
};
export default _default;
export default {
name: "statusBar",
flow: "row",
backgroundColor: "#007acc",
boxShadow: "0 1px 5px 0 #8c8c8c91",
span: "20px",
flexShrink: 0,
};
declare const _default: {
name: string;
flow: string;
backgroundColor: string;
span: string;
boxShadow: string;
flexShrink: number;
children: {
name: string;
flow: string;
children: never[];
}[];
};
export default _default;
export default {
name: "taskbar",
flow: "row",
backgroundColor: "#f3f3f3",
span: "40px",
boxShadow: "0 1px 5px 0 #8c8c8c91",
flexShrink: 0,
children: [
{
name: "tasks",
flow: "row",
children: [],
},
{
name: "operations",
flow: "row",
children: [],
}
]
};
declare const _default: (props?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineTemplate } from "../../../../gui/utils";
import { ipc } from "@cloudos/ipc";
const template = (x) => {
const { onMinimize = () => { ipc.dispatch("window-minimize"); }, onMaximize = () => { ipc.dispatch("window-maximize"); }, onRestore = () => { ipc.dispatch("window-restore"); }, onClose = () => { ipc.dispatch("window-close"); }, } = x || {};
return {
// "typename": "window-control",
"span": "100px",
"flow": "row",
"alignItems": "center",
"justifyContent": "space-evenly",
"children": [
{
"type": "WindowMinimize",
onClick: onMinimize,
},
{
"type": "WindowRestore",
onClick: onRestore,
},
{
"type": "WindowMaximize",
onClick: onMaximize,
},
{
"type": "WindowClose",
onClick: onClose,
}
]
};
};
export default defineTemplate(template);
declare const _default: (params?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineReusable } from "../../../gui/engine";
export default defineReusable({
name: "box",
position: "fixed",
backgroundColor: "white",
border: "solid 1px black",
left: 10,
right: 10,
top: 10,
bottom: 10,
children: []
});
import box from './box';
import rnd from './rnd';
export { box, rnd, };
import box from './box';
// import pane from './pane';
import rnd from './rnd';
// import sortablePane from './sortablePane';
export { box,
// pane,
rnd,
// sortablePane
};
declare const _default: (params?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineReusable } from "../../../framework/engine";
export default defineReusable({
type: "pane",
name: "window",
resizable: { x: true, y: true, xy: true },
defaultSize: { width: 200, height: 400 },
minHeight: 300,
minWidth: 150,
children: []
});
declare const _default: (params?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineReusable } from "../../../gui/engine";
export default defineReusable({
type: "rnd",
name: "window",
bounds: 'parent',
default: {
x: 0,
y: 0,
width: 400,
height: 300,
},
minWidth: 300,
minHeight: 200,
dragHandleClassName: "drag-handle",
children: []
});
declare const _default: (params?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineReusable } from "../../../framework/engine";
export default defineReusable({
type: "sortable-pane",
name: "window",
direction: "horizontal",
margin: 20,
children: []
});
import DemoAppWorker from './worker?worker';
export { DemoAppWorker };
import DemoAppWorker from './worker?worker';
export { DemoAppWorker };
declare const _default: {
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
flexShrink: number;
};
export default _default;
export default {
name: "activityBar",
flow: "column",
span: "55px",
backgroundColor: "#2c2c2c",
boxShadow: "0 1px 5px 0 #8c8c8c91",
flexShrink: 0,
};
declare const _default: {
name: string;
description: string;
span: string;
flow: string;
backgroundColor: string;
boxShadow: string;
children: never[];
};
export default _default;
export default {
name: "appBox",
description: "where app ui is displayed",
span: "100%",
flow: "row",
backgroundColor: "white",
boxShadow: "0 1px 5px 0 #8c8c8c91",
children: [
// {
// type:"div",
// children: [
// {
// type: "text-view",
// onClick: () => {
// alert("hi");
// },
// style: {
// backgroundColor: "green",
// },
// children: [
// "Hello World !"
// ]
// }
// ]
// }
]
};
declare const _default: {
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
className: string;
children: ({
span: string;
flow: string;
alignItems: string;
justifyContent: string;
children: {
type: string;
}[];
} | {
name: string;
minWidth: string;
span?: undefined;
} | {
name: string;
span: string;
minWidth?: undefined;
})[];
};
export default _default;
import windowControl from './windowControl';
export default {
name: "header",
flow: "row",
backgroundColor: "#e5e5e5",
boxShadow: "0 1px 5px 0 #8c8c8c91",
span: "35px",
flexShrink: 0,
className: "drag-handle",
children: [
{
name: "menuBar",
// backgroundColor: "#16488d",
minWidth: "100px",
},
{
name: "blank",
span: "100%",
},
windowControl,
]
};
declare const _default: {
name: string;
flow: string;
width: string;
height: string;
children: ({
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
} | {
flow: string;
span: string;
children: ({
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
} | {
description: string;
flow: string;
span: string;
children: ({
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
flexShrink: number;
} | {
name: string;
description: string;
span: string;
flow: string;
backgroundColor: string;
boxShadow: string;
children: never[];
} | {
name: string;
flow: string;
span: string;
flexShrink: number;
boxShadow: string;
children: {
description: string;
flow: string;
}[];
})[];
})[];
})[];
};
export default _default;
import header from "./header";
import activityBar from "./activityBar";
import sidebar from "./sidebar";
import taskbar from "./taskbar";
import infoBar from "./infoBar";
import panel from "./panel";
import appBox from "./appBox";
import statusBar from "./statusBar";
export default {
name: "page",
flow: "column",
width: "100%",
height: "100%",
children: [
header,
{
flow: "row",
span: "100%",
children: [
activityBar,
sidebar,
{
description: "right area",
flow: "column",
span: "100%",
children: [
taskbar,
infoBar,
appBox,
panel,
]
}
]
},
statusBar,
]
};
declare const _default: {
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
flexShrink: number;
};
export default _default;
export default {
name: "infoBar",
flow: "row",
span: "20px",
backgroundColor: "#fffeee",
boxShadow: "0 1px 5px 0 #8c8c8c91",
flexShrink: 0,
};
declare const _default: {
name: string;
flow: string;
span: string;
flexShrink: number;
boxShadow: string;
children: {
description: string;
flow: string;
}[];
};
export default _default;
export default {
// type:"resizable"
name: "panel",
flow: "column",
span: "50px",
flexShrink: 1,
boxShadow: "0 1px 5px 0 #8c8c8c91",
children: [
{
description: "problems|output|terminal|console---other operations",
flow: "row",
},
{
description: "iostream",
flow: "column",
}
]
};
declare const _default: {
name: string;
flow: string;
span: string;
backgroundColor: string;
boxShadow: string;
};
export default _default;
export default {
name: "sidebar",
flow: "column",
span: "200px",
backgroundColor: "#f3f3f3",
boxShadow: "0 1px 5px 0 #8c8c8c91",
};
declare const _default: {
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
};
export default _default;
export default {
name: "statusBar",
flow: "row",
backgroundColor: "#007acc",
boxShadow: "0 1px 5px 0 #8c8c8c91",
span: "20px",
flexShrink: 0,
};
declare const _default: {
name: string;
flow: string;
backgroundColor: string;
span: string;
boxShadow: string;
flexShrink: number;
children: {
name: string;
flow: string;
children: never[];
}[];
};
export default _default;
export default {
name: "taskbar",
flow: "row",
backgroundColor: "#f3f3f3",
span: "40px",
boxShadow: "0 1px 5px 0 #8c8c8c91",
flexShrink: 0,
children: [
{
name: "tasks",
flow: "row",
children: [],
},
{
name: "operations",
flow: "row",
children: [],
}
]
};
declare const _default: {
span: string;
flow: string;
alignItems: string;
justifyContent: string;
children: {
type: string;
}[];
};
export default _default;
// const {
// onMinimize ,
// onMaximize },
// onRestore },
// onClose },
// }={};
export default {
// "typename": "window-control",
"span": "100px",
"flow": "row",
"alignItems": "center",
"justifyContent": "space-evenly",
"children": [
{
"type": "WindowMinimize",
// onClick: onMinimize,
},
{
"type": "WindowRestore",
// onClick: onRestore,
},
{
"type": "WindowMaximize",
// onClick: onMaximize,
},
{
"type": "WindowClose",
// onClick: onClose,
}
]
};
declare const _default: (params?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineReusable } from "../../../gui/engine";
export default defineReusable({
name: "box",
position: "fixed",
backgroundColor: "white",
border: "solid 1px black",
left: 10,
right: 10,
top: 10,
bottom: 10,
children: []
});
import box from './box';
import rnd from './rnd';
export { box, rnd, };
import box from './box';
// import pane from './pane';
import rnd from './rnd';
// import sortablePane from './sortablePane';
export { box,
// pane,
rnd,
// sortablePane
};
declare const _default: (params?: object | undefined, children?: any[] | undefined) => any;
export default _default;
import { defineReusable } from "../../../gui/engine";
export default defineReusable({
type: "rnd",
name: "window",
bounds: 'parent',
default: {
x: 0,
y: 0,
width: 400,
height: 300,
},
minWidth: 300,
minHeight: 200,
dragHandleClassName: "drag-handle",
children: []
});
import { defineApp } from "@/appman";
import Coder from "./pages/Coder";
const app = {
name: "demo",
description: "A demo app",
start() {
return {
type: "box",
children: [
{
type: "window",
children: [
Coder
]
}
]
};
},
exit() {
console.log("demo app exited.");
}
};
defineApp(app);
export declare const useWorkerDemoApp: () => {
start: () => void;
};
import MyWorker from './worker?worker';
// const Comlink =import("https://unpkg.com/comlink/dist/esm/comlink.mjs");
import * as Comlink from 'comlink';
export const useWorkerDemoApp = () => {
const start = () => {
async function init() {
const worker = new MyWorker();
// WebWorkers use `postMessage` and therefore work with Comlink.
const obj = Comlink.wrap(worker);
alert(`Counter: ${await obj.counter}`);
await obj.inc();
alert(`Counter: ${await obj.counter}`);
}
init();
};
return {
start
};
};
export declare const stringToURL: (s: string) => string;
export const stringToURL = (s) => {
const URL = window.URL || window.webkitURL;
let blob;
try {
blob = new Blob([s], { type: 'application/javascript' });
}
catch (e) { // Backwards-compatibility
const BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
blob = new BlobBuilder();
blob.append(s);
blob = blob.getBlob();
}
return URL.createObjectURL(blob);
};
import * as Comlink from 'comlink';
// importScripts("../../../dist/umd/comlink.js");
const obj = {
counter: 0,
inc() {
this.counter++;
},
};
Comlink.expose(obj);
export declare const pickProps: (obj: Object, keys: string[]) => {
[k: string]: any;
};
export declare const excludeProps: (obj: Object, keys: string[]) => {
[k: string]: any;
};
export declare type Override<T1, T2> = Omit<T1, keyof T2> & T2;
export declare const isClassComponent: (component: any) => boolean;
export declare const isFunctionComponent: (component: any) => boolean;
export declare const isReactComponent: (component: any) => boolean;
export const pickProps = (obj, keys) => Object.fromEntries(keys
.filter(key => key in obj)
.map(key => [key, obj[key]]));
export const excludeProps = (obj, keys) => Object.fromEntries(Object.keys(obj).filter(key => (keys.indexOf(key) === -1)).map((key => [key, obj[key]])));
export const isClassComponent = (component) => {
return (typeof component === 'function' &&
!!component.prototype?.isReactComponent);
};
export const isFunctionComponent = (component) => {
return (typeof component === 'function');
};
export const isReactComponent = (component) => {
return (isClassComponent(component) ||
isFunctionComponent(component));
};
declare const _default: {
type: string;
transformer: (node: any, key: any, children: any[]) => any;
};
export default _default;
import { createTransformer } from "../utils";
export default {
type: "box",
transformer: createTransformer({
name: "box",
position: "fixed",
backgroundColor: "white",
border: "solid 1px black",
left: 10,
right: 10,
top: 10,
bottom: 10,
children: []
})
};
declare const _default: {
type: string;
transformer: (node: any, key?: any, children?: any[] | undefined) => ChildNode | null;
};
export default _default;
export default {
type: "html",
transformer: (node, key, children) => {
var div = document.createElement('div');
if (typeof node.text === 'string') {
div.innerHTML = node.text.trim();
return div.firstChild;
}
throw new Error("Prop 'text' should be string, but got :" + typeof node.text);
// Change this to div.childNodes to support multiple top-level nodes.
}
};
import ContentEditable from "react-contenteditable";
export { ContentEditable };
import ContentEditable from "react-contenteditable";
export { ContentEditable };
import { CSSProperties, HTMLAttributes } from '@cloudos/flow-ui';
import { ReactNode, FC } from 'react';
export declare type FlexboxProps = CSSProperties & HTMLAttributes<null> & {
style?: string | object;
flow?: "column" | "row" | "column-reverse" | "row-reverse";
span?: string | number;
children?: ReactNode[];
key?: any;
onTakeEffect?: Function;
innerRef?: any;
[k: string]: any;
};
export declare const Flexbox: FC<{}>;
import { jsx as _jsx } from "react/jsx-runtime";
import { commonStyleProps, standardComponentPropNames } from '@cloudos/flow-ui';
import { useEffect, createRef } from 'react';
import { pickProps, excludeProps } from '../../common/utils';
const handledProps = [...commonStyleProps, ...standardComponentPropNames,
...["style", "children", "flow", "span", "key", "onTakeEffect", "innerRef"]
];
export const Flexbox = ((props) => {
// console.log(props);
// const elProps=pickProps(props,InnerComponentProps);
const elProps = excludeProps(props, handledProps);
const style = pickProps(props, commonStyleProps);
const { onTakeEffect, innerRef = createRef() } = props;
if (onTakeEffect)
useEffect(() => {
return onTakeEffect();
});
((style, comp) => {
// set extra styles
Object.assign(style, { display: "flex", "flexFlow": comp.flow || "row" });
if (typeof comp.span !== 'undefined') {
style["flexBasis"] = comp.span;
}
})(style, props);
return _jsx("div", { ref: innerRef, "data-name": props.name, "data-description": props.description, style: style, ...elProps, children: props.children }, void 0);
});
export declare const WindowRestore: import("react-icons/lib").IconType;
export declare const WindowClose: import("react-icons/lib").IconType;
export declare const WindowMaximize: import("react-icons/lib").IconType;
export declare const WindowMinimize: import("react-icons/lib").IconType;
import { VscChromeRestore, VscChromeClose, VscChromeMaximize, VscChromeMinimize } from 'react-icons/vsc';
export const WindowRestore = VscChromeRestore;
export const WindowClose = VscChromeClose;
export const WindowMaximize = VscChromeMaximize;
export const WindowMinimize = VscChromeMinimize;
export { Rnd } from 'react-rnd';
export type { Props as RndProps } from 'react-rnd';
export { Rnd } from 'react-rnd';
import { WindowHeaderProps } from './windowHeader';
export declare type WindowProps = {
width?: number | string;
height?: number | string;
} & WindowHeaderProps;
declare const _default: {
type: string;
transformer: (node: any, key: any, children: any[]) => any;
};
export default _default;
import { createTransformer } from "../../utils";
import windowHeader from './windowHeader';
export default {
type: "window",
transformer: createTransformer((x = {}, children = []) => {
const { width = 400, height = 300, ...windowHeaderProps } = x;
return {
type: "rnd",
name: "window",
bounds: 'parent',
default: {
x: 0,
y: 0,
width: width,
height: height,
},
minWidth: 300,
minHeight: 200,
dragHandleClassName: "drag-handle",
children: [
{
name: "page",
flow: "column",
width: "100%",
height: "100%",
backgroundColor: "gray",
children: [
windowHeader(windowHeaderProps),
{
flow: "row",
span: "100%",
children: [
...children || []
]
},
]
}
]
};
})
};
export declare type WindowControlProps = {
onMinimize?: Function;
onRestore?: Function;
onMaximize?: Function;
onClose?: Function;
};
declare const _default: (x?: WindowControlProps) => {
name: string;
span: string;
flow: string;
alignItems: string;
justifyContent: string;
children: {
type: string;
onClick: Function;
}[];
};
export default _default;
import { ipc } from "@cloudos/ipc";
export default (x = {}) => {
const { onMinimize = () => { ipc.dispatch("window-minimize"); }, onMaximize = () => { ipc.dispatch("window-maximize"); }, onRestore = () => { ipc.dispatch("window-restore"); }, onClose = () => { ipc.dispatch("window-close"); }, } = x;
return {
"name": "window-control",
"span": "200px",
"flow": "row",
"alignItems": "center",
"justifyContent": "space-evenly",
"children": [
{
"type": "WindowMinimize",
onClick: onMinimize,
},
{
"type": "WindowRestore",
onClick: onRestore,
},
{
"type": "WindowMaximize",
onClick: onMaximize,
},
{
"type": "WindowClose",
onClick: onClose,
}
]
};
};
import { WindowControlProps } from './windowControl';
export declare type WindowHeaderProps = {} & WindowControlProps;
declare const _default: (x?: WindowHeaderProps) => {
name: string;
flow: string;
backgroundColor: string;
boxShadow: string;
span: string;
flexShrink: number;
className: string;
children: ({
name: string;
span: string;
flow: string;
alignItems: string;
justifyContent: string;
children: {
type: string;
onClick: Function;
}[];
} | {
name: string;
minWidth: string;
span?: undefined;
} | {
name: string;
span: string;
minWidth?: undefined;
})[];
};
export default _default;
import windowControl from './windowControl';
export default (x = {}) => {
return {
name: "header",
flow: "row",
backgroundColor: "#e5e5e5",
boxShadow: "0 1px 5px 0 #8c8c8c91",
span: "35px",
flexShrink: 0,
className: "drag-handle",
children: [
{
name: "menuBar",
// backgroundColor: "#16488d",
minWidth: "100px",
},
{
name: "blank",
span: "100%",
},
windowControl({
...x
}),
]
};
};
/// <reference types="react" />
export declare const createUI: (node: any, context?: {
[p: string]: any;
key?: any;
} | undefined) => any, defineReusable: (node: any) => (params?: object | undefined, children?: any[] | undefined) => any, registerComponent: any, render: (comp: HTMLElement | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, dom: HTMLElement) => void, registerComponentDict: any, registerPostprocessor: Function, registerPreprocessor: Function;
import { makeEngine } from "@cloudos/flow-ui";
export const { createUI, defineReusable, registerComponent, render, registerComponentDict, registerPostprocessor, registerPreprocessor } = makeEngine();
registerPreprocessor(({ node, context }) => {
if (typeof node === 'function')
node = node({ key: context.key });
return { node, context };
});
registerPreprocessor((x) => {
const isComponent = (x) => { return (typeof x === 'object'); };
if (isComponent(x.node) && !x.node.type && !x.transformer)
x.node.type = "flexbox";
return x;
});
export declare const registerDomComponent: (typeName: string, createEl: string | Function) => void;
export declare const registerReactComponent: (rcName: string, rc: string | import("./plugins/react").ReactComponent) => void;
export declare const init: () => void;
export * from './engine';
import { registerComponent } from "./engine";
import pluginDom from './plugins/dom';
import pluginReact from './plugins/react';
import pluginReact2Dom from './plugins/react2dom';
import window from "./components/window";
import box from "./components/box";
import html from "./components/html";
import { Rnd } from './components/react-components/rnd';
import { Flexbox } from "./components/react-components/flexbox";
import { ContentEditable } from "./components/react-components/contenteditable";
import { WindowClose, WindowMaximize, WindowMinimize, WindowRestore } from './components/react-components/icons';
export const { registerDomComponent } = pluginDom.use();
export const { registerReactComponent } = pluginReact.use();
pluginReact2Dom.use();
export const init = () => {
registerReactComponent("flexbox", Flexbox);
registerReactComponent("rnd", Rnd);
registerReactComponent("contenteditable", ContentEditable);
const registerReactHTMLComponents = (tags) => tags.forEach(tag => registerReactComponent(tag, tag));
registerReactHTMLComponents("div span".split(" "));
const registerDomComponents = (tags) => tags.forEach(tag => registerDomComponent(`dom-${tag}`, tag));
registerDomComponents("div span".split(" "));
registerComponent(window);
registerComponent(box);
registerComponent(html);
const icons = {
WindowClose,
WindowMaximize,
WindowRestore,
WindowMinimize
};
const dict2descriptors = (dict) => Object.keys(dict).map(key => [key, dict[key]]);
dict2descriptors(icons).forEach(args => registerReactComponent(args[0], args[1]));
console.log("framework init finished.");
};
init();
export * from './engine';
import { MakeComponent } from '@cloudos/flow-ui';
export interface DomComponent extends MakeComponent<{}, "dom"> {
tag: string;
}
export declare const registerDomComponent: (typeName: string, createEl: string | Function) => void;
declare const _default: {
registerDomComponent: (typeName: string, createEl: string | Function) => void;
use: () => {
registerDomComponent: (typeName: string, createEl: string | Function) => void;
};
};
export default _default;
import { excludeProps } from '../common/utils';
import { standardComponentPropNames } from '@cloudos/flow-ui';
import { registerComponent } from '../engine';
const handledProps = ["tag"];
const domCreator = (comp, key, children) => {
const props = excludeProps(comp, (standardComponentPropNames.concat(handledProps)));
let el = document.createElement(comp.tag);
Object.assign(el, props);
children?.forEach(child => el.appendChild(child));
return el;
};
export const registerDomComponent = (typeName, createEl) => {
registerComponent({
type: typeName,
transformer: (node, key, children = []) => {
let el;
if (typeof createEl === 'string') {
el = document.createElement(createEl);
const { type, children, ...props } = node;
for (let key in props) {
el.setAttribute(key, props[key]);
}
}
else
el = createEl(node);
children?.forEach((child) => { el.append(child); });
return el;
}
});
};
export default {
registerDomComponent,
use: () => {
registerComponent({
type: "dom",
transformer: domCreator
});
return { registerDomComponent };
}
};
import { Component as ReactClassComponent, FunctionComponent as ReactFunctionComponent } from 'react';
import { MakeComponent } from '@cloudos/flow-ui';
export declare type ReactComponent = (typeof ReactClassComponent) | ReactFunctionComponent;
export interface RcComponent extends MakeComponent<{}, "rc"> {
rc: ReactComponent | string;
}
export declare const registerReactComponent: (rcName: string, rc: ReactComponent | string) => void;
declare const _default: {
registerReactComponent: (rcName: string, rc: string | ReactComponent) => void;
use: () => {
registerReactComponent: (rcName: string, rc: string | ReactComponent) => void;
};
};
export default _default;
import { excludeProps, isReactComponent } from '../common/utils';
import { createElement, isValidElement } from 'react';
import { standardComponentPropNames } from '@cloudos/flow-ui';
import { registerComponent, registerPreprocessor } from '../engine';
const handledProps = [...standardComponentPropNames, "rc"];
const rcCreator = (comp, key, children) => {
const props = excludeProps(comp, handledProps);
return createElement(comp.rc, { ...props, key }, children);
};
const makeReactComponentTranfomer = (rc) => {
return (comp, key, children) => {
// console.log("creating react component:",{key,comp,children})
const props = excludeProps(comp, handledProps);
let child = null;
if (children && children.length == 1)
child = children[0];
const result = createElement(rc, { ...props, key }, child || children);
// console.log({result});
return result;
};
};
export const registerReactComponent = (rcName, rc) => {
registerComponent({
type: rcName,
transformer: makeReactComponentTranfomer(rc)
});
};
export default {
registerReactComponent,
use: () => {
registerComponent({
type: "rc",
transformer: rcCreator
});
registerPreprocessor((x) => {
const isComponent = (x) => { return (typeof x === 'object'); };
if (isComponent(x.node) && !isValidElement(x.node) && isReactComponent(x.node.type) && !x.node.transformer) {
x.node.transformer = makeReactComponentTranfomer(x.node.type);
}
return x;
});
return { registerReactComponent };
}
};
declare const _default: {
use: () => void;
};
export default _default;
import { render } from "react-dom";
import { registerComponent } from "../engine";
export default {
use: () => {
registerComponent({
type: "react2dom",
transformer: ({ node, children }) => {
let el = document.createElement("div");
children?.forEach((child) => {
render(child, el);
});
return el;
}
});
}
};
export declare const defineTemplate: (node: any) => (props?: object | undefined, children?: any[] | undefined) => any;
declare type TemplateMaker = ((props?: any, children?: any[]) => any) | object;
export declare const createTransformer: (maker: TemplateMaker) => (node: any, key: any, children: any[]) => any;
export {};
import { createUI } from '../engine';
export const defineTemplate = (node) => (props, children) => Object.assign({}, node, typeof props === 'undefined' ? {} : props, {
children: typeof children === 'undefined' ? node.children : children,
});
export const createTransformer = (maker) => {
const template = typeof maker === 'function' ? maker : defineTemplate(maker);
return (node, key, children) => {
// console.log("template:",{key,node,children})
const { type, ...props } = node;
const res = createUI(template(props, children), { key });
return res;
};
};
### cloudos-core
The core of a cloud os system.
+1
-1

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

import { createUI } from "../../framework";
import { createUI } from "../../gui";
import { createRef, useEffect, useState } from "react";

@@ -3,0 +3,0 @@ // import "./style.css";

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

import { createUI, render } from '../../framework';
import { createUI, render } from '../../gui';
import mousetrap from 'mousetrap';

@@ -3,0 +3,0 @@ import { unmountComponentAtNode } from 'react-dom';

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

export * from './framework';
export * from './gui';

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

export * from './framework';
export * from './gui';
import { usePipeline } from "@cloudos/logic";
import { useCommandPanel } from "./apps/commandPanel";
import useDemoApp from "./useDemoApp";
import { DemoAppWorker } from "./apps/demo";
import { loadAppFromWorker, getAppByName } from "./appman";
import { createUI, render } from ".";
// import DemoCoderWorker from './apps/coder/worker?worker';
const boot = usePipeline([
() => {
useCommandPanel().start();
useDemoApp().start();
async () => {
let woker = new DemoAppWorker();
let app = await loadAppFromWorker(woker);
console.log(getAppByName('demo'));
// let app=await loadAppFromWorker(new DemoCoderWorker());
let result = await app.start();
console.log('start result:', result);
render(createUI(result), document.getElementById('root'));
// await app.start();
// await app.exit();
}
]);
boot();
{
"name": "@cloudos/core",
"version": "1.0.24",
"version": "1.0.25",
"description": "cloudos-core",

@@ -20,2 +20,3 @@ "main": "lib/index.js",

"@cloudos/logic": "^1.0.31",
"comlink": "^4.3.1",
"fuse.js": "^6.5.3",

@@ -27,6 +28,8 @@ "mousetrap": "^1.6.5",

"react-icons": "^4.3.1",
"react-rnd": "^10.3.5"
"react-rnd": "^10.3.5",
"taffydb": "^2.7.3"
},
"devDependencies": {
"@types/mousetrap": "^1.6.9",
"@types/node": "^17.0.10",
"@types/react": "^17.0.33",

@@ -33,0 +36,0 @@ "@types/react-dom": "^17.0.10",