capdag 0.168.411 → 0.169.414
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/build-browser.js +6 -24
- package/package.json +1 -1
package/build-browser.js
CHANGED
|
@@ -31,14 +31,13 @@ const outDir = process.argv[2]
|
|
|
31
31
|
fs.mkdirSync(outDir, { recursive: true });
|
|
32
32
|
|
|
33
33
|
function stripCJS(src) {
|
|
34
|
-
// Strip
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
// The IIFE shim further down rebinds the names from `window.*`.
|
|
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.
|
|
39
38
|
return src
|
|
40
39
|
.replace(/^\/\/.*Import TaggedUrn.*\n/m, '')
|
|
41
|
-
.replace(/^const\s*\{
|
|
40
|
+
.replace(/^const\s*\{\s*TaggedUrn\s*\}\s*=\s*require\s*\(\s*['"]tagged-urn['"]\s*\)\s*;?\s*$/m, '')
|
|
42
41
|
.replace(/^module\.exports\s*=\s*\{[\s\S]*?\};?\s*$/m, '');
|
|
43
42
|
}
|
|
44
43
|
|
|
@@ -61,11 +60,6 @@ window.TaggedUrnBuilder = TaggedUrnBuilder;
|
|
|
61
60
|
window.UrnMatcher = UrnMatcher;
|
|
62
61
|
window.TaggedUrnError = TaggedUrnError;
|
|
63
62
|
window.TaggedUrnErrorCodes = ErrorCodes;
|
|
64
|
-
// scoreTagValue / valuesMatch are exported by the npm package and
|
|
65
|
-
// consumed by capdag.js. The browser shim depends on them being on
|
|
66
|
-
// window so the rebinder at the top of capdag.js can find them.
|
|
67
|
-
window.taggedUrnScoreTagValue = scoreTagValue;
|
|
68
|
-
window.taggedUrnValuesMatch = valuesMatch;
|
|
69
63
|
|
|
70
64
|
})();
|
|
71
65
|
`;
|
|
@@ -108,22 +102,10 @@ ${parserSrc}
|
|
|
108
102
|
(function() {
|
|
109
103
|
'use strict';
|
|
110
104
|
|
|
111
|
-
const { TaggedUrn
|
|
105
|
+
const { TaggedUrn } = window;
|
|
112
106
|
if (!TaggedUrn) {
|
|
113
107
|
throw new Error('TaggedUrn global is not defined. Load tagged-urn.js before capdag.js.');
|
|
114
108
|
}
|
|
115
|
-
if (typeof taggedUrnScoreTagValue !== 'function' || typeof taggedUrnValuesMatch !== 'function') {
|
|
116
|
-
throw new Error('tagged-urn.js browser bundle is out of date — missing taggedUrnScoreTagValue / taggedUrnValuesMatch.');
|
|
117
|
-
}
|
|
118
|
-
// The capdag.js source destructures these out of `require('tagged-urn')`
|
|
119
|
-
// as `{ valuesMatch: taggedUrnValuesMatch }` and `{ scoreTagValue }`.
|
|
120
|
-
// stripCJS removed the require lines; rebind the same names so the
|
|
121
|
-
// downstream code (e.g. `taggedUrnValuesMatch(inst, patt)` at the
|
|
122
|
-
// six-form matcher, `scoreTagValue(value)` in y-axis specificity)
|
|
123
|
-
// resolves cleanly.
|
|
124
|
-
// taggedUrnValuesMatch is already bound by the destructure above; alias
|
|
125
|
-
// scoreTagValue under its unprefixed name.
|
|
126
|
-
const scoreTagValue = taggedUrnScoreTagValue;
|
|
127
109
|
|
|
128
110
|
${inlinedParser}
|
|
129
111
|
|
package/package.json
CHANGED