njk-tool 0.0.1 → 0.0.3

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.
@@ -8,7 +8,10 @@ var require$$0$3 = require('path');
8
8
  var require$$2 = require('util');
9
9
  var require$$1 = require('stream');
10
10
  var require$$2$1 = require('os');
11
+ var node_path = require('node:path');
12
+ var node_url = require('node:url');
11
13
 
14
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
15
  /******************************************************************************
13
16
  Copyright (c) Microsoft Corporation.
14
17
 
@@ -13328,13 +13331,16 @@ var TagType;
13328
13331
  TagType["Table"] = "table";
13329
13332
  })(TagType || (TagType = {}));
13330
13333
 
13331
- const externalTemplatesDir = `${process.cwd()}/src`;
13334
+ const externalTemplatesDir = node_url.fileURLToPath(new URL("../bundle/src", `${(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('app.min.cjs', document.baseURI).href))}`));
13332
13335
  nunjucks.configure(externalTemplatesDir, {
13333
13336
  autoescape: true,
13334
13337
  noCache: true
13335
13338
  });
13336
- const BASE_STYLE_PATH = `${process.cwd()}/src/base.style`;
13337
- const TEMPLATES_DIR = `index.html`;
13339
+ const BASE_STYLE_PATH = node_path.join(externalTemplatesDir, "base.style");
13340
+ const TEMPLATES_DIR = node_path.join(externalTemplatesDir, "index.html");
13341
+ console.log({ externalTemplatesDir });
13342
+ console.log({ BASE_STYLE_PATH });
13343
+ console.log({ TEMPLATES_DIR });
13338
13344
  const loadStyle = (basePath) => __awaiter(void 0, void 0, void 0, function* () {
13339
13345
  try {
13340
13346
  return yield import('fs/promises').then(({ readFile }) => readFile(basePath, "utf8"));
@@ -13399,7 +13405,7 @@ const njkRenderSync = (config, options = {}) => {
13399
13405
  const processedConfig = Array.isArray(config)
13400
13406
  ? processConfig(config, cssUrl)
13401
13407
  : processConfig([config], cssUrl);
13402
- const html = nunjucks.render(templateDir, {
13408
+ const html = nunjucks.render('index.html', {
13403
13409
  ctx: processedConfig,
13404
13410
  });
13405
13411
  return getStyleContent({ isAsync: true }) + html;