ember-scoped-css 3.2.0 → 3.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.
- package/README.md +12 -5
- package/dist/cjs/all-DurjGbDW.cjs +1711 -0
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/dist/runtime/test-support.js +5 -0
- package/dist/runtime/test-support.js.map +1 -1
- package/package.json +1 -1
- package/src/build/babel-plugin.js +1 -5
- package/src/build/babel-plugin.test.ts +113 -0
- package/src/build/template-plugin.js +36 -32
- package/src/lib/css/rewrite.js +9 -0
- package/src/lib/css/rewrite.test.ts +35 -1
- package/src/lib/renameClass.js +5 -0
- package/src/lib/rewriteHbs.classes.concat.test.ts +156 -0
- package/src/lib/rewriteHbs.classes.test.ts +28 -0
- package/src/lib/rewriteHbs.if.test.ts +168 -0
- package/src/lib/rewriteHbs.js +277 -38
- package/src/lib/rewriteHbs.scopedClass.test.ts +19 -0
- package/src/lib/rewriteHbs.unless.test.ts +63 -0
- package/src/template-lint/plugin.js +74 -6
- package/dist/cjs/all-DJjr6YEx.cjs +0 -1534
package/dist/cjs/all.cjs
CHANGED
package/dist/cjs/babel.cjs
CHANGED
package/dist/cjs/rollup.cjs
CHANGED
package/dist/cjs/vite.cjs
CHANGED
|
@@ -383,6 +383,11 @@ function splitClassList(classList) {
|
|
|
383
383
|
return classList.split(/\s+/).filter(Boolean);
|
|
384
384
|
}
|
|
385
385
|
/**
|
|
386
|
+
* Postfixes every class in `className`, which may be a space-separated list.
|
|
387
|
+
*
|
|
388
|
+
* `classesInCss` is consulted one class at a time, so it has to be keyed on
|
|
389
|
+
* individual class names — a Set built from a whole space-separated list
|
|
390
|
+
* matches nothing. Omit it to postfix every class unconditionally.
|
|
386
391
|
*
|
|
387
392
|
* @param {string} className
|
|
388
393
|
* @param {string} postfix
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-support.js","names":["hash"],"sources":["../../src/lib/path/md5.js","../../src/lib/path/hash-from-module-path.js","../../src/lib/renameClass.js","../../src/runtime/test-support.ts"],"sourcesContent":["/*\n * JavaScript MD5\n * https://github.com/blueimp/JavaScript-MD5\n *\n * Copyright 2011, Sebastian Tschan\n * https://blueimp.net\n *\n * Licensed under the MIT license:\n * https://opensource.org/licenses/MIT\n *\n * Based on\n * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message\n * Digest Algorithm, as defined in RFC 1321.\n * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for more info.\n *\n * Modifications:\n * - removed IIFE, exported md5 (this file is now ESM)\n */\n\n/**\n * Add integers, wrapping at 2^32.\n * This uses 16-bit operations internally to work around bugs in interpreters.\n *\n * @param {number} x First integer\n * @param {number} y Second integer\n * @returns {number} Sum\n */\nfunction safeAdd(x, y) {\n var lsw = (x & 0xffff) + (y & 0xffff);\n var msw = (x >> 16) + (y >> 16) + (lsw >> 16);\n\n return (msw << 16) | (lsw & 0xffff);\n}\n\n/**\n * Bitwise rotate a 32-bit number to the left.\n *\n * @param {number} num 32-bit number\n * @param {number} cnt Rotation count\n * @returns {number} Rotated number\n */\nfunction bitRotateLeft(num, cnt) {\n return (num << cnt) | (num >>> (32 - cnt));\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} q q\n * @param {number} a a\n * @param {number} b b\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5cmn(q, a, b, x, s, t) {\n return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5ff(a, b, c, d, x, s, t) {\n return md5cmn((b & c) | (~b & d), a, b, x, s, t);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5gg(a, b, c, d, x, s, t) {\n return md5cmn((b & d) | (c & ~d), a, b, x, s, t);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5hh(a, b, c, d, x, s, t) {\n return md5cmn(b ^ c ^ d, a, b, x, s, t);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5ii(a, b, c, d, x, s, t) {\n return md5cmn(c ^ (b | ~d), a, b, x, s, t);\n}\n\n/**\n * Calculate the MD5 of an array of little-endian words, and a bit length.\n *\n * @param {Array} x Array of little-endian words\n * @param {number} len Bit length\n * @returns {Array<number>} MD5 Array\n */\nfunction binlMD5(x, len) {\n /* append padding */\n x[len >> 5] |= 0x80 << len % 32;\n x[(((len + 64) >>> 9) << 4) + 14] = len;\n\n var i;\n var olda;\n var oldb;\n var oldc;\n var oldd;\n var a = 1732584193;\n var b = -271733879;\n var c = -1732584194;\n var d = 271733878;\n\n for (i = 0; i < x.length; i += 16) {\n olda = a;\n oldb = b;\n oldc = c;\n oldd = d;\n\n a = md5ff(a, b, c, d, x[i], 7, -680876936);\n d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);\n c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);\n b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);\n a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);\n d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);\n c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);\n b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);\n a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);\n d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);\n c = md5ff(c, d, a, b, x[i + 10], 17, -42063);\n b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);\n a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);\n d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);\n c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);\n b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);\n\n a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);\n d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);\n c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);\n b = md5gg(b, c, d, a, x[i], 20, -373897302);\n a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);\n d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);\n c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);\n b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);\n a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);\n d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);\n c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);\n b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);\n a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);\n d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);\n c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);\n b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);\n\n a = md5hh(a, b, c, d, x[i + 5], 4, -378558);\n d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);\n c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);\n b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);\n a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);\n d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);\n c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);\n b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);\n a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);\n d = md5hh(d, a, b, c, x[i], 11, -358537222);\n c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);\n b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);\n a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);\n d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);\n c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);\n b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);\n\n a = md5ii(a, b, c, d, x[i], 6, -198630844);\n d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);\n c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);\n b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);\n a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);\n d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);\n c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);\n b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);\n a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);\n d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);\n c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);\n b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);\n a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);\n d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);\n c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);\n b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);\n\n a = safeAdd(a, olda);\n b = safeAdd(b, oldb);\n c = safeAdd(c, oldc);\n d = safeAdd(d, oldd);\n }\n\n return [a, b, c, d];\n}\n\n/**\n * Convert an array of little-endian words to a string\n *\n * @param {Array<number>} input MD5 Array\n * @returns {string} MD5 string\n */\nfunction binl2rstr(input) {\n var i;\n var output = '';\n var length32 = input.length * 32;\n\n for (i = 0; i < length32; i += 8) {\n output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);\n }\n\n return output;\n}\n\n/**\n * Convert a raw string to an array of little-endian words\n * Characters >255 have their high-byte silently ignored.\n *\n * @param {string} input Raw input string\n * @returns {Array<number>} Array of little-endian words\n */\nfunction rstr2binl(input) {\n var i;\n var output = [];\n output[(input.length >> 2) - 1] = undefined;\n\n for (i = 0; i < output.length; i += 1) {\n output[i] = 0;\n }\n\n var length8 = input.length * 8;\n\n for (i = 0; i < length8; i += 8) {\n output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;\n }\n\n return output;\n}\n\n/**\n * Calculate the MD5 of a raw string\n *\n * @param {string} s Input string\n * @returns {string} Raw MD5 string\n */\nfunction rstrMD5(s) {\n return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));\n}\n\n/**\n * Calculates the HMAC-MD5 of a key and some data (raw strings)\n *\n * @param {string} key HMAC key\n * @param {string} data Raw input string\n * @returns {string} Raw MD5 string\n */\nfunction rstrHMACMD5(key, data) {\n var i;\n var bkey = rstr2binl(key);\n var ipad = [];\n var opad = [];\n var hash;\n ipad[15] = opad[15] = undefined;\n\n if (bkey.length > 16) {\n bkey = binlMD5(bkey, key.length * 8);\n }\n\n for (i = 0; i < 16; i += 1) {\n ipad[i] = bkey[i] ^ 0x36363636;\n opad[i] = bkey[i] ^ 0x5c5c5c5c;\n }\n\n hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);\n\n return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));\n}\n\n/**\n * Convert a raw string to a hex string\n *\n * @param {string} input Raw input string\n * @returns {string} Hex encoded string\n */\nfunction rstr2hex(input) {\n var hexTab = '0123456789abcdef';\n var output = '';\n var x;\n var i;\n\n for (i = 0; i < input.length; i += 1) {\n x = input.charCodeAt(i);\n output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);\n }\n\n return output;\n}\n\n/**\n * Encode a string as UTF-8\n *\n * @param {string} input Input string\n * @returns {string} UTF8 string\n */\nfunction str2rstrUTF8(input) {\n return unescape(encodeURIComponent(input));\n}\n\n/**\n * Encodes input string as raw MD5 string\n *\n * @param {string} s Input string\n * @returns {string} Raw MD5 string\n */\nfunction rawMD5(s) {\n return rstrMD5(str2rstrUTF8(s));\n}\n\n/**\n * Encodes input string as Hex encoded string\n *\n * @param {string} s Input string\n * @returns {string} Hex encoded string\n */\nfunction hexMD5(s) {\n return rstr2hex(rawMD5(s));\n}\n\n/**\n * Calculates the raw HMAC-MD5 for the given key and data\n *\n * @param {string} k HMAC key\n * @param {string} d Input string\n * @returns {string} Raw MD5 string\n */\nfunction rawHMACMD5(k, d) {\n return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));\n}\n\n/**\n * Calculates the Hex encoded HMAC-MD5 for the given key and data\n *\n * @param {string} k HMAC key\n * @param {string} d Input string\n * @returns {string} Raw MD5 string\n */\nfunction hexHMACMD5(k, d) {\n return rstr2hex(rawHMACMD5(k, d));\n}\n\n/**\n * Calculates MD5 value for a given string.\n * If a key is provided, calculates the HMAC-MD5 value.\n * Returns a Hex encoded string unless the raw argument is given.\n *\n * @param {string} string Input string\n * @param {string} [key] HMAC key\n * @param {boolean} [raw] Raw output switch\n * @returns {string} MD5 output\n */\nexport function md5(string, key, raw) {\n if (!key) {\n if (!raw) {\n return hexMD5(string);\n }\n\n return rawMD5(string);\n }\n\n if (!raw) {\n return hexHMACMD5(key, string);\n }\n\n return rawHMACMD5(key, string);\n}\n","import { md5 } from './md5.js';\n\n/**\n * The intent of this function is to generate the suffix/postfix for the\n * css classes, based on the module-scoped path name.\n *\n * for example,\n * hash('my-app/components/foo')\n * instead of\n * hash('app/components/foo')\n *\n * (unless your app name is 'app')\n *\n * @param {string} modulePath\n * @returns {string}\n */\nexport function hash(modulePath) {\n return 'e' + md5(modulePath).substring(0, 8);\n}\n\nif (import.meta.vitest) {\n const { it, expect } = import.meta.vitest;\n\n it('should return a string', function () {\n const postfix = hash('foo.css');\n\n expect(postfix).to.be.a('string');\n });\n\n it('should return a string starting with \"e\"', function () {\n const postfix = hash('foo.css');\n\n expect(postfix).to.match(/^e/);\n });\n\n it('should return a string of length 9', function () {\n const postfix = hash('foo.css');\n\n expect(postfix).to.have.lengthOf(9);\n });\n}\n\nexport const hashFromModulePath = hash;\n","/**\n * Splits a space-separated class list (the value of a `class` attribute or of\n * a `[class=\"...\"]` selector) into its individual class names.\n *\n * @param {string} classList\n * @returns {string[]}\n */\nexport function splitClassList(classList) {\n return classList.split(/\\s+/).filter(Boolean);\n}\n\n/**\n *\n * @param {string} className\n * @param {string} postfix\n * @param {Set<string>} [classesInCss]\n * @returns\n */\nexport function renameClass(className, postfix, classesInCss) {\n const renamedClasses = splitClassList(className)\n .map((c) => {\n if (!classesInCss || classesInCss.has(c)) {\n if (c.endsWith(postfix)) return c;\n\n return c + '_' + postfix;\n }\n\n return c;\n })\n .join(' ');\n\n const renamedWithPreservedSpaces = className.replace(\n className.trimStart().trimEnd(),\n renamedClasses,\n );\n\n return renamedWithPreservedSpaces;\n}\n","import { hash } from '../lib/path/hash-from-module-path.js';\nimport { renameClass } from '../lib/renameClass.js';\n\n/**\n * On element selectors where there are no classes,\n * you may pass only the modulePath and get the hash for the element.\n *\n * For example, in app code,\n * with template code `<h3>x</h3>`\n * and css `h3 { }`\n * a class will be added during the build, result in:\n * the template: `<h3 class=\"some-hash\">x</h3>`\n * and css `h3.some-hash { }`\n *\n * @example\n * If a file is located at `app/components/foo/bar.hbs`\n * The associated css should be at `app/components/foo/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/components/foo/bar`\n *\n * @example\n * If a file is located at `app/templates/bar.hbs`\n * The associated css should be at `app/templates/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/templates/bar`\n *\n * @example\n * If a file is located at `<podModulePrefix>/bar/template.hbs`\n * The associated css should be at `app/<podModulePrefix sub path>/bar/styles.css`\n * and the path passed to `scopedClass` should be `<podModulePrefix>/bar`\n *\n */\nexport function scopedClass(modulePath: string): string;\n\n/**\n * Retrieve the built hash for a class.\n *\n * For example, in app code,\n * with template code `<h3 class=\"foo\">x</h3>`\n * and css `.foo { }`\n * a hash will be added during the build, resulting in:\n * the template: `<h3 class=\"foo_some-hash\">x</h3>`\n * and css `.foo_some-hash { }`\n *\n * @example\n * If a file is located at `app/components/foo/bar.hbs`\n * The associated css should be at `app/components/foo/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/components/foo/bar`\n *\n * @example\n * If a file is located at `app/templates/bar.hbs`\n * The associated css should be at `app/templates/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/templates/bar`\n *\n * @example\n * If a file is located at `<podModulePrefix>/bar/template.hbs`\n * The associated css should be at `app/<podModulePrefix sub path>/bar/styles.css`\n * and the path passed to `scopedClass` should be `<podModulePrefix>/bar`\n *\n */\nexport function scopedClass(className: string, modulePath: string): string;\n\nexport function scopedClass(\n ...args: [modulepath: string] | [className: string, modulePath: string]\n) {\n if (args.length === 1) {\n return hash(args[0]);\n }\n\n let [className, modulePath] = args;\n\n const postfix = hash(modulePath);\n\n return renameClass(className, postfix);\n}\n"],"mappings":";;;;;;;;;AA8BA,SAAS,QAAQ,GAAG,GAAG;CACrB,IAAI,OAAO,IAAI,UAAW,IAAI;AAG9B,SAFW,KAAK,OAAO,KAAK,OAAO,OAAO,OAE3B,KAAO,MAAM;;;;;;;;;AAU9B,SAAS,cAAc,KAAK,KAAK;AAC/B,QAAQ,OAAO,MAAQ,QAAS,KAAK;;;;;;;;;;;;;AAcvC,SAAS,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;AAChC,QAAO,QAAQ,cAAc,QAAQ,QAAQ,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;;;;;;;;;;;;;;AAe5E,SAA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/B,eACD;;;;;AC0BH,SAAgB,YACd,GAAG,MACH;AACA,KAAI,KAAK,WAAW,EAClB,QAAO,KAAK,KAAK,GAAG;CAGtB,IAAI,CAAC,WAAW,cAAc;AAI9B,QAAO,YAAY,WAFH,KAAK,WAAW,CAEM"}
|
|
1
|
+
{"version":3,"file":"test-support.js","names":["hash"],"sources":["../../src/lib/path/md5.js","../../src/lib/path/hash-from-module-path.js","../../src/lib/renameClass.js","../../src/runtime/test-support.ts"],"sourcesContent":["/*\n * JavaScript MD5\n * https://github.com/blueimp/JavaScript-MD5\n *\n * Copyright 2011, Sebastian Tschan\n * https://blueimp.net\n *\n * Licensed under the MIT license:\n * https://opensource.org/licenses/MIT\n *\n * Based on\n * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message\n * Digest Algorithm, as defined in RFC 1321.\n * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for more info.\n *\n * Modifications:\n * - removed IIFE, exported md5 (this file is now ESM)\n */\n\n/**\n * Add integers, wrapping at 2^32.\n * This uses 16-bit operations internally to work around bugs in interpreters.\n *\n * @param {number} x First integer\n * @param {number} y Second integer\n * @returns {number} Sum\n */\nfunction safeAdd(x, y) {\n var lsw = (x & 0xffff) + (y & 0xffff);\n var msw = (x >> 16) + (y >> 16) + (lsw >> 16);\n\n return (msw << 16) | (lsw & 0xffff);\n}\n\n/**\n * Bitwise rotate a 32-bit number to the left.\n *\n * @param {number} num 32-bit number\n * @param {number} cnt Rotation count\n * @returns {number} Rotated number\n */\nfunction bitRotateLeft(num, cnt) {\n return (num << cnt) | (num >>> (32 - cnt));\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} q q\n * @param {number} a a\n * @param {number} b b\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5cmn(q, a, b, x, s, t) {\n return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5ff(a, b, c, d, x, s, t) {\n return md5cmn((b & c) | (~b & d), a, b, x, s, t);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5gg(a, b, c, d, x, s, t) {\n return md5cmn((b & d) | (c & ~d), a, b, x, s, t);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5hh(a, b, c, d, x, s, t) {\n return md5cmn(b ^ c ^ d, a, b, x, s, t);\n}\n\n/**\n * Basic operation the algorithm uses.\n *\n * @param {number} a a\n * @param {number} b b\n * @param {number} c c\n * @param {number} d d\n * @param {number} x x\n * @param {number} s s\n * @param {number} t t\n * @returns {number} Result\n */\nfunction md5ii(a, b, c, d, x, s, t) {\n return md5cmn(c ^ (b | ~d), a, b, x, s, t);\n}\n\n/**\n * Calculate the MD5 of an array of little-endian words, and a bit length.\n *\n * @param {Array} x Array of little-endian words\n * @param {number} len Bit length\n * @returns {Array<number>} MD5 Array\n */\nfunction binlMD5(x, len) {\n /* append padding */\n x[len >> 5] |= 0x80 << len % 32;\n x[(((len + 64) >>> 9) << 4) + 14] = len;\n\n var i;\n var olda;\n var oldb;\n var oldc;\n var oldd;\n var a = 1732584193;\n var b = -271733879;\n var c = -1732584194;\n var d = 271733878;\n\n for (i = 0; i < x.length; i += 16) {\n olda = a;\n oldb = b;\n oldc = c;\n oldd = d;\n\n a = md5ff(a, b, c, d, x[i], 7, -680876936);\n d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);\n c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);\n b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);\n a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);\n d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);\n c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);\n b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);\n a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);\n d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);\n c = md5ff(c, d, a, b, x[i + 10], 17, -42063);\n b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);\n a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);\n d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);\n c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);\n b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);\n\n a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);\n d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);\n c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);\n b = md5gg(b, c, d, a, x[i], 20, -373897302);\n a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);\n d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);\n c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);\n b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);\n a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);\n d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);\n c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);\n b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);\n a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);\n d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);\n c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);\n b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);\n\n a = md5hh(a, b, c, d, x[i + 5], 4, -378558);\n d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);\n c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);\n b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);\n a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);\n d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);\n c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);\n b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);\n a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);\n d = md5hh(d, a, b, c, x[i], 11, -358537222);\n c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);\n b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);\n a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);\n d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);\n c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);\n b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);\n\n a = md5ii(a, b, c, d, x[i], 6, -198630844);\n d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);\n c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);\n b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);\n a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);\n d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);\n c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);\n b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);\n a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);\n d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);\n c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);\n b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);\n a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);\n d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);\n c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);\n b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);\n\n a = safeAdd(a, olda);\n b = safeAdd(b, oldb);\n c = safeAdd(c, oldc);\n d = safeAdd(d, oldd);\n }\n\n return [a, b, c, d];\n}\n\n/**\n * Convert an array of little-endian words to a string\n *\n * @param {Array<number>} input MD5 Array\n * @returns {string} MD5 string\n */\nfunction binl2rstr(input) {\n var i;\n var output = '';\n var length32 = input.length * 32;\n\n for (i = 0; i < length32; i += 8) {\n output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);\n }\n\n return output;\n}\n\n/**\n * Convert a raw string to an array of little-endian words\n * Characters >255 have their high-byte silently ignored.\n *\n * @param {string} input Raw input string\n * @returns {Array<number>} Array of little-endian words\n */\nfunction rstr2binl(input) {\n var i;\n var output = [];\n output[(input.length >> 2) - 1] = undefined;\n\n for (i = 0; i < output.length; i += 1) {\n output[i] = 0;\n }\n\n var length8 = input.length * 8;\n\n for (i = 0; i < length8; i += 8) {\n output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;\n }\n\n return output;\n}\n\n/**\n * Calculate the MD5 of a raw string\n *\n * @param {string} s Input string\n * @returns {string} Raw MD5 string\n */\nfunction rstrMD5(s) {\n return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));\n}\n\n/**\n * Calculates the HMAC-MD5 of a key and some data (raw strings)\n *\n * @param {string} key HMAC key\n * @param {string} data Raw input string\n * @returns {string} Raw MD5 string\n */\nfunction rstrHMACMD5(key, data) {\n var i;\n var bkey = rstr2binl(key);\n var ipad = [];\n var opad = [];\n var hash;\n ipad[15] = opad[15] = undefined;\n\n if (bkey.length > 16) {\n bkey = binlMD5(bkey, key.length * 8);\n }\n\n for (i = 0; i < 16; i += 1) {\n ipad[i] = bkey[i] ^ 0x36363636;\n opad[i] = bkey[i] ^ 0x5c5c5c5c;\n }\n\n hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);\n\n return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));\n}\n\n/**\n * Convert a raw string to a hex string\n *\n * @param {string} input Raw input string\n * @returns {string} Hex encoded string\n */\nfunction rstr2hex(input) {\n var hexTab = '0123456789abcdef';\n var output = '';\n var x;\n var i;\n\n for (i = 0; i < input.length; i += 1) {\n x = input.charCodeAt(i);\n output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);\n }\n\n return output;\n}\n\n/**\n * Encode a string as UTF-8\n *\n * @param {string} input Input string\n * @returns {string} UTF8 string\n */\nfunction str2rstrUTF8(input) {\n return unescape(encodeURIComponent(input));\n}\n\n/**\n * Encodes input string as raw MD5 string\n *\n * @param {string} s Input string\n * @returns {string} Raw MD5 string\n */\nfunction rawMD5(s) {\n return rstrMD5(str2rstrUTF8(s));\n}\n\n/**\n * Encodes input string as Hex encoded string\n *\n * @param {string} s Input string\n * @returns {string} Hex encoded string\n */\nfunction hexMD5(s) {\n return rstr2hex(rawMD5(s));\n}\n\n/**\n * Calculates the raw HMAC-MD5 for the given key and data\n *\n * @param {string} k HMAC key\n * @param {string} d Input string\n * @returns {string} Raw MD5 string\n */\nfunction rawHMACMD5(k, d) {\n return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));\n}\n\n/**\n * Calculates the Hex encoded HMAC-MD5 for the given key and data\n *\n * @param {string} k HMAC key\n * @param {string} d Input string\n * @returns {string} Raw MD5 string\n */\nfunction hexHMACMD5(k, d) {\n return rstr2hex(rawHMACMD5(k, d));\n}\n\n/**\n * Calculates MD5 value for a given string.\n * If a key is provided, calculates the HMAC-MD5 value.\n * Returns a Hex encoded string unless the raw argument is given.\n *\n * @param {string} string Input string\n * @param {string} [key] HMAC key\n * @param {boolean} [raw] Raw output switch\n * @returns {string} MD5 output\n */\nexport function md5(string, key, raw) {\n if (!key) {\n if (!raw) {\n return hexMD5(string);\n }\n\n return rawMD5(string);\n }\n\n if (!raw) {\n return hexHMACMD5(key, string);\n }\n\n return rawHMACMD5(key, string);\n}\n","import { md5 } from './md5.js';\n\n/**\n * The intent of this function is to generate the suffix/postfix for the\n * css classes, based on the module-scoped path name.\n *\n * for example,\n * hash('my-app/components/foo')\n * instead of\n * hash('app/components/foo')\n *\n * (unless your app name is 'app')\n *\n * @param {string} modulePath\n * @returns {string}\n */\nexport function hash(modulePath) {\n return 'e' + md5(modulePath).substring(0, 8);\n}\n\nif (import.meta.vitest) {\n const { it, expect } = import.meta.vitest;\n\n it('should return a string', function () {\n const postfix = hash('foo.css');\n\n expect(postfix).to.be.a('string');\n });\n\n it('should return a string starting with \"e\"', function () {\n const postfix = hash('foo.css');\n\n expect(postfix).to.match(/^e/);\n });\n\n it('should return a string of length 9', function () {\n const postfix = hash('foo.css');\n\n expect(postfix).to.have.lengthOf(9);\n });\n}\n\nexport const hashFromModulePath = hash;\n","/**\n * Splits a space-separated class list (the value of a `class` attribute or of\n * a `[class=\"...\"]` selector) into its individual class names.\n *\n * @param {string} classList\n * @returns {string[]}\n */\nexport function splitClassList(classList) {\n return classList.split(/\\s+/).filter(Boolean);\n}\n\n/**\n * Postfixes every class in `className`, which may be a space-separated list.\n *\n * `classesInCss` is consulted one class at a time, so it has to be keyed on\n * individual class names — a Set built from a whole space-separated list\n * matches nothing. Omit it to postfix every class unconditionally.\n *\n * @param {string} className\n * @param {string} postfix\n * @param {Set<string>} [classesInCss]\n * @returns\n */\nexport function renameClass(className, postfix, classesInCss) {\n const renamedClasses = splitClassList(className)\n .map((c) => {\n if (!classesInCss || classesInCss.has(c)) {\n if (c.endsWith(postfix)) return c;\n\n return c + '_' + postfix;\n }\n\n return c;\n })\n .join(' ');\n\n const renamedWithPreservedSpaces = className.replace(\n className.trimStart().trimEnd(),\n renamedClasses,\n );\n\n return renamedWithPreservedSpaces;\n}\n","import { hash } from '../lib/path/hash-from-module-path.js';\nimport { renameClass } from '../lib/renameClass.js';\n\n/**\n * On element selectors where there are no classes,\n * you may pass only the modulePath and get the hash for the element.\n *\n * For example, in app code,\n * with template code `<h3>x</h3>`\n * and css `h3 { }`\n * a class will be added during the build, result in:\n * the template: `<h3 class=\"some-hash\">x</h3>`\n * and css `h3.some-hash { }`\n *\n * @example\n * If a file is located at `app/components/foo/bar.hbs`\n * The associated css should be at `app/components/foo/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/components/foo/bar`\n *\n * @example\n * If a file is located at `app/templates/bar.hbs`\n * The associated css should be at `app/templates/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/templates/bar`\n *\n * @example\n * If a file is located at `<podModulePrefix>/bar/template.hbs`\n * The associated css should be at `app/<podModulePrefix sub path>/bar/styles.css`\n * and the path passed to `scopedClass` should be `<podModulePrefix>/bar`\n *\n */\nexport function scopedClass(modulePath: string): string;\n\n/**\n * Retrieve the built hash for a class.\n *\n * For example, in app code,\n * with template code `<h3 class=\"foo\">x</h3>`\n * and css `.foo { }`\n * a hash will be added during the build, resulting in:\n * the template: `<h3 class=\"foo_some-hash\">x</h3>`\n * and css `.foo_some-hash { }`\n *\n * @example\n * If a file is located at `app/components/foo/bar.hbs`\n * The associated css should be at `app/components/foo/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/components/foo/bar`\n *\n * @example\n * If a file is located at `app/templates/bar.hbs`\n * The associated css should be at `app/templates/bar.css`\n * and the path passed to `scopedClass` should be `<modulePrefix>/templates/bar`\n *\n * @example\n * If a file is located at `<podModulePrefix>/bar/template.hbs`\n * The associated css should be at `app/<podModulePrefix sub path>/bar/styles.css`\n * and the path passed to `scopedClass` should be `<podModulePrefix>/bar`\n *\n */\nexport function scopedClass(className: string, modulePath: string): string;\n\nexport function scopedClass(\n ...args: [modulepath: string] | [className: string, modulePath: string]\n) {\n if (args.length === 1) {\n return hash(args[0]);\n }\n\n let [className, modulePath] = args;\n\n const postfix = hash(modulePath);\n\n return renameClass(className, postfix);\n}\n"],"mappings":";;;;;;;;;AA8BA,SAAS,QAAQ,GAAG,GAAG;CACrB,IAAI,OAAO,IAAI,UAAW,IAAI;AAG9B,SAFW,KAAK,OAAO,KAAK,OAAO,OAAO,OAE3B,KA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AAe/C,SAAgB,YAAY,WAAW,SAAS,cAAc;CAC5D,MAAM,iBAAiB,eAAe,UAAU,CAC7C,KAAK,MAAM;AACV,MAAI,CAAC,gBAAgB,aAAa,IAAI,EAAE,EAAE;AACxC,OAAI,EAAE,SAAS,QAAQ,CAAE,QAAO;AAEhC,UAAO,IAAI,MAAM;;AAGnB,SAAO;GACP,CACD,KAAK,IAAI;AAOZ,QALmC,UAAU,QAC3C,UAAU,WAAW,CAAC,SAAS,EAC/B,eACD;;;;;ACqBH,SAAgB,YACd,GAAG,MACH;AACA,KAAI,KAAK,WAAW,EAClB,QAAO,KAAK,KAAK,GAAG;CAGtB,IAAI,CAAC,WAAW,cAAc;AAI9B,QAAO,YAAY,WAFH,KAAK,WAAW,CAEM"}
|
package/package.json
CHANGED
|
@@ -90,11 +90,7 @@ export const scopedCSS = (config) => (env, options, workingDirectory) => {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
const original = path.node.arguments[0].value;
|
|
93
|
-
const renamed = renameClass(
|
|
94
|
-
original,
|
|
95
|
-
state.postfix,
|
|
96
|
-
new Set([original]),
|
|
97
|
-
);
|
|
93
|
+
const renamed = renameClass(original, state.postfix);
|
|
98
94
|
const transformedString = env.types.stringLiteral(renamed);
|
|
99
95
|
|
|
100
96
|
path.replaceWith(transformedString);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import * as babel from '@babel/core';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { hash } from '../lib/path/hash-from-module-path.js';
|
|
7
|
+
import { paths } from '../lib/path/utils.paths.test.js';
|
|
8
|
+
import { scopedCSS } from './babel-plugin.js';
|
|
9
|
+
|
|
10
|
+
const modulePath = 'vite-app/components/scoped-class-helper';
|
|
11
|
+
const postfix = hash(modulePath);
|
|
12
|
+
const filename = path.join(
|
|
13
|
+
paths.viteApp,
|
|
14
|
+
'src/components/scoped-class-helper.js',
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
async function transform(code: string) {
|
|
18
|
+
const result = await babel.transformAsync(code, {
|
|
19
|
+
plugins: [[scopedCSS({}), {}]],
|
|
20
|
+
filename,
|
|
21
|
+
cwd: paths.viteApp,
|
|
22
|
+
root: paths.viteApp,
|
|
23
|
+
babelrc: false,
|
|
24
|
+
configFile: false,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return result?.code;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The value the `scopedClass(...)` call is replaced with. */
|
|
31
|
+
async function scopedClassOf(argument: string) {
|
|
32
|
+
const code = await transform(
|
|
33
|
+
[
|
|
34
|
+
`import { scopedClass } from 'ember-scoped-css';`,
|
|
35
|
+
`export const result = scopedClass(${argument});`,
|
|
36
|
+
].join('\n'),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const match = code?.match(/export const result = "(.*)";/);
|
|
40
|
+
|
|
41
|
+
return match?.[1];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe('scopedClass()', () => {
|
|
45
|
+
it('postfixes a single class', async () => {
|
|
46
|
+
expect(await scopedClassOf(`'bar-complete'`)).to.equal(
|
|
47
|
+
`bar-complete_${postfix}`,
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('postfixes every class of a multi-class argument', async () => {
|
|
52
|
+
expect(await scopedClassOf(`'column column-hidden'`)).to.equal(
|
|
53
|
+
`column_${postfix} column-hidden_${postfix}`,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('postfixes every class regardless of how they are spaced', async () => {
|
|
58
|
+
// Leading and trailing whitespace survives; whitespace between classes
|
|
59
|
+
// collapses to a single space.
|
|
60
|
+
expect(await scopedClassOf(`' column column-hidden '`)).to.equal(
|
|
61
|
+
` column_${postfix} column-hidden_${postfix} `,
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('agrees with the test-support helper, which the app asserts against', async () => {
|
|
66
|
+
const { scopedClass } = await import('../runtime/test-support.js');
|
|
67
|
+
|
|
68
|
+
expect(await scopedClassOf(`'column column-hidden'`)).to.equal(
|
|
69
|
+
scopedClass('column column-hidden', modulePath),
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('does not postfix a class twice', async () => {
|
|
74
|
+
expect(await scopedClassOf(`'bar-complete_${postfix}'`)).to.equal(
|
|
75
|
+
`bar-complete_${postfix}`,
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('removes the import', async () => {
|
|
80
|
+
const code = await transform(
|
|
81
|
+
[
|
|
82
|
+
`import { scopedClass } from 'ember-scoped-css';`,
|
|
83
|
+
`export const result = scopedClass('bar-complete');`,
|
|
84
|
+
].join('\n'),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(code).to.not.include('ember-scoped-css');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('rejects arguments it cannot resolve at build time', () => {
|
|
91
|
+
it('throws on a dynamic argument', async () => {
|
|
92
|
+
await expect(
|
|
93
|
+
transform(
|
|
94
|
+
[
|
|
95
|
+
`import { scopedClass } from 'ember-scoped-css';`,
|
|
96
|
+
`export const result = scopedClass(someVariable);`,
|
|
97
|
+
].join('\n'),
|
|
98
|
+
),
|
|
99
|
+
).rejects.toThrow(/only accepts a single, non-dynamic, string literal/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('throws on more than one argument', async () => {
|
|
103
|
+
await expect(
|
|
104
|
+
transform(
|
|
105
|
+
[
|
|
106
|
+
`import { scopedClass } from 'ember-scoped-css';`,
|
|
107
|
+
`export const result = scopedClass('column', 'column-hidden');`,
|
|
108
|
+
].join('\n'),
|
|
109
|
+
),
|
|
110
|
+
).rejects.toThrow(/only accepts a single, non-dynamic, string literal/);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -171,43 +171,47 @@ export function createPlugin(config) {
|
|
|
171
171
|
AttrNode(...args) {
|
|
172
172
|
return visitors.AttrNode(...args);
|
|
173
173
|
},
|
|
174
|
-
ElementNode
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
174
|
+
ElementNode: {
|
|
175
|
+
enter(node, walker) {
|
|
176
|
+
visitors.ElementNode.enter(node, walker);
|
|
177
|
+
|
|
178
|
+
if (hasScopedAttribute(node)) {
|
|
179
|
+
if (walker.parent?.node.type !== 'Template') {
|
|
180
|
+
throw new Error(
|
|
181
|
+
'<style scoped> tags must be at the root of the template, they cannot be nested',
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (hasInlineAttributeWithoutLang(node)) {
|
|
186
|
+
let text = textContent(node);
|
|
187
|
+
let scopedText = rewriteCss(
|
|
188
|
+
text,
|
|
189
|
+
postfix,
|
|
190
|
+
localCssPath,
|
|
191
|
+
config.layerName,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Traverse this and allow interpolation
|
|
196
|
+
*/
|
|
197
|
+
node.children = [env.syntax.builders.text(scopedText)];
|
|
198
|
+
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Returning null removes the node
|
|
203
|
+
return null;
|
|
183
204
|
}
|
|
184
205
|
|
|
185
206
|
if (hasInlineAttributeWithoutLang(node)) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
text,
|
|
189
|
-
postfix,
|
|
190
|
-
localCssPath,
|
|
191
|
-
config.layerName,
|
|
207
|
+
throw new Error(
|
|
208
|
+
`<style inline> is not valid. Please add the scoped attribute: <style scoped inline>`,
|
|
192
209
|
);
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Traverse this and allow interpolation
|
|
196
|
-
*/
|
|
197
|
-
node.children = [env.syntax.builders.text(scopedText)];
|
|
198
|
-
|
|
199
|
-
return;
|
|
200
210
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (hasInlineAttributeWithoutLang(node)) {
|
|
207
|
-
throw new Error(
|
|
208
|
-
`<style inline> is not valid. Please add the scoped attribute: <style scoped inline>`,
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
+
},
|
|
212
|
+
exit(...args) {
|
|
213
|
+
return visitors.ElementNode.exit(...args);
|
|
214
|
+
},
|
|
211
215
|
},
|
|
212
216
|
MustacheStatement(...args) {
|
|
213
217
|
return visitors.MustacheStatement(...args);
|
package/src/lib/css/rewrite.js
CHANGED
|
@@ -167,6 +167,14 @@ export function rewriteCss(css, postfix, fileName, layerName) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
function updateDeclarationName(node) {
|
|
171
|
+
let replacement = referenceables.property[node.prop];
|
|
172
|
+
|
|
173
|
+
if (replacement) {
|
|
174
|
+
node.prop = replacement;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
170
178
|
function updateShorthandContents(node) {
|
|
171
179
|
if (node.prop === 'animation') {
|
|
172
180
|
let parts = node.value.split(' ');
|
|
@@ -218,6 +226,7 @@ export function rewriteCss(css, postfix, fileName, layerName) {
|
|
|
218
226
|
// Step 2: postfix and update referenced referenceables
|
|
219
227
|
ast.walk((node) => {
|
|
220
228
|
if (isDeclaration(node)) {
|
|
229
|
+
updateDeclarationName(node);
|
|
221
230
|
updateDirectReferences(node);
|
|
222
231
|
updateShorthandContents(node);
|
|
223
232
|
|
|
@@ -565,7 +565,7 @@ describe('@property', () => {
|
|
|
565
565
|
border: 1px dashed black;
|
|
566
566
|
|
|
567
567
|
/* set custom property values on parent */
|
|
568
|
-
--item-
|
|
568
|
+
--item-size__postfix: 20%;
|
|
569
569
|
--item-color: orange;
|
|
570
570
|
}
|
|
571
571
|
|
|
@@ -579,6 +579,40 @@ describe('@property', () => {
|
|
|
579
579
|
"
|
|
580
580
|
`);
|
|
581
581
|
});
|
|
582
|
+
|
|
583
|
+
it('updates assignments inside keyframes', () => {
|
|
584
|
+
const css = `
|
|
585
|
+
@property --loading-angle {
|
|
586
|
+
syntax: "<angle>";
|
|
587
|
+
inherits: false;
|
|
588
|
+
initial-value: 0turn;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.button::after {
|
|
592
|
+
background: conic-gradient(from var(--loading-angle), blue, transparent);
|
|
593
|
+
animation: loading-ring 1s linear infinite;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
@keyframes loading-ring {
|
|
597
|
+
to {
|
|
598
|
+
--loading-angle: 1turn;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
`;
|
|
602
|
+
|
|
603
|
+
const postfix = 'postfix';
|
|
604
|
+
const fileName = 'foo.css';
|
|
605
|
+
const rewritten = rewriteCss(css, postfix, fileName, 'components');
|
|
606
|
+
const postfixedProperty = '--loading-angle__postfix';
|
|
607
|
+
|
|
608
|
+
expect(rewritten).toContain(`@property ${postfixedProperty}`);
|
|
609
|
+
expect(rewritten).toContain(`var(${postfixedProperty})`);
|
|
610
|
+
expect(rewritten).toContain(`${postfixedProperty}: 1turn;`);
|
|
611
|
+
expect(rewritten).toContain(
|
|
612
|
+
'animation: loading-ring__postfix 1s linear infinite;',
|
|
613
|
+
);
|
|
614
|
+
expect(rewritten).toContain('@keyframes loading-ring__postfix');
|
|
615
|
+
});
|
|
582
616
|
});
|
|
583
617
|
|
|
584
618
|
describe('@supports', () => {
|
package/src/lib/renameClass.js
CHANGED
|
@@ -10,6 +10,11 @@ export function splitClassList(classList) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
+
* Postfixes every class in `className`, which may be a space-separated list.
|
|
14
|
+
*
|
|
15
|
+
* `classesInCss` is consulted one class at a time, so it has to be keyed on
|
|
16
|
+
* individual class names — a Set built from a whole space-separated list
|
|
17
|
+
* matches nothing. Omit it to postfix every class unconditionally.
|
|
13
18
|
*
|
|
14
19
|
* @param {string} className
|
|
15
20
|
* @param {string} postfix
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import rewriteHbs from './rewriteHbs.js';
|
|
4
|
+
|
|
5
|
+
const postfix = 'pfx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `a` and `b` are in the co-located CSS; `global-thing` deliberately is not, so
|
|
9
|
+
* tests can distinguish "renamed" from "left alone for a global class".
|
|
10
|
+
*/
|
|
11
|
+
const classes = new Set(['a', 'b']);
|
|
12
|
+
|
|
13
|
+
function rewrite(hbs) {
|
|
14
|
+
return rewriteHbs(hbs, classes, new Set(), postfix);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A `concat` sitting in the class attribute's value itself -- the whole
|
|
19
|
+
* unquoted value, a quoted value, or one part of a value the attribute
|
|
20
|
+
* already has (e.g. once a scoped element's postfix class is appended) --
|
|
21
|
+
* is spliced into the native parts it's equivalent to, so the call is gone
|
|
22
|
+
* from every case here regardless of whether anything ends up renamed. A
|
|
23
|
+
* `concat` nested inside that one's own params joins in the same way, since
|
|
24
|
+
* concatenation doesn't care how its inputs were grouped. Only a `concat`
|
|
25
|
+
* nested inside an `if`/`unless` branch keeps its call, because a branch has
|
|
26
|
+
* to stay one value; see the last test.
|
|
27
|
+
*/
|
|
28
|
+
describe('concat in a class attribute', () => {
|
|
29
|
+
it('renames a lone param that is the whole class', () => {
|
|
30
|
+
expect(rewrite('<div class={{concat "a"}}></div>')).to.equal(
|
|
31
|
+
'<div class="a_pfx"></div>',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renames every param that is a whole class name', () => {
|
|
36
|
+
expect(rewrite('<div class={{concat "a" " " "b"}}></div>')).to.equal(
|
|
37
|
+
'<div class="a_pfx b_pfx"></div>',
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('leaves a param that is not in the CSS alone', () => {
|
|
42
|
+
expect(
|
|
43
|
+
rewrite('<div class={{concat "a" " " "global-thing"}}></div>'),
|
|
44
|
+
).to.equal('<div class="a_pfx global-thing"></div>');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('folds fused literal params into one class and renames it', () => {
|
|
48
|
+
// Renaming just "a" would emit a_pfx-suffix, which matches no selector
|
|
49
|
+
// the CSS rewrite produces -- concat's own job of joining "a" and
|
|
50
|
+
// "-suffix" into "a-suffix" makes this the same case as any other
|
|
51
|
+
// TextNode class value.
|
|
52
|
+
const rewriteWithSuffixClass = (hbs) =>
|
|
53
|
+
rewriteHbs(hbs, new Set(['a', 'b', 'a-suffix']), new Set(), postfix);
|
|
54
|
+
|
|
55
|
+
expect(
|
|
56
|
+
rewriteWithSuffixClass('<div class={{concat "a" "-suffix"}}></div>'),
|
|
57
|
+
).to.equal('<div class="a-suffix_pfx"></div>');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renames a literal fused with a runtime value the same as a hand-written attribute would', () => {
|
|
61
|
+
// Once concat is spliced away, "a" and this.suffix are just adjacent
|
|
62
|
+
// parts of a native attribute value -- the same shape `class="a{{this.suffix}}"`
|
|
63
|
+
// already has -- so "a" is renamed on its own, with no cross-part fusion
|
|
64
|
+
// detection. A boundary of its own still bounds it either way.
|
|
65
|
+
expect(rewrite('<div class={{concat "a" this.suffix}}></div>')).to.equal(
|
|
66
|
+
'<div class="a_pfx{{this.suffix}}"></div>',
|
|
67
|
+
);
|
|
68
|
+
expect(rewrite('<div class={{concat "a " this.suffix}}></div>')).to.equal(
|
|
69
|
+
'<div class="a_pfx {{this.suffix}}"></div>',
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('gives an arbitrary helper call among its params its own mustache', () => {
|
|
74
|
+
expect(
|
|
75
|
+
rewrite('<div class={{concat "a " (someHelper "x") " b"}}></div>'),
|
|
76
|
+
).to.equal('<div class="a_pfx {{someHelper "x"}} b_pfx"></div>');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('replaces the call with the native parts it is equivalent to', () => {
|
|
80
|
+
expect(rewrite('<div class={{concat x y z}}></div>')).to.equal(
|
|
81
|
+
'<div class="{{x}}{{y}}{{z}}"></div>',
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('gives a nested class-building helper its own mustache too', () => {
|
|
86
|
+
expect(
|
|
87
|
+
rewrite('<div class={{concat (if x y z) " " (if a b c)}}></div>'),
|
|
88
|
+
).to.equal('<div class="{{if x y z}} {{if a b c}}"></div>');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('splices into the value a scoped element has already been given', () => {
|
|
92
|
+
// A scoped tag gets its postfix class appended to the class attribute,
|
|
93
|
+
// which the concat now arrives as one part of rather than as the whole
|
|
94
|
+
// of it.
|
|
95
|
+
const rewriteScopingDiv = (hbs) =>
|
|
96
|
+
rewriteHbs(hbs, classes, new Set(['div']), postfix);
|
|
97
|
+
|
|
98
|
+
expect(
|
|
99
|
+
rewriteScopingDiv('<div class={{concat "a" " " "b"}}></div>'),
|
|
100
|
+
).to.equal('<div class="a_pfx b_pfx pfx"></div>');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('joins no params at all into an empty value', () => {
|
|
104
|
+
expect(rewrite('<div class={{concat ""}}></div>')).to.equal(
|
|
105
|
+
'<div class=""></div>',
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('renames the same params in a quoted attribute value', () => {
|
|
110
|
+
expect(rewrite(`<div class="{{concat 'a' ' ' 'b'}}"></div>`)).to.equal(
|
|
111
|
+
`<div class="a_pfx b_pfx"></div>`,
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('skips concat when it is a block param', () => {
|
|
116
|
+
expect(
|
|
117
|
+
rewrite(
|
|
118
|
+
'{{#let x as |concat|}}<div class={{concat "a" " " "b"}}></div>{{/let}}',
|
|
119
|
+
),
|
|
120
|
+
).to.equal(
|
|
121
|
+
'{{#let x as |concat|}}<div class={{concat "a" " " "b"}}></div>{{/let}}',
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("joins a nested concat's params in directly, folding fused literals", () => {
|
|
126
|
+
// concat(concat("a", " ", "b"), " b") joins to the same string as
|
|
127
|
+
// concat("a", " ", "b", " b") -- the inner call's own params flatten
|
|
128
|
+
// into the outer one rather than surviving as a nested call.
|
|
129
|
+
expect(
|
|
130
|
+
rewrite('<div class={{concat (concat "a" " " "b") " b"}}></div>'),
|
|
131
|
+
).to.equal('<div class="a_pfx b_pfx b_pfx"></div>');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("gives a class-building call among a nested concat's params its own mustache", () => {
|
|
135
|
+
expect(
|
|
136
|
+
rewrite('<div class={{concat (concat "a " (if x "a" "b")) " c"}}></div>'),
|
|
137
|
+
).to.equal('<div class="a_pfx {{if x "a_pfx" "b_pfx"}} c"></div>');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("gives an opaque helper among a nested concat's params its own mustache too", () => {
|
|
141
|
+
expect(
|
|
142
|
+
rewrite(
|
|
143
|
+
'<div class={{concat (concat "a " (someHelper "z") " b") " c"}}></div>',
|
|
144
|
+
),
|
|
145
|
+
).to.equal('<div class="a_pfx {{someHelper "z"}} b_pfx c"></div>');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('keeps a concat nested inside an if branch, renaming its whole-class-name params', () => {
|
|
149
|
+
// The branch's result has to stay one value for if to choose between, so
|
|
150
|
+
// the concat inside it survives as a call -- and gets the boundary-aware
|
|
151
|
+
// rename a concat that must stay one value needs, not the splice above.
|
|
152
|
+
expect(
|
|
153
|
+
rewrite('<div class={{if x (concat "a" " " "b") "c"}}></div>'),
|
|
154
|
+
).to.equal('<div class={{if x (concat "a_pfx" " " "b_pfx") "c"}}></div>');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import rewriteHbs from './rewriteHbs.js';
|
|
4
|
+
|
|
5
|
+
const postfix = 'pfx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `a` and `b` are in the co-located CSS; `global-thing` deliberately is not, so
|
|
9
|
+
* tests can distinguish "renamed" from "left alone for a global class".
|
|
10
|
+
*/
|
|
11
|
+
const classes = new Set(['a', 'b']);
|
|
12
|
+
|
|
13
|
+
function rewrite(hbs) {
|
|
14
|
+
return rewriteHbs(hbs, classes, new Set(), postfix);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Cross-cutting behavior of the class-attribute dispatch that isn't specific
|
|
19
|
+
* to any one helper; see rewriteHbs.if.test.ts, rewriteHbs.scopedClass.test.ts,
|
|
20
|
+
* and rewriteHbs.classes.concat.test.ts for per-helper coverage.
|
|
21
|
+
*/
|
|
22
|
+
describe('class attribute dispatch', () => {
|
|
23
|
+
it('only touches the class attribute', () => {
|
|
24
|
+
expect(rewrite('<div data-x={{if x "a" "b"}}></div>')).to.equal(
|
|
25
|
+
'<div data-x={{if x "a" "b"}}></div>',
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
});
|