@specbook/vite 0.3.0 → 0.4.0

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -20,8 +20,9 @@ var faker = new Proxy({}, {
20
20
  });
21
21
 
22
22
  // ../core/src/template.ts
23
- var WHOLE = /^\s*\{\{\s*([\w.$-]+)\s*\}\}\s*$/;
24
- var EMBED = /\{\{\s*([\w.$-]+)\s*\}\}/g;
23
+ var NAME = String.raw`[\w.$\[\]-]+`;
24
+ var WHOLE = new RegExp(String.raw`^\s*\{\{\s*(${NAME})\s*\}\}\s*$`);
25
+ var EMBED = new RegExp(String.raw`\{\{\s*(${NAME})\s*\}\}`, "g");
25
26
  var DEFERRED_NAMESPACES = ["secrets", "session"];
26
27
  var TemplateError = class extends Error {
27
28
  constructor(variable) {
@@ -46,11 +47,12 @@ function fromFaker(path) {
46
47
  }
47
48
  return { found: true, value: typeof cur === "function" ? cur.call(parent) : cur };
48
49
  }
50
+ var steps = (path) => path.replace(/\[(\d+)\]/g, ".$1").split(".");
49
51
  function lookup(scope, path) {
50
52
  if (isFakerName(path)) return fromFaker(path);
51
53
  let cur = scope;
52
- for (const part of path.split(".")) {
53
- if (cur !== null && typeof cur === "object" && part in cur) {
54
+ for (const part of steps(path)) {
55
+ if (cur !== null && typeof cur === "object" && Object.hasOwn(cur, part)) {
54
56
  cur = cur[part];
55
57
  } else {
56
58
  return { found: false };
@@ -727,7 +729,7 @@ async function writeEnvKey(file, key, value) {
727
729
  import { relative as relative2, sep as sep2 } from "path";
728
730
  import fg2 from "fast-glob";
729
731
  var IGNORE = ["**/node_modules/**", "**/.generated/**", "**/dist/**", "**/.git/**"];
730
- var NAME = /\.example\.json$/;
732
+ var NAME2 = /\.example\.json$/;
731
733
  async function scanExamples(root, outDir, operations) {
732
734
  const examples = {};
733
735
  const assets = {};
@@ -745,7 +747,7 @@ async function scanExamples(root, outDir, operations) {
745
747
  const [svc, , id, file] = relative2(gen, abs).split(sep2);
746
748
  if (!operations.has(`${svc}/${id}`)) continue;
747
749
  add(`${svc}/${id}`, {
748
- name: file.replace(NAME, ""),
750
+ name: file.replace(NAME2, ""),
749
751
  abs,
750
752
  source: "generated",
751
753
  dir: `${svc}/${id}@generated`
@@ -759,7 +761,7 @@ async function scanExamples(root, outDir, operations) {
759
761
  const key = `${svc}/${id}`;
760
762
  if (!svc || !id || !operations.has(key)) continue;
761
763
  add(key, {
762
- name: file.replace(NAME, ""),
764
+ name: file.replace(NAME2, ""),
763
765
  abs,
764
766
  source: "project",
765
767
  dir: `${svc}/${id}@project`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specbook/vite",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "The Specbook plugin for Vite: the registry, the docs UI hooks and the dev server credential proxy.",
5
5
  "keywords": [
6
6
  "specbook",
@@ -34,8 +34,8 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@specbook/codegen": "0.3.0",
38
- "@specbook/core": "0.3.0",
37
+ "@specbook/codegen": "0.4.0",
38
+ "@specbook/core": "0.4.0",
39
39
  "fast-glob": "3.3.2",
40
40
  "marked": "^18.1.1"
41
41
  },