solely 0.0.30 → 0.1.1

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 (52) hide show
  1. package/README.md +817 -507
  2. package/dist/compiler/index.d.ts +2 -0
  3. package/dist/compiler/ir/buildIR.d.ts +12 -0
  4. package/dist/compiler/ir/index.d.ts +1 -0
  5. package/dist/compiler/parser/index.d.ts +1 -0
  6. package/dist/compiler/parser/parser.d.ts +5 -0
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.js +1768 -0
  9. package/dist/index.umd.cjs +46 -0
  10. package/dist/plugin.d.ts +1 -0
  11. package/dist/plugins/html-parse-precompile.d.ts +1 -0
  12. package/dist/plugins/html-precompile.d.ts +1 -0
  13. package/dist/plugins/index.d.ts +1 -0
  14. package/dist/runtime/component/base-element.d.ts +24 -0
  15. package/dist/{base → runtime/component}/decorators.d.ts +6 -4
  16. package/dist/runtime/component/index.d.ts +2 -0
  17. package/dist/runtime/index.d.ts +4 -0
  18. package/dist/runtime/reactivity/index.d.ts +2 -0
  19. package/dist/runtime/reactivity/observe.d.ts +47 -0
  20. package/dist/{utils/observe.d.ts → runtime/reactivity/types.d.ts} +0 -8
  21. package/dist/runtime/renderer/index.d.ts +1 -0
  22. package/dist/runtime/renderer/renderIR.d.ts +25 -0
  23. package/dist/runtime/router/core.d.ts +43 -0
  24. package/dist/runtime/router/index.d.ts +6 -0
  25. package/dist/runtime/router/router-link.d.ts +19 -0
  26. package/dist/runtime/router/router-view.d.ts +25 -0
  27. package/dist/runtime/router/types.d.ts +65 -0
  28. package/dist/shared/event-listeners.d.ts +2 -0
  29. package/dist/shared/gen-function.d.ts +3 -0
  30. package/dist/shared/index.d.ts +6 -0
  31. package/dist/shared/templateError.d.ts +9 -0
  32. package/dist/types/ast.d.ts +38 -0
  33. package/dist/types/component.d.ts +66 -0
  34. package/dist/types/index.d.ts +4 -0
  35. package/dist/types/ir.d.ts +67 -0
  36. package/dist/types/lifecycle.d.ts +4 -0
  37. package/dist/types/loop.d.ts +4 -0
  38. package/package.json +24 -6
  39. package/dist/base/base-element.d.ts +0 -56
  40. package/dist/base/index.d.ts +0 -5
  41. package/dist/base/router-view.d.ts +0 -43
  42. package/dist/solely.d.ts +0 -2
  43. package/dist/solely.js +0 -941
  44. package/dist/solely.umd.cjs +0 -3
  45. package/dist/utils/ast-processor.d.ts +0 -2
  46. package/dist/utils/async-queue.d.ts +0 -1
  47. package/dist/utils/event-listeners.d.ts +0 -2
  48. package/dist/utils/html-parse.d.ts +0 -45
  49. package/dist/utils/index.d.ts +0 -8
  50. /package/dist/{utils → shared}/functions.d.ts +0 -0
  51. /package/dist/{utils → shared}/is-object.d.ts +0 -0
  52. /package/dist/{utils → shared}/url.d.ts +0 -0
@@ -0,0 +1,67 @@
1
+ import { ASTType, SourceLocation } from './ast';
2
+ /** IR 属性 */
3
+ export interface IRAttr {
4
+ key: string;
5
+ value?: string;
6
+ fid?: number;
7
+ dynamic: 0 | 1;
8
+ /**
9
+ * 执行语义角色(Execution Role)
10
+ *
11
+ * - model:
12
+ * 数据同步语义(如 s-model / v-model 展开)
13
+ * 必须在同一事件中最先执行,
14
+ * 以保证用户事件观察到的是最新数据状态
15
+ *
16
+ * - user:
17
+ * 用户显式声明的事件处理逻辑(@click / @input 等)
18
+ * 在 model 同步完成后执行
19
+ */
20
+ role?: 'model' | 'user';
21
+ }
22
+ /** 局部变量作用域 */
23
+ export interface IRLocal {
24
+ item?: string;
25
+ index?: string;
26
+ }
27
+ /** 核心 IR 节点 */
28
+ export interface IRNode {
29
+ type: ASTType;
30
+ dynamic: 0 | 1;
31
+ tag?: string;
32
+ attrs?: IRAttr[];
33
+ txt?: string;
34
+ fid?: number;
35
+ item?: string;
36
+ index?: string;
37
+ branches?: {
38
+ condFid: number | null;
39
+ children: IRNode[];
40
+ attrs?: IRAttr[];
41
+ __meta?: any;
42
+ }[];
43
+ children?: IRNode[];
44
+ }
45
+ /** 🎯 IR 根节点 - 核心数据结构 */
46
+ export interface IRRoot {
47
+ type: 'root';
48
+ version: string;
49
+ functions: Function[];
50
+ nodes: IRNode[];
51
+ stats: {
52
+ totalFunctions: number;
53
+ cachedFunctions: number;
54
+ dynamicNodes: number;
55
+ totalNodes: number;
56
+ };
57
+ metadata?: {
58
+ compiledAt: string;
59
+ astSize: number;
60
+ source?: string;
61
+ filename: string;
62
+ };
63
+ }
64
+ export interface Meta {
65
+ expr: string;
66
+ loc?: SourceLocation;
67
+ }
@@ -0,0 +1,4 @@
1
+ export type LifecycleKind = 'mounted' | 'updated' | 'unmounted';
2
+ export declare const LIFECYCLE_ATTRS_MAP: Record<string, LifecycleKind>;
3
+ export declare function mapAttrKeyToLifecycleKind(key: string): LifecycleKind | null;
4
+ export declare function isLifecycleKind(value: string): value is LifecycleKind;
@@ -0,0 +1,4 @@
1
+ export interface runtimeLoop {
2
+ itmVal: any;
3
+ idxVal: number;
4
+ }
package/package.json CHANGED
@@ -1,27 +1,44 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.0.30",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
- "module": "./dist/solely.js",
7
- "types": "./dist/solely.d.ts",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./plugin": "./dist/plugin.js"
12
+ },
8
13
  "files": [
9
14
  "dist"
10
15
  ],
11
16
  "keywords": [
12
17
  "ast",
13
- "vnode"
18
+ "vnode",
19
+ "template",
20
+ "custom-element",
21
+ "web-component",
22
+ "framework",
23
+ "library",
24
+ "ui",
25
+ "component",
26
+ "design",
27
+ "development"
14
28
  ],
15
29
  "author": "Sun Yue",
16
30
  "scripts": {
17
31
  "dev": "vite",
18
- "build": "tsc && vite build",
32
+ "build": "vite build",
33
+ "build-dev": "vite build && npm run plugin:build",
19
34
  "preview": "vite preview",
20
35
  "link": "npm link && echo '✅ 全局链接成功,可在其他项目中使用 solely 命令'",
21
36
  "test": "vitest",
22
37
  "test:ui": "vitest --ui",
23
38
  "test:coverage": "vitest --coverage",
24
- "pack:local": "npm pack && echo '✅ 打包完成,可在其他项目中使用 file: 引用'"
39
+ "pack:local": "npm pack && echo '✅ 打包完成,可在其他项目中使用 file: 引用'",
40
+ "dev:debug": "node --inspect-brk ./node_modules/vite/bin/vite.js",
41
+ "plugin:build": "tsup src/plugin.ts --format esm,cjs --dts"
25
42
  },
26
43
  "devDependencies": {
27
44
  "@rollup/plugin-strip": "^3.0.4",
@@ -33,6 +50,7 @@
33
50
  "jsdom": "27.0.0",
34
51
  "sass": "^1.83.0",
35
52
  "terser": "^5.44.0",
53
+ "tsup": "^8.5.1",
36
54
  "typescript": "~5.6.2",
37
55
  "vite": "^5.4.10",
38
56
  "vite-plugin-dts": "^4.4.0",
@@ -1,56 +0,0 @@
1
- import { Manifest } from './decorators';
2
- /**
3
- * 泛型接口
4
- * 外部组件可定义 $data 的结构类型(带智能提示)
5
- * 例如:class MyEl extends BaseElement<{ count: number; name: string }> {}
6
- */
7
- declare interface BaseElement<TData = any> {
8
- _manifest: Manifest;
9
- }
10
- /**
11
- * BaseElement<TData>
12
- * -------------------------------------------------------
13
- * 核心功能:
14
- * ✅ 响应式数据系统(observe + Proxy)
15
- * ✅ 虚拟 DOM 渲染(patch)
16
- * ✅ 延迟样式注入(connectedCallback 阶段)
17
- * ✅ 生命周期钩子(created, mounted, updated, unmounted)
18
- * ✅ 属性同步 ($data <-> attribute)
19
- */
20
- declare class BaseElement<TData extends object> extends HTMLElement {
21
- #private;
22
- /** Web Components 标准方法:声明哪些属性变化会触发 attributeChangedCallback */
23
- static get observedAttributes(): any;
24
- /**
25
- * 构造函数
26
- * -------------------------------------------------------
27
- * 初始化模板、响应式数据和渲染根节点。
28
- * 样式注入延迟到 connectedCallback 阶段。
29
- */
30
- constructor(initialData?: TData);
31
- /** 获取当前组件数据 */
32
- get $data(): TData;
33
- /** 更新组件数据 */
34
- set $data(value: TData);
35
- /**
36
- * 手动刷新组件
37
- * 外部可调用,用于数据未触发 observe 或强制刷新
38
- */
39
- refresh(): void;
40
- connectedCallback(): void;
41
- disconnectedCallback(): void;
42
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
43
- /** 兼容旧组件的初始化钩子(首次 mounted 后调用) */
44
- onInit(): void | Promise<void>;
45
- /** 组件创建完成(构造函数结束时调用) */
46
- created(): void;
47
- /** 组件首次挂载到 DOM 后调用 */
48
- mounted(): void;
49
- /** 每次更新前调用 */
50
- beforeUpdate(): void;
51
- /** 每次更新完成后调用 */
52
- updated(): void;
53
- /** 组件从 DOM 中卸载时调用 */
54
- unmounted(): void;
55
- }
56
- export default BaseElement;
@@ -1,5 +0,0 @@
1
- export { default as BaseElement } from './base-element';
2
- export { CustomElement } from './decorators';
3
- export type { Manifest } from './decorators';
4
- export { RouterViewElement } from './router-view';
5
- export type { IRouter } from './router-view';
@@ -1,43 +0,0 @@
1
- export interface IRouter {
2
- path: string;
3
- tagName: string;
4
- children?: IRouter[];
5
- }
6
- export declare class RouterViewElement extends HTMLElement {
7
- #private;
8
- get isRouterView(): boolean;
9
- get $routes(): IRouter[];
10
- set $routes(v: IRouter[]);
11
- get $remainingPath(): string[];
12
- get $matchedRoute(): IRouter | null;
13
- set $pipe(v: Record<string, any>);
14
- connectedCallback(): void;
15
- disconnectedCallback(): void;
16
- /**
17
- * Hash 变化时的核心处理函数
18
- */
19
- private onHashChange;
20
- /**
21
- * 准备传递给子组件的 props 和事件监听
22
- * @param params 从路由中解析出的参数
23
- * @returns 包含 props 和 on 的对象
24
- */
25
- private prepareComponentData;
26
- /**
27
- * 在路由表中查找与当前路径匹配的路由
28
- * @param routes 路由配置数组
29
- * @param pathSegments URL 路径分段数组
30
- * @returns 匹配结果
31
- */
32
- private matchRoute;
33
- /**
34
- * 递归通知所有子节点中的 router-view 进行更新
35
- * @param node 当前遍历的起始节点
36
- */
37
- private propagateToChildRouterViews;
38
- /**
39
- * 沿 DOM 树向上查找最近的父 router-view 实例
40
- * @returns 父 RouterViewElement 实例或 null
41
- */
42
- private findAncestorRouterView;
43
- }
package/dist/solely.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- export * from './base';