Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-vike

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-vike - npm Package Compare versions

Comparing version 0.0.336 to 0.0.338

boilerplate-react-ts/renderer/PageLayout.css

2

boilerplate-react-ts/package.json

@@ -33,3 +33,3 @@ {

"typescript": "^5.3.3",
"vike": "^0.4.171",
"vike": "^0.4.173",
"vite": "^5.0.10"

@@ -36,0 +36,0 @@ },

@@ -24,3 +24,3 @@ {

"sirv": "^2.0.3",
"vike": "^0.4.171",
"vike": "^0.4.173",
"vite": "^5.0.10"

@@ -27,0 +27,0 @@ },

@@ -5,3 +5,3 @@ // https://vike.dev/onRenderClient

import ReactDOM from 'react-dom/client'
import { PageShell } from './PageShell'
import { PageLayout } from './PageLayout'
import { getPageTitle } from './getPageTitle'

@@ -21,5 +21,5 @@

const page = (
<PageShell pageContext={pageContext}>
<PageLayout pageContext={pageContext}>
<Page />
</PageShell>
</PageLayout>
)

@@ -26,0 +26,0 @@ if (pageContext.isHydration) {

@@ -5,3 +5,3 @@ // https://vike.dev/onRenderHtml

import ReactDOMServer from 'react-dom/server'
import { PageShell } from './PageShell'
import { PageLayout } from './PageLayout'
import { escapeInject, dangerouslySkipEscape } from 'vike/server'

@@ -20,5 +20,5 @@ import logoUrl from './logo.svg'

const pageHtml = ReactDOMServer.renderToString(
<PageShell pageContext={pageContext}>
<PageLayout pageContext={pageContext}>
<Page />
</PageShell>
</PageLayout>
)

@@ -25,0 +25,0 @@

@@ -24,3 +24,3 @@ {

"typescript": "^5.3.3",
"vike": "^0.4.171",
"vike": "^0.4.173",
"vite": "^5.0.10",

@@ -27,0 +27,0 @@ "vue": "^3.3.10",

export { createApp }
import { createSSRApp, defineComponent, h, markRaw, reactive, ref } from 'vue'
import PageShell from './PageShell.vue'
import { createSSRApp, h, markRaw, reactive, ref } from 'vue'
import PageLayout from './PageLayout.vue'
import { setPageContext } from './usePageContext'
import type { PageContext } from 'vike/types'
import { setData } from './useData'
import { isObject, objectAssign } from './utils'

@@ -12,13 +14,17 @@ function createApp(pageContext: PageContext) {

const pageRef = ref(markRaw(Page))
const PageWithShell = defineComponent({
const PageWithLayout = {
render() {
return h(PageShell, {}, { default: () => h(pageRef.value) })
return h(PageLayout, {}, { default: () => h(pageRef.value) })
}
})
}
const app = createSSRApp(PageWithShell)
const app = createSSRApp(PageWithLayout)
// We use `app.changePage()` to do Client Routing, see `+onRenderClient.ts`
// app.changePage() is called upon navigation, see +onRenderClient.ts
objectAssign(app, {
changePage: (pageContext: PageContext) => {
const data = pageContext.data ?? {}
assertDataIsObject(data)
Object.assign(dataReactive, data)
Object.assign(pageContextReactive, pageContext)

@@ -29,8 +35,8 @@ pageRef.value = markRaw(pageContext.Page)

// When doing Client Routing, we mutate pageContext (see usage of `app.changePage()` in `+onRenderClient.ts`).
// We therefore use a reactive pageContext.
const data = pageContext.data ?? {}
assertDataIsObject(data)
const dataReactive = reactive(data)
const pageContextReactive = reactive(pageContext)
// Make pageContext available from any Vue component
setPageContext(app, pageContextReactive)
setData(app, dataReactive)

@@ -40,8 +46,4 @@ return app

// Same as `Object.assign()` but with type inference
function objectAssign<Obj extends object, ObjAddendum>(
obj: Obj,
objAddendum: ObjAddendum
): asserts obj is Obj & ObjAddendum {
Object.assign(obj, objAddendum)
function assertDataIsObject(data: unknown): asserts data is Record<string, unknown> {
if (!isObject(data)) throw new Error('Return value of data() hook should be an object, undefined, or null')
}
// https://vike.dev/useData
export { useData }
export { setData }
import { type ComputedRef, computed } from 'vue'
import { usePageContext } from './usePageContext'
import { inject } from 'vue'
import type { App } from 'vue'
const key = Symbol()
/** https://vike.dev/useData */
function useData<Data>(): ComputedRef<Data> {
const data = computed(() => (usePageContext() as { data: Data }).data)
return data
function useData<Data>(): Data {
const data = inject(key)
if (!data) throw new Error('setData() not called')
return data as any
}
function setData(app: App, data: unknown): void {
app.provide(key, data)
}

@@ -12,3 +12,3 @@ // https://vike.dev/usePageContext

/** https://vike.dev/usePageContext */
function usePageContext() {
function usePageContext(): PageContext {
const pageContext = inject(key)

@@ -19,4 +19,4 @@ if (!pageContext) throw new Error('setPageContext() not called in parent')

function setPageContext(app: App, pageContext: PageContext) {
function setPageContext(app: App, pageContext: PageContext): void {
app.provide(key, pageContext)
}

@@ -18,3 +18,3 @@ {

"sirv": "^2.0.3",
"vike": "^0.4.171",
"vike": "^0.4.173",
"vite": "^5.0.10",

@@ -21,0 +21,0 @@ "vue": "^3.3.10"

export { createApp }
import { createSSRApp, defineComponent, h, markRaw, reactive, ref } from 'vue'
import PageShell from './PageShell.vue'
import { createSSRApp, h, markRaw, reactive, ref } from 'vue'
import PageLayout from './PageLayout.vue'
import { setPageContext } from './usePageContext'
import { setData } from './useData'
import { isObject } from './utils'

@@ -12,13 +14,16 @@ function createApp(pageContext) {

const PageWithShell = defineComponent({
const PageWithLayout = {
render() {
return h(PageShell, {}, { default: () => h(pageRef.value) })
return h(PageLayout, {}, { default: () => h(pageRef.value) })
}
})
}
const app = createSSRApp(PageWithShell)
const app = createSSRApp(PageWithLayout)
// We use `app.changePage()` to do Client Routing, see `+onRenderClient.ts`
// app.changePage() is called upon navigation, see +onRenderClient.ts
Object.assign(app, {
changePage: (pageContext) => {
const data = pageContext.data ?? {}
assertDataIsObject(data)
Object.assign(dataReactive, data)
Object.assign(pageContextReactive, pageContext)

@@ -29,10 +34,14 @@ pageRef.value = markRaw(pageContext.Page)

// When doing Client Routing, we mutate pageContext (see usage of `app.changePage()` in `+onRenderClient.ts`).
// We therefore use a reactive pageContext.
const data = pageContext.data ?? {}
assertDataIsObject(data)
const dataReactive = reactive(data)
const pageContextReactive = reactive(pageContext)
// Make pageContext available from any Vue component
setPageContext(app, pageContextReactive)
setData(app, dataReactive)
return app
}
function assertDataIsObject(data) {
if (!isObject(data)) throw new Error('Return value of data() hook should be an object, undefined, or null')
}
// https://vike.dev/useData
export { useData }
export { setData }
import { computed } from 'vue'
import { usePageContext } from './usePageContext'
import { inject } from 'vue'
const key = Symbol()
/** https://vike.dev/useData */
function useData() {
const data = computed(() => usePageContext().data)
const data = inject(key)
if (!data) throw new Error('setData() not called')
return data
}
function setData(app, data) {
app.provide(key, data)
}
{
"name": "create-vike",
"version": "0.0.336",
"version": "0.0.338",
"license": "MIT",

@@ -5,0 +5,0 @@ "bin": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc