sommark 4.5.0 → 4.5.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.
@@ -18,7 +18,7 @@ export function registerHostSettings(settings) {
18
18
  hostSettings = settings || {};
19
19
  }
20
20
 
21
- const version = "4.5.0";
21
+ const version = "4.5.2";
22
22
 
23
23
  const SomMark = {
24
24
  version,
package/core/modules.js CHANGED
@@ -366,6 +366,7 @@ export async function resolveModules(ast, context) {
366
366
  security: context.instance.security,
367
367
  showSpinner: context.instance.showSpinner,
368
368
  importStack: [...stack, absFilename],
369
+ moduleIdentityToken: context.instance.moduleIdentityToken,
369
370
  moduleCache: context.instance.moduleCache
370
371
  });
371
372
 
@@ -5,6 +5,7 @@ import { matchedValue } from "../helpers/utils.js";
5
5
  import { dedentBy } from "../helpers/dedent.js";
6
6
  import { preprocessRuntimeLogic } from "./helpers/preprocessor.js";
7
7
  import { wrapRuntimeLogic } from "./helpers/runtimeOutput.js";
8
+ import path from "pathe";
8
9
 
9
10
  const randomBytesHex = (size) => {
10
11
  const arr = new Uint8Array(size);
@@ -493,6 +494,14 @@ export async function transpiler(optionsOrAst, format, mapperFile) {
493
494
  settings.fs = instance.fs;
494
495
  }
495
496
 
497
+ const fileBaseDir = (() => {
498
+ const filename = instance?.filename;
499
+ const cwd = instance?.cwd || "/";
500
+ if (!filename || filename === "anonymous") return cwd;
501
+ const abs = /^(\/|[a-zA-Z]:\\|https?:\/\/)/.test(filename) ? filename : path.resolve(cwd, filename);
502
+ return path.dirname(abs);
503
+ })();
504
+
496
505
  const generateRuntimeOutput = optionsOrAst?.generateRuntimeOutput || false;
497
506
  const hideRuntimeOutput = optionsOrAst?.hideRuntimeOutput || false;
498
507
  const dualOutput = optionsOrAst?.dualOutput || false;
@@ -519,7 +528,7 @@ export async function transpiler(optionsOrAst, format, mapperFile) {
519
528
  }
520
529
 
521
530
  // Initialize Logic Sandbox
522
- await evaluator.init(null, security, settings, targetMapper);
531
+ await evaluator.init(fileBaseDir, security, settings, targetMapper);
523
532
  // Inject global data
524
533
  const placeholders = optionsOrAst?.placeholders || settings?.placeholders || {};
525
534
  const variables = optionsOrAst?.variables || settings?.variables || {};
@@ -561,7 +570,7 @@ export async function transpiler(optionsOrAst, format, mapperFile) {
561
570
  idState.idx = 0;
562
571
  prev_was_silent = false;
563
572
 
564
- await evaluator.init(null, security, settings, targetMapper);
573
+ await evaluator.init(fileBaseDir, security, settings, targetMapper);
565
574
  evaluator.inject(placeholders);
566
575
  evaluator.inject(variables);
567
576
 
@@ -9184,7 +9184,7 @@ function registerHostSettings(settings) {
9184
9184
  hostSettings = settings || {};
9185
9185
  }
9186
9186
 
9187
- const version = "4.5.0";
9187
+ const version = "4.5.2";
9188
9188
 
9189
9189
  const SomMark$1 = {
9190
9190
  version,
@@ -11024,6 +11024,14 @@ async function transpiler(optionsOrAst, format, mapperFile) {
11024
11024
  settings.fs = instance.fs;
11025
11025
  }
11026
11026
 
11027
+ const fileBaseDir = (() => {
11028
+ const filename = instance?.filename;
11029
+ const cwd = instance?.cwd || "/";
11030
+ if (!filename || filename === "anonymous") return cwd;
11031
+ const abs = /^(\/|[a-zA-Z]:\\|https?:\/\/)/.test(filename) ? filename : posix.resolve(cwd, filename);
11032
+ return posix.dirname(abs);
11033
+ })();
11034
+
11027
11035
  const generateRuntimeOutput = optionsOrAst?.generateRuntimeOutput || false;
11028
11036
  const hideRuntimeOutput = optionsOrAst?.hideRuntimeOutput || false;
11029
11037
  const dualOutput = optionsOrAst?.dualOutput || false;
@@ -11050,7 +11058,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
11050
11058
  }
11051
11059
 
11052
11060
  // Initialize Logic Sandbox
11053
- await Evaluator$1.init(null, security, settings, targetMapper);
11061
+ await Evaluator$1.init(fileBaseDir, security, settings, targetMapper);
11054
11062
  // Inject global data
11055
11063
  const placeholders = optionsOrAst?.placeholders || settings?.placeholders || {};
11056
11064
  const variables = optionsOrAst?.variables || settings?.variables || {};
@@ -11092,7 +11100,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
11092
11100
  idState.idx = 0;
11093
11101
  prev_was_silent = false;
11094
11102
 
11095
- await Evaluator$1.init(null, security, settings, targetMapper);
11103
+ await Evaluator$1.init(fileBaseDir, security, settings, targetMapper);
11096
11104
  Evaluator$1.inject(placeholders);
11097
11105
  Evaluator$1.inject(variables);
11098
11106
 
@@ -13818,6 +13826,7 @@ async function resolveModules(ast, context) {
13818
13826
  security: context.instance.security,
13819
13827
  showSpinner: context.instance.showSpinner,
13820
13828
  importStack: [...stack, absFilename],
13829
+ moduleIdentityToken: context.instance.moduleIdentityToken,
13821
13830
  moduleCache: context.instance.moduleCache
13822
13831
  });
13823
13832
 
@@ -9932,6 +9932,14 @@ async function transpiler(optionsOrAst, format, mapperFile) {
9932
9932
  settings.fs = instance.fs;
9933
9933
  }
9934
9934
 
9935
+ const fileBaseDir = (() => {
9936
+ const filename = instance?.filename;
9937
+ const cwd = instance?.cwd || "/";
9938
+ if (!filename || filename === "anonymous") return cwd;
9939
+ const abs = /^(\/|[a-zA-Z]:\\|https?:\/\/)/.test(filename) ? filename : posix.resolve(cwd, filename);
9940
+ return posix.dirname(abs);
9941
+ })();
9942
+
9935
9943
  const generateRuntimeOutput = optionsOrAst?.generateRuntimeOutput || false;
9936
9944
  const hideRuntimeOutput = optionsOrAst?.hideRuntimeOutput || false;
9937
9945
  const dualOutput = optionsOrAst?.dualOutput || false;
@@ -9958,7 +9966,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
9958
9966
  }
9959
9967
 
9960
9968
  // Initialize Logic Sandbox
9961
- await Evaluator.init(null, security, settings, targetMapper);
9969
+ await Evaluator.init(fileBaseDir, security, settings, targetMapper);
9962
9970
  // Inject global data
9963
9971
  const placeholders = optionsOrAst?.placeholders || settings?.placeholders || {};
9964
9972
  const variables = optionsOrAst?.variables || settings?.variables || {};
@@ -10000,7 +10008,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
10000
10008
  idState.idx = 0;
10001
10009
  prev_was_silent = false;
10002
10010
 
10003
- await Evaluator.init(null, security, settings, targetMapper);
10011
+ await Evaluator.init(fileBaseDir, security, settings, targetMapper);
10004
10012
  Evaluator.inject(placeholders);
10005
10013
  Evaluator.inject(variables);
10006
10014
 
@@ -12726,6 +12734,7 @@ async function resolveModules(ast, context) {
12726
12734
  security: context.instance.security,
12727
12735
  showSpinner: context.instance.showSpinner,
12728
12736
  importStack: [...stack, absFilename],
12737
+ moduleIdentityToken: context.instance.moduleIdentityToken,
12729
12738
  moduleCache: context.instance.moduleCache
12730
12739
  });
12731
12740
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sommark",
3
- "version": "4.5.0",
3
+ "version": "4.5.2",
4
4
  "description": "SomMark is a declarative, extensible markup language for structured content that can be converted to HTML, Markdown, MDX, JSON, XML, and more.",
5
5
  "main": "index.js",
6
6
  "files": [