@shopify/shop-minis-react 0.0.0-snapshot.20251211173028 → 0.0.0-snapshot.20251211183509

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.
@@ -1,5 +1,5 @@
1
- var e = { exports: {} };
1
+ var r = {};
2
2
  export {
3
- e as __module
3
+ r as __exports
4
4
  };
5
5
  //# sourceMappingURL=index4.js.map
@@ -1,6 +1,5 @@
1
- import { __require as r } from "../shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js";
2
- var i = r();
1
+ var e = { exports: {} };
3
2
  export {
4
- i as l
3
+ e as __module
5
4
  };
6
5
  //# sourceMappingURL=index5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,6 @@
1
- var r = {};
1
+ import { __require as r } from "../shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js";
2
+ var i = r();
2
3
  export {
3
- r as __exports
4
+ i as l
4
5
  };
5
6
  //# sourceMappingURL=index6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,4 +1,4 @@
1
- import { __module as q } from "../../../../../../../../_virtual/index4.js";
1
+ import { __module as q } from "../../../../../../../../_virtual/index5.js";
2
2
  import { __require as F } from "../../../../../global@4.4.0/node_modules/global/window.js";
3
3
  import { __require as N } from "../../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js";
4
4
  import { __require as J } from "../../../../../is-function@1.0.2/node_modules/is-function/index.js";
@@ -2,7 +2,7 @@ import L from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-ut
2
2
  import T from "../../../../../../../_virtual/window.js";
3
3
  import { forEachMediaGroup as Z } from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js";
4
4
  import J from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
5
- import { l as Q } from "../../../../../../../_virtual/index5.js";
5
+ import { l as Q } from "../../../../../../../_virtual/index6.js";
6
6
  /*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */
7
7
  const w = (e) => !!e && typeof e == "object", E = (...e) => e.reduce((n, t) => (typeof t != "object" || Object.keys(t).forEach((r) => {
8
8
  Array.isArray(n[r]) && Array.isArray(t[r]) ? n[r] = n[r].concat(t[r]) : w(n[r]) && w(t[r]) ? n[r] = E(n[r], t[r]) : n[r] = t[r];
@@ -1,4 +1,4 @@
1
- import { __exports as i } from "../../../../../../_virtual/index6.js";
1
+ import { __exports as i } from "../../../../../../_virtual/index4.js";
2
2
  var c;
3
3
  function d() {
4
4
  if (c) return i;
@@ -3,32 +3,46 @@
3
3
  * @fileoverview Warns about template literals that may construct asset paths dynamically
4
4
  */
5
5
 
6
- // eslint-disable-next-line import/extensions
7
- const {ASSET_EXTENSIONS, REMOTE_PATTERNS} = require('./asset-path-patterns.cjs')
6
+ const {
7
+ ASSET_EXTENSIONS,
8
+ LOCAL_PATH_PATTERNS,
9
+ REMOTE_PATTERNS,
10
+ // eslint-disable-next-line import/extensions
11
+ } = require('./asset-path-patterns.cjs')
8
12
 
9
13
  /**
10
- * Check if a template literal might contain an asset path
14
+ * Check if a template literal might contain an asset path but we can't be certain
15
+ * Returns true only for UNCERTAIN cases (ends with asset extension but doesn't
16
+ * start with a known local path pattern). Definite cases are handled by
17
+ * no-hardcoded-asset-paths rule.
11
18
  * @param {object} node - The TemplateLiteral AST node
12
19
  * @returns {boolean}
13
20
  */
14
- function templateLiteralHasAssetExtension(node) {
15
- // Check all the static parts (quasis) of the template literal
16
- for (const quasi of node.quasis) {
17
- const value = quasi.value.raw || quasi.value.cooked || ''
18
-
19
- // If any static part ends with an asset extension, flag it
20
- if (ASSET_EXTENSIONS.test(value)) {
21
- // Make sure it's not part of a remote URL
22
- const fullTemplate = node.quasis
23
- .map(q => q.value.raw || q.value.cooked || '')
24
- .join('')
25
- if (REMOTE_PATTERNS.some(pattern => pattern.test(fullTemplate))) {
26
- return false
27
- }
28
- return true
29
- }
30
- }
31
- return false
21
+ function isUncertainAssetTemplateLiteral(node) {
22
+ const quasis = node.quasis
23
+ if (quasis.length === 0) return false
24
+
25
+ // Get the first static part to check if it starts with a local path
26
+ const firstPart = quasis[0].value.raw || quasis[0].value.cooked || ''
27
+
28
+ // Get the last static part to check if it ends with an asset extension
29
+ const lastPart =
30
+ quasis[quasis.length - 1].value.raw ||
31
+ quasis[quasis.length - 1].value.cooked ||
32
+ ''
33
+
34
+ // Must end with an asset extension
35
+ if (!ASSET_EXTENSIONS.test(lastPart)) return false
36
+
37
+ // Check if it starts with a remote URL (only need to check first static part)
38
+ if (REMOTE_PATTERNS.some(pattern => pattern.test(firstPart))) return false
39
+
40
+ // If it starts with a local path pattern, it's a DEFINITE error (handled by other rule)
41
+ // We only want to flag UNCERTAIN cases here
42
+ if (LOCAL_PATH_PATTERNS.some(pattern => pattern.test(firstPart))) return false
43
+
44
+ // Ends with asset extension but doesn't start with known local path = uncertain
45
+ return true
32
46
  }
33
47
 
34
48
  module.exports = {
@@ -51,7 +65,8 @@ module.exports = {
51
65
  create(context) {
52
66
  return {
53
67
  TemplateLiteral(node) {
54
- if (templateLiteralHasAssetExtension(node)) {
68
+ // Only flag uncertain cases (definite cases handled by no-hardcoded-asset-paths)
69
+ if (isUncertainAssetTemplateLiteral(node)) {
55
70
  context.report({
56
71
  node,
57
72
  messageId: 'noDynamicAssetPath',
@@ -28,6 +28,36 @@ function isLocalAssetPath(value) {
28
28
  return LOCAL_PATH_PATTERNS.some(pattern => pattern.test(value))
29
29
  }
30
30
 
31
+ /**
32
+ * Check if a template literal is definitely a local asset path
33
+ * Returns true only if we can determine with certainty it's a local path
34
+ * (starts with a local path pattern AND ends with an asset extension)
35
+ * @param {object} node - The TemplateLiteral AST node
36
+ * @returns {boolean}
37
+ */
38
+ function isLocalAssetTemplateLiteral(node) {
39
+ const quasis = node.quasis
40
+ if (quasis.length === 0) return false
41
+
42
+ // Get the first static part to check if it starts with a local path
43
+ const firstPart = quasis[0].value.raw || quasis[0].value.cooked || ''
44
+
45
+ // Get the last static part to check if it ends with an asset extension
46
+ const lastPart =
47
+ quasis[quasis.length - 1].value.raw ||
48
+ quasis[quasis.length - 1].value.cooked ||
49
+ ''
50
+
51
+ // Must end with an asset extension
52
+ if (!ASSET_EXTENSIONS.test(lastPart)) return false
53
+
54
+ // Check if it starts with a remote URL (only need to check first static part)
55
+ if (REMOTE_PATTERNS.some(pattern => pattern.test(firstPart))) return false
56
+
57
+ // Must start with a local path pattern (this makes it a definite error)
58
+ return LOCAL_PATH_PATTERNS.some(pattern => pattern.test(firstPart))
59
+ }
60
+
31
61
  module.exports = {
32
62
  meta: {
33
63
  type: 'problem',
@@ -41,6 +71,8 @@ module.exports = {
41
71
  messages: {
42
72
  noHardcodedAssetPath:
43
73
  'Hardcoded asset path "{{path}}" will not work in production. Import the asset instead: `import asset from "{{path}}"` then use the imported variable. See: https://vite.dev/guide/assets',
74
+ noHardcodedAssetPathTemplate:
75
+ 'Template literal contains a hardcoded local asset path that will not work in production. Import assets instead of constructing paths. See: https://vite.dev/guide/assets',
44
76
  },
45
77
  schema: [],
46
78
  },
@@ -76,6 +108,17 @@ module.exports = {
76
108
  })
77
109
  }
78
110
  },
111
+
112
+ TemplateLiteral(node) {
113
+ // Only flag template literals that are DEFINITELY local asset paths
114
+ // (start with local path pattern AND end with asset extension)
115
+ if (isLocalAssetTemplateLiteral(node)) {
116
+ context.report({
117
+ node,
118
+ messageId: 'noHardcodedAssetPathTemplate',
119
+ })
120
+ }
121
+ },
79
122
  }
80
123
  },
81
124
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-react",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.0.0-snapshot.20251211173028",
4
+ "version": "0.0.0-snapshot.20251211183509",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "engines": {
@@ -46,7 +46,7 @@
46
46
  "typescript": ">=5.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@shopify/shop-minis-platform": "0.0.0-snapshot.20251211173028",
49
+ "@shopify/shop-minis-platform": "0.0.0-snapshot.20251211183509",
50
50
  "@tailwindcss/vite": "4.1.8",
51
51
  "@tanstack/react-query": "5.86.0",
52
52
  "@types/color": "3.0.6",