@socketsecurity/lib 3.0.2 → 3.0.4
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/CHANGELOG.md +21 -1
- package/dist/abort.js +60 -1
- package/dist/abort.js.map +2 -2
- package/dist/agent.js +289 -1
- package/dist/agent.js.map +2 -2
- package/dist/ansi.js +60 -1
- package/dist/ansi.js.map +2 -2
- package/dist/argv/flags.js +282 -1
- package/dist/argv/flags.js.map +2 -2
- package/dist/argv/parse.js +171 -1
- package/dist/argv/parse.js.map +2 -2
- package/dist/arrays.js +85 -1
- package/dist/arrays.js.map +2 -2
- package/dist/bin.js +419 -5
- package/dist/bin.js.map +2 -2
- package/dist/cacache.js +139 -1
- package/dist/cacache.js.map +2 -2
- package/dist/cache-with-ttl.js +223 -1
- package/dist/cache-with-ttl.js.map +2 -2
- package/dist/constants/agents.js +126 -1
- package/dist/constants/agents.js.map +2 -2
- package/dist/constants/core.js +57 -2
- package/dist/constants/core.js.map +2 -2
- package/dist/constants/encoding.js +48 -1
- package/dist/constants/encoding.js.map +2 -2
- package/dist/constants/github.js +30 -1
- package/dist/constants/github.js.map +2 -2
- package/dist/constants/licenses.js +66 -1
- package/dist/constants/licenses.js.map +2 -2
- package/dist/constants/node.js +185 -1
- package/dist/constants/node.js.map +2 -2
- package/dist/constants/packages.js +128 -1
- package/dist/constants/packages.js.map +2 -2
- package/dist/constants/paths.js +150 -1
- package/dist/constants/paths.js.map +2 -2
- package/dist/constants/platform.js +41 -1
- package/dist/constants/platform.js.map +2 -2
- package/dist/constants/process.js +52 -1
- package/dist/constants/process.js.map +2 -2
- package/dist/constants/socket.js +102 -1
- package/dist/constants/socket.js.map +2 -2
- package/dist/constants/testing.js +36 -1
- package/dist/constants/testing.js.map +2 -2
- package/dist/constants/time.js +39 -1
- package/dist/constants/time.js.map +2 -2
- package/dist/constants/typescript.js +54 -1
- package/dist/constants/typescript.js.map +2 -2
- package/dist/cover/code.js +135 -1
- package/dist/cover/code.js.map +2 -2
- package/dist/cover/formatters.js +101 -11
- package/dist/cover/formatters.js.map +2 -2
- package/dist/cover/type.js +63 -1
- package/dist/cover/type.js.map +2 -2
- package/dist/cover/types.js +15 -1
- package/dist/cover/types.js.map +2 -2
- package/dist/debug.js +337 -2
- package/dist/debug.js.map +2 -2
- package/dist/dlx-binary.js +408 -7
- package/dist/dlx-binary.js.map +2 -2
- package/dist/dlx-package.js +278 -7
- package/dist/dlx-package.js.map +2 -2
- package/dist/dlx.js +214 -7
- package/dist/dlx.js.map +3 -3
- package/dist/effects/pulse-frames.js +64 -1
- package/dist/effects/pulse-frames.js.map +2 -2
- package/dist/effects/text-shimmer.js +174 -1
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/effects/types.js +15 -1
- package/dist/effects/types.js.map +2 -2
- package/dist/effects/ultra.js +61 -1
- package/dist/effects/ultra.js.map +2 -2
- package/dist/env/ci.js +31 -1
- package/dist/env/ci.js.map +2 -2
- package/dist/env/debug.js +30 -1
- package/dist/env/debug.js.map +2 -2
- package/dist/env/github.js +65 -1
- package/dist/env/github.js.map +2 -2
- package/dist/env/helpers.js +47 -1
- package/dist/env/helpers.js.map +2 -2
- package/dist/env/home.js +30 -1
- package/dist/env/home.js.map +2 -2
- package/dist/env/locale.js +40 -1
- package/dist/env/locale.js.map +2 -2
- package/dist/env/node-auth-token.js +30 -1
- package/dist/env/node-auth-token.js.map +2 -2
- package/dist/env/node-env.js +30 -1
- package/dist/env/node-env.js.map +2 -2
- package/dist/env/npm.js +50 -1
- package/dist/env/npm.js.map +2 -2
- package/dist/env/package-manager.js +73 -1
- package/dist/env/package-manager.js.map +2 -2
- package/dist/env/path.js +30 -1
- package/dist/env/path.js.map +2 -2
- package/dist/env/pre-commit.js +31 -1
- package/dist/env/pre-commit.js.map +2 -2
- package/dist/env/rewire.js +72 -1
- package/dist/env/rewire.js.map +2 -2
- package/dist/env/shell.js +30 -1
- package/dist/env/shell.js.map +2 -2
- package/dist/env/socket-cli-shadow.js +51 -1
- package/dist/env/socket-cli-shadow.js.map +2 -2
- package/dist/env/socket-cli.js +86 -1
- package/dist/env/socket-cli.js.map +2 -2
- package/dist/env/socket.js +101 -1
- package/dist/env/socket.js.map +2 -2
- package/dist/env/temp-dir.js +40 -1
- package/dist/env/temp-dir.js.map +2 -2
- package/dist/env/term.js +30 -1
- package/dist/env/term.js.map +2 -2
- package/dist/env/test.js +43 -1
- package/dist/env/test.js.map +2 -2
- package/dist/env/windows.js +45 -1
- package/dist/env/windows.js.map +2 -2
- package/dist/env/xdg.js +40 -1
- package/dist/env/xdg.js.map +2 -2
- package/dist/env.js +170 -1
- package/dist/env.js.map +2 -2
- package/dist/external/@socketregistry/packageurl-js.js +12 -2
- package/dist/fs.js +670 -7
- package/dist/fs.js.map +2 -2
- package/dist/functions.js +68 -1
- package/dist/functions.js.map +2 -2
- package/dist/git.js +329 -2
- package/dist/git.js.map +2 -2
- package/dist/github.js +202 -1
- package/dist/github.js.map +2 -2
- package/dist/globs.js +149 -1
- package/dist/globs.js.map +2 -2
- package/dist/http-request.js +335 -3
- package/dist/http-request.js.map +2 -2
- package/dist/index.js +69 -1
- package/dist/index.js.map +2 -2
- package/dist/ipc.js +244 -1
- package/dist/ipc.js.map +2 -2
- package/dist/json.js +73 -1
- package/dist/json.js.map +2 -2
- package/dist/links/index.js +60 -1
- package/dist/links/index.js.map +2 -2
- package/dist/logger.js +1383 -6
- package/dist/logger.js.map +2 -2
- package/dist/maintained-node-versions.js +35 -1
- package/dist/maintained-node-versions.js.map +2 -2
- package/dist/memoization.js +210 -1
- package/dist/memoization.js.map +2 -2
- package/dist/objects.js +311 -1
- package/dist/objects.js.map +3 -3
- package/dist/packages/editable.js +356 -9
- package/dist/packages/editable.js.map +2 -2
- package/dist/packages/exports.js +162 -1
- package/dist/packages/exports.js.map +2 -2
- package/dist/packages/isolation.js +187 -1
- package/dist/packages/isolation.js.map +2 -2
- package/dist/packages/licenses.js +214 -1
- package/dist/packages/licenses.js.map +2 -2
- package/dist/packages/manifest.js +190 -1
- package/dist/packages/manifest.js.map +2 -2
- package/dist/packages/normalize.js +132 -1
- package/dist/packages/normalize.js.map +2 -2
- package/dist/packages/operations.js +320 -1
- package/dist/packages/operations.js.map +2 -2
- package/dist/packages/paths.js +53 -1
- package/dist/packages/paths.js.map +2 -2
- package/dist/packages/provenance.js +178 -1
- package/dist/packages/provenance.js.map +2 -2
- package/dist/packages/specs.js +83 -1
- package/dist/packages/specs.js.map +2 -2
- package/dist/packages/validation.js +51 -1
- package/dist/packages/validation.js.map +2 -2
- package/dist/packages.js +129 -1
- package/dist/packages.js.map +2 -2
- package/dist/path.js +446 -1
- package/dist/path.js.map +2 -2
- package/dist/paths/rewire.js +79 -1
- package/dist/paths/rewire.js.map +2 -2
- package/dist/paths.js +190 -1
- package/dist/paths.js.map +2 -2
- package/dist/performance.js +216 -15
- package/dist/performance.js.map +2 -2
- package/dist/process-lock.js +287 -8
- package/dist/process-lock.js.map +2 -2
- package/dist/promise-queue.js +109 -1
- package/dist/promise-queue.js.map +2 -2
- package/dist/promises.js +267 -1
- package/dist/promises.js.map +2 -2
- package/dist/prompts/index.js +45 -1
- package/dist/prompts/index.js.map +2 -2
- package/dist/prompts.js +58 -1
- package/dist/prompts.js.map +2 -2
- package/dist/regexps.js +30 -1
- package/dist/regexps.js.map +2 -2
- package/dist/sea.js +44 -1
- package/dist/sea.js.map +2 -2
- package/dist/shadow.js +58 -1
- package/dist/shadow.js.map +2 -2
- package/dist/signal-exit.js +248 -1
- package/dist/signal-exit.js.map +2 -2
- package/dist/sorts.js +94 -1
- package/dist/sorts.js.map +2 -2
- package/dist/spawn.js +200 -1
- package/dist/spawn.js.map +2 -2
- package/dist/spinner.js +965 -1
- package/dist/spinner.js.map +3 -3
- package/dist/ssri.js +71 -1
- package/dist/ssri.js.map +2 -2
- package/dist/stdio/clear.js +82 -1
- package/dist/stdio/clear.js.map +2 -2
- package/dist/stdio/divider.js +89 -3
- package/dist/stdio/divider.js.map +2 -2
- package/dist/stdio/footer.js +94 -2
- package/dist/stdio/footer.js.map +2 -2
- package/dist/stdio/header.js +100 -2
- package/dist/stdio/header.js.map +2 -2
- package/dist/stdio/mask.js +207 -5
- package/dist/stdio/mask.js.map +2 -2
- package/dist/stdio/progress.js +209 -2
- package/dist/stdio/progress.js.map +2 -2
- package/dist/stdio/prompts.js +88 -1
- package/dist/stdio/prompts.js.map +2 -2
- package/dist/stdio/stderr.js +89 -2
- package/dist/stdio/stderr.js.map +2 -2
- package/dist/stdio/stdout.js +103 -2
- package/dist/stdio/stdout.js.map +2 -2
- package/dist/streams.js +78 -1
- package/dist/streams.js.map +2 -2
- package/dist/strings.js +251 -3
- package/dist/strings.js.map +2 -2
- package/dist/suppress-warnings.js +98 -1
- package/dist/suppress-warnings.js.map +2 -2
- package/dist/tables.js +128 -3
- package/dist/tables.js.map +2 -2
- package/dist/temporary-executor.js +53 -1
- package/dist/temporary-executor.js.map +2 -2
- package/dist/themes/context.js +71 -1
- package/dist/themes/context.js.map +3 -3
- package/dist/themes/index.d.ts +2 -2
- package/dist/themes/index.js +57 -1
- package/dist/themes/index.js.map +3 -3
- package/dist/themes/themes.d.ts +5 -5
- package/dist/themes/themes.js +204 -1
- package/dist/themes/themes.js.map +3 -3
- package/dist/themes/types.js +15 -1
- package/dist/themes/types.js.map +2 -2
- package/dist/themes/utils.js +116 -1
- package/dist/themes/utils.js.map +2 -2
- package/dist/types.js +59 -1
- package/dist/types.js.map +2 -2
- package/dist/url.js +142 -1
- package/dist/url.js.map +2 -2
- package/dist/utils/get-ipc.js +58 -1
- package/dist/utils/get-ipc.js.map +2 -2
- package/dist/validation/json-parser.js +127 -1
- package/dist/validation/json-parser.js.map +2 -2
- package/dist/validation/types.js +15 -1
- package/dist/validation/types.js.map +2 -2
- package/dist/versions.js +154 -1
- package/dist/versions.js.map +2 -2
- package/dist/words.js +50 -1
- package/dist/words.js.map +2 -2
- package/dist/zod.js +27 -1
- package/dist/zod.js.map +2 -2
- package/package.json +2 -2
|
@@ -1,11 +1,358 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var editable_exports = {};
|
|
20
|
+
__export(editable_exports, {
|
|
21
|
+
getEditablePackageJsonClass: () => getEditablePackageJsonClass,
|
|
22
|
+
pkgJsonToEditable: () => pkgJsonToEditable,
|
|
23
|
+
toEditablePackageJson: () => toEditablePackageJson,
|
|
24
|
+
toEditablePackageJsonSync: () => toEditablePackageJsonSync
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(editable_exports);
|
|
27
|
+
var import_path = require("../path");
|
|
28
|
+
var import_normalize = require("./normalize");
|
|
29
|
+
var import_paths = require("./paths");
|
|
30
|
+
const identSymbol = Symbol.for("indent");
|
|
31
|
+
const newlineSymbol = Symbol.for("newline");
|
|
32
|
+
let _EditablePackageJsonClass;
|
|
33
|
+
let _fs;
|
|
34
|
+
// @__NO_SIDE_EFFECTS__
|
|
35
|
+
function getFs() {
|
|
36
|
+
if (_fs === void 0) {
|
|
37
|
+
_fs = require("node:fs");
|
|
38
|
+
}
|
|
39
|
+
return _fs;
|
|
40
|
+
}
|
|
41
|
+
let _path;
|
|
42
|
+
// @__NO_SIDE_EFFECTS__
|
|
43
|
+
function getPath() {
|
|
44
|
+
if (_path === void 0) {
|
|
45
|
+
_path = require("node:path");
|
|
46
|
+
}
|
|
47
|
+
return _path;
|
|
48
|
+
}
|
|
49
|
+
let _util;
|
|
50
|
+
// @__NO_SIDE_EFFECTS__
|
|
51
|
+
function getUtil() {
|
|
52
|
+
if (_util === void 0) {
|
|
53
|
+
_util = require("node:util");
|
|
54
|
+
}
|
|
55
|
+
return _util;
|
|
56
|
+
}
|
|
57
|
+
// @__NO_SIDE_EFFECTS__
|
|
58
|
+
function getEditablePackageJsonClass() {
|
|
59
|
+
if (_EditablePackageJsonClass === void 0) {
|
|
60
|
+
const EditablePackageJsonBase = require("../external/@npmcli/package-json");
|
|
61
|
+
const { parse, read } = require("../external/@npmcli/package-json/lib/read-package");
|
|
62
|
+
const { packageSort } = require("../external/@npmcli/package-json/lib/sort");
|
|
63
|
+
_EditablePackageJsonClass = class EditablePackageJson extends EditablePackageJsonBase {
|
|
64
|
+
static fixSteps = EditablePackageJsonBase.fixSteps;
|
|
65
|
+
static normalizeSteps = EditablePackageJsonBase.normalizeSteps;
|
|
66
|
+
static prepareSteps = EditablePackageJsonBase.prepareSteps;
|
|
67
|
+
_canSave = true;
|
|
68
|
+
_path = void 0;
|
|
69
|
+
_readFileContent = "";
|
|
70
|
+
_readFileJson = void 0;
|
|
71
|
+
get content() {
|
|
72
|
+
return super.content;
|
|
73
|
+
}
|
|
74
|
+
get filename() {
|
|
75
|
+
const path = this._path;
|
|
76
|
+
if (!path) {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
if (path.endsWith("package.json")) {
|
|
80
|
+
return path;
|
|
81
|
+
}
|
|
82
|
+
const nodePath = /* @__PURE__ */ getPath();
|
|
83
|
+
return nodePath.join(path, "package.json");
|
|
84
|
+
}
|
|
85
|
+
static async create(path, opts = {}) {
|
|
86
|
+
const p = new _EditablePackageJsonClass();
|
|
87
|
+
await p.create(path);
|
|
88
|
+
return opts.data ? p.update(opts.data) : p;
|
|
89
|
+
}
|
|
90
|
+
static async fix(path, opts) {
|
|
91
|
+
const p = new _EditablePackageJsonClass();
|
|
92
|
+
await p.load(path, true);
|
|
93
|
+
return await p.fix(opts);
|
|
94
|
+
}
|
|
95
|
+
static async load(path, opts = {}) {
|
|
96
|
+
const p = new _EditablePackageJsonClass();
|
|
97
|
+
if (!opts.create) {
|
|
98
|
+
return await p.load(path);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
return await p.load(path);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
if (!err.message.startsWith("Could not read package.json")) {
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
return p.create(path);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
static async normalize(path, opts) {
|
|
110
|
+
const p = new _EditablePackageJsonClass();
|
|
111
|
+
await p.load(path);
|
|
112
|
+
return await p.normalize(opts);
|
|
113
|
+
}
|
|
114
|
+
static async prepare(path, opts) {
|
|
115
|
+
const p = new _EditablePackageJsonClass();
|
|
116
|
+
await p.load(path, true);
|
|
117
|
+
return await p.prepare(opts);
|
|
118
|
+
}
|
|
119
|
+
create(path) {
|
|
120
|
+
super.create(path);
|
|
121
|
+
this._path = path;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
async fix(opts = {}) {
|
|
125
|
+
await super.fix(opts);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
fromContent(data) {
|
|
129
|
+
super.fromContent(data);
|
|
130
|
+
this._canSave = false;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
fromJSON(data) {
|
|
134
|
+
super.fromJSON(data);
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
async load(path, create) {
|
|
138
|
+
this._path = path;
|
|
139
|
+
const { promises: fsPromises } = /* @__PURE__ */ getFs();
|
|
140
|
+
let parseErr;
|
|
141
|
+
try {
|
|
142
|
+
this._readFileContent = await read(this.filename);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
if (!create) {
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
147
|
+
parseErr = err;
|
|
148
|
+
}
|
|
149
|
+
if (parseErr) {
|
|
150
|
+
const nodePath = /* @__PURE__ */ getPath();
|
|
151
|
+
const indexFile = nodePath.resolve(this.path || "", "index.js");
|
|
152
|
+
let indexFileContent;
|
|
153
|
+
try {
|
|
154
|
+
indexFileContent = await fsPromises.readFile(indexFile, "utf8");
|
|
155
|
+
} catch {
|
|
156
|
+
throw parseErr;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
this.fromContent(indexFileContent);
|
|
160
|
+
} catch {
|
|
161
|
+
throw parseErr;
|
|
162
|
+
}
|
|
163
|
+
this._canSave = false;
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
this.fromJSON(this._readFileContent);
|
|
167
|
+
this._readFileJson = parse(this._readFileContent);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
async normalize(opts = {}) {
|
|
171
|
+
await super.normalize(opts);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
get path() {
|
|
175
|
+
return this._path;
|
|
176
|
+
}
|
|
177
|
+
async prepare(opts = {}) {
|
|
178
|
+
await super.prepare(opts);
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
async save(options) {
|
|
182
|
+
if (!this._canSave || this.content === void 0) {
|
|
183
|
+
throw new Error("No package.json to save to");
|
|
184
|
+
}
|
|
185
|
+
const { ignoreWhitespace = false, sort = false } = {
|
|
186
|
+
__proto__: null,
|
|
187
|
+
...options
|
|
188
|
+
};
|
|
189
|
+
const {
|
|
190
|
+
[identSymbol]: indent,
|
|
191
|
+
[newlineSymbol]: newline,
|
|
192
|
+
...rest
|
|
193
|
+
} = this.content;
|
|
194
|
+
const content = sort ? packageSort(rest) : rest;
|
|
195
|
+
const {
|
|
196
|
+
[identSymbol]: _indent,
|
|
197
|
+
[newlineSymbol]: _newline,
|
|
198
|
+
...origContent
|
|
199
|
+
} = this._readFileJson || {};
|
|
200
|
+
if (ignoreWhitespace && (/* @__PURE__ */ getUtil()).isDeepStrictEqual(content, origContent)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const format = indent === void 0 || indent === null ? " " : indent;
|
|
204
|
+
const eol = newline === void 0 || newline === null ? "\n" : newline;
|
|
205
|
+
const fileContent = `${JSON.stringify(
|
|
206
|
+
content,
|
|
207
|
+
void 0,
|
|
208
|
+
format
|
|
209
|
+
)}
|
|
210
|
+
`.replace(/\n/g, eol);
|
|
211
|
+
if (!ignoreWhitespace && fileContent.trim() === this._readFileContent.trim()) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const { promises: fsPromises } = /* @__PURE__ */ getFs();
|
|
215
|
+
await fsPromises.writeFile(this.filename, fileContent);
|
|
216
|
+
this._readFileContent = fileContent;
|
|
217
|
+
this._readFileJson = parse(fileContent);
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
saveSync(options) {
|
|
221
|
+
if (!this._canSave || this.content === void 0) {
|
|
222
|
+
throw new Error("No package.json to save to");
|
|
223
|
+
}
|
|
224
|
+
const { ignoreWhitespace = false, sort = false } = {
|
|
225
|
+
__proto__: null,
|
|
226
|
+
...options
|
|
227
|
+
};
|
|
228
|
+
const {
|
|
229
|
+
[Symbol.for("indent")]: indent,
|
|
230
|
+
[Symbol.for("newline")]: newline,
|
|
231
|
+
...rest
|
|
232
|
+
} = this.content;
|
|
233
|
+
const content = sort ? packageSort(rest) : rest;
|
|
234
|
+
if (ignoreWhitespace && (/* @__PURE__ */ getUtil()).isDeepStrictEqual(content, this._readFileJson)) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const format = indent === void 0 || indent === null ? " " : indent;
|
|
238
|
+
const eol = newline === void 0 || newline === null ? "\n" : newline;
|
|
239
|
+
const fileContent = `${JSON.stringify(
|
|
240
|
+
content,
|
|
241
|
+
void 0,
|
|
242
|
+
format
|
|
243
|
+
)}
|
|
244
|
+
`.replace(/\n/g, eol);
|
|
245
|
+
if (!ignoreWhitespace && fileContent.trim() === this._readFileContent.trim()) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
const fs = /* @__PURE__ */ getFs();
|
|
249
|
+
fs.writeFileSync(this.filename, fileContent);
|
|
250
|
+
this._readFileContent = fileContent;
|
|
251
|
+
this._readFileJson = parse(fileContent);
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
update(content) {
|
|
255
|
+
super.update(content);
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
willSave(options) {
|
|
259
|
+
const { ignoreWhitespace = false, sort = false } = {
|
|
260
|
+
__proto__: null,
|
|
261
|
+
...options
|
|
262
|
+
};
|
|
263
|
+
if (!this._canSave || this.content === void 0) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
const {
|
|
267
|
+
[Symbol.for("indent")]: indent,
|
|
268
|
+
[Symbol.for("newline")]: newline,
|
|
269
|
+
...rest
|
|
270
|
+
} = this.content;
|
|
271
|
+
const content = sort ? packageSort(rest) : rest;
|
|
272
|
+
if (ignoreWhitespace && (/* @__PURE__ */ getUtil()).isDeepStrictEqual(content, this._readFileJson)) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
const format = indent === void 0 || indent === null ? " " : indent;
|
|
276
|
+
const eol = newline === void 0 || newline === null ? "\n" : newline;
|
|
277
|
+
const fileContent = `${JSON.stringify(
|
|
278
|
+
content,
|
|
279
|
+
void 0,
|
|
280
|
+
format
|
|
281
|
+
)}
|
|
282
|
+
`.replace(/\n/g, eol);
|
|
283
|
+
if (!ignoreWhitespace && fileContent.trim() === this._readFileContent.trim()) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
return _EditablePackageJsonClass;
|
|
291
|
+
}
|
|
292
|
+
// @__NO_SIDE_EFFECTS__
|
|
293
|
+
function pkgJsonToEditable(pkgJson, options) {
|
|
294
|
+
const { normalize, ...normalizeOptions } = {
|
|
295
|
+
__proto__: null,
|
|
296
|
+
...options
|
|
297
|
+
};
|
|
298
|
+
const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
|
|
299
|
+
return new EditablePackageJson().fromContent(
|
|
300
|
+
normalize ? (0, import_normalize.normalizePackageJson)(pkgJson, normalizeOptions) : pkgJson
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
// @__NO_SIDE_EFFECTS__
|
|
304
|
+
async function toEditablePackageJson(pkgJson, options) {
|
|
305
|
+
const { path: filepath, ...pkgJsonToEditableOptions } = {
|
|
306
|
+
__proto__: null,
|
|
307
|
+
...options
|
|
308
|
+
};
|
|
309
|
+
const { normalize, ...normalizeOptions } = pkgJsonToEditableOptions;
|
|
310
|
+
if (typeof filepath !== "string") {
|
|
311
|
+
return /* @__PURE__ */ pkgJsonToEditable(pkgJson, pkgJsonToEditableOptions);
|
|
312
|
+
}
|
|
313
|
+
const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
|
|
314
|
+
const pkgJsonPath = (0, import_paths.resolvePackageJsonDirname)(filepath);
|
|
315
|
+
return (await EditablePackageJson.load(pkgJsonPath, { create: true })).fromJSON(
|
|
316
|
+
`${JSON.stringify(
|
|
317
|
+
normalize ? (0, import_normalize.normalizePackageJson)(pkgJson, {
|
|
318
|
+
...(0, import_path.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
|
|
319
|
+
...normalizeOptions
|
|
320
|
+
}) : pkgJson,
|
|
321
|
+
null,
|
|
322
|
+
2
|
|
323
|
+
)}
|
|
324
|
+
`
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
// @__NO_SIDE_EFFECTS__
|
|
328
|
+
function toEditablePackageJsonSync(pkgJson, options) {
|
|
329
|
+
const { path: filepath, ...pkgJsonToEditableOptions } = {
|
|
330
|
+
__proto__: null,
|
|
331
|
+
...options
|
|
332
|
+
};
|
|
333
|
+
const { normalize, ...normalizeOptions } = pkgJsonToEditableOptions;
|
|
334
|
+
if (typeof filepath !== "string") {
|
|
335
|
+
return /* @__PURE__ */ pkgJsonToEditable(pkgJson, pkgJsonToEditableOptions);
|
|
336
|
+
}
|
|
337
|
+
const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
|
|
338
|
+
const pkgJsonPath = (0, import_paths.resolvePackageJsonDirname)(filepath);
|
|
339
|
+
return new EditablePackageJson().create(pkgJsonPath).fromJSON(
|
|
340
|
+
`${JSON.stringify(
|
|
341
|
+
normalize ? (0, import_normalize.normalizePackageJson)(pkgJson, {
|
|
342
|
+
...(0, import_path.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
|
|
343
|
+
...normalizeOptions
|
|
344
|
+
}) : pkgJson,
|
|
345
|
+
null,
|
|
346
|
+
2
|
|
347
|
+
)}
|
|
348
|
+
`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
352
|
+
0 && (module.exports = {
|
|
353
|
+
getEditablePackageJsonClass,
|
|
354
|
+
pkgJsonToEditable,
|
|
355
|
+
toEditablePackageJson,
|
|
356
|
+
toEditablePackageJsonSync
|
|
357
|
+
});
|
|
11
358
|
//# sourceMappingURL=editable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/packages/editable.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * @fileoverview Editable package.json manipulation utilities.\n */\n\nimport type {\n EditablePackageJsonOptions,\n NormalizeOptions,\n PackageJson,\n SaveOptions,\n} from '../packages'\nimport { isNodeModules } from '../path'\nimport { normalizePackageJson } from './normalize'\nimport { resolvePackageJsonDirname } from './paths'\n\nconst identSymbol = Symbol.for('indent')\nconst newlineSymbol = Symbol.for('newline')\n\n// Define the interface for the dynamic class\ninterface EditablePackageJsonConstructor {\n new (): EditablePackageJsonInstance\n fixSteps: unknown[]\n normalizeSteps: unknown[]\n prepareSteps: unknown[]\n create(\n path: string,\n opts?: EditablePackageJsonOptions,\n ): Promise<EditablePackageJsonInstance>\n fix(path: string, opts?: unknown): Promise<EditablePackageJsonInstance>\n load(\n path: string,\n opts?: EditablePackageJsonOptions,\n ): Promise<EditablePackageJsonInstance>\n normalize(\n path: string,\n opts?: NormalizeOptions,\n ): Promise<EditablePackageJsonInstance>\n prepare(path: string, opts?: unknown): Promise<EditablePackageJsonInstance>\n}\n\n/**\n * EditablePackageJson instance interface extending NPMCliPackageJson functionality.\n * Provides enhanced package.json manipulation with Socket-specific features.\n * @extends NPMCliPackageJson (from @npmcli/package-json)\n */\nexport interface EditablePackageJsonInstance {\n /**\n * The parsed package.json content as a readonly object.\n * @readonly\n */\n content: Readonly<PackageJson>\n\n /**\n * Create a new package.json file at the specified path.\n * @param path - The directory path where package.json will be created\n */\n create(path: string): this\n\n /**\n * Apply automatic fixes to the package.json based on npm standards.\n * @param opts - Optional fix configuration\n */\n fix(opts?: unknown | undefined): Promise<this>\n\n /**\n * Initialize the instance from a content object.\n * @param content - The package.json content object\n */\n fromContent(content: unknown): this\n\n /**\n * Initialize the instance from a JSON string.\n * @param json - The package.json content as a JSON string\n */\n fromJSON(json: string): this\n\n /**\n * Load a package.json file from the specified path.\n * @param path - The directory containing the package.json\n * @param create - Whether to create the file if it doesn't exist\n */\n load(path: string, create?: boolean): Promise<this>\n\n /**\n * Normalize the package.json content according to npm standards.\n * @param opts - Normalization options\n */\n normalize(opts?: NormalizeOptions): Promise<this>\n\n /**\n * Prepare the package.json for publishing.\n * @param opts - Preparation options\n */\n prepare(opts?: unknown): Promise<this>\n\n /**\n * Update the package.json content with new values.\n * @param content - Partial package.json object with fields to update\n * @override from NPMCliPackageJson\n */\n update(content: Partial<PackageJson>): this\n\n /**\n * Save the package.json file to disk.\n * @param options - Save options for formatting and sorting\n * @override from NPMCliPackageJson\n */\n save(options?: SaveOptions | undefined): Promise<boolean>\n\n /**\n * Synchronously save the package.json file to disk.\n * @param options - Save options for formatting and sorting\n */\n saveSync(options?: SaveOptions | undefined): boolean\n\n /**\n * Check if the package.json will be saved based on current changes.\n * @param options - Save options to evaluate\n */\n willSave(options?: SaveOptions | undefined): boolean\n}\n\nlet _EditablePackageJsonClass: EditablePackageJsonConstructor | undefined\n\nlet _fs: typeof import('fs') | undefined\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('path')\n}\n\nlet _util: typeof import('util') | undefined\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUtil() {\n if (_util === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _util = /*@__PURE__*/ require('node:util')\n }\n return _util as typeof import('util')\n}\n\n/**\n * Get the EditablePackageJson class for package.json manipulation.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function getEditablePackageJsonClass(): EditablePackageJsonConstructor {\n if (_EditablePackageJsonClass === undefined) {\n const EditablePackageJsonBase =\n /*@__PURE__*/ require('../external/@npmcli/package-json')\n const { parse, read } =\n /*@__PURE__*/ require('../external/@npmcli/package-json/lib/read-package')\n const { packageSort } =\n /*@__PURE__*/ require('../external/@npmcli/package-json/lib/sort')\n _EditablePackageJsonClass =\n class EditablePackageJson extends (EditablePackageJsonBase as EditablePackageJsonConstructor) {\n static override fixSteps = EditablePackageJsonBase.fixSteps\n static override normalizeSteps = EditablePackageJsonBase.normalizeSteps\n static override prepareSteps = EditablePackageJsonBase.prepareSteps\n\n _canSave = true\n _path: string | undefined = undefined\n _readFileContent = ''\n _readFileJson: unknown = undefined\n\n override get content(): Readonly<PackageJson> {\n return super.content\n }\n\n get filename(): string {\n const path = this._path\n if (!path) {\n return ''\n }\n if (path.endsWith('package.json')) {\n return path\n }\n const nodePath = getPath()\n return nodePath.join(path, 'package.json')\n }\n\n static override async create(\n path: string,\n opts: EditablePackageJsonOptions = {},\n ) {\n const p = new (\n _EditablePackageJsonClass as EditablePackageJsonConstructor\n )()\n await p.create(path)\n return opts.data ? p.update(opts.data) : p\n }\n\n static override async fix(path: string, opts: unknown) {\n const p = new (\n _EditablePackageJsonClass as EditablePackageJsonConstructor\n )()\n await p.load(path, true)\n return await p.fix(opts)\n }\n\n static override async load(\n path: string,\n opts: EditablePackageJsonOptions = {},\n ) {\n const p = new (\n _EditablePackageJsonClass as EditablePackageJsonConstructor\n )()\n // Avoid try/catch if we aren't going to create\n if (!opts.create) {\n return await p.load(path)\n }\n try {\n return await p.load(path)\n } catch (err: unknown) {\n if (\n !(err as Error).message.startsWith('Could not read package.json')\n ) {\n throw err\n }\n return p.create(path)\n }\n }\n\n static override async normalize(path: string, opts: NormalizeOptions) {\n const p = new (\n _EditablePackageJsonClass as EditablePackageJsonConstructor\n )()\n await p.load(path)\n return await p.normalize(opts)\n }\n\n static override async prepare(path: string, opts: unknown) {\n const p = new (\n _EditablePackageJsonClass as EditablePackageJsonConstructor\n )()\n await p.load(path, true)\n return await p.prepare(opts)\n }\n\n override create(path: string) {\n super.create(path)\n ;(this as unknown as { _path: string })._path = path\n return this\n }\n\n override async fix(opts: unknown = {}) {\n await super.fix(opts)\n return this\n }\n\n override fromContent(data: unknown) {\n super.fromContent(data)\n ;(this as unknown as { _canSave: boolean })._canSave = false\n return this\n }\n\n override fromJSON(data: string): this {\n super.fromJSON(data)\n return this\n }\n\n override async load(path: string, create?: boolean): Promise<this> {\n this._path = path\n const { promises: fsPromises } = getFs()\n let parseErr: unknown\n try {\n this._readFileContent = await read(this.filename)\n } catch (err) {\n if (!create) {\n throw err\n }\n parseErr = err\n }\n if (parseErr) {\n const nodePath = getPath()\n const indexFile = nodePath.resolve(this.path || '', 'index.js')\n let indexFileContent: string\n try {\n indexFileContent = await fsPromises.readFile(indexFile, 'utf8')\n } catch {\n throw parseErr\n }\n try {\n this.fromContent(indexFileContent)\n } catch {\n throw parseErr\n }\n // This wasn't a package.json so prevent saving\n this._canSave = false\n return this\n }\n this.fromJSON(this._readFileContent)\n // Add AFTER fromJSON is called in case it errors.\n this._readFileJson = parse(this._readFileContent)\n return this\n }\n\n override async normalize(opts: NormalizeOptions = {}): Promise<this> {\n await super.normalize(opts)\n return this\n }\n\n get path() {\n return this._path\n }\n\n override async prepare(opts: unknown = {}): Promise<this> {\n await super.prepare(opts)\n return this\n }\n\n override async save(options?: SaveOptions): Promise<boolean> {\n if (!this._canSave || this.content === undefined) {\n throw new Error('No package.json to save to')\n }\n const { ignoreWhitespace = false, sort = false } = {\n __proto__: null,\n ...options,\n } as SaveOptions\n const {\n [identSymbol]: indent,\n [newlineSymbol]: newline,\n ...rest\n } = this.content as Record<string | symbol, unknown>\n const content = sort ? packageSort(rest) : rest\n const {\n [identSymbol]: _indent,\n [newlineSymbol]: _newline,\n ...origContent\n } = (this._readFileJson || {}) as Record<string | symbol, unknown>\n\n if (\n ignoreWhitespace &&\n getUtil().isDeepStrictEqual(content, origContent)\n ) {\n return false\n }\n\n const format =\n indent === undefined || indent === null\n ? ' '\n : (indent as string | number)\n const eol =\n newline === undefined || newline === null\n ? '\\n'\n : (newline as string)\n const fileContent = `${JSON.stringify(\n content,\n undefined,\n format,\n )}\\n`.replace(/\\n/g, eol)\n\n if (\n !ignoreWhitespace &&\n fileContent.trim() === this._readFileContent.trim()\n ) {\n return false\n }\n\n const { promises: fsPromises } = getFs()\n await fsPromises.writeFile(this.filename, fileContent)\n this._readFileContent = fileContent\n this._readFileJson = parse(fileContent)\n return true\n }\n\n override saveSync(options?: SaveOptions): boolean {\n if (!this._canSave || this.content === undefined) {\n throw new Error('No package.json to save to')\n }\n const { ignoreWhitespace = false, sort = false } = {\n __proto__: null,\n ...options,\n } as SaveOptions\n const {\n [Symbol.for('indent')]: indent,\n [Symbol.for('newline')]: newline,\n ...rest\n } = this.content as Record<string | symbol, unknown>\n const content = sort ? packageSort(rest) : rest\n\n if (\n ignoreWhitespace &&\n getUtil().isDeepStrictEqual(content, this._readFileJson)\n ) {\n return false\n }\n\n const format =\n indent === undefined || indent === null\n ? ' '\n : (indent as string | number)\n const eol =\n newline === undefined || newline === null\n ? '\\n'\n : (newline as string)\n const fileContent = `${JSON.stringify(\n content,\n undefined,\n format,\n )}\\n`.replace(/\\n/g, eol)\n\n if (\n !ignoreWhitespace &&\n fileContent.trim() === this._readFileContent.trim()\n ) {\n return false\n }\n\n const fs = getFs()\n fs.writeFileSync(this.filename, fileContent)\n this._readFileContent = fileContent\n this._readFileJson = parse(fileContent)\n return true\n }\n\n override update(content: PackageJson): this {\n super.update(content)\n return this\n }\n\n override willSave(options?: SaveOptions): boolean {\n const { ignoreWhitespace = false, sort = false } = {\n __proto__: null,\n ...options,\n } as SaveOptions as SaveOptions\n if (!this._canSave || this.content === undefined) {\n return false\n }\n const {\n [Symbol.for('indent')]: indent,\n [Symbol.for('newline')]: newline,\n ...rest\n } = this.content as Record<string | symbol, unknown>\n const content = sort ? packageSort(rest) : rest\n\n if (\n ignoreWhitespace &&\n getUtil().isDeepStrictEqual(content, this._readFileJson)\n ) {\n return false\n }\n\n const format =\n indent === undefined || indent === null\n ? ' '\n : (indent as string | number)\n const eol =\n newline === undefined || newline === null\n ? '\\n'\n : (newline as string)\n const fileContent = `${JSON.stringify(\n content,\n undefined,\n format,\n )}\\n`.replace(/\\n/g, eol)\n\n if (\n !ignoreWhitespace &&\n fileContent.trim() === this._readFileContent.trim()\n ) {\n return false\n }\n return true\n }\n } as EditablePackageJsonConstructor\n }\n return _EditablePackageJsonClass as EditablePackageJsonConstructor\n}\n\n/**\n * Convert a package.json object to an editable instance.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function pkgJsonToEditable(\n pkgJson: PackageJson,\n options?: EditablePackageJsonOptions,\n): unknown {\n const { normalize, ...normalizeOptions } = {\n __proto__: null,\n ...options,\n } as EditablePackageJsonOptions\n const EditablePackageJson = getEditablePackageJsonClass()\n return new EditablePackageJson().fromContent(\n normalize ? normalizePackageJson(pkgJson, normalizeOptions) : pkgJson,\n )\n}\n\n/**\n * Convert package.json to editable instance with file persistence.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function toEditablePackageJson(\n pkgJson: PackageJson,\n options?: EditablePackageJsonOptions,\n): Promise<unknown> {\n const { path: filepath, ...pkgJsonToEditableOptions } = {\n __proto__: null,\n ...options,\n }\n const { normalize, ...normalizeOptions } = pkgJsonToEditableOptions\n if (typeof filepath !== 'string') {\n return pkgJsonToEditable(pkgJson, pkgJsonToEditableOptions)\n }\n const EditablePackageJson = getEditablePackageJsonClass()\n const pkgJsonPath = resolvePackageJsonDirname(filepath)\n return (\n await EditablePackageJson.load(pkgJsonPath, { create: true })\n ).fromJSON(\n `${JSON.stringify(\n normalize\n ? normalizePackageJson(pkgJson, {\n ...(isNodeModules(pkgJsonPath) ? {} : { preserve: ['repository'] }),\n ...normalizeOptions,\n })\n : pkgJson,\n null,\n 2,\n )}\\n`,\n )\n}\n\n/**\n * Convert package.json to editable instance with file persistence synchronously.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function toEditablePackageJsonSync(\n pkgJson: PackageJson,\n options?: EditablePackageJsonOptions,\n): unknown {\n const { path: filepath, ...pkgJsonToEditableOptions } = {\n __proto__: null,\n ...options,\n }\n const { normalize, ...normalizeOptions } = pkgJsonToEditableOptions\n if (typeof filepath !== 'string') {\n return pkgJsonToEditable(pkgJson, pkgJsonToEditableOptions)\n }\n const EditablePackageJson = getEditablePackageJsonClass()\n const pkgJsonPath = resolvePackageJsonDirname(filepath)\n return new EditablePackageJson().create(pkgJsonPath).fromJSON(\n `${JSON.stringify(\n normalize\n ? normalizePackageJson(pkgJson, {\n ...(isNodeModules(pkgJsonPath) ? {} : { preserve: ['repository'] }),\n ...normalizeOptions,\n })\n : pkgJson,\n null,\n 2,\n )}\\n`,\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAA8B;AAC9B,uBAAqC;AACrC,mBAA0C;AAE1C,MAAM,cAAc,OAAO,IAAI,QAAQ;AACvC,MAAM,gBAAgB,OAAO,IAAI,SAAS;AA0G1C,IAAI;AAEJ,IAAI;AAAA;AAEJ,SAAS,QAAQ;AACf,MAAI,QAAQ,QAAW;AAGrB,UAAoB,QAAQ,SAAS;AAAA,EACvC;AACA,SAAO;AACT;AAEA,IAAI;AAAA;AAMJ,SAAS,UAAU;AACjB,MAAI,UAAU,QAAW;AAGvB,YAAsB,QAAQ,WAAW;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,IAAI;AAAA;AAEJ,SAAS,UAAU;AACjB,MAAI,UAAU,QAAW;AAGvB,YAAsB,QAAQ,WAAW;AAAA,EAC3C;AACA,SAAO;AACT;AAAA;AAMO,SAAS,8BAA8D;AAC5E,MAAI,8BAA8B,QAAW;AAC3C,UAAM,0BACU,QAAQ,kCAAkC;AAC1D,UAAM,EAAE,OAAO,KAAK,IACJ,QAAQ,mDAAmD;AAC3E,UAAM,EAAE,YAAY,IACJ,QAAQ,2CAA2C;AACnE,gCACE,MAAM,4BAA6B,wBAA2D;AAAA,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c,wCAA0B,QAAQ;AACtD,UACE,MAAM,oBAAoB,KAAK,aAAa,EAAE,QAAQ,KAAK,CAAC,GAC5D;AAAA,IACA,GAAG,KAAK;AAAA,MACN,gBACI,uCAAqB,SAAS;AAAA,QAC5B,OAAI,2BAAc,WAAW,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,EAAE;AAAA,QACjE,GAAG;AAAA,MACL,CAAC,IACD;AAAA,MACJ;AAAA,MACA;AAAA,IACF,CAAC;AAAA;AAAA,EACH;AACF;AAAA;AAMO,SAAS,0BACd,SACA,SACS;AACT,QAAM,EAAE,MAAM,UAAU,GAAG,yBAAyB,IAAI;AAAA,IACtD,WAAW;AAAA,IACX,GAAG;AAAA,EACL;AACA,QAAM,EAAE,WAAW,GAAG,iBAAiB,IAAI;AAC3C,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO,kCAAkB,SAAS,wBAAwB;AAAA,EAC5D;AACA,QAAM,sBAAsB,4CAA4B;AACxD,QAAM,kBAAc,wCAA0B,QAAQ;AACtD,SAAO,IAAI,oBAAoB,EAAE,OAAO,WAAW,EAAE;AAAA,IACnD,GAAG,KAAK;AAAA,MACN,gBACI,uCAAqB,SAAS;AAAA,QAC5B,OAAI,2BAAc,WAAW,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,EAAE;AAAA,QACjE,GAAG;AAAA,MACL,CAAC,IACD;AAAA,MACJ;AAAA,MACA;AAAA,IACF,CAAC;AAAA;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/packages/exports.js
CHANGED
|
@@ -1,3 +1,164 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var exports_exports = {};
|
|
20
|
+
__export(exports_exports, {
|
|
21
|
+
findTypesForSubpath: () => findTypesForSubpath,
|
|
22
|
+
getExportFilePaths: () => getExportFilePaths,
|
|
23
|
+
getSubpaths: () => getSubpaths,
|
|
24
|
+
isConditionalExports: () => isConditionalExports,
|
|
25
|
+
isSubpathExports: () => isSubpathExports,
|
|
26
|
+
resolvePackageJsonEntryExports: () => resolvePackageJsonEntryExports
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(exports_exports);
|
|
29
|
+
var import_core = require("#constants/core");
|
|
30
|
+
var import_arrays = require("../arrays");
|
|
31
|
+
var import_objects = require("../objects");
|
|
32
|
+
// @__NO_SIDE_EFFECTS__
|
|
33
|
+
function findTypesForSubpath(entryExports, subpath) {
|
|
34
|
+
const queue = [entryExports];
|
|
35
|
+
let pos = 0;
|
|
36
|
+
while (pos < queue.length) {
|
|
37
|
+
if (pos === import_core.LOOP_SENTINEL) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"Detected infinite loop in entry exports crawl of getTypesForSubpath"
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const value = queue[pos++];
|
|
43
|
+
if ((0, import_arrays.isArray)(value)) {
|
|
44
|
+
for (let i = 0, { length } = value; i < length; i += 1) {
|
|
45
|
+
const item = value[i];
|
|
46
|
+
if (item === subpath) {
|
|
47
|
+
return value.types;
|
|
48
|
+
}
|
|
49
|
+
if ((0, import_objects.isObject)(item)) {
|
|
50
|
+
queue.push(item);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} else if ((0, import_objects.isObject)(value)) {
|
|
54
|
+
const keys = Object.getOwnPropertyNames(value);
|
|
55
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
56
|
+
const key = keys[i];
|
|
57
|
+
const item = value[key];
|
|
58
|
+
if (item === subpath) {
|
|
59
|
+
return value.types;
|
|
60
|
+
}
|
|
61
|
+
if ((0, import_objects.isObject)(item)) {
|
|
62
|
+
queue.push(item);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
// @__NO_SIDE_EFFECTS__
|
|
70
|
+
function getSubpaths(entryExports) {
|
|
71
|
+
if (!(0, import_objects.isObject)(entryExports)) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
return Object.getOwnPropertyNames(entryExports).filter(
|
|
75
|
+
(key) => key.startsWith(".")
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
// @__NO_SIDE_EFFECTS__
|
|
79
|
+
function getExportFilePaths(entryExports) {
|
|
80
|
+
if (!(0, import_objects.isObject)(entryExports)) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const paths = [];
|
|
84
|
+
for (const key of Object.getOwnPropertyNames(entryExports)) {
|
|
85
|
+
if (!key.startsWith(".")) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const value = entryExports[key];
|
|
89
|
+
if (typeof value === "string") {
|
|
90
|
+
paths.push(value);
|
|
91
|
+
} else if ((0, import_objects.isObject)(value)) {
|
|
92
|
+
for (const subKey of Object.getOwnPropertyNames(value)) {
|
|
93
|
+
const subValue = value[subKey];
|
|
94
|
+
if (typeof subValue === "string") {
|
|
95
|
+
paths.push(subValue);
|
|
96
|
+
} else if ((0, import_arrays.isArray)(subValue)) {
|
|
97
|
+
for (const item of subValue) {
|
|
98
|
+
if (typeof item === "string") {
|
|
99
|
+
paths.push(item);
|
|
100
|
+
} else if ((0, import_objects.isObject)(item)) {
|
|
101
|
+
for (const nestedKey of Object.getOwnPropertyNames(item)) {
|
|
102
|
+
const nestedValue = item[nestedKey];
|
|
103
|
+
if (typeof nestedValue === "string") {
|
|
104
|
+
paths.push(nestedValue);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return [...new Set(paths)].filter((p) => p.startsWith("./"));
|
|
114
|
+
}
|
|
115
|
+
// @__NO_SIDE_EFFECTS__
|
|
116
|
+
function isConditionalExports(entryExports) {
|
|
117
|
+
if (!(0, import_objects.isObjectObject)(entryExports)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
const keys = Object.getOwnPropertyNames(entryExports);
|
|
121
|
+
const { length } = keys;
|
|
122
|
+
if (!length) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
for (let i = 0; i < length; i += 1) {
|
|
126
|
+
const key = keys[i];
|
|
127
|
+
if (key.length > 0 && key.charCodeAt(0) === 46) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
// @__NO_SIDE_EFFECTS__
|
|
134
|
+
function isSubpathExports(entryExports) {
|
|
135
|
+
if ((0, import_objects.isObjectObject)(entryExports)) {
|
|
136
|
+
const keys = Object.getOwnPropertyNames(entryExports);
|
|
137
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
138
|
+
if (keys[i]?.charCodeAt(0) === 46) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
// @__NO_SIDE_EFFECTS__
|
|
146
|
+
function resolvePackageJsonEntryExports(entryExports) {
|
|
147
|
+
if (typeof entryExports === "string" || (0, import_arrays.isArray)(entryExports)) {
|
|
148
|
+
return { ".": entryExports };
|
|
149
|
+
}
|
|
150
|
+
if (/* @__PURE__ */ isConditionalExports(entryExports)) {
|
|
151
|
+
return entryExports;
|
|
152
|
+
}
|
|
153
|
+
return (0, import_objects.isObject)(entryExports) ? entryExports : void 0;
|
|
154
|
+
}
|
|
155
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
+
0 && (module.exports = {
|
|
157
|
+
findTypesForSubpath,
|
|
158
|
+
getExportFilePaths,
|
|
159
|
+
getSubpaths,
|
|
160
|
+
isConditionalExports,
|
|
161
|
+
isSubpathExports,
|
|
162
|
+
resolvePackageJsonEntryExports
|
|
163
|
+
});
|
|
3
164
|
//# sourceMappingURL=exports.js.map
|