capdag 0.170.416 → 0.171.419

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/build-browser.js +14 -7
  2. package/package.json +1 -1
package/build-browser.js CHANGED
@@ -31,13 +31,19 @@ const outDir = process.argv[2]
31
31
  fs.mkdirSync(outDir, { recursive: true });
32
32
 
33
33
  function stripCJS(src) {
34
- // Strip the CJS `const { TaggedUrn } = require('tagged-urn')` line and
35
- // the trailing `module.exports = {...}` block. Both are at known
36
- // positions in the source; the regex matches the full single-line
37
- // require and the multi-line module.exports object literal.
34
+ // Strip the CJS `Import TaggedUrn` comment and the trailing
35
+ // `module.exports = {...}` block, then rewrite any single-line
36
+ // `const { ... } = require('tagged-urn')` destructure into a
37
+ // destructure from `window`. The destructure may include any subset
38
+ // of names (TaggedUrn, valuesMatch, scoreTagValue, …) so long as it
39
+ // is one line; renames like `valuesMatch: taggedUrnValuesMatch` are
40
+ // preserved verbatim.
38
41
  return src
39
42
  .replace(/^\/\/.*Import TaggedUrn.*\n/m, '')
40
- .replace(/^const\s*\{\s*TaggedUrn\s*\}\s*=\s*require\s*\(\s*['"]tagged-urn['"]\s*\)\s*;?\s*$/m, '')
43
+ .replace(
44
+ /^const\s*(\{[^}]*\})\s*=\s*require\s*\(\s*['"]tagged-urn['"]\s*\)\s*;?\s*$/gm,
45
+ 'const $1 = window;'
46
+ )
41
47
  .replace(/^module\.exports\s*=\s*\{[\s\S]*?\};?\s*$/m, '');
42
48
  }
43
49
 
@@ -60,6 +66,8 @@ window.TaggedUrnBuilder = TaggedUrnBuilder;
60
66
  window.UrnMatcher = UrnMatcher;
61
67
  window.TaggedUrnError = TaggedUrnError;
62
68
  window.TaggedUrnErrorCodes = ErrorCodes;
69
+ window.valuesMatch = valuesMatch;
70
+ window.scoreTagValue = scoreTagValue;
63
71
 
64
72
  })();
65
73
  `;
@@ -102,8 +110,7 @@ ${parserSrc}
102
110
  (function() {
103
111
  'use strict';
104
112
 
105
- const { TaggedUrn } = window;
106
- if (!TaggedUrn) {
113
+ if (!window.TaggedUrn) {
107
114
  throw new Error('TaggedUrn global is not defined. Load tagged-urn.js before capdag.js.');
108
115
  }
109
116
 
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "pretest": "npm run build:parser",
41
41
  "test": "node capdag.test.js"
42
42
  },
43
- "version": "0.170.416"
43
+ "version": "0.171.419"
44
44
  }