ranuts 0.1.0-alpha.1 → 0.1.0-alpha.2

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.
Files changed (116) hide show
  1. package/package.json +1 -1
  2. package/dist/src/file/fileInfo.d.ts +0 -7
  3. package/dist/src/file/fs.d.ts +0 -2
  4. package/dist/src/file/readDir.d.ts +0 -6
  5. package/dist/src/file/readFile.d.ts +0 -8
  6. package/dist/src/file/watchFile.d.ts +0 -8
  7. package/dist/src/file/writeFile.d.ts +0 -8
  8. package/dist/src/mode/subscribe.d.ts +0 -16
  9. package/dist/src/ranlog/behavior.d.ts +0 -1
  10. package/dist/src/ranlog/env.d.ts +0 -5
  11. package/dist/src/ranlog/error.d.ts +0 -2
  12. package/dist/src/ranlog/index.d.ts +0 -26
  13. package/dist/src/ranlog/performance.d.ts +0 -21
  14. package/dist/src/ranlog/report.d.ts +0 -7
  15. package/dist/src/ranlog/request.d.ts +0 -18
  16. package/dist/src/ranlog/utils.d.ts +0 -19
  17. package/dist/src/utils/filterObj.d.ts +0 -8
  18. package/dist/src/utils/str2Xml.d.ts +0 -8
  19. package/dist/src/vnode/h.d.ts +0 -6
  20. package/dist/src/vnode/hooks.d.ts +0 -23
  21. package/dist/src/vnode/htmlDomApi.d.ts +0 -33
  22. package/dist/src/vnode/init.d.ts +0 -2
  23. package/dist/src/vnode/is.d.ts +0 -5
  24. package/dist/src/vnode/modules/attributes.d.ts +0 -8
  25. package/dist/src/vnode/modules/class.d.ts +0 -8
  26. package/dist/src/vnode/modules/index.d.ts +0 -7
  27. package/dist/src/vnode/modules/listeners.d.ts +0 -14
  28. package/dist/src/vnode/modules/props.d.ts +0 -8
  29. package/dist/src/vnode/modules/style.d.ts +0 -14
  30. package/dist/src/vnode/vnode.d.ts +0 -31
  31. package/src/astParser/Parser.ts +0 -654
  32. package/src/astParser/Tokenizer.ts +0 -447
  33. package/src/astParser/nodeTypes.ts +0 -194
  34. package/src/astParser/utils.ts +0 -27
  35. package/src/babel/parser.ts +0 -10
  36. package/src/colors/fmt.ts +0 -29
  37. package/src/colors/isColorSupported.ts +0 -13
  38. package/src/file/appendFile.ts +0 -29
  39. package/src/file/fileInfo.ts +0 -22
  40. package/src/file/fs.ts +0 -9
  41. package/src/file/readDir.ts +0 -18
  42. package/src/file/readFile.ts +0 -26
  43. package/src/file/watchFile.ts +0 -31
  44. package/src/file/writeFile.ts +0 -38
  45. package/src/mode/subscribe.ts +0 -89
  46. package/src/ran/commit.ts +0 -0
  47. package/src/ran/dom.ts +0 -0
  48. package/src/ran/hooks.ts +0 -0
  49. package/src/ran/reconcile.ts +0 -0
  50. package/src/ran/schedule.ts +0 -0
  51. package/src/ranlog/behavior.ts +0 -5
  52. package/src/ranlog/console.ts +0 -16
  53. package/src/ranlog/env.ts +0 -29
  54. package/src/ranlog/error.ts +0 -11
  55. package/src/ranlog/performance.ts +0 -65
  56. package/src/ranlog/report.ts +0 -33
  57. package/src/ranlog/request.ts +0 -60
  58. package/src/ranlog/utils.ts +0 -92
  59. package/src/ranpack/ast/Declaration.ts +0 -120
  60. package/src/ranpack/ast/Node.ts +0 -7
  61. package/src/ranpack/ast/Reference.ts +0 -32
  62. package/src/ranpack/ast/Scope.ts +0 -80
  63. package/src/ranpack/bundle.ts +0 -50
  64. package/src/ranpack/graph.ts +0 -143
  65. package/src/ranpack/module.ts +0 -431
  66. package/src/ranpack/moduleLoader.ts +0 -73
  67. package/src/ranpack/plugins.ts +0 -70
  68. package/src/ranpack/statement.ts +0 -66
  69. package/src/ranpack/utils/buildScope.ts +0 -77
  70. package/src/ranpack/utils/findReference.ts +0 -36
  71. package/src/ranpack/utils/isFunctionDeclaration.ts +0 -41
  72. package/src/ranpack/utils/makeLegalIdentifier.ts +0 -18
  73. package/src/ranpack/utils/object.ts +0 -8
  74. package/src/ranpack/utils/resolve.ts +0 -32
  75. package/src/ranpack/utils/walk.ts +0 -66
  76. package/src/ranpack/ws.ts +0 -269
  77. package/src/server/connectType.ts +0 -9
  78. package/src/server/encodeUrl.ts +0 -46
  79. package/src/server/escapeHtml.ts +0 -46
  80. package/src/server/get.ts +0 -36
  81. package/src/server/jitter.ts +0 -77
  82. package/src/server/mimeType.ts +0 -858
  83. package/src/server/paresUrl.ts +0 -40
  84. package/src/server/send.ts +0 -89
  85. package/src/server/server.ts +0 -67
  86. package/src/server/status.ts +0 -191
  87. package/src/server/traverse.ts +0 -54
  88. package/src/server/websocket.ts +0 -200
  89. package/src/sort/bubble.ts +0 -21
  90. package/src/sort/bucket.ts +0 -11
  91. package/src/sort/count.ts +0 -10
  92. package/src/sort/heap.ts +0 -10
  93. package/src/sort/insert.ts +0 -20
  94. package/src/sort/merge.ts +0 -35
  95. package/src/sort/quick.ts +0 -50
  96. package/src/sort/radix.ts +0 -11
  97. package/src/sort/randomArray.ts +0 -21
  98. package/src/sort/select.ts +0 -23
  99. package/src/sort/shell.ts +0 -22
  100. package/src/utils/compose.ts +0 -37
  101. package/src/utils/filterObj.ts +0 -21
  102. package/src/utils/mergeObj.ts +0 -12
  103. package/src/utils/startTask.ts +0 -15
  104. package/src/utils/str2Xml.ts +0 -26
  105. package/src/utils/taskEnd.ts +0 -14
  106. package/src/vnode/h.ts +0 -108
  107. package/src/vnode/hooks.ts +0 -25
  108. package/src/vnode/htmlDomApi.ts +0 -199
  109. package/src/vnode/init.ts +0 -429
  110. package/src/vnode/is.ts +0 -17
  111. package/src/vnode/modules/attributes.ts +0 -70
  112. package/src/vnode/modules/class.ts +0 -46
  113. package/src/vnode/modules/listeners.ts +0 -123
  114. package/src/vnode/modules/props.ts +0 -41
  115. package/src/vnode/modules/style.ts +0 -118
  116. package/src/vnode/vnode.ts +0 -65
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ranuts",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "常用函数",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "module": "dist/index.js",
@@ -1,7 +0,0 @@
1
- /**
2
- * @description: 查询一个文件的详细信息,一般用于区分文件还是目录(data.isDirectory())
3
- * @param {string} path 文件路径
4
- * @return {Promise}
5
- */
6
- declare const queryFileInfo: (path: string) => Promise<Ranuts.Identification>;
7
- export default queryFileInfo;
@@ -1,2 +0,0 @@
1
- declare let fileSystem: any;
2
- export default fileSystem;
@@ -1,6 +0,0 @@
1
- interface Options {
2
- dirPath: string;
3
- ignores?: Array<string>;
4
- }
5
- declare const readDir: (options: Options) => Array<string>;
6
- export default readDir;
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: 读取一个文件,读取成功返回状态码和文件内容
3
- * @param {string} path 文件路径
4
- * @param {string} format 读取格式,默认utf-8
5
- * @return {Promise}
6
- */
7
- declare const readFile: (path: string, format?: string) => Promise<Ranuts.Identification>;
8
- export default readFile;
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: 观察一个文件是否被改变,返回状态
3
- * @param {string} path 监听的文件路径
4
- * @param {number} interval 监听的时间,单位毫秒,默认20毫秒
5
- * @return {Promise}
6
- */
7
- declare const watchFile: (path: string, interval?: number) => Promise<Ranuts.Identification>;
8
- export default watchFile;
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: 根据文件路径创建文件,如果文件存在会清空再写入,如果不存在会创建
3
- * @param {string} path 文件路径
4
- * @param {string} content 文件内容
5
- * @return {Promise}
6
- */
7
- declare const writeFile: (path: string, content: string) => Promise<Ranuts.Identification>;
8
- export default writeFile;
@@ -1,16 +0,0 @@
1
- declare type Callback = (...args: any) => unknown;
2
- declare type EventName = string | symbol;
3
- declare type EventItem = {
4
- name?: string | symbol;
5
- callback: Callback;
6
- initialCallback?: Callback;
7
- };
8
- declare class Subscribe {
9
- _events: Record<EventName, Array<EventItem>>;
10
- constructor();
11
- on: (eventName: EventName, eventItem: EventItem | Callback) => void;
12
- emit: (eventName: EventName, ...args: Array<unknown>) => void;
13
- once: (eventName: EventName, eventItem: EventItem | Callback) => void;
14
- off: (eventName: EventName, eventItem: EventItem | Callback) => void;
15
- }
16
- export default Subscribe;
@@ -1 +0,0 @@
1
- export declare const handleClick: (hooks?: (event: MouseEvent) => void) => void;
@@ -1,5 +0,0 @@
1
- /**
2
- * @description: Gets the current environment configuration
3
- * @return {string}
4
- */
5
- export declare const getHost: (env?: string) => string;
@@ -1,2 +0,0 @@
1
- import type { Hooks } from './utils';
2
- export declare const handleError: (hooks?: Hooks) => void;
@@ -1,26 +0,0 @@
1
- export interface Payload {
2
- payload: Record<string, unknown>;
3
- type?: string;
4
- }
5
- declare class Monitor {
6
- /**
7
- * @description: 页面加载性能上报
8
- * @param {Payload} param1
9
- */
10
- reportPerformance(): void;
11
- /**
12
- * @description: 手动触发的上报
13
- * @param {Record} payload
14
- * @param {*} unknown
15
- */
16
- log(payload: Record<string, unknown>): void;
17
- /**
18
- * @description: 点击上报
19
- * @return {*}
20
- */
21
- reportClick(): void;
22
- reportXhr(): void;
23
- reportFetch(): void;
24
- reportError(): void;
25
- }
26
- export default Monitor;
@@ -1,21 +0,0 @@
1
- interface BasicType {
2
- [x: string]: number | undefined;
3
- dnsSearch: number;
4
- tcpConnect: number;
5
- sslConnect: number;
6
- request: number;
7
- response: number;
8
- parseDomTree: number;
9
- resource: number;
10
- domReady: number;
11
- httpHead: number;
12
- interactive: number;
13
- complete: number;
14
- redirect: number;
15
- redirectTime: number;
16
- duration: number;
17
- fp: number | undefined;
18
- fcp: number | undefined;
19
- }
20
- export declare function getPerformance(): BasicType;
21
- export {};
@@ -1,7 +0,0 @@
1
- interface BeaconPayload {
2
- url?: string;
3
- type?: string;
4
- payload: Record<string, unknown>;
5
- }
6
- export declare const report: ({ url, type, payload }: BeaconPayload) => boolean | undefined | void;
7
- export {};
@@ -1,18 +0,0 @@
1
- import type { Hooks } from './utils';
2
- interface Options {
3
- requestHook: Hooks;
4
- responseHook: Hooks;
5
- errorHook: Hooks;
6
- }
7
- /**
8
- * @description: fetch
9
- * @param {Partial} options
10
- */
11
- export declare const handleFetchHook: (options?: Partial<Options>) => void;
12
- /**
13
- * @description: xhr
14
- * @param {Partial} options
15
- * @return {*}
16
- */
17
- export declare const handleXhrHook: (options?: Partial<Options>) => void;
18
- export {};
@@ -1,19 +0,0 @@
1
- export declare function querystring(data?: {}): string;
2
- export declare function randomString(len?: number): string;
3
- export declare function getCookie(name: string): string;
4
- export declare function createData(params?: Record<string, unknown>): Record<string, unknown>;
5
- export declare const throttle: (fn: Function, wait?: number) => Function;
6
- export declare const Noop: () => void;
7
- export declare function changeHumpToLowerCase(str: string): string;
8
- /**
9
- * 重写对象上面的某个属性
10
- *
11
- * @export
12
- * @param {IAnyObject} source 需要被重写的对象
13
- * @param {string} name 需要被重写对象的key
14
- * @param {(...args: any[]) => any} replacement 以原有的函数作为参数,执行并重写原有函数
15
- * @param {boolean} isForced 是否强制重写(可能原先没有该属性)
16
- */
17
- export declare function replaceOld(source: any, name: string, replacement: (...args: unknown[]) => unknown, isForced?: boolean): void;
18
- export declare const isString: (obj: unknown) => boolean;
19
- export declare type Hooks = (...args: unknown[]) => void;
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: 过滤对象的属性,去除对象中在list数组里面有的属性,返回一个新对象,一般是用于去除空字符和null
3
- * @param {Object} obj 传入对象
4
- * @param {Array} list 传入数组
5
- * @return {Object}
6
- */
7
- declare const filterObj: (obj: Record<string | symbol, any>, list: Array<string | symbol>) => Record<string | symbol, any>;
8
- export default filterObj;
@@ -1,8 +0,0 @@
1
- /**
2
- * @description: 传入字符串和指定的格式,将字符串转成xml
3
- * @param {string} xmlStr
4
- * @param {DOMParserSupportedType} format
5
- * @return {Document}
6
- */
7
- declare const str2Xml: (xmlStr: string, format?: DOMParserSupportedType) => HTMLElement | undefined;
8
- export default str2Xml;
@@ -1,6 +0,0 @@
1
- import type { VNode, VNodeChildren, VNodeData } from './vnode';
2
- export declare function addNS(data: VNodeData, children: Array<VNode | string | number> | undefined, sel: string | undefined): void;
3
- export declare function h(sel: string): VNode;
4
- export declare function h(sel: string, data: VNodeData | null): VNode;
5
- export declare function h(sel: string, children: VNodeChildren): VNode;
6
- export declare function h(sel: string, data: VNodeData | null, children: VNodeChildren): VNode;
@@ -1,23 +0,0 @@
1
- import type { VNode } from "./vnode";
2
- export declare type PreHook = () => any;
3
- export declare type InitHook = (vNode: VNode) => any;
4
- export declare type CreateHook = (emptyVNode: VNode, vNode: VNode) => any;
5
- export declare type InsertHook = (vNode: VNode) => any;
6
- export declare type PrePatchHook = (oldVNode: VNode, vNode: VNode) => any;
7
- export declare type UpdateHook = (oldVNode: VNode, vNode: VNode) => any;
8
- export declare type PostPatchHook = (oldVNode: VNode, vNode: VNode) => any;
9
- export declare type DestroyHook = (vNode: VNode) => any;
10
- export declare type RemoveHook = (vNode: VNode, removeCallback: () => void) => any;
11
- export declare type PostHook = () => any;
12
- export interface Hooks {
13
- pre?: PreHook;
14
- init?: InitHook;
15
- create?: CreateHook;
16
- insert?: InsertHook;
17
- prepatch?: PrePatchHook;
18
- update?: UpdateHook;
19
- postpatch?: PostPatchHook;
20
- destroy?: DestroyHook;
21
- remove?: RemoveHook;
22
- post?: PostHook;
23
- }
@@ -1,33 +0,0 @@
1
- export interface Fragment extends DocumentFragment {
2
- parent: Node | null;
3
- firstChildNode: ChildNode | null;
4
- lastChildNode: ChildNode | null;
5
- }
6
- export interface DOMAPI {
7
- createElement: (tagName: any, options?: ElementCreationOptions) => HTMLElement;
8
- createElementNS: (namespaceURI: string, qualifiedName: string, options?: ElementCreationOptions) => Element;
9
- /**
10
- * @experimental
11
- * @todo Make it required when the fragment is considered stable.
12
- */
13
- createDocumentFragment?: () => Fragment;
14
- createTextNode: (text: string) => Text;
15
- createComment: (text: string) => Comment;
16
- insertBefore: (parentNode: Node, newNode: Node, referenceNode: Node | null) => void;
17
- removeChild: (node: Node, child: Node) => void;
18
- appendChild: (node: Node, child: Node) => void;
19
- parentNode: (node: Node) => Node | null;
20
- nextSibling: (node: Node) => Node | null;
21
- tagName: (elm: Element) => string;
22
- setTextContent: (node: Node, text: string | null) => void;
23
- getTextContent: (node: Node) => string | null;
24
- isElement: (node: Node) => node is Element;
25
- isText: (node: Node) => node is Text;
26
- isComment: (node: Node) => node is Comment;
27
- /**
28
- * @experimental
29
- * @todo Make it required when the fragment is considered stable.
30
- */
31
- isDocumentFragment?: (node: Node) => node is DocumentFragment;
32
- }
33
- export declare const htmlDomApi: DOMAPI;
@@ -1,2 +0,0 @@
1
- import type { VNode } from './vnode';
2
- export declare function init(): (oldVnode: VNode | Element, vnode: VNode) => VNode;
@@ -1,5 +0,0 @@
1
- import type { VNode } from './vnode';
2
- export declare const array: (arg: any) => arg is any[];
3
- export declare const isStr: (str: unknown) => str is string;
4
- export declare function primitive(s: unknown): s is string | number;
5
- export declare function isVnode(s: any): s is VNode;
@@ -1,8 +0,0 @@
1
- import type { VNode } from '../vnode';
2
- export declare type Attrs = Record<string, string | number | boolean>;
3
- declare function updateAttrs(oldVnode: VNode, vnode: VNode): void;
4
- export declare const attributesModule: {
5
- create: typeof updateAttrs;
6
- update: typeof updateAttrs;
7
- };
8
- export {};
@@ -1,8 +0,0 @@
1
- import type { VNode } from '../vnode';
2
- export declare type Classes = Record<string, boolean>;
3
- declare function updateClass(oldVnode: VNode, vnode: VNode): void;
4
- export declare const classModule: {
5
- create: typeof updateClass;
6
- update: typeof updateClass;
7
- };
8
- export {};
@@ -1,7 +0,0 @@
1
- export declare type ModuleHook = any;
2
- export declare type Modules = {
3
- [key: string]: {
4
- [key: string]: ModuleHook;
5
- };
6
- };
7
- export declare const modules: Modules;
@@ -1,14 +0,0 @@
1
- import type { VNode } from '../vnode';
2
- declare type Listener<T> = (this: VNode, ev: T, vnode: VNode) => void;
3
- export declare type On = {
4
- [N in keyof HTMLElementEventMap]?: Listener<HTMLElementEventMap[N]> | Array<Listener<HTMLElementEventMap[N]>>;
5
- } & {
6
- [event: string]: Listener<any> | Array<Listener<any>>;
7
- };
8
- declare function updateEventListeners(oldVnode: VNode, vnode?: VNode): void;
9
- export declare const eventListenersModule: {
10
- create: typeof updateEventListeners;
11
- update: typeof updateEventListeners;
12
- destroy: typeof updateEventListeners;
13
- };
14
- export {};
@@ -1,8 +0,0 @@
1
- import type { VNode } from '../vnode';
2
- export declare type Props = Record<string, any>;
3
- declare function updateProps(oldVnode: VNode, vnode: VNode): void;
4
- export declare const propsModule: {
5
- create: typeof updateProps;
6
- update: typeof updateProps;
7
- };
8
- export {};
@@ -1,14 +0,0 @@
1
- import type { VNode } from '../vnode';
2
- export declare type VNodeStyle = Record<string, any>;
3
- declare function updateStyle(oldVnode: VNode, vnode: VNode): void;
4
- declare function forceReflow(): void;
5
- declare function applyDestroyStyle(vnode: VNode): void;
6
- declare function applyRemoveStyle(vnode: VNode, rm: () => void): void;
7
- export declare const styleModule: {
8
- pre: typeof forceReflow;
9
- create: typeof updateStyle;
10
- update: typeof updateStyle;
11
- destroy: typeof applyDestroyStyle;
12
- remove: typeof applyRemoveStyle;
13
- };
14
- export {};
@@ -1,31 +0,0 @@
1
- import type { On } from './modules/listeners';
2
- import type { Attrs } from './modules/attributes';
3
- import type { Classes } from './modules/class';
4
- import type { Props } from './modules/props';
5
- import type { VNodeStyle } from './modules/style';
6
- import type { Hooks } from "./hooks";
7
- export declare type VNodes = VNode[];
8
- export declare type VNodeChildElement = VNode | string | number;
9
- export declare type ArrayOrElement<T> = T | T[];
10
- export declare type VNodeChildren = ArrayOrElement<VNodeChildElement>;
11
- export declare type Key = string | number;
12
- export interface VNode {
13
- sel: string | undefined;
14
- data: VNodeData | undefined;
15
- children: Array<VNode | string | number> | undefined;
16
- elm: Node | undefined;
17
- text: string | number | undefined;
18
- key: Key | undefined;
19
- listener?: EventListenerOrEventListenerObject | undefined;
20
- }
21
- export interface VNodeData {
22
- props?: Props;
23
- attrs?: Attrs;
24
- class?: Classes;
25
- style?: VNodeStyle;
26
- on?: On;
27
- key?: Key;
28
- ns?: string;
29
- hook?: Hooks;
30
- }
31
- export declare function vnode(sel: string | undefined, data: any | undefined, children: Array<VNode | string | number> | undefined, text: string | number | undefined, elm: Element | Text | undefined): VNode;