x-state-lib 0.4.1 → 0.4.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 (2) hide show
  1. package/dist/index.js +154 -1
  2. package/package.json +8 -7
package/dist/index.js CHANGED
@@ -1 +1,154 @@
1
- import"x-essential-lib";function e({id:e,name:t,type:n}){return{id:e,name:t,type:n}}function t(t){if(!t)return;let n=[];for(let r of t)n.push(e(r));return n}function n(e){return{version:e.version,arguments:t(e.arguments),states:t(e.states)}}function r(e){if(!e)return;let n=[];for(let{id:r,name:i,inputs:a,outputs:o}of e)n.push({id:r,name:i,inputs:t(a),outputs:t(o)});return n}function i(e){if(!e)return;let n=[];for(let{id:r,name:i,params:a}of e)n.push({id:r,name:i,params:t(a)});return n}function a(e){if(!e)return;let n=[];for(let{id:a,name:o,properties:s,methods:c,events:l}of e)n.push({id:a,name:o,properties:t(s),methods:r(c),events:i(l)});return n}function o(e){return{version:e.version,properties:t(e.properties),methods:r(e.methods),events:i(e.events),slots:a(e.slots),states:t(e.states)}}function s(){return{appList:[],activeApp:{id:``,compGroups:[],comps:[]},activePage:{id:``,meta:{version:``}},activeComp:{id:``,meta:{version:``}},activeObject:{type:`page`,subtype:``,version:``,nodes:[]},depends:{}}}function c({id:e,name:t,type:n}){return{id:e,name:t,type:n}}function l(e){if(!e)return;let t=[];for(let n of e)t.push(c(n));return t}function u(){return{spaces:[],activeFunc:{id:``,name:``,inputs:[],outputs:[]},activeFlow:{id:``,name:``},activeObject:{type:`func`,version:``}}}function d(){return{spaces:[]}}function f(){return{spaces:[]}}const p=(function(){return window.globalState||(window.globalState={app:s(),compute:u(),data:d(),resource:f()}),window.globalState})();export{p as globalState,s as initApp,u as initCompute,d as initData,f as initResource,o as toCompMeta,l as toFields,n as toPageMeta};
1
+ (function(){try{document.getElementById(`x-state-lib`)?.remove();const e = document.createElement(`style`);e.setAttribute(`id`, `x-state-lib`);const t = document.createTextNode(``);e.appendChild(t);document.head.appendChild(e);}catch(e){console.error('rolldown-plugin-inject-css', e);}})()
2
+ import "x-essential-lib";
3
+
4
+ //#region src/state/app.ts
5
+ function toField$1({ id, name, type }) {
6
+ return {
7
+ id,
8
+ name,
9
+ type
10
+ };
11
+ }
12
+ function toFields$1(srcFields) {
13
+ if (!srcFields) return;
14
+ const dstFields = [];
15
+ for (const srcField of srcFields) dstFields.push(toField$1(srcField));
16
+ return dstFields;
17
+ }
18
+ function toPageMeta(src) {
19
+ return {
20
+ version: src.version,
21
+ arguments: toFields$1(src.arguments),
22
+ states: toFields$1(src.states)
23
+ };
24
+ }
25
+ function toMethods(srcMethods) {
26
+ if (!srcMethods) return;
27
+ const dstMethods = [];
28
+ for (const { id, name, inputs, outputs } of srcMethods) dstMethods.push({
29
+ id,
30
+ name,
31
+ inputs: toFields$1(inputs),
32
+ outputs: toFields$1(outputs)
33
+ });
34
+ return dstMethods;
35
+ }
36
+ function toEvents(srcEvents) {
37
+ if (!srcEvents) return;
38
+ const dstEvents = [];
39
+ for (const { id, name, params } of srcEvents) dstEvents.push({
40
+ id,
41
+ name,
42
+ params: toFields$1(params)
43
+ });
44
+ return dstEvents;
45
+ }
46
+ function toSlots(srcSlots) {
47
+ if (!srcSlots) return;
48
+ const dstSlots = [];
49
+ for (const { id, name, properties, methods, events } of srcSlots) dstSlots.push({
50
+ id,
51
+ name,
52
+ properties: toFields$1(properties),
53
+ methods: toMethods(methods),
54
+ events: toEvents(events)
55
+ });
56
+ return dstSlots;
57
+ }
58
+ function toCompMeta(src) {
59
+ return {
60
+ version: src.version,
61
+ properties: toFields$1(src.properties),
62
+ methods: toMethods(src.methods),
63
+ events: toEvents(src.events),
64
+ slots: toSlots(src.slots),
65
+ states: toFields$1(src.states)
66
+ };
67
+ }
68
+ function initApp() {
69
+ return {
70
+ appList: [],
71
+ activeApp: {
72
+ id: "",
73
+ compGroups: [],
74
+ comps: []
75
+ },
76
+ activePage: {
77
+ id: "",
78
+ meta: { version: "" }
79
+ },
80
+ activeComp: {
81
+ id: "",
82
+ meta: { version: "" }
83
+ },
84
+ activeObject: {
85
+ type: "page",
86
+ subtype: "",
87
+ version: "",
88
+ nodes: []
89
+ },
90
+ depends: {}
91
+ };
92
+ }
93
+
94
+ //#endregion
95
+ //#region src/state/compute.ts
96
+ function toField({ id, name, type }) {
97
+ return {
98
+ id,
99
+ name,
100
+ type
101
+ };
102
+ }
103
+ function toFields(srcFields) {
104
+ if (!srcFields) return;
105
+ const dstFields = [];
106
+ for (const entry of srcFields) dstFields.push(toField(entry));
107
+ return dstFields;
108
+ }
109
+ function initCompute() {
110
+ return {
111
+ spaces: [],
112
+ activeFunc: {
113
+ id: "",
114
+ name: "",
115
+ inputs: [],
116
+ outputs: []
117
+ },
118
+ activeFlow: {
119
+ id: "",
120
+ name: ""
121
+ },
122
+ activeObject: {
123
+ type: "func",
124
+ version: ""
125
+ }
126
+ };
127
+ }
128
+
129
+ //#endregion
130
+ //#region src/state/data.ts
131
+ function initData() {
132
+ return { spaces: [] };
133
+ }
134
+
135
+ //#endregion
136
+ //#region src/state/resource.ts
137
+ function initResource() {
138
+ return { spaces: [] };
139
+ }
140
+
141
+ //#endregion
142
+ //#region src/state/state.ts
143
+ const globalState = (function() {
144
+ if (!window.globalState) window.globalState = {
145
+ app: initApp(),
146
+ compute: initCompute(),
147
+ data: initData(),
148
+ resource: initResource()
149
+ };
150
+ return window.globalState;
151
+ })();
152
+
153
+ //#endregion
154
+ export { globalState, initApp, initCompute, initData, initResource, toCompMeta, toFields, toPageMeta };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-state-lib",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -34,18 +34,19 @@
34
34
  "tsdown": "^0.22.3",
35
35
  "typescript": "^6.0.3",
36
36
  "vite": "^8.0.16",
37
- "x-config-lib": "^0.1.2",
38
- "x-config-oxfmt": "^0.1.3",
39
- "x-config-oxlint": "^0.1.2"
37
+ "x-config-lib": "^0.1.5",
38
+ "x-config-oxfmt": "^0.1.4",
39
+ "x-config-oxlint": "^0.1.4"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "vue": "^3.5.38",
43
43
  "vuetify": "^4.1.2",
44
- "x-error-lib": "^0.6.1",
45
- "x-essential-lib": "^0.10.1",
46
- "x-runtime-lib": "^0.10.1"
44
+ "x-error-lib": "^0.6.3",
45
+ "x-essential-lib": "^0.10.7",
46
+ "x-runtime-lib": "^0.10.2"
47
47
  },
48
48
  "lint-staged": {
49
+ "*.{js,jsx,ts,tsx,vue}": "oxlint",
49
50
  "*": "oxfmt --no-error-on-unmatched-pattern"
50
51
  }
51
52
  }