vite-plugin-react-shopify 1.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 +407 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.js +638 -0
- package/dist/runtime/Liquid.client.d.ts +6 -0
- package/dist/runtime/Liquid.client.js +7 -0
- package/dist/runtime/Liquid.d.ts +11 -0
- package/dist/runtime/Liquid.js +10 -0
- package/dist/runtime/settings.d.ts +8 -0
- package/dist/runtime/settings.js +44 -0
- package/package.json +58 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/runtime/settings.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
var SettingsContext = createContext({});
|
|
4
|
+
var SettingsProvider = SettingsContext.Provider;
|
|
5
|
+
function useShopifySettings() {
|
|
6
|
+
const ctx = useContext(SettingsContext);
|
|
7
|
+
if (Object.keys(ctx).length > 0) return ctx;
|
|
8
|
+
if (typeof globalThis.window === "undefined") {
|
|
9
|
+
const target = globalThis.__shopify_ssg_target || "section";
|
|
10
|
+
const prefix = target === "block" ? "block" : "section";
|
|
11
|
+
return new Proxy(
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get(_, key) {
|
|
15
|
+
return `{{ ${prefix}.settings.${String(key)} }}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
var ParamsContext = createContext({});
|
|
23
|
+
var ParamsProvider = ParamsContext.Provider;
|
|
24
|
+
function useShopifyParams() {
|
|
25
|
+
const ctx = useContext(ParamsContext);
|
|
26
|
+
if (Object.keys(ctx).length > 0) return ctx;
|
|
27
|
+
if (typeof globalThis.window === "undefined") {
|
|
28
|
+
return new Proxy(
|
|
29
|
+
{},
|
|
30
|
+
{
|
|
31
|
+
get(_, key) {
|
|
32
|
+
return `{{ ${String(key)} }}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
ParamsProvider,
|
|
41
|
+
SettingsProvider,
|
|
42
|
+
useShopifyParams,
|
|
43
|
+
useShopifySettings
|
|
44
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vite-plugin-react-shopify",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vite plugin for React Shopify themes",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./runtime": {
|
|
16
|
+
"types": "./dist/runtime/Liquid.d.ts",
|
|
17
|
+
"default": "./dist/runtime/Liquid.js"
|
|
18
|
+
},
|
|
19
|
+
"./runtime/Liquid": {
|
|
20
|
+
"types": "./dist/runtime/Liquid.d.ts",
|
|
21
|
+
"default": "./dist/runtime/Liquid.js"
|
|
22
|
+
},
|
|
23
|
+
"./runtime/Liquid.client": {
|
|
24
|
+
"types": "./dist/runtime/Liquid.client.d.ts",
|
|
25
|
+
"default": "./dist/runtime/Liquid.client.js"
|
|
26
|
+
},
|
|
27
|
+
"./runtime/settings": {
|
|
28
|
+
"types": "./dist/runtime/settings.d.ts",
|
|
29
|
+
"default": "./dist/runtime/settings.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "tsup --watch",
|
|
34
|
+
"build": "tsup && cp dev-server-index.html dist/",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"release": "bumpp && pnpm publish",
|
|
38
|
+
"release:patch": "bumpp --patch",
|
|
39
|
+
"release:minor": "bumpp --minor",
|
|
40
|
+
"release:major": "bumpp --major"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"debug": "^4.4.0",
|
|
44
|
+
"fast-glob": "^3.3.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/debug": "^4.1.0",
|
|
48
|
+
"@types/node": "^22.0.0",
|
|
49
|
+
"bumpp": "^11.1.0",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^5.8.0",
|
|
52
|
+
"vite": "^8.0.14",
|
|
53
|
+
"vitest": "^3.1.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"vite": "^8.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|