@drawbridge/drawbridge-utils 0.0.160 → 0.0.161

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/dist/html.cjs ADDED
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // lib/html.js
20
+ var html_exports = {};
21
+ __export(html_exports, {
22
+ escapeHtml: () => escapeHtml
23
+ });
24
+ module.exports = __toCommonJS(html_exports);
25
+ var escapeHtml = (value) => String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ escapeHtml
29
+ });
@@ -0,0 +1,32 @@
1
+ // Escaping for values interpolated into HTML we generate ourselves.
2
+ //
3
+ // ITS OWN MODULE, not part of sanitize.js, because that one imports the
4
+ // ~120K-entry disposable-domain set at load — about 6MB of RSS its own comment
5
+ // flags as a footprint to watch. Every email sync renders would have paid that
6
+ // to escape five characters.
7
+ //
8
+ // Three copies of this existed before it moved here: drawbridge-api's oembed
9
+ // route, drawbridge-sync's email renderer, and drawbridge-emails' signature
10
+ // builder. They had already drifted — the signature builder escapes four
11
+ // characters and omits the apostrophe. Harmless where it sits (its output lands
12
+ // in text content and one double-quoted href, and the input is a config of our
13
+ // own staff), which is exactly why it survived: a divergence with no symptom is
14
+ // the kind that is only found by looking.
15
+
16
+ // The five characters that change meaning inside markup. `&` FIRST — escaping it
17
+ // after the others would re-escape the ampersands they just introduced and turn
18
+ // `&lt;` into `&amp;lt;`.
19
+ //
20
+ // Escapes for BOTH contexts, text and attribute, rather than asking callers
21
+ // which they are in: `"` and `'` are inert in text content and cost nothing to
22
+ // escape there, while getting it wrong in an attribute is an injection. A single
23
+ // function nobody has to think about beats two that are chosen correctly most of
24
+ // the time.
25
+ const escapeHtml = ( value ) => String( value ?? '' )
26
+ .replace( /&/g, '&amp;' )
27
+ .replace( /</g, '&lt;' )
28
+ .replace( />/g, '&gt;' )
29
+ .replace( /"/g, '&quot;' )
30
+ .replace( /'/g, '&#39;' );
31
+
32
+ export { escapeHtml };
package/dist/html.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ // Escaping for values interpolated into HTML we generate ourselves.
2
+ //
3
+ // ITS OWN MODULE, not part of sanitize.js, because that one imports the
4
+ // ~120K-entry disposable-domain set at load — about 6MB of RSS its own comment
5
+ // flags as a footprint to watch. Every email sync renders would have paid that
6
+ // to escape five characters.
7
+ //
8
+ // Three copies of this existed before it moved here: drawbridge-api's oembed
9
+ // route, drawbridge-sync's email renderer, and drawbridge-emails' signature
10
+ // builder. They had already drifted — the signature builder escapes four
11
+ // characters and omits the apostrophe. Harmless where it sits (its output lands
12
+ // in text content and one double-quoted href, and the input is a config of our
13
+ // own staff), which is exactly why it survived: a divergence with no symptom is
14
+ // the kind that is only found by looking.
15
+
16
+ // The five characters that change meaning inside markup. `&` FIRST — escaping it
17
+ // after the others would re-escape the ampersands they just introduced and turn
18
+ // `&lt;` into `&amp;lt;`.
19
+ //
20
+ // Escapes for BOTH contexts, text and attribute, rather than asking callers
21
+ // which they are in: `"` and `'` are inert in text content and cost nothing to
22
+ // escape there, while getting it wrong in an attribute is an injection. A single
23
+ // function nobody has to think about beats two that are chosen correctly most of
24
+ // the time.
25
+ const escapeHtml = ( value ) => String( value ?? '' )
26
+ .replace( /&/g, '&amp;' )
27
+ .replace( /</g, '&lt;' )
28
+ .replace( />/g, '&gt;' )
29
+ .replace( /"/g, '&quot;' )
30
+ .replace( /'/g, '&#39;' );
31
+
32
+ export { escapeHtml };
package/dist/html.js ADDED
@@ -0,0 +1,5 @@
1
+ // lib/html.js
2
+ var escapeHtml = (value) => String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3
+ export {
4
+ escapeHtml
5
+ };
package/package.json CHANGED
@@ -148,6 +148,11 @@
148
148
  "import": "./dist/twilio.js",
149
149
  "require": "./dist/twilio.cjs"
150
150
  },
151
+ "./html": {
152
+ "types": "./dist/html.d.ts",
153
+ "import": "./dist/html.js",
154
+ "require": "./dist/html.cjs"
155
+ },
151
156
  "./http": {
152
157
  "types": "./dist/http.d.ts",
153
158
  "import": "./dist/http.js",
@@ -221,5 +226,5 @@
221
226
  "prepublishOnly": ". \"$HOME/.nvm/nvm.sh\" && nvm use && tsup && node --test"
222
227
  },
223
228
  "types": "dist/index.d.ts",
224
- "version": "0.0.160"
229
+ "version": "0.0.161"
225
230
  }