@cldmv/wisp 1.0.1 → 1.0.6
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/index.cjs +15 -0
- package/index.mjs +15 -0
- package/package.json +13 -7
- package/src/lib/resolve-from-caller.mjs +13 -6
- package/src/wisp.mjs +16 -13
- package/types/lib/resolve-from-caller.d.mts.map +1 -1
- package/types/wisp.d.mts.map +1 -1
package/index.cjs
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @Project: @cldmv/wisp
|
|
4
|
+
* @Filename: /index.cjs
|
|
5
|
+
* @Date: 2025-10-30T15:06:33-07:00 (1761861993)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
+
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
+
* -----
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T15:12:05-07:00 (1790979125)
|
|
11
|
+
* -----
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* @fileoverview CJS entry point for @cldmv/wisp, providing version-agnostic JSON importing.
|
|
3
18
|
* @module @cldmv/wisp
|
package/index.mjs
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @Project: @cldmv/wisp
|
|
4
|
+
* @Filename: /index.mjs
|
|
5
|
+
* @Date: 2025-10-30T15:06:33-07:00 (1761861993)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
+
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
+
* -----
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T15:12:05-07:00 (1790979125)
|
|
11
|
+
* -----
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* @fileoverview Main entry point for @cldmv/wisp, providing version-agnostic JSON importing.
|
|
3
18
|
* @module @cldmv/wisp
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/wisp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Version-agnostic JSON importing for Node.js with fallback handling and caller path resolution.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "mocha --recursive \"test/**/*.mjs\"",
|
|
14
14
|
"test:watch": "mocha --watch \"test/**/*.mjs\"",
|
|
15
|
-
"lint": "eslint
|
|
15
|
+
"lint": "eslint --config .configs/eslint.config.mjs .",
|
|
16
16
|
"build:types": "tsc",
|
|
17
17
|
"test:types": "tsc --noEmit",
|
|
18
|
-
"build:ci": "npm run test && npm run build:types && npm run test:types"
|
|
18
|
+
"build:ci": "npm run test && npm run build:types && npm run test:types",
|
|
19
|
+
"fix:headers": "fix-headers --config .configs/fix-headers.json"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [
|
|
21
22
|
"json",
|
|
@@ -64,10 +65,15 @@
|
|
|
64
65
|
"package.json"
|
|
65
66
|
],
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"@types/node": "^
|
|
68
|
+
"@cldmv/configs": "^1.2.1",
|
|
69
|
+
"@cldmv/fix-headers": "^2.1.2",
|
|
70
|
+
"@eslint/js": "^10.0.1",
|
|
71
|
+
"@types/node": "^26.6.2",
|
|
72
|
+
"chai": "^6.2.2",
|
|
73
|
+
"eslint": "^10.10.0",
|
|
74
|
+
"globals": "^17.12.0",
|
|
75
|
+
"mocha": "^12.0.1",
|
|
76
|
+
"typescript": "^6.0.3"
|
|
71
77
|
},
|
|
72
78
|
"publishConfig": {
|
|
73
79
|
"access": "public"
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
*
|
|
2
3
|
* @Project: @cldmv/wisp
|
|
3
4
|
* @Filename: /src/lib/resolve-from-caller.mjs
|
|
4
|
-
* @Date: 2025-09-
|
|
5
|
-
* @Author: Nate
|
|
5
|
+
* @Date: 2025-09-09T13:22:38-07:00 (1757449358)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
6
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
7
8
|
* -----
|
|
8
|
-
* @Last modified by: Nate
|
|
9
|
-
* @Last modified time:
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T15:12:05-07:00 (1790979125)
|
|
10
11
|
* -----
|
|
11
|
-
* @Copyright: Copyright (c) 2013-
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -133,7 +135,6 @@ export function getStack(skipFn) {
|
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
const THIS_FILE = fileURLToPath(import.meta.url);
|
|
136
|
-
const THIS_DIR = path.dirname(THIS_FILE);
|
|
137
138
|
|
|
138
139
|
// Find the package root by looking for package.json
|
|
139
140
|
function findPackageRoot(startPath) {
|
|
@@ -182,6 +183,11 @@ const PACKAGE_ROOT = findPackageRoot(THIS_FILE);
|
|
|
182
183
|
*/
|
|
183
184
|
function pickPrimaryBaseFile() {
|
|
184
185
|
let exitedSrcOrDist = false; // Flag 1: Have we exited src/ or dist/?
|
|
186
|
+
// This function's own docstring documents a "Flag 2 set, return this!"
|
|
187
|
+
// scenario, but nothing reads exitedIndex to return early once it's set --
|
|
188
|
+
// looks like a pre-existing gap between the documented intent and the
|
|
189
|
+
// implementation. Left as-is; fixing the behavior is a separate decision
|
|
190
|
+
// from unblocking lint.
|
|
185
191
|
let exitedIndex = false; // Flag 2: Have we exited index.*?
|
|
186
192
|
let previousWasInSrcOrDist = false;
|
|
187
193
|
let previousWasIndex = false;
|
|
@@ -214,6 +220,7 @@ function pickPrimaryBaseFile() {
|
|
|
214
220
|
|
|
215
221
|
// Flag 2: Check if we've exited index.* (was index, now not index)
|
|
216
222
|
if (previousWasIndex && !currentIsIndex) {
|
|
223
|
+
// eslint-disable-next-line no-unused-vars -- see the declaration above
|
|
217
224
|
exitedIndex = true;
|
|
218
225
|
}
|
|
219
226
|
|
package/src/wisp.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
*
|
|
2
3
|
* @Project: @cldmv/wisp
|
|
3
4
|
* @Filename: /src/wisp.mjs
|
|
4
|
-
* @Date: 2025-10-
|
|
5
|
-
* @Author: Nate
|
|
5
|
+
* @Date: 2025-10-30T14:12:05-07:00 (1761858725)
|
|
6
|
+
* @Author: Nate Corcoran <CLDMV>
|
|
6
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
7
8
|
* -----
|
|
8
|
-
* @Last modified by: Nate
|
|
9
|
-
* @Last modified time:
|
|
9
|
+
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
+
* @Last modified time: 2026-10-02T15:12:05-07:00 (1790979125)
|
|
10
11
|
* -----
|
|
11
|
-
* @Copyright: Copyright (c) 2013-
|
|
12
|
+
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
+
*
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -90,14 +92,15 @@ export async function wisp(input, options = {}) {
|
|
|
90
92
|
try {
|
|
91
93
|
validate(val);
|
|
92
94
|
} catch (e) {
|
|
93
|
-
throw new Error(`@cldmv/wisp: ${e?.message ?? e}
|
|
95
|
+
throw new Error(`@cldmv/wisp: ${e?.message ?? e}`, { cause: e });
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
return val;
|
|
97
99
|
} catch {}
|
|
98
100
|
|
|
99
101
|
try {
|
|
100
|
-
|
|
102
|
+
// Legacy import assertions (`assert`) for Node 16.14-20.9, which predate `with`; the cast keeps the type checker from rejecting the key.
|
|
103
|
+
const mod = await import(url.href, /** @type {any} */ ({ assert: { type } }));
|
|
101
104
|
if (!reviver && !validate) return mod?.default ?? mod;
|
|
102
105
|
let val = deepClone(mod?.default ?? mod);
|
|
103
106
|
if (reviver) val = JSON.parse(JSON.stringify(val), reviver);
|
|
@@ -105,7 +108,7 @@ export async function wisp(input, options = {}) {
|
|
|
105
108
|
try {
|
|
106
109
|
validate(val);
|
|
107
110
|
} catch (e) {
|
|
108
|
-
throw new Error(`@cldmv/wisp: ${e?.message ?? e}
|
|
111
|
+
throw new Error(`@cldmv/wisp: ${e?.message ?? e}`, { cause: e });
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
return val;
|
|
@@ -119,7 +122,7 @@ export async function wisp(input, options = {}) {
|
|
|
119
122
|
try {
|
|
120
123
|
validate(val);
|
|
121
124
|
} catch (e) {
|
|
122
|
-
throw new Error(`@cldmv/wisp: ${e?.message ?? e}
|
|
125
|
+
throw new Error(`@cldmv/wisp: ${e?.message ?? e}`, { cause: e });
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
128
|
return val;
|
|
@@ -127,7 +130,7 @@ export async function wisp(input, options = {}) {
|
|
|
127
130
|
if (fallback) {
|
|
128
131
|
return wisp(fallback, options);
|
|
129
132
|
}
|
|
130
|
-
throw new Error(`@cldmv/wisp: Failed to load JSON file at ${url.href}: ${e.message}
|
|
133
|
+
throw new Error(`@cldmv/wisp: Failed to load JSON file at ${url.href}: ${e.message}`, { cause: e });
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -154,7 +157,7 @@ export async function wisp(input, options = {}) {
|
|
|
154
157
|
* const data = wispSync('./config.json');
|
|
155
158
|
*/
|
|
156
159
|
export function wispSync(input, options = {}) {
|
|
157
|
-
const { base, validate, reviver,
|
|
160
|
+
const { base, validate, reviver, fallback } = options;
|
|
158
161
|
let url;
|
|
159
162
|
if (input instanceof URL) url = input;
|
|
160
163
|
else {
|
|
@@ -172,7 +175,7 @@ export function wispSync(input, options = {}) {
|
|
|
172
175
|
try {
|
|
173
176
|
validate(val);
|
|
174
177
|
} catch (e) {
|
|
175
|
-
throw new Error(`@cldmv/wisp: ${e?.message ?? e}
|
|
178
|
+
throw new Error(`@cldmv/wisp: ${e?.message ?? e}`, { cause: e });
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
return val;
|
|
@@ -180,7 +183,7 @@ export function wispSync(input, options = {}) {
|
|
|
180
183
|
if (fallback) {
|
|
181
184
|
return wispSync(fallback, options);
|
|
182
185
|
}
|
|
183
|
-
throw new Error(`@cldmv/wisp: Failed to load JSON file at ${url.href}: ${e.message}
|
|
186
|
+
throw new Error(`@cldmv/wisp: Failed to load JSON file at ${url.href}: ${e.message}`, { cause: e });
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-from-caller.d.mts","sourceRoot":"","sources":["../../src/lib/resolve-from-caller.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-from-caller.d.mts","sourceRoot":"","sources":["../../src/lib/resolve-from-caller.mjs"],"names":[],"mappings":"AAuFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,6CAhCa,KAAK,CAAC,QAAQ,CAAC,CA0C3B;AA4MD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,2CAzCW,MAAM,GACJ,MAAM,CAsDlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,0CA1CW,MAAM,GACJ,MAAM,CAuDlB;AAtXM,4BAvBI,GAAG,GACD,MAAM,GAAC,IAAI,CAsB+F;;iBA0XzG,MAAY,MAAM,GAAC,SAAS;mBAC5B,MAAY,MAAM,GAAC,SAAS;qBAC5B,MAAY,MAAM,GAAC,SAAS;iBAC5B,MAAY,MAAM,GAAC,SAAS;mBAC5B,MAAY,MAAM,GAAC,SAAS;8BAC5B,MAAY,MAAM,GAAC,SAAS;qBAC5B,MAAY,MAAM,GAAC,SAAS;cAC5B,MAAY,OAAO,GAAC,SAAS;YAC7B,MAAY,OAAO,GAAC,SAAS;mBAC7B,MAAY,OAAO,GAAC,SAAS;gBAC7B,MAAY,OAAO,GAAC,SAAS;aAC7B,MAAY,OAAO,GAAC,SAAS;kBAC7B,MAAY,OAAO,GAAC,SAAS;qBAC7B,MAAY,MAAM,GAAC,SAAS"}
|
package/types/wisp.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wisp.d.mts","sourceRoot":"","sources":["../src/wisp.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wisp.d.mts","sourceRoot":"","sources":["../src/wisp.mjs"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4BAjBW,MAAM,GAAC,GAAG,YAElB;IAA6B,IAAI,GAAzB,MAAM,GAAC,GAAG;IACmB,QAAQ,GAArC,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI;IACoC,OAAO,GAA7D,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG;IAC1B,IAAI,GAArB,MAAM;IACe,QAAQ,GAA7B,MAAM,GAAC,GAAG;CAClB,GAAU,OAAO,CAAC,GAAC,CAAC,CA0EtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,gCAhBW,MAAM,GAAC,GAAG,YAElB;IAA6B,IAAI,GAAzB,MAAM,GAAC,GAAG;IACmB,QAAQ,GAArC,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI;IACoC,OAAO,GAA7D,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG;IAC1B,IAAI,GAArB,MAAM;IACe,QAAQ,GAA7B,MAAM,GAAC,GAAG;CAClB,GAAU,GAAC,CAsCb"}
|