obsidian-dev-utils 87.1.1 → 87.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 87.1.2
4
+
5
+ - feat(demo-vault-helper): create the invocable scripts folder on bootstrap
6
+ - chore: update libs
7
+ - feat(community-plugins): add installConfigureEnableCommunityPlugin
8
+
3
9
  ## 87.1.1
4
10
 
5
11
  - fix: load original-fs via window.require so demo-vault asar extraction works
@@ -1,8 +1,17 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
14
+ };
6
15
  var __export = (target, all) => {
7
16
  for (var name in all)
8
17
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,8 +24,423 @@ var __copyProps = (to, from, except, desc) => {
15
24
  }
16
25
  return to;
17
26
  };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
+ mod
34
+ ));
18
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
36
 
37
+ // node_modules/path-browserify/index.js
38
+ var require_path_browserify = __commonJS({
39
+ "node_modules/path-browserify/index.js"(exports2, module2) {
40
+ "use strict";
41
+ function assertPath(path) {
42
+ if (typeof path !== "string") {
43
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
44
+ }
45
+ }
46
+ function normalizeStringPosix(path, allowAboveRoot) {
47
+ var res = "";
48
+ var lastSegmentLength = 0;
49
+ var lastSlash = -1;
50
+ var dots = 0;
51
+ var code;
52
+ for (var i = 0; i <= path.length; ++i) {
53
+ if (i < path.length)
54
+ code = path.charCodeAt(i);
55
+ else if (code === 47)
56
+ break;
57
+ else
58
+ code = 47;
59
+ if (code === 47) {
60
+ if (lastSlash === i - 1 || dots === 1) {
61
+ } else if (lastSlash !== i - 1 && dots === 2) {
62
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
63
+ if (res.length > 2) {
64
+ var lastSlashIndex = res.lastIndexOf("/");
65
+ if (lastSlashIndex !== res.length - 1) {
66
+ if (lastSlashIndex === -1) {
67
+ res = "";
68
+ lastSegmentLength = 0;
69
+ } else {
70
+ res = res.slice(0, lastSlashIndex);
71
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
72
+ }
73
+ lastSlash = i;
74
+ dots = 0;
75
+ continue;
76
+ }
77
+ } else if (res.length === 2 || res.length === 1) {
78
+ res = "";
79
+ lastSegmentLength = 0;
80
+ lastSlash = i;
81
+ dots = 0;
82
+ continue;
83
+ }
84
+ }
85
+ if (allowAboveRoot) {
86
+ if (res.length > 0)
87
+ res += "/..";
88
+ else
89
+ res = "..";
90
+ lastSegmentLength = 2;
91
+ }
92
+ } else {
93
+ if (res.length > 0)
94
+ res += "/" + path.slice(lastSlash + 1, i);
95
+ else
96
+ res = path.slice(lastSlash + 1, i);
97
+ lastSegmentLength = i - lastSlash - 1;
98
+ }
99
+ lastSlash = i;
100
+ dots = 0;
101
+ } else if (code === 46 && dots !== -1) {
102
+ ++dots;
103
+ } else {
104
+ dots = -1;
105
+ }
106
+ }
107
+ return res;
108
+ }
109
+ function _format(sep2, pathObject) {
110
+ var dir = pathObject.dir || pathObject.root;
111
+ var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
112
+ if (!dir) {
113
+ return base;
114
+ }
115
+ if (dir === pathObject.root) {
116
+ return dir + base;
117
+ }
118
+ return dir + sep2 + base;
119
+ }
120
+ var posix2 = {
121
+ // path.resolve([from ...], to)
122
+ resolve: function resolve() {
123
+ var resolvedPath = "";
124
+ var resolvedAbsolute = false;
125
+ var cwd;
126
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
127
+ var path;
128
+ if (i >= 0)
129
+ path = arguments[i];
130
+ else {
131
+ if (cwd === void 0)
132
+ cwd = process.cwd();
133
+ path = cwd;
134
+ }
135
+ assertPath(path);
136
+ if (path.length === 0) {
137
+ continue;
138
+ }
139
+ resolvedPath = path + "/" + resolvedPath;
140
+ resolvedAbsolute = path.charCodeAt(0) === 47;
141
+ }
142
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
143
+ if (resolvedAbsolute) {
144
+ if (resolvedPath.length > 0)
145
+ return "/" + resolvedPath;
146
+ else
147
+ return "/";
148
+ } else if (resolvedPath.length > 0) {
149
+ return resolvedPath;
150
+ } else {
151
+ return ".";
152
+ }
153
+ },
154
+ normalize: function normalize(path) {
155
+ assertPath(path);
156
+ if (path.length === 0) return ".";
157
+ var isAbsolute = path.charCodeAt(0) === 47;
158
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47;
159
+ path = normalizeStringPosix(path, !isAbsolute);
160
+ if (path.length === 0 && !isAbsolute) path = ".";
161
+ if (path.length > 0 && trailingSeparator) path += "/";
162
+ if (isAbsolute) return "/" + path;
163
+ return path;
164
+ },
165
+ isAbsolute: function isAbsolute(path) {
166
+ assertPath(path);
167
+ return path.length > 0 && path.charCodeAt(0) === 47;
168
+ },
169
+ join: function join2() {
170
+ if (arguments.length === 0)
171
+ return ".";
172
+ var joined;
173
+ for (var i = 0; i < arguments.length; ++i) {
174
+ var arg = arguments[i];
175
+ assertPath(arg);
176
+ if (arg.length > 0) {
177
+ if (joined === void 0)
178
+ joined = arg;
179
+ else
180
+ joined += "/" + arg;
181
+ }
182
+ }
183
+ if (joined === void 0)
184
+ return ".";
185
+ return posix2.normalize(joined);
186
+ },
187
+ relative: function relative2(from, to) {
188
+ assertPath(from);
189
+ assertPath(to);
190
+ if (from === to) return "";
191
+ from = posix2.resolve(from);
192
+ to = posix2.resolve(to);
193
+ if (from === to) return "";
194
+ var fromStart = 1;
195
+ for (; fromStart < from.length; ++fromStart) {
196
+ if (from.charCodeAt(fromStart) !== 47)
197
+ break;
198
+ }
199
+ var fromEnd = from.length;
200
+ var fromLen = fromEnd - fromStart;
201
+ var toStart = 1;
202
+ for (; toStart < to.length; ++toStart) {
203
+ if (to.charCodeAt(toStart) !== 47)
204
+ break;
205
+ }
206
+ var toEnd = to.length;
207
+ var toLen = toEnd - toStart;
208
+ var length = fromLen < toLen ? fromLen : toLen;
209
+ var lastCommonSep = -1;
210
+ var i = 0;
211
+ for (; i <= length; ++i) {
212
+ if (i === length) {
213
+ if (toLen > length) {
214
+ if (to.charCodeAt(toStart + i) === 47) {
215
+ return to.slice(toStart + i + 1);
216
+ } else if (i === 0) {
217
+ return to.slice(toStart + i);
218
+ }
219
+ } else if (fromLen > length) {
220
+ if (from.charCodeAt(fromStart + i) === 47) {
221
+ lastCommonSep = i;
222
+ } else if (i === 0) {
223
+ lastCommonSep = 0;
224
+ }
225
+ }
226
+ break;
227
+ }
228
+ var fromCode = from.charCodeAt(fromStart + i);
229
+ var toCode = to.charCodeAt(toStart + i);
230
+ if (fromCode !== toCode)
231
+ break;
232
+ else if (fromCode === 47)
233
+ lastCommonSep = i;
234
+ }
235
+ var out = "";
236
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
237
+ if (i === fromEnd || from.charCodeAt(i) === 47) {
238
+ if (out.length === 0)
239
+ out += "..";
240
+ else
241
+ out += "/..";
242
+ }
243
+ }
244
+ if (out.length > 0)
245
+ return out + to.slice(toStart + lastCommonSep);
246
+ else {
247
+ toStart += lastCommonSep;
248
+ if (to.charCodeAt(toStart) === 47)
249
+ ++toStart;
250
+ return to.slice(toStart);
251
+ }
252
+ },
253
+ _makeLong: function _makeLong(path) {
254
+ return path;
255
+ },
256
+ dirname: function dirname2(path) {
257
+ assertPath(path);
258
+ if (path.length === 0) return ".";
259
+ var code = path.charCodeAt(0);
260
+ var hasRoot = code === 47;
261
+ var end = -1;
262
+ var matchedSlash = true;
263
+ for (var i = path.length - 1; i >= 1; --i) {
264
+ code = path.charCodeAt(i);
265
+ if (code === 47) {
266
+ if (!matchedSlash) {
267
+ end = i;
268
+ break;
269
+ }
270
+ } else {
271
+ matchedSlash = false;
272
+ }
273
+ }
274
+ if (end === -1) return hasRoot ? "/" : ".";
275
+ if (hasRoot && end === 1) return "//";
276
+ return path.slice(0, end);
277
+ },
278
+ basename: function basename2(path, ext) {
279
+ if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
280
+ assertPath(path);
281
+ var start = 0;
282
+ var end = -1;
283
+ var matchedSlash = true;
284
+ var i;
285
+ if (ext !== void 0 && ext.length > 0 && ext.length <= path.length) {
286
+ if (ext.length === path.length && ext === path) return "";
287
+ var extIdx = ext.length - 1;
288
+ var firstNonSlashEnd = -1;
289
+ for (i = path.length - 1; i >= 0; --i) {
290
+ var code = path.charCodeAt(i);
291
+ if (code === 47) {
292
+ if (!matchedSlash) {
293
+ start = i + 1;
294
+ break;
295
+ }
296
+ } else {
297
+ if (firstNonSlashEnd === -1) {
298
+ matchedSlash = false;
299
+ firstNonSlashEnd = i + 1;
300
+ }
301
+ if (extIdx >= 0) {
302
+ if (code === ext.charCodeAt(extIdx)) {
303
+ if (--extIdx === -1) {
304
+ end = i;
305
+ }
306
+ } else {
307
+ extIdx = -1;
308
+ end = firstNonSlashEnd;
309
+ }
310
+ }
311
+ }
312
+ }
313
+ if (start === end) end = firstNonSlashEnd;
314
+ else if (end === -1) end = path.length;
315
+ return path.slice(start, end);
316
+ } else {
317
+ for (i = path.length - 1; i >= 0; --i) {
318
+ if (path.charCodeAt(i) === 47) {
319
+ if (!matchedSlash) {
320
+ start = i + 1;
321
+ break;
322
+ }
323
+ } else if (end === -1) {
324
+ matchedSlash = false;
325
+ end = i + 1;
326
+ }
327
+ }
328
+ if (end === -1) return "";
329
+ return path.slice(start, end);
330
+ }
331
+ },
332
+ extname: function extname2(path) {
333
+ assertPath(path);
334
+ var startDot = -1;
335
+ var startPart = 0;
336
+ var end = -1;
337
+ var matchedSlash = true;
338
+ var preDotState = 0;
339
+ for (var i = path.length - 1; i >= 0; --i) {
340
+ var code = path.charCodeAt(i);
341
+ if (code === 47) {
342
+ if (!matchedSlash) {
343
+ startPart = i + 1;
344
+ break;
345
+ }
346
+ continue;
347
+ }
348
+ if (end === -1) {
349
+ matchedSlash = false;
350
+ end = i + 1;
351
+ }
352
+ if (code === 46) {
353
+ if (startDot === -1)
354
+ startDot = i;
355
+ else if (preDotState !== 1)
356
+ preDotState = 1;
357
+ } else if (startDot !== -1) {
358
+ preDotState = -1;
359
+ }
360
+ }
361
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
362
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
363
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
364
+ return "";
365
+ }
366
+ return path.slice(startDot, end);
367
+ },
368
+ format: function format2(pathObject) {
369
+ if (pathObject === null || typeof pathObject !== "object") {
370
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
371
+ }
372
+ return _format("/", pathObject);
373
+ },
374
+ parse: function parse2(path) {
375
+ assertPath(path);
376
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
377
+ if (path.length === 0) return ret;
378
+ var code = path.charCodeAt(0);
379
+ var isAbsolute = code === 47;
380
+ var start;
381
+ if (isAbsolute) {
382
+ ret.root = "/";
383
+ start = 1;
384
+ } else {
385
+ start = 0;
386
+ }
387
+ var startDot = -1;
388
+ var startPart = 0;
389
+ var end = -1;
390
+ var matchedSlash = true;
391
+ var i = path.length - 1;
392
+ var preDotState = 0;
393
+ for (; i >= start; --i) {
394
+ code = path.charCodeAt(i);
395
+ if (code === 47) {
396
+ if (!matchedSlash) {
397
+ startPart = i + 1;
398
+ break;
399
+ }
400
+ continue;
401
+ }
402
+ if (end === -1) {
403
+ matchedSlash = false;
404
+ end = i + 1;
405
+ }
406
+ if (code === 46) {
407
+ if (startDot === -1) startDot = i;
408
+ else if (preDotState !== 1) preDotState = 1;
409
+ } else if (startDot !== -1) {
410
+ preDotState = -1;
411
+ }
412
+ }
413
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
414
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
415
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
416
+ if (end !== -1) {
417
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);
418
+ else ret.base = ret.name = path.slice(startPart, end);
419
+ }
420
+ } else {
421
+ if (startPart === 0 && isAbsolute) {
422
+ ret.name = path.slice(1, startDot);
423
+ ret.base = path.slice(1, end);
424
+ } else {
425
+ ret.name = path.slice(startPart, startDot);
426
+ ret.base = path.slice(startPart, end);
427
+ }
428
+ ret.ext = path.slice(startDot, end);
429
+ }
430
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);
431
+ else if (isAbsolute) ret.dir = "/";
432
+ return ret;
433
+ },
434
+ sep: "/",
435
+ delimiter: ":",
436
+ win32: null,
437
+ posix: null
438
+ };
439
+ posix2.posix = posix2;
440
+ module2.exports = posix2;
441
+ }
442
+ });
443
+
20
444
  // demo-vault-helper/main.ts
21
445
  var main_exports = {};
22
446
  __export(main_exports, {
@@ -25,14 +449,49 @@ __export(main_exports, {
25
449
  module.exports = __toCommonJS(main_exports);
26
450
  var import_obsidian2 = require("obsidian");
27
451
 
28
- // src/obsidian/community-plugins.ts
29
- var import_obsidian = require("obsidian");
452
+ // src/path.ts
453
+ var import_path_browserify = __toESM(require_path_browserify(), 1);
30
454
 
31
455
  // src/function.ts
32
456
  function noop() {
33
457
  }
34
458
  var noopAsyncSingletonPromise = Promise.resolve();
35
459
 
460
+ // src/abort-controller.ts
461
+ var INFINITE_TIMEOUT = Number.POSITIVE_INFINITY;
462
+
463
+ // src/string.ts
464
+ var ESCAPE_MAP = {
465
+ "\n": "\\n",
466
+ "\r": "\\r",
467
+ " ": "\\t",
468
+ "\b": "\\b",
469
+ "\f": "\\f",
470
+ "'": "\\'",
471
+ '"': '\\"',
472
+ "\\": "\\\\"
473
+ };
474
+ var UNESCAPE_MAP = {};
475
+ for (const [key, value] of Object.entries(ESCAPE_MAP)) {
476
+ UNESCAPE_MAP[value] = key;
477
+ }
478
+
479
+ // src/path.ts
480
+ var posix = import_path_browserify.default.posix;
481
+ var delimiter = posix.delimiter;
482
+ var sep = import_path_browserify.default.posix.sep;
483
+ var basename = posix.basename;
484
+ var dirname = posix.dirname;
485
+ var extname = posix.extname;
486
+ var format = posix.format;
487
+ var join = posix.join;
488
+ var normalizePath = posix.normalize;
489
+ var parse = posix.parse;
490
+ var relative = posix.relative;
491
+
492
+ // src/obsidian/community-plugins.ts
493
+ var import_obsidian = require("obsidian");
494
+
36
495
  // src/value-wrapper.ts
37
496
  var ValueWrapper = class _ValueWrapper {
38
497
  /**
@@ -206,6 +665,7 @@ async function bootstrapDemoVault(params) {
206
665
  pluginId: CODE_SCRIPT_TOOLKIT_PLUGIN_ID,
207
666
  settings: CODE_SCRIPT_TOOLKIT_SETTINGS
208
667
  });
668
+ await ensureInvocableScriptsFolder(app);
209
669
  if (!app.plugins.enabledPlugins.has(CODE_SCRIPT_TOOLKIT_PLUGIN_ID)) {
210
670
  await enableCommunityPlugin({ app, pluginId: CODE_SCRIPT_TOOLKIT_PLUGIN_ID });
211
671
  } else if (didSettingsChange) {
@@ -213,6 +673,12 @@ async function bootstrapDemoVault(params) {
213
673
  await enableCommunityPlugin({ app, pluginId: CODE_SCRIPT_TOOLKIT_PLUGIN_ID });
214
674
  }
215
675
  }
676
+ async function ensureInvocableScriptsFolder(app) {
677
+ const invocableScriptsFolderPath = join(CODE_SCRIPT_TOOLKIT_MODULES_ROOT, CODE_SCRIPT_TOOLKIT_SETTINGS.invocableScriptsFolder);
678
+ if (!await app.vault.adapter.exists(invocableScriptsFolderPath)) {
679
+ await app.vault.adapter.mkdir(invocableScriptsFolderPath);
680
+ }
681
+ }
216
682
 
217
683
  // demo-vault-helper/main.ts
218
684
  var DemoVaultHelperPlugin = class extends import_obsidian2.Plugin {