ember-scoped-css 1.1.0 → 2.0.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 +203 -47
- package/dist/cjs/all-Du43cBa9.cjs +1308 -0
- package/dist/cjs/all.cjs +3 -0
- package/dist/cjs/babel.cjs +9 -0
- package/dist/cjs/rollup.cjs +8 -0
- package/dist/cjs/vite.cjs +8 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +12 -8
- package/dist/runtime/index.js.map +1 -7
- package/{declarations → dist}/runtime/test-support.d.ts +5 -2
- package/dist/runtime/test-support.d.ts.map +1 -0
- package/dist/runtime/test-support.js +357 -182
- package/dist/runtime/test-support.js.map +1 -7
- package/package.json +21 -24
- package/src/build/babel-plugin.js +4 -1
- package/src/build/public-exports/all.js +10 -0
- package/src/build/public-exports/babel.js +5 -0
- package/src/build/public-exports/rollup.js +3 -0
- package/src/build/public-exports/vite.js +3 -0
- package/src/build/scoped-css-unplugin.js +10 -33
- package/src/build/template-plugin.js +9 -19
- package/src/build/template-plugin.test.ts +108 -19
- package/src/build/unplugin-colocated.js +103 -0
- package/src/build/unplugin-inline.js +71 -0
- package/src/lib/css/rewrite.js +8 -8
- package/src/lib/css/rewrite.test.ts +69 -128
- package/src/lib/path/const.js +19 -0
- package/src/lib/path/hash-from-absolute-path.js +3 -2
- package/src/lib/path/template-transform-paths.js +3 -2
- package/src/lib/path/utils.appPath.test.ts +2 -2
- package/src/lib/path/utils.hashFrom.test.ts +2 -2
- package/src/lib/path/utils.js +63 -20
- package/src/lib/request.js +58 -33
- package/src/runtime/index.ts +1 -1
- package/declarations/build/template-plugin.d.ts +0 -7
- package/declarations/build/template-plugin.d.ts.map +0 -1
- package/declarations/build/template-plugin.test.d.ts +0 -2
- package/declarations/build/template-plugin.test.d.ts.map +0 -1
- package/declarations/lib/css/rewrite.d.ts +0 -2
- package/declarations/lib/css/rewrite.d.ts.map +0 -1
- package/declarations/lib/css/rewrite.test.d.ts +0 -2
- package/declarations/lib/css/rewrite.test.d.ts.map +0 -1
- package/declarations/lib/css/utils.d.ts +0 -29
- package/declarations/lib/css/utils.d.ts.map +0 -1
- package/declarations/lib/path/hash-from-absolute-path.d.ts +0 -3
- package/declarations/lib/path/hash-from-absolute-path.d.ts.map +0 -1
- package/declarations/lib/path/hash-from-absolute-path.test.d.ts +0 -2
- package/declarations/lib/path/hash-from-absolute-path.test.d.ts.map +0 -1
- package/declarations/lib/path/hash-from-module-path.d.ts +0 -31
- package/declarations/lib/path/hash-from-module-path.d.ts.map +0 -1
- package/declarations/lib/path/md5.d.ts +0 -12
- package/declarations/lib/path/md5.d.ts.map +0 -1
- package/declarations/lib/path/template-transform-paths.d.ts +0 -11
- package/declarations/lib/path/template-transform-paths.d.ts.map +0 -1
- package/declarations/lib/path/template-transform-paths.test.d.ts +0 -2
- package/declarations/lib/path/template-transform-paths.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.appPath.test.d.ts +0 -2
- package/declarations/lib/path/utils.appPath.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.d.ts +0 -94
- package/declarations/lib/path/utils.d.ts.map +0 -1
- package/declarations/lib/path/utils.findWorkspacePath.test.d.ts +0 -2
- package/declarations/lib/path/utils.findWorkspacePath.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.hashFrom.test.d.ts +0 -2
- package/declarations/lib/path/utils.hashFrom.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.isRelevantFile.test.d.ts +0 -2
- package/declarations/lib/path/utils.isRelevantFile.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.paths.test.d.ts +0 -5
- package/declarations/lib/path/utils.paths.test.d.ts.map +0 -1
- package/declarations/lib/renameClass.d.ts +0 -9
- package/declarations/lib/renameClass.d.ts.map +0 -1
- package/declarations/lib/request.d.ts +0 -8
- package/declarations/lib/request.d.ts.map +0 -1
- package/declarations/lib/rewriteHbs.d.ts +0 -17
- package/declarations/lib/rewriteHbs.d.ts.map +0 -1
- package/declarations/runtime/index.d.ts +0 -8
- package/declarations/runtime/index.d.ts.map +0 -1
- package/declarations/runtime/test-support.d.ts.map +0 -1
- package/dist/cjs/babel-plugin.cjs +0 -176
- package/dist/cjs/index.cjs +0 -968
- package/dist/cjs/template-plugin.cjs +0 -856
- package/src/build/index.js +0 -7
- package/src/build/vite.js +0 -3
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/lib/path/md5.js", "../../src/lib/path/hash-from-module-path.js", "../../src/lib/renameClass.js", "../../src/runtime/test-support.ts"],
|
|
4
|
-
"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\n\nexport const hashFromModulePath = hash;\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 classes = className.split(/\\s+/);\n const renamedClasses = classes\n .filter((c) => c)\n .map((c) => c.trim())\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"],
|
|
5
|
-
"mappings": ";AA8BA,SAAS,QAAQ,GAAG,GAAG;AACrB,MAAI,OAAO,IAAI,UAAW,IAAI;AAC9B,MAAI,OAAO,KAAK,OAAO,KAAK,OAAO,OAAO;AAE1C,SAAQ,OAAO,KAAO,MAAM;AAC9B;AASA,SAAS,cAAc,KAAK,KAAK;AAC/B,SAAQ,OAAO,MAAQ,QAAS,KAAK;AACvC;AAaA,SAAS,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;AAChC,SAAO,QAAQ,cAAc,QAAQ,QAAQ,GAAG,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3E;AAcA,SAAS,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;A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,EAAG,QAAO;AAEhC,aAAO,IAAI,MAAM;AAAA,IACnB;AAEA,WAAO;AAAA,EACT,CAAC,EACA,KAAK,GAAG;AAEX,QAAM,6BAA6B,UAAU;AAAA,IAC3C,UAAU,UAAU,EAAE,QAAQ;AAAA,IAC9B;AAAA,EACF;AAEA,SAAO;AACT;;;AC+BO,SAAS,eACX,MACH;AACA,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO,KAAK,KAAK,CAAC,CAAC;AAAA,EACrB;AAEA,MAAI,CAAC,WAAW,UAAU,IAAI;AAE9B,QAAM,UAAU,KAAK,UAAU;AAE/B,SAAO,YAAY,WAAW,OAAO;AACvC;",
|
|
6
|
-
"names": ["hash"]
|
|
7
|
-
}
|
|
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 *\n * @param {string} className\n * @param {string} postfix\n * @param {Set<string>} [classesInCss]\n * @returns\n */\nexport function renameClass(className, postfix, classesInCss) {\n const classes = className.split(/\\s+/);\n const renamedClasses = classes\n .filter((c) => c)\n .map((c) => c.trim())\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,S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AAM,iBADU,UAAU,MAAM,MAAM,CAEnC,QAAQ,MAAM,EAAE,CAChB,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,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;;;;;ACkCH,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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-scoped-css",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
"types": "./declarations/runtime/index.d.ts",
|
|
27
27
|
"default": "./dist/runtime/index.js"
|
|
28
28
|
},
|
|
29
|
+
"./babel": {
|
|
30
|
+
"import": "./src/build/public-exports/babel.js",
|
|
31
|
+
"require": "./dist/cjs/babel.js"
|
|
32
|
+
},
|
|
33
|
+
"./rollup": {
|
|
34
|
+
"import": "./src/build/public-exports/rollup.js",
|
|
35
|
+
"require": "./dist/cjs/rollup.js"
|
|
36
|
+
},
|
|
37
|
+
"./vite": {
|
|
38
|
+
"import": "./src/build/public-exports/vite.js",
|
|
39
|
+
"require": "./dist/cjs/vite.js"
|
|
40
|
+
},
|
|
29
41
|
"./template-registry": {
|
|
30
42
|
"types": "./template-registry.d.ts",
|
|
31
43
|
"default": "./src/noop.js"
|
|
@@ -34,28 +46,13 @@
|
|
|
34
46
|
"types": "./declarations/runtime/test-support.d.ts",
|
|
35
47
|
"default": "./dist/runtime/test-support.js"
|
|
36
48
|
},
|
|
37
|
-
"./build": {
|
|
38
|
-
"import": "./src/build/index.js",
|
|
39
|
-
"require": "./dist/cjs/index.cjs"
|
|
40
|
-
},
|
|
41
|
-
"./vite": {
|
|
42
|
-
"import": "./src/build/vite.js"
|
|
43
|
-
},
|
|
44
49
|
"./helpers/scoped-class": {
|
|
45
50
|
"default": "./classic-app-support/helpers/scoped-class.js"
|
|
46
51
|
},
|
|
47
|
-
"./addon-main.cjs": "./addon-main.cjs"
|
|
48
|
-
"./babel-plugin": {
|
|
49
|
-
"import": "./src/build/babel-plugin.js",
|
|
50
|
-
"require": "./dist/cjs/babel-plugin.cjs"
|
|
51
|
-
},
|
|
52
|
-
"./template-plugin": {
|
|
53
|
-
"import": "./src/build/template-plugin.js",
|
|
54
|
-
"require": "./dist/cjs/template-plugin.cjs"
|
|
55
|
-
}
|
|
52
|
+
"./addon-main.cjs": "./addon-main.cjs"
|
|
56
53
|
},
|
|
57
54
|
"dependencies": {
|
|
58
|
-
"@babel/parser": "^7.
|
|
55
|
+
"@babel/parser": "^7.28.5",
|
|
59
56
|
"@embroider/addon-shim": "^1.9.0",
|
|
60
57
|
"babel-import-util": "^3.0.1",
|
|
61
58
|
"broccoli-concat": "^4.2.5",
|
|
@@ -67,10 +64,10 @@
|
|
|
67
64
|
"postcss": "^8.5.3",
|
|
68
65
|
"postcss-selector-parser": "^6.0.16",
|
|
69
66
|
"recast": "^0.23.7",
|
|
70
|
-
"unplugin": "^2.
|
|
67
|
+
"unplugin": "^2.3.10"
|
|
71
68
|
},
|
|
72
69
|
"devDependencies": {
|
|
73
|
-
"@babel/core": "^7.28.
|
|
70
|
+
"@babel/core": "^7.28.5",
|
|
74
71
|
"@babel/eslint-parser": "^7.26.8",
|
|
75
72
|
"@nullvoxpopuli/eslint-configs": "^5.3.4",
|
|
76
73
|
"@tsconfig/ember": "^3.0.9",
|
|
@@ -81,14 +78,13 @@
|
|
|
81
78
|
"@vitest/coverage-v8": "^3.2.4",
|
|
82
79
|
"babel-plugin-ember-template-compilation": "^3.0.1",
|
|
83
80
|
"common-tags": "^1.8.2",
|
|
84
|
-
"concurrently": "^9.1
|
|
81
|
+
"concurrently": "^9.2.1",
|
|
85
82
|
"content-tag": "^3.1.1",
|
|
86
83
|
"ember-template-lint": "^6.1.0",
|
|
87
|
-
"esbuild": "^0.25.0",
|
|
88
|
-
"esbuild-plugin-vitest-cleaner": "^0.5.1",
|
|
89
84
|
"eslint": "^9.36.0",
|
|
90
85
|
"jscodeshift": "^17.3.0",
|
|
91
86
|
"prettier": "^3.6.2",
|
|
87
|
+
"tsdown": "^0.15.12",
|
|
92
88
|
"typescript": "^5.2.2",
|
|
93
89
|
"vitest": "^3.0.6",
|
|
94
90
|
"webpack": "^5.98.0"
|
|
@@ -123,13 +119,14 @@
|
|
|
123
119
|
"extends": "../package.json"
|
|
124
120
|
},
|
|
125
121
|
"scripts": {
|
|
126
|
-
"build": "
|
|
122
|
+
"build": "tsdown",
|
|
127
123
|
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
|
|
128
124
|
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"",
|
|
129
125
|
"lint:js": "eslint .",
|
|
130
126
|
"lint:js:fix": "eslint . --fix",
|
|
131
127
|
"lint:prettier:fix": "prettier . -w",
|
|
132
128
|
"lint:prettier": "prettier . -c",
|
|
129
|
+
"start": "tsdown --watch",
|
|
133
130
|
"test": "vitest"
|
|
134
131
|
}
|
|
135
132
|
}
|
|
@@ -15,7 +15,10 @@ function _isRelevantFile(state, cwd) {
|
|
|
15
15
|
* @param {object} options - the options for scoped-css -- this is also available in each visitor's state.opts
|
|
16
16
|
* @param {string} workingDirectory
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export const scopedCSS = (config) => (env, options, workingDirectory) => {
|
|
19
|
+
// not really a deep merge, but the idea is to use one or the other and not mix the configs
|
|
20
|
+
options = { ...config, ...options };
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* This babel plugin does two things:
|
|
21
24
|
* - removes the import of scopedClass, if it exists
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as babel from '../babel-plugin.js';
|
|
2
|
+
import { unplugin } from '../scoped-css-unplugin.js';
|
|
3
|
+
import * as template from '../template-plugin.js';
|
|
4
|
+
|
|
5
|
+
export const scopedCSS = {
|
|
6
|
+
vite: unplugin.vite,
|
|
7
|
+
rollup: unplugin.rollup,
|
|
8
|
+
babel: babel.scopedCSS,
|
|
9
|
+
template: template.createPlugin,
|
|
10
|
+
};
|
|
@@ -1,39 +1,16 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
1
|
import { createUnplugin } from 'unplugin';
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { colocated } from './unplugin-colocated.js';
|
|
4
|
+
import { inline } from './unplugin-inline.js';
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
|
-
* The plugin that handles CSS requests
|
|
7
|
+
* The plugin that handles CSS requests for `<style>` elements and transforms
|
|
8
|
+
* for existing files
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* we
|
|
10
|
+
* vite: CSS files are resolved by vite. We use their resolver to also get
|
|
11
|
+
* HMR. That is, for all non-physical CSS files, we extend vite by our
|
|
12
|
+
* resolver and also can enrich metadata to it (for better debugging)
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
13
|
-
return
|
|
14
|
-
name: 'ember-scoped-css-unplugin',
|
|
15
|
-
|
|
16
|
-
resolveId(id, importer) {
|
|
17
|
-
if (isScopedCSSRequest(id)) {
|
|
18
|
-
let parsed = decodeScopedCSSRequest(id);
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
id: path.resolve(path.dirname(importer), parsed.postfix + '.css'),
|
|
22
|
-
meta: {
|
|
23
|
-
'scoped-css': {
|
|
24
|
-
css: parsed.css,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
load(id) {
|
|
32
|
-
let meta = this.getModuleInfo(id)?.meta?.['scoped-css'];
|
|
33
|
-
|
|
34
|
-
if (meta) {
|
|
35
|
-
return meta.css;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
14
|
+
export const unplugin = createUnplugin((options = {}) => {
|
|
15
|
+
return [colocated(options), inline(options)];
|
|
39
16
|
});
|
|
@@ -4,16 +4,20 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
|
|
7
10
|
import { rewriteCss } from '../lib/css/rewrite.js';
|
|
8
11
|
import { getCSSContentInfo, getCSSInfo } from '../lib/css/utils.js';
|
|
9
12
|
import { fixFilename } from '../lib/path/template-transform-paths.js';
|
|
10
13
|
import {
|
|
11
14
|
appPath,
|
|
12
15
|
cssPathFor,
|
|
16
|
+
forcePosix,
|
|
13
17
|
hashFromModulePath,
|
|
14
18
|
isRelevantFile,
|
|
15
19
|
} from '../lib/path/utils.js';
|
|
16
|
-
import {
|
|
20
|
+
import { request } from '../lib/request.js';
|
|
17
21
|
import { templatePlugin } from '../lib/rewriteHbs.js';
|
|
18
22
|
|
|
19
23
|
const noopPlugin = {
|
|
@@ -31,6 +35,7 @@ export function createPlugin(config) {
|
|
|
31
35
|
*/
|
|
32
36
|
return function scopedCss(env) {
|
|
33
37
|
let cwd = process.cwd();
|
|
38
|
+
|
|
34
39
|
let isRelevant = isRelevantFile(env.filename, {
|
|
35
40
|
additionalRoots: config.additionalRoots,
|
|
36
41
|
cwd,
|
|
@@ -73,6 +78,7 @@ export function createPlugin(config) {
|
|
|
73
78
|
|
|
74
79
|
let cssPath = cssPathFor(absolutePath);
|
|
75
80
|
let info = getCSSInfo(cssPath);
|
|
81
|
+
let localCssPath = forcePosix(cssPath.replace(cwd + path.sep, ''));
|
|
76
82
|
|
|
77
83
|
/**
|
|
78
84
|
* This will be falsey if we don't have a co-located CSS file.
|
|
@@ -81,15 +87,7 @@ export function createPlugin(config) {
|
|
|
81
87
|
if (info) {
|
|
82
88
|
addInfo(info);
|
|
83
89
|
|
|
84
|
-
let
|
|
85
|
-
let scopedCss = rewriteCss(
|
|
86
|
-
info.css,
|
|
87
|
-
postfix,
|
|
88
|
-
localCssPath,
|
|
89
|
-
config.layerName,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
let cssRequest = makeRequest(postfix, info.id, scopedCss);
|
|
90
|
+
let cssRequest = request.colocated.create(info.id, postfix, localCssPath);
|
|
93
91
|
|
|
94
92
|
/**
|
|
95
93
|
* With this we don't need a JS plugin
|
|
@@ -125,13 +123,6 @@ export function createPlugin(config) {
|
|
|
125
123
|
if (hasScopedAttribute(styleTag)) {
|
|
126
124
|
let css = textContent(styleTag);
|
|
127
125
|
let info = getCSSContentInfo(css);
|
|
128
|
-
let localCssPath = `<inline>/` + cssPath.replace(cwd + '/', '');
|
|
129
|
-
let scopedCss = rewriteCss(
|
|
130
|
-
info.css,
|
|
131
|
-
postfix,
|
|
132
|
-
localCssPath,
|
|
133
|
-
config.layerName,
|
|
134
|
-
);
|
|
135
126
|
|
|
136
127
|
addInfo(info);
|
|
137
128
|
|
|
@@ -142,7 +133,7 @@ export function createPlugin(config) {
|
|
|
142
133
|
return;
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
let cssRequest =
|
|
136
|
+
let cssRequest = request.inline.create(info.id, postfix, css);
|
|
146
137
|
|
|
147
138
|
env.meta.jsutils.importForSideEffect(cssRequest);
|
|
148
139
|
}
|
|
@@ -166,7 +157,6 @@ export function createPlugin(config) {
|
|
|
166
157
|
|
|
167
158
|
if (hasInlineAttribute(node)) {
|
|
168
159
|
let text = textContent(node);
|
|
169
|
-
let localCssPath = cssPath.replace(cwd + '/', '');
|
|
170
160
|
let scopedText = rewriteCss(
|
|
171
161
|
text,
|
|
172
162
|
postfix,
|
|
@@ -2,7 +2,7 @@ import * as babel from '@babel/core';
|
|
|
2
2
|
import { stripIndent } from 'common-tags';
|
|
3
3
|
import { Preprocessor } from 'content-tag';
|
|
4
4
|
import jscodeshift from 'jscodeshift';
|
|
5
|
-
import { expect, it } from 'vitest';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { createPlugin } from './template-plugin.js';
|
|
8
8
|
|
|
@@ -50,6 +50,66 @@ function templateContentsOf(file: string | null | undefined) {
|
|
|
50
50
|
return result;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
describe('no transformation needed', () => {
|
|
54
|
+
describe('plain style tag', () => {
|
|
55
|
+
it('vanilla', async () => {
|
|
56
|
+
let output = await transform(`
|
|
57
|
+
export const Foo = <template>
|
|
58
|
+
<div class="foo">
|
|
59
|
+
<h1>Hello, World!</h1>
|
|
60
|
+
</div>
|
|
61
|
+
<style>
|
|
62
|
+
.foo {
|
|
63
|
+
color: red;
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
66
|
+
</template>;
|
|
67
|
+
`);
|
|
68
|
+
|
|
69
|
+
expect(templateContentsOf(output)).toMatchInlineSnapshot(`
|
|
70
|
+
[
|
|
71
|
+
"<div class="foo">
|
|
72
|
+
<h1>Hello, World!</h1>
|
|
73
|
+
</div>
|
|
74
|
+
<style>
|
|
75
|
+
.foo {
|
|
76
|
+
color: red;
|
|
77
|
+
}
|
|
78
|
+
</style>",
|
|
79
|
+
]
|
|
80
|
+
`);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('with @scope', async () => {
|
|
84
|
+
let output = await transform(`
|
|
85
|
+
export const Foo = <template>
|
|
86
|
+
<div class="foo">
|
|
87
|
+
<h1>Hello, World!</h1>
|
|
88
|
+
</div>
|
|
89
|
+
<style>
|
|
90
|
+
.foo {
|
|
91
|
+
color: red;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
94
|
+
</template>;
|
|
95
|
+
`);
|
|
96
|
+
|
|
97
|
+
expect(templateContentsOf(output)).toMatchInlineSnapshot(`
|
|
98
|
+
[
|
|
99
|
+
"<div class="foo">
|
|
100
|
+
<h1>Hello, World!</h1>
|
|
101
|
+
</div>
|
|
102
|
+
<style>
|
|
103
|
+
.foo {
|
|
104
|
+
color: red;
|
|
105
|
+
}
|
|
106
|
+
</style>",
|
|
107
|
+
]
|
|
108
|
+
`);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
53
113
|
it('scoped transforms correctly', async () => {
|
|
54
114
|
let output = await transform(`
|
|
55
115
|
export const Foo = <template>
|
|
@@ -61,7 +121,7 @@ it('scoped transforms correctly', async () => {
|
|
|
61
121
|
color: red;
|
|
62
122
|
}
|
|
63
123
|
</style>
|
|
64
|
-
</template>;
|
|
124
|
+
</template>;
|
|
65
125
|
`);
|
|
66
126
|
|
|
67
127
|
expect(templateContentsOf(output)).toMatchInlineSnapshot(`
|
|
@@ -73,6 +133,39 @@ it('scoped transforms correctly', async () => {
|
|
|
73
133
|
`);
|
|
74
134
|
});
|
|
75
135
|
|
|
136
|
+
it('scoped with @scope transforms correctly', async () => {
|
|
137
|
+
let output = await transform(`
|
|
138
|
+
export const Foo = <template>
|
|
139
|
+
<div class="foo">
|
|
140
|
+
<h1>Hello, World!</h1>
|
|
141
|
+
</div>
|
|
142
|
+
<style scoped inline>
|
|
143
|
+
@scope {
|
|
144
|
+
.foo {
|
|
145
|
+
color: red;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
149
|
+
</template>;
|
|
150
|
+
`);
|
|
151
|
+
|
|
152
|
+
expect(templateContentsOf(output)).toMatchInlineSnapshot(`
|
|
153
|
+
[
|
|
154
|
+
"<div class="foo_e65d154a1">
|
|
155
|
+
<h1>Hello, World!</h1>
|
|
156
|
+
</div>
|
|
157
|
+
<style scoped inline>/* src/components/example-component.css */
|
|
158
|
+
|
|
159
|
+
@scope {
|
|
160
|
+
.foo_e65d154a1 {
|
|
161
|
+
color: red;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
</style>",
|
|
165
|
+
]
|
|
166
|
+
`);
|
|
167
|
+
});
|
|
168
|
+
|
|
76
169
|
it('scoped inline transforms correctly', async () => {
|
|
77
170
|
let output = await transform(`
|
|
78
171
|
export const Foo = <template>
|
|
@@ -84,24 +177,20 @@ it('scoped inline transforms correctly', async () => {
|
|
|
84
177
|
color: red;
|
|
85
178
|
}
|
|
86
179
|
</style>
|
|
87
|
-
</template>;
|
|
180
|
+
</template>;
|
|
88
181
|
`);
|
|
89
182
|
|
|
90
183
|
expect(templateContentsOf(output)).toMatchInlineSnapshot(`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
</style>",
|
|
105
|
-
]
|
|
106
|
-
`);
|
|
184
|
+
[
|
|
185
|
+
"<div class="foo_e65d154a1">
|
|
186
|
+
<h1>Hello, World!</h1>
|
|
187
|
+
</div>
|
|
188
|
+
<style scoped inline>/* src/components/example-component.css */
|
|
189
|
+
|
|
190
|
+
.foo_e65d154a1 {
|
|
191
|
+
color: red;
|
|
192
|
+
}
|
|
193
|
+
</style>",
|
|
194
|
+
]
|
|
195
|
+
`);
|
|
107
196
|
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { rewriteCss } from '../lib/css/rewrite.js';
|
|
5
|
+
import { request } from '../lib/request.js';
|
|
6
|
+
|
|
7
|
+
const META = 'scoped-css:colocated';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Plugin for supporting colocated styles
|
|
11
|
+
*
|
|
12
|
+
* e.g.:
|
|
13
|
+
* src/components/my-component.js
|
|
14
|
+
* src/components/my-component.css
|
|
15
|
+
*/
|
|
16
|
+
export function colocated(options = {}) {
|
|
17
|
+
const CWD = process.cwd();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {string} id the request id / what was imported
|
|
22
|
+
* @param {string} filePath path on disk
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function buildResponse(id, filePath) {
|
|
26
|
+
const parsed = request.colocated.decode(id);
|
|
27
|
+
const relativeFilePath = path.relative(CWD, filePath);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
id: filePath,
|
|
31
|
+
meta: {
|
|
32
|
+
[META]: {
|
|
33
|
+
postfix: parsed.postfix,
|
|
34
|
+
fileName: relativeFilePath,
|
|
35
|
+
fullPath: filePath,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
name: 'ember-scoped-css:colocated',
|
|
43
|
+
resolveId(id, importer) {
|
|
44
|
+
// handles: some-file.css?scoped=[postfix]
|
|
45
|
+
// this is only run in rollup, vite handles it differently
|
|
46
|
+
if (request.is.colocated(id)) {
|
|
47
|
+
const parsed = request.colocated.decode(id);
|
|
48
|
+
|
|
49
|
+
const filePath = path.resolve(
|
|
50
|
+
path.dirname(importer),
|
|
51
|
+
path.basename(parsed.fileName),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Rollup doesn't normally watch CSS files
|
|
56
|
+
*/
|
|
57
|
+
this.addWatchFile(filePath);
|
|
58
|
+
|
|
59
|
+
return buildResponse(id, filePath);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
load(id) {
|
|
63
|
+
const meta = this.getModuleInfo(id)?.meta?.[META];
|
|
64
|
+
|
|
65
|
+
if (meta) {
|
|
66
|
+
let code = readFileSync(meta.fullPath, 'utf-8');
|
|
67
|
+
|
|
68
|
+
let css = rewriteCss(
|
|
69
|
+
code,
|
|
70
|
+
meta.postfix,
|
|
71
|
+
meta.fileName,
|
|
72
|
+
options.layerName,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return css;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
vite: {
|
|
79
|
+
/**
|
|
80
|
+
* There may not be meta for this request yet.
|
|
81
|
+
*
|
|
82
|
+
* @param {*} id
|
|
83
|
+
*/
|
|
84
|
+
load(id) {
|
|
85
|
+
if (request.is.colocated(id)) {
|
|
86
|
+
const parsed = request.colocated.decode(id);
|
|
87
|
+
|
|
88
|
+
let code = readFileSync(parsed.fileName, 'utf-8');
|
|
89
|
+
let relativeFilePath = path.relative(CWD, parsed.fileName);
|
|
90
|
+
|
|
91
|
+
let css = rewriteCss(
|
|
92
|
+
code,
|
|
93
|
+
parsed.postfix,
|
|
94
|
+
relativeFilePath,
|
|
95
|
+
options.layerName,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
return css;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|