@uniformdev/context-remix
Advanced tools
Comparing version 17.7.1-alpha.140 to 17.7.1-alpha.167
@@ -1,1 +0,60 @@ | ||
import{CookieTransitionDataStore as f,UNIFORM_DEFAULT_COOKIE_NAME as p}from"@uniformdev/context";import{parse as u}from"cookie";var s=class extends f{constructor({request:r,...o}){var e,n;super({...o,serverCookieValue:r?u((e=r.headers.get("cookie"))!=null?e:"")[(n=o.cookieName)!=null?n:p]:void 0})}};import{useLocation as x}from"@remix-run/react";import{UniformContext as d}from"@uniformdev/context-react";import{parse as C}from"cookie";import R from"react";import{useEffect as l}from"react";import*as i from"react";var a=i.createContext(null),v=a.Provider;function c(){let t=i.useContext(a);if(t===null)throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider");return t}var L=({children:t,...r})=>{let o=c(),e=x();return l(()=>{var m;if(typeof document=="undefined")return;let n=new URL(`${document.location.protocol}//${document.location.host}${e.pathname}${e.search}`);o.update({url:n,cookies:C((m=document.cookie)!=null?m:"")})},[e,o]),R.createElement(d,{...r,context:o,trackRouteOnRender:!1},t)};export{s as RemixCookieTransitionDataStore,L as RemixUniformContext,v as RemixUniformContextProvider,c as useRemixUniformProvider}; | ||
// src/RemixCookieTransitionDataStore.ts | ||
import { | ||
CookieTransitionDataStore, | ||
UNIFORM_DEFAULT_COOKIE_NAME | ||
} from "@uniformdev/context"; | ||
import { parse } from "cookie"; | ||
var RemixCookieTransitionDataStore = class extends CookieTransitionDataStore { | ||
constructor({ request, ...options }) { | ||
var _a, _b; | ||
super({ | ||
...options, | ||
serverCookieValue: request ? parse((_a = request.headers.get("cookie")) != null ? _a : "")[(_b = options.cookieName) != null ? _b : UNIFORM_DEFAULT_COOKIE_NAME] : void 0 | ||
}); | ||
} | ||
}; | ||
// src/RemixUniformContext.tsx | ||
import { useLocation } from "@remix-run/react"; | ||
import { UniformContext } from "@uniformdev/context-react"; | ||
import { parse as parse2 } from "cookie"; | ||
import React2 from "react"; | ||
import { useEffect } from "react"; | ||
// src/RemixUniformProvider.tsx | ||
import * as React from "react"; | ||
var RemixUniformProviderContext = React.createContext(null); | ||
var RemixUniformContextProvider = RemixUniformProviderContext.Provider; | ||
function useRemixUniformProvider() { | ||
const context = React.useContext(RemixUniformProviderContext); | ||
if (context === null) { | ||
throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider"); | ||
} | ||
return context; | ||
} | ||
// src/RemixUniformContext.tsx | ||
var RemixUniformContext = ({ children, ...props }) => { | ||
const context = useRemixUniformProvider(); | ||
const location = useLocation(); | ||
useEffect(() => { | ||
var _a; | ||
if (typeof document === "undefined") { | ||
return; | ||
} | ||
const url = new URL( | ||
`${document.location.protocol}//${document.location.host}${location.pathname}${location.search}` | ||
); | ||
context.update({ | ||
url, | ||
cookies: parse2((_a = document.cookie) != null ? _a : "") | ||
}); | ||
}, [location, context]); | ||
return /* @__PURE__ */ React2.createElement(UniformContext, { ...props, context, trackRouteOnRender: false }, children); | ||
}; | ||
export { | ||
RemixCookieTransitionDataStore, | ||
RemixUniformContext, | ||
RemixUniformContextProvider, | ||
useRemixUniformProvider | ||
}; |
@@ -1,1 +0,93 @@ | ||
"use strict";var O=Object.create;var i=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var E=(o,e)=>{for(var t in e)i(o,t,{get:e[t],enumerable:!0})},p=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!D.call(o,r)&&r!==t&&i(o,r,{get:()=>e[r],enumerable:!(n=P(e,r))||n.enumerable});return o};var u=(o,e,t)=>(t=o!=null?O(h(o)):{},p(e||!o||!o.__esModule?i(t,"default",{value:o,enumerable:!0}):t,o)),T=o=>p(i({},"__esModule",{value:!0}),o);var $={};E($,{RemixCookieTransitionDataStore:()=>a,RemixUniformContext:()=>S,RemixUniformContextProvider:()=>w,useRemixUniformProvider:()=>c});module.exports=T($);var m=require("@uniformdev/context"),x=require("cookie"),a=class extends m.CookieTransitionDataStore{constructor({request:e,...t}){var n,r;super({...t,serverCookieValue:e?(0,x.parse)((n=e.headers.get("cookie"))!=null?n:"")[(r=t.cookieName)!=null?r:m.UNIFORM_DEFAULT_COOKIE_NAME]:void 0})}};var C=require("@remix-run/react"),R=require("@uniformdev/context-react"),l=require("cookie"),U=u(require("react")),k=require("react");var s=u(require("react")),d=s.createContext(null),w=d.Provider;function c(){let o=s.useContext(d);if(o===null)throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider");return o}var S=({children:o,...e})=>{let t=c(),n=(0,C.useLocation)();return(0,k.useEffect)(()=>{var f;if(typeof document=="undefined")return;let r=new URL(`${document.location.protocol}//${document.location.host}${n.pathname}${n.search}`);t.update({url:r,cookies:(0,l.parse)((f=document.cookie)!=null?f:"")})},[n,t]),U.default.createElement(R.UniformContext,{...e,context:t,trackRouteOnRender:!1},o)};0&&(module.exports={RemixCookieTransitionDataStore,RemixUniformContext,RemixUniformContextProvider,useRemixUniformProvider}); | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
RemixCookieTransitionDataStore: () => RemixCookieTransitionDataStore, | ||
RemixUniformContext: () => RemixUniformContext, | ||
RemixUniformContextProvider: () => RemixUniformContextProvider, | ||
useRemixUniformProvider: () => useRemixUniformProvider | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/RemixCookieTransitionDataStore.ts | ||
var import_context = require("@uniformdev/context"); | ||
var import_cookie = require("cookie"); | ||
var RemixCookieTransitionDataStore = class extends import_context.CookieTransitionDataStore { | ||
constructor({ request, ...options }) { | ||
var _a, _b; | ||
super({ | ||
...options, | ||
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 | ||
}); | ||
} | ||
}; | ||
// src/RemixUniformContext.tsx | ||
var import_react = require("@remix-run/react"); | ||
var import_context_react = require("@uniformdev/context-react"); | ||
var import_cookie2 = require("cookie"); | ||
var import_react2 = __toESM(require("react")); | ||
var import_react3 = require("react"); | ||
// src/RemixUniformProvider.tsx | ||
var React = __toESM(require("react")); | ||
var RemixUniformProviderContext = React.createContext(null); | ||
var RemixUniformContextProvider = RemixUniformProviderContext.Provider; | ||
function useRemixUniformProvider() { | ||
const context = React.useContext(RemixUniformProviderContext); | ||
if (context === null) { | ||
throw new Error("useRemixUniformProvider must be used within a RemixUniformProvider"); | ||
} | ||
return context; | ||
} | ||
// src/RemixUniformContext.tsx | ||
var RemixUniformContext = ({ children, ...props }) => { | ||
const context = useRemixUniformProvider(); | ||
const location = (0, import_react.useLocation)(); | ||
(0, import_react3.useEffect)(() => { | ||
var _a; | ||
if (typeof document === "undefined") { | ||
return; | ||
} | ||
const url = new URL( | ||
`${document.location.protocol}//${document.location.host}${location.pathname}${location.search}` | ||
); | ||
context.update({ | ||
url, | ||
cookies: (0, import_cookie2.parse)((_a = document.cookie) != null ? _a : "") | ||
}); | ||
}, [location, context]); | ||
return /* @__PURE__ */ import_react2.default.createElement(import_context_react.UniformContext, { ...props, context, trackRouteOnRender: false }, children); | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
RemixCookieTransitionDataStore, | ||
RemixUniformContext, | ||
RemixUniformContextProvider, | ||
useRemixUniformProvider | ||
}); |
{ | ||
"name": "@uniformdev/context-remix", | ||
"version": "17.7.1-alpha.140+80ab6baf9", | ||
"version": "17.7.1-alpha.167+a358adea9", | ||
"description": "Uniform Context Remix integration package", | ||
@@ -18,3 +18,3 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"scripts": { | ||
"build": "tsup --minify", | ||
"build": "tsup", | ||
"dev": "tsup --watch", | ||
@@ -34,4 +34,4 @@ "clean": "rimraf dist", | ||
"dependencies": { | ||
"@uniformdev/context": "^17.7.1-alpha.140+80ab6baf9", | ||
"@uniformdev/context-react": "^17.7.1-alpha.140+80ab6baf9", | ||
"@uniformdev/context": "^17.7.1-alpha.167+a358adea9", | ||
"@uniformdev/context-react": "^17.7.1-alpha.167+a358adea9", | ||
"cookie": "0.5.0" | ||
@@ -50,3 +50,3 @@ }, | ||
}, | ||
"gitHead": "80ab6baf9edea6b520738bd3dff5c6afc882bf77" | ||
"gitHead": "a358adea91b24a877e577be784d56b794c4cfab8" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
10679
227
2
2