Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "qwik-monorepo",
"version": "0.0.25",
"version": "0.0.26",
"scripts": {
"build": "yarn node scripts --tsc --build --api --platform-binding-wasm-copy",
"build.full": "yarn node scripts --tsc --build --api --eslint --qwikcity --platform-binding --wasm",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-qwik",
"version": "0.0.25",
"version": "0.0.26",
"description": "Interactive CLI and API for generating Qwik projects.",
"bin": "create-qwik",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@builder.io/partytown": "^0.6.0",
"@builder.io/qwik": "0.0.25",
"@builder.io/qwik": "0.0.24",
"@builder.io/qwik-city": "0.0.12",
"@cloudflare/kv-asset-handler": "0.2.0",
"autoprefixer": "10.4.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-qwik",
"version": "0.0.25",
"version": "0.0.26",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "index.js",
"author": "Builder Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@builder.io/qwik": ">=0.0.22"
},
"devDependencies": {
"@builder.io/qwik": "0.0.25",
"@builder.io/qwik": "0.0.24",
"@microsoft/api-extractor": "7.24.2",
"@types/github-slugger": "^1.3.0",
"@types/marked": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "0.0.25",
"version": "0.0.26",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "./dist/core.cjs",
"module": "./dist/core.mjs",
Expand Down
6 changes: 6 additions & 0 deletions packages/qwik/src/core/import/qrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
QError_runtimeQrlNoElement,
QError_unknownTypeArgument,
} from '../error/error';
import { qDev } from '../util/qdev';
import { getProxyTarget } from '../object/store';
import { verifySerializable } from '../object/q-object';

let runtimeSymbolId = 0;
const RUNTIME_QRL = '/runtimeQRL';
Expand Down Expand Up @@ -155,6 +158,9 @@ const unwrapLexicalScope = (lexicalScope: any[] | null) => {
if (isArray(lexicalScope)) {
for (let i = 0; i < lexicalScope.length; i++) {
lexicalScope[i] = unwrapSubscriber(lexicalScope[i]);
if (qDev) {
verifySerializable(getProxyTarget(lexicalScope[i]) ?? lexicalScope[i]);
}
}
}
return lexicalScope;
Expand Down
36 changes: 21 additions & 15 deletions packages/qwik/src/core/object/q-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Subscriber, unwrapSubscriber } from '../use/use-subscriber';
import { tryGetContext } from '../props/props';
import { RenderEvent } from '../util/markers';
import { getProxyTarget } from './store';
import { isArray, isObject } from '../util/types';
import { isArray, isFunction, isObject } from '../util/types';

export type ObjToProxyMap = WeakMap<any, any>;
export type QObject<T extends {}> = T & { __brand__: 'QObject' };
Expand Down Expand Up @@ -336,29 +336,35 @@ export const notifyWatch = (watch: WatchDescriptor) => {
}
};

const verifySerializable = <T>(value: T) => {
export const verifySerializable = <T>(value: T) => {
if (value == null) {
return;
}
const type = typeof value;
if (type === 'object') {
if (isArray(value)) return;
if (Object.getPrototypeOf(value) === Object.prototype) return;
if (shouldSerialize(value)) return;
if (isQrl(value)) return;
if (isElement(value)) return;
if (isDocument(value)) return;
}
if (['boolean', 'string', 'number'].includes(type)) {
return;
if (shouldSerialize(value)) {
switch (typeof value) {
case 'object':
if (isArray(value)) return;
if (Object.getPrototypeOf(value) === Object.prototype) return;
if (isQrl(value)) return;
if (isElement(value)) return;
if (isDocument(value)) return;
break;
case 'boolean':
case 'string':
case 'number':
return;
}
throw qError(QError_verifySerializable, value);
}
throw qError(QError_verifySerializable);
};

const noSerializeSet = /*#__PURE__*/ new WeakSet<any>();

export const shouldSerialize = (obj: any): boolean => {
return !noSerializeSet.has(obj);
if (isObject(obj) || isFunction(obj)) {
return !noSerializeSet.has(obj);
}
return true;
};

/**
Expand Down
13 changes: 10 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@builder.io/qwik-city@workspace:packages/qwik-city"
dependencies:
"@builder.io/qwik": 0.0.25
"@builder.io/qwik": 0.0.24
"@mdx-js/mdx": ^2.1.1
"@microsoft/api-extractor": 7.24.2
"@types/github-slugger": ^1.3.0
Expand Down Expand Up @@ -453,7 +453,14 @@ __metadata:
languageName: node
linkType: hard

"@builder.io/qwik@0.0.25, @builder.io/qwik@workspace:packages/qwik":
"@builder.io/qwik@npm:0.0.24":
version: 0.0.24
resolution: "@builder.io/qwik@npm:0.0.24"
checksum: 8c51e19933c05f30711091c44d8b1d8abaa504aec83439a4434a814fd2cfbf2dd24b4bc218741796d6ef0ccb872196656198a1658a1cfb58a037ae3afc8a1da5
languageName: node
linkType: hard

"@builder.io/qwik@workspace:packages/qwik":
version: 0.0.0-use.local
resolution: "@builder.io/qwik@workspace:packages/qwik"
languageName: unknown
Expand Down Expand Up @@ -7651,7 +7658,7 @@ __metadata:
resolution: "qwik-docs@workspace:packages/docs"
dependencies:
"@builder.io/partytown": ^0.6.0
"@builder.io/qwik": 0.0.25
"@builder.io/qwik": 0.0.24
"@builder.io/qwik-city": 0.0.12
"@cloudflare/kv-asset-handler": 0.2.0
autoprefixer: 10.4.7
Expand Down