@uniformdev/context-remix 17.7.1-alpha.34 → 18.0.1-alpha.3
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/LICENSE.txt +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +60 -1
- package/dist/index.js +93 -1
- package/dist/index.mjs +60 -1
- package/package.json +6 -6
package/LICENSE.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
©
|
|
1
|
+
© 2023 Uniform Systems, Inc. All Rights Reserved.
|
|
2
2
|
See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { UniformContextProps } from '@uniformdev/context-react';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default from 'react';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type RemixCookieTransitionDataStoreOptions = Omit<CookieTransitionDataStoreOptions, 'serverCookieValue'> & {
|
|
7
7
|
request: Request | undefined;
|
|
8
8
|
};
|
|
9
9
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
// src/RemixCookieTransitionDataStore.ts
|
|
2
|
+
import {
|
|
3
|
+
CookieTransitionDataStore,
|
|
4
|
+
UNIFORM_DEFAULT_COOKIE_NAME
|
|
5
|
+
} from "@uniformdev/context";
|
|
6
|
+
import { parse } from "cookie";
|
|
7
|
+
var RemixCookieTransitionDataStore = class extends CookieTransitionDataStore {
|
|
8
|
+
constructor({ request, ...options }) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
super({
|
|
11
|
+
...options,
|
|
12
|
+
serverCookieValue: request ? parse((_a = request.headers.get("cookie")) != null ? _a : "")[(_b = options.cookieName) != null ? _b : UNIFORM_DEFAULT_COOKIE_NAME] : void 0
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/RemixUniformContext.tsx
|
|
18
|
+
import { useLocation } from "@remix-run/react";
|
|
19
|
+
import { UniformContext } from "@uniformdev/context-react";
|
|
20
|
+
import { parse as parse2 } from "cookie";
|
|
21
|
+
import React2 from "react";
|
|
22
|
+
import { useEffect } from "react";
|
|
23
|
+
|
|
24
|
+
// src/RemixUniformProvider.tsx
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
var RemixUniformProviderContext = React.createContext(null);
|
|
27
|
+
var RemixUniformContextProvider = RemixUniformProviderContext.Provider;
|
|
28
|
+
function useRemixUniformProvider() {
|
|
29
|
+
const context = React.useContext(RemixUniformProviderContext);
|
|
30
|
+
if (context === null) {
|
|
31
|
+
throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/RemixUniformContext.tsx
|
|
37
|
+
var RemixUniformContext = ({ children, ...props }) => {
|
|
38
|
+
const context = useRemixUniformProvider();
|
|
39
|
+
const location = useLocation();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (typeof document === "undefined") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const url = new URL(
|
|
46
|
+
`${document.location.protocol}//${document.location.host}${location.pathname}${location.search}`
|
|
47
|
+
);
|
|
48
|
+
context.update({
|
|
49
|
+
url,
|
|
50
|
+
cookies: parse2((_a = document.cookie) != null ? _a : "")
|
|
51
|
+
});
|
|
52
|
+
}, [location, context]);
|
|
53
|
+
return /* @__PURE__ */ React2.createElement(UniformContext, { ...props, context, trackRouteOnRender: false }, children);
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
RemixCookieTransitionDataStore,
|
|
57
|
+
RemixUniformContext,
|
|
58
|
+
RemixUniformContextProvider,
|
|
59
|
+
useRemixUniformProvider
|
|
60
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1,93 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var src_exports = {};
|
|
28
|
+
__export(src_exports, {
|
|
29
|
+
RemixCookieTransitionDataStore: () => RemixCookieTransitionDataStore,
|
|
30
|
+
RemixUniformContext: () => RemixUniformContext,
|
|
31
|
+
RemixUniformContextProvider: () => RemixUniformContextProvider,
|
|
32
|
+
useRemixUniformProvider: () => useRemixUniformProvider
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
|
|
36
|
+
// src/RemixCookieTransitionDataStore.ts
|
|
37
|
+
var import_context = require("@uniformdev/context");
|
|
38
|
+
var import_cookie = require("cookie");
|
|
39
|
+
var RemixCookieTransitionDataStore = class extends import_context.CookieTransitionDataStore {
|
|
40
|
+
constructor({ request, ...options }) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
super({
|
|
43
|
+
...options,
|
|
44
|
+
serverCookieValue: request ? (0, import_cookie.parse)((_a = request.headers.get("cookie")) != null ? _a : "")[(_b = options.cookieName) != null ? _b : import_context.UNIFORM_DEFAULT_COOKIE_NAME] : void 0
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/RemixUniformContext.tsx
|
|
50
|
+
var import_react = require("@remix-run/react");
|
|
51
|
+
var import_context_react = require("@uniformdev/context-react");
|
|
52
|
+
var import_cookie2 = require("cookie");
|
|
53
|
+
var import_react2 = __toESM(require("react"));
|
|
54
|
+
var import_react3 = require("react");
|
|
55
|
+
|
|
56
|
+
// src/RemixUniformProvider.tsx
|
|
57
|
+
var React = __toESM(require("react"));
|
|
58
|
+
var RemixUniformProviderContext = React.createContext(null);
|
|
59
|
+
var RemixUniformContextProvider = RemixUniformProviderContext.Provider;
|
|
60
|
+
function useRemixUniformProvider() {
|
|
61
|
+
const context = React.useContext(RemixUniformProviderContext);
|
|
62
|
+
if (context === null) {
|
|
63
|
+
throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider");
|
|
64
|
+
}
|
|
65
|
+
return context;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/RemixUniformContext.tsx
|
|
69
|
+
var RemixUniformContext = ({ children, ...props }) => {
|
|
70
|
+
const context = useRemixUniformProvider();
|
|
71
|
+
const location = (0, import_react.useLocation)();
|
|
72
|
+
(0, import_react3.useEffect)(() => {
|
|
73
|
+
var _a;
|
|
74
|
+
if (typeof document === "undefined") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const url = new URL(
|
|
78
|
+
`${document.location.protocol}//${document.location.host}${location.pathname}${location.search}`
|
|
79
|
+
);
|
|
80
|
+
context.update({
|
|
81
|
+
url,
|
|
82
|
+
cookies: (0, import_cookie2.parse)((_a = document.cookie) != null ? _a : "")
|
|
83
|
+
});
|
|
84
|
+
}, [location, context]);
|
|
85
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_context_react.UniformContext, { ...props, context, trackRouteOnRender: false }, children);
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
RemixCookieTransitionDataStore,
|
|
90
|
+
RemixUniformContext,
|
|
91
|
+
RemixUniformContextProvider,
|
|
92
|
+
useRemixUniformProvider
|
|
93
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
// src/RemixCookieTransitionDataStore.ts
|
|
2
|
+
import {
|
|
3
|
+
CookieTransitionDataStore,
|
|
4
|
+
UNIFORM_DEFAULT_COOKIE_NAME
|
|
5
|
+
} from "@uniformdev/context";
|
|
6
|
+
import { parse } from "cookie";
|
|
7
|
+
var RemixCookieTransitionDataStore = class extends CookieTransitionDataStore {
|
|
8
|
+
constructor({ request, ...options }) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
super({
|
|
11
|
+
...options,
|
|
12
|
+
serverCookieValue: request ? parse((_a = request.headers.get("cookie")) != null ? _a : "")[(_b = options.cookieName) != null ? _b : UNIFORM_DEFAULT_COOKIE_NAME] : void 0
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/RemixUniformContext.tsx
|
|
18
|
+
import { useLocation } from "@remix-run/react";
|
|
19
|
+
import { UniformContext } from "@uniformdev/context-react";
|
|
20
|
+
import { parse as parse2 } from "cookie";
|
|
21
|
+
import React2 from "react";
|
|
22
|
+
import { useEffect } from "react";
|
|
23
|
+
|
|
24
|
+
// src/RemixUniformProvider.tsx
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
var RemixUniformProviderContext = React.createContext(null);
|
|
27
|
+
var RemixUniformContextProvider = RemixUniformProviderContext.Provider;
|
|
28
|
+
function useRemixUniformProvider() {
|
|
29
|
+
const context = React.useContext(RemixUniformProviderContext);
|
|
30
|
+
if (context === null) {
|
|
31
|
+
throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/RemixUniformContext.tsx
|
|
37
|
+
var RemixUniformContext = ({ children, ...props }) => {
|
|
38
|
+
const context = useRemixUniformProvider();
|
|
39
|
+
const location = useLocation();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (typeof document === "undefined") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const url = new URL(
|
|
46
|
+
`${document.location.protocol}//${document.location.host}${location.pathname}${location.search}`
|
|
47
|
+
);
|
|
48
|
+
context.update({
|
|
49
|
+
url,
|
|
50
|
+
cookies: parse2((_a = document.cookie) != null ? _a : "")
|
|
51
|
+
});
|
|
52
|
+
}, [location, context]);
|
|
53
|
+
return /* @__PURE__ */ React2.createElement(UniformContext, { ...props, context, trackRouteOnRender: false }, children);
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
RemixCookieTransitionDataStore,
|
|
57
|
+
RemixUniformContext,
|
|
58
|
+
RemixUniformContextProvider,
|
|
59
|
+
useRemixUniformProvider
|
|
60
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/context-remix",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.1-alpha.3+2267c1ac6",
|
|
4
4
|
"description": "Uniform Context Remix integration package",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "tsup
|
|
18
|
+
"build": "tsup",
|
|
19
19
|
"dev": "tsup --watch",
|
|
20
20
|
"clean": "rimraf dist",
|
|
21
21
|
"test": "jest --maxWorkers=1 --passWithNoTests",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@remix-run/react": "1.
|
|
26
|
+
"@remix-run/react": "1.10.0",
|
|
27
27
|
"@types/cookie": "0.5.1",
|
|
28
28
|
"@types/react": "18.0.26",
|
|
29
29
|
"react": "18.2.0",
|
|
30
30
|
"react-dom": "18.2.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@uniformdev/context": "
|
|
34
|
-
"@uniformdev/context-react": "
|
|
33
|
+
"@uniformdev/context": "18.0.1-alpha.3+2267c1ac6",
|
|
34
|
+
"@uniformdev/context-react": "18.0.1-alpha.3+2267c1ac6",
|
|
35
35
|
"cookie": "0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2267c1ac6f5f6929be6b12d0099905ab46848d0c"
|
|
49
49
|
}
|