@voxgig/model 1.5.0 → 2.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 voxgig
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/model.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Config } from './lib/config';
2
2
  import { BuildResult, Spec } from './lib/build';
3
3
  import { Watch } from './lib/watch';
4
- import { dive, joins, get, pinify, camelify } from './lib/util';
4
+ import { dive, joins, get, pinify, camelify } from '@voxgig/util';
5
5
  declare class Model {
6
6
  config: Config;
7
7
  build: any;
package/dist/model.js CHANGED
@@ -11,7 +11,7 @@ const config_1 = require("./lib/config");
11
11
  const watch_1 = require("./lib/watch");
12
12
  const model_1 = require("./lib/builder/model");
13
13
  const local_1 = require("./lib/builder/local");
14
- const util_1 = require("./lib/util");
14
+ const util_1 = require("@voxgig/util");
15
15
  Object.defineProperty(exports, "dive", { enumerable: true, get: function () { return util_1.dive; } });
16
16
  Object.defineProperty(exports, "joins", { enumerable: true, get: function () { return util_1.joins; } });
17
17
  Object.defineProperty(exports, "get", { enumerable: true, get: function () { return util_1.get; } });
package/dist/model.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../model.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;AAEpD,6BAA6B;AAC7B,4CAAmB;AAEnB,yCAAqC;AAErC,uCAAmC;AAEnC,+CAAmD;AACnD,+CAAmD;AAEnD,qCAMmB;AAgHjB,qFArHA,WAAI,OAqHA;AACJ,sFArHA,YAAK,OAqHA;AACL,oFArHA,UAAG,OAqHA;AACH,uFArHA,aAAM,OAqHA;AACN,yFArHA,eAAQ,OAqHA;AAjHV,MAAM,MAAM,GAAG,UAAU,EAAE,CAAA;AAE3B,MAAM,KAAK;IAQT,YAAY,IAAU;QAHtB,kBAAa,GAAG,KAAK,CAAA;QAKnB,oDAAoD;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;YACpC,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,KAAK,EAAE,KAAY,EAAE,EAAE;gBAE5B,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;oBAEvB,eAAe;oBACf,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;oBAE9C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBAC7B,CAAC;qBACI,CAAC;oBACJ,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;oBACzB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;gBACrB,CAAC;YACH,CAAC;SACF,CAAC,CAAA;QAGF,oBAAoB;QACpB,IAAI,CAAC,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AoCC,sBAAK;AAjCP,SAAS,UAAU;IACjB,OAAO;QACL,UAAU,CAAC,IAAU,EAAE,mBAAgC;YACrD,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;YACxC,IAAI,KAAK,GAAG,KAAK,GAAG,sBAAsB,CAAA;YAE1C,yBAAyB;YACzB,IAAI,GAAG,GAAG,YAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;YAE3C,IAAI,KAAK,GAAS;gBAChB,GAAG,EAAE,GAAG;gBACR,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,KAAK;gBACX,GAAG,EAAE;oBAEH,iDAAiD;oBACjD;wBACE,IAAI,EAAE,GAAG;wBACT,KAAK,EAAE,qBAAa;qBACrB;oBAED,mBAAmB;iBACpB;gBACD,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAA;YAED,OAAO,IAAI,eAAM,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;KACF,CAAA;AACH,CAAC"}
package/model.ts CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  get,
17
17
  pinify,
18
18
  camelify,
19
- } from './lib/util'
19
+ } from '@voxgig/util'
20
20
 
21
21
 
22
22
  const intern = makeIntern()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/model",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "main": "dist/model.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/model.d.ts",
@@ -44,16 +44,17 @@
44
44
  "LICENSE"
45
45
  ],
46
46
  "dependencies": {
47
+ "@voxgig/util": "^0.0.1",
47
48
  "aontu": "0.21.1",
48
49
  "chokidar": "3.6.0"
49
50
  },
50
51
  "devDependencies": {
51
- "@types/node": "20.14.2",
52
52
  "@types/jest": "^29.5.12",
53
+ "@types/node": "20.14.2",
54
+ "es-jest": "^2.1.0",
53
55
  "esbuild": "^0.21.5",
54
56
  "esbuild-jest": "^0.5.0",
55
57
  "jest": "^29.7.0",
56
- "es-jest": "^2.1.0",
57
58
  "typescript": "^5.4.5"
58
59
  }
59
60
  }
package/lib/util.ts DELETED
@@ -1,119 +0,0 @@
1
- /* Copyright © 2021-2023 Voxgig Ltd, MIT License. */
2
-
3
-
4
- type DiveMapper = (path: any[], leaf: any) => any[]
5
-
6
- function dive(node: any, depth?: number | DiveMapper, mapper?: DiveMapper): any[] {
7
- let d = (null == depth || 'number' != typeof depth) ? 2 : depth
8
- mapper = 'function' === typeof depth ? depth : mapper
9
-
10
- let items: any[] = []
11
-
12
- Object.entries(node || {}).reduce(
13
- (items: any[], entry: any[]) => {
14
- let key = entry[0]
15
- let child = entry[1]
16
-
17
- // console.log('CHILD', d, key, child)
18
-
19
- if ('$' === key) {
20
- // console.log('BBB', d)
21
- items.push([[], child])
22
- }
23
- else if (
24
- d <= 1 ||
25
- null == child ||
26
- 'object' !== typeof child ||
27
- 0 === Object.keys(child).length
28
- ) {
29
- // console.log('AAA', d)
30
- items.push([[key], child])
31
- }
32
- else {
33
- // console.log('CCC', d)
34
- let children = dive(child, d - 1)
35
- children = children.map(child => {
36
- child[0].unshift(key)
37
- return child
38
- })
39
- items.push(...children)
40
- }
41
-
42
- return items
43
- },
44
- items
45
- )
46
-
47
- // console.log('ITEMS', items)
48
-
49
- if (mapper) {
50
- return items.reduce(((a, entry) => {
51
- entry = (mapper as any)(entry[0], entry[1])
52
- if (null != entry[0]) {
53
- a[entry[0]] = entry[1]
54
- }
55
- return a
56
- }), {} as any)
57
- }
58
-
59
- return items
60
- }
61
-
62
-
63
- /*
64
- * , => a,b
65
- * :, => a:1,b:2
66
- * :,/ => a:1,b:2/c:3,d:4/e:5,f:6
67
- */
68
- function joins(arr: any[], ...seps: string[]) {
69
- arr = arr || []
70
- seps = seps || []
71
- let sa = []
72
- for (let i = 0; i < arr.length; i++) {
73
- sa.push(arr[i])
74
- if (i < arr.length - 1) {
75
- for (let j = seps.length - 1; -1 < j; j--) {
76
- if (0 === (i + 1) % (1 << j)) {
77
- sa.push(seps[j])
78
- break
79
- }
80
- }
81
- }
82
- }
83
- return sa.join('')
84
- }
85
-
86
-
87
- function get(root: any, path: string | string[]): any {
88
- path = 'string' === typeof path ? path.split('.') : path
89
- let node = root
90
- for (let i = 0; i < path.length && null != node; i++) {
91
- node = node[path[i]]
92
- }
93
- return node
94
- }
95
-
96
-
97
- function pinify(path: string[]) {
98
- let pin = path
99
- .map((p: string, i: number) =>
100
- p + (i % 2 ? (i === path.length - 1 ? '' : ',') : ':'))
101
- .join('')
102
- return pin
103
- }
104
-
105
-
106
- function camelify(input: any[] | string) {
107
- let parts = 'string' == typeof input ? input.split('-') : input.map(n => '' + n)
108
- return parts
109
- .map((p: string) => ('' === p ? '' : (p[0].toUpperCase() + p.substring(1))))
110
- .join('')
111
- }
112
-
113
- export {
114
- dive,
115
- joins,
116
- get,
117
- pinify,
118
- camelify,
119
- }