How to use exposeSetupStateOnRenderContext method in Playwright Internal

Best JavaScript code snippet using playwright-internal

size-check.global.js

Source:size-check.global.js Github

copy

Full Screen

...4461 });4462 }4463 }4464 // dev only4465 function exposeSetupStateOnRenderContext(instance) {4466 const { ctx, setupState } = instance;4467 Object.keys(toRaw(setupState)).forEach(key => {4468 Object.defineProperty(ctx, key, {4469 enumerable: true,4470 configurable: true,4471 get: () => setupState[key],4472 set: NOOP4473 });4474 });4475 }4476 const emptyAppContext = createAppContext();4477 let uid$1 = 0;4478 function createComponentInstance(vnode, parent, suspense) {4479 // inherit parent app context - or - if root, adopt from root vnode4480 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;4481 const instance = {4482 uid: uid$1++,4483 vnode,4484 parent,4485 appContext,4486 type: vnode.type,4487 root: null,4488 next: null,4489 subTree: null,4490 update: null,4491 render: null,4492 proxy: null,4493 withProxy: null,4494 effects: null,4495 provides: parent ? parent.provides : Object.create(appContext.provides),4496 accessCache: null,4497 renderCache: [],4498 // state4499 ctx: EMPTY_OBJ,4500 data: EMPTY_OBJ,4501 props: EMPTY_OBJ,4502 attrs: EMPTY_OBJ,4503 slots: EMPTY_OBJ,4504 refs: EMPTY_OBJ,4505 setupState: EMPTY_OBJ,4506 setupContext: null,4507 // per-instance asset storage (mutable during options resolution)4508 components: Object.create(appContext.components),4509 directives: Object.create(appContext.directives),4510 // suspense related4511 suspense,4512 asyncDep: null,4513 asyncResolved: false,4514 // lifecycle hooks4515 // not using enums here because it results in computed properties4516 isMounted: false,4517 isUnmounted: false,4518 isDeactivated: false,4519 bc: null,4520 c: null,4521 bm: null,4522 m: null,4523 bu: null,4524 u: null,4525 um: null,4526 bum: null,4527 da: null,4528 a: null,4529 rtg: null,4530 rtc: null,4531 ec: null,4532 emit: null // to be set immediately4533 };4534 {4535 instance.ctx = createRenderContext(instance);4536 }4537 instance.root = parent ? parent.root : instance;4538 instance.emit = emit.bind(null, instance);4539 return instance;4540 }4541 let currentInstance = null;4542 const setCurrentInstance = (instance) => {4543 currentInstance = instance;4544 };4545 const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');4546 function validateComponentName(name, config) {4547 const appIsNativeTag = config.isNativeTag || NO;4548 if (isBuiltInTag(name) || appIsNativeTag(name)) {4549 warn('Do not use built-in or reserved HTML elements as component id: ' + name);4550 }4551 }4552 let isInSSRComponentSetup = false;4553 function setupComponent(instance, isSSR = false) {4554 isInSSRComponentSetup = isSSR;4555 const { props, children, shapeFlag } = instance.vnode;4556 const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;4557 initProps(instance, props, isStateful, isSSR);4558 initSlots(instance, children);4559 const setupResult = isStateful4560 ? setupStatefulComponent(instance, isSSR)4561 : undefined;4562 isInSSRComponentSetup = false;4563 return setupResult;4564 }4565 function setupStatefulComponent(instance, isSSR) {4566 const Component = instance.type;4567 {4568 if (Component.name) {4569 validateComponentName(Component.name, instance.appContext.config);4570 }4571 if (Component.components) {4572 const names = Object.keys(Component.components);4573 for (let i = 0; i < names.length; i++) {4574 validateComponentName(names[i], instance.appContext.config);4575 }4576 }4577 if (Component.directives) {4578 const names = Object.keys(Component.directives);4579 for (let i = 0; i < names.length; i++) {4580 validateDirectiveName(names[i]);4581 }4582 }4583 }4584 // 0. create render proxy property access cache4585 instance.accessCache = {};4586 // 1. create public instance / render proxy4587 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);4588 {4589 exposePropsOnRenderContext(instance);4590 }4591 // 2. call setup()4592 const { setup } = Component;4593 if (setup) {4594 const setupContext = (instance.setupContext =4595 setup.length > 1 ? createSetupContext(instance) : null);4596 currentInstance = instance;4597 pauseTracking();4598 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);4599 resetTracking();4600 currentInstance = null;4601 if (isPromise(setupResult)) {4602 if (isSSR) {4603 // return the promise so server-renderer can wait on it4604 return setupResult.then((resolvedResult) => {4605 handleSetupResult(instance, resolvedResult);4606 });4607 }4608 else {4609 // async setup returned Promise.4610 // bail here and wait for re-entry.4611 instance.asyncDep = setupResult;4612 }4613 }4614 else {4615 handleSetupResult(instance, setupResult);4616 }4617 }4618 else {4619 finishComponentSetup(instance);4620 }4621 }4622 function handleSetupResult(instance, setupResult, isSSR) {4623 if (isFunction(setupResult)) {4624 // setup returned an inline render function4625 instance.render = setupResult;4626 }4627 else if (isObject(setupResult)) {4628 if ( isVNode(setupResult)) {4629 warn(`setup() should not return VNodes directly - ` +4630 `return a render function instead.`);4631 }4632 // setup returned bindings.4633 // assuming a render function compiled from template is present.4634 instance.setupState = reactive(setupResult);4635 {4636 exposeSetupStateOnRenderContext(instance);4637 }4638 }4639 else if ( setupResult !== undefined) {4640 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);4641 }4642 finishComponentSetup(instance);4643 }4644 function finishComponentSetup(instance, isSSR) {4645 const Component = instance.type;4646 // template / render function normalization4647 if (!instance.render) {4648 if ( !Component.render) {4649 /* istanbul ignore if */4650 if ( Component.template) { ...

Full Screen

Full Screen

bundle.esm.js

Source:bundle.esm.js Github

copy

Full Screen

...4639 });4640 }4641}4642// dev only4643function exposeSetupStateOnRenderContext(instance) {4644 const { ctx, setupState } = instance;4645 Object.keys(toRaw(setupState)).forEach(key => {4646 Object.defineProperty(ctx, key, {4647 enumerable: true,4648 configurable: true,4649 get: () => setupState[key],4650 set: NOOP4651 });4652 });4653}4654const emptyAppContext = createAppContext();4655let uid$1 = 0;4656function createComponentInstance(vnode, parent, suspense) {4657 // inherit parent app context - or - if root, adopt from root vnode4658 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;4659 const instance = {4660 uid: uid$1++,4661 vnode,4662 parent,4663 appContext,4664 type: vnode.type,4665 root: null,4666 next: null,4667 subTree: null,4668 update: null,4669 render: null,4670 proxy: null,4671 withProxy: null,4672 effects: null,4673 provides: parent ? parent.provides : Object.create(appContext.provides),4674 accessCache: null,4675 renderCache: [],4676 // state4677 ctx: EMPTY_OBJ,4678 data: EMPTY_OBJ,4679 props: EMPTY_OBJ,4680 attrs: EMPTY_OBJ,4681 slots: EMPTY_OBJ,4682 refs: EMPTY_OBJ,4683 setupState: EMPTY_OBJ,4684 setupContext: null,4685 // per-instance asset storage (mutable during options resolution)4686 components: Object.create(appContext.components),4687 directives: Object.create(appContext.directives),4688 // suspense related4689 suspense,4690 asyncDep: null,4691 asyncResolved: false,4692 // lifecycle hooks4693 // not using enums here because it results in computed properties4694 isMounted: false,4695 isUnmounted: false,4696 isDeactivated: false,4697 bc: null,4698 c: null,4699 bm: null,4700 m: null,4701 bu: null,4702 u: null,4703 um: null,4704 bum: null,4705 da: null,4706 a: null,4707 rtg: null,4708 rtc: null,4709 ec: null,4710 emit: null // to be set immediately4711 };4712 {4713 instance.ctx = createRenderContext(instance);4714 }4715 instance.root = parent ? parent.root : instance;4716 instance.emit = emit.bind(null, instance);4717 return instance;4718}4719let currentInstance = null;4720const setCurrentInstance = (instance) => {4721 currentInstance = instance;4722};4723const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');4724function validateComponentName(name, config) {4725 const appIsNativeTag = config.isNativeTag || NO;4726 if (isBuiltInTag(name) || appIsNativeTag(name)) {4727 warn('Do not use built-in or reserved HTML elements as component id: ' + name);4728 }4729}4730let isInSSRComponentSetup = false;4731function setupComponent(instance, isSSR = false) {4732 isInSSRComponentSetup = isSSR;4733 const { props, children, shapeFlag } = instance.vnode;4734 const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;4735 initProps(instance, props, isStateful, isSSR);4736 initSlots(instance, children);4737 const setupResult = isStateful4738 ? setupStatefulComponent(instance, isSSR)4739 : undefined;4740 isInSSRComponentSetup = false;4741 return setupResult;4742}4743function setupStatefulComponent(instance, isSSR) {4744 const Component = instance.type;4745 {4746 if (Component.name) {4747 validateComponentName(Component.name, instance.appContext.config);4748 }4749 if (Component.components) {4750 const names = Object.keys(Component.components);4751 for (let i = 0; i < names.length; i++) {4752 validateComponentName(names[i], instance.appContext.config);4753 }4754 }4755 if (Component.directives) {4756 const names = Object.keys(Component.directives);4757 for (let i = 0; i < names.length; i++) {4758 validateDirectiveName(names[i]);4759 }4760 }4761 }4762 // 0. create render proxy property access cache4763 instance.accessCache = {};4764 // 1. create public instance / render proxy4765 // also mark it raw so it's never observed4766 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);4767 {4768 exposePropsOnRenderContext(instance);4769 }4770 // 2. call setup()4771 const { setup } = Component;4772 if (setup) {4773 const setupContext = (instance.setupContext =4774 setup.length > 1 ? createSetupContext(instance) : null);4775 currentInstance = instance;4776 pauseTracking();4777 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);4778 resetTracking();4779 currentInstance = null;4780 if (isPromise(setupResult)) {4781 if (isSSR) {4782 // return the promise so server-renderer can wait on it4783 return setupResult.then((resolvedResult) => {4784 handleSetupResult(instance, resolvedResult);4785 });4786 }4787 else {4788 // async setup returned Promise.4789 // bail here and wait for re-entry.4790 instance.asyncDep = setupResult;4791 }4792 }4793 else {4794 handleSetupResult(instance, setupResult);4795 }4796 }4797 else {4798 finishComponentSetup(instance);4799 }4800}4801function handleSetupResult(instance, setupResult, isSSR) {4802 if (isFunction(setupResult)) {4803 // setup returned an inline render function4804 instance.render = setupResult;4805 }4806 else if (isObject(setupResult)) {4807 if ( isVNode(setupResult)) {4808 warn(`setup() should not return VNodes directly - ` +4809 `return a render function instead.`);4810 }4811 // setup returned bindings.4812 // assuming a render function compiled from template is present.4813 instance.setupState = reactive(setupResult);4814 {4815 exposeSetupStateOnRenderContext(instance);4816 }4817 }4818 else if ( setupResult !== undefined) {4819 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);4820 }4821 finishComponentSetup(instance);4822}4823function finishComponentSetup(instance, isSSR) {4824 const Component = instance.type;4825 // template / render function normalization4826 if (!instance.render) {4827 if ( !Component.render) {4828 /* istanbul ignore if */4829 if ( Component.template) { ...

Full Screen

Full Screen

vendor.js

Source:vendor.js Github

copy

Full Screen

...3081 });3082 });3083 }3084}3085function exposeSetupStateOnRenderContext(instance) {3086 const { ctx, setupState } = instance;3087 Object.keys(toRaw(setupState)).forEach((key) => {3088 if (!setupState.__isScriptSetup) {3089 if (key[0] === "$" || key[0] === "_") {3090 warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" which are reserved prefixes for Vue internals.`);3091 return;3092 }3093 Object.defineProperty(ctx, key, {3094 enumerable: true,3095 configurable: true,3096 get: () => setupState[key],3097 set: NOOP3098 });3099 }3100 });3101}3102const emptyAppContext = createAppContext();3103let uid$1 = 0;3104function createComponentInstance(vnode, parent, suspense) {3105 const type = vnode.type;3106 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;3107 const instance = {3108 uid: uid$1++,3109 vnode,3110 type,3111 parent,3112 appContext,3113 root: null,3114 next: null,3115 subTree: null,3116 effect: null,3117 update: null,3118 scope: new EffectScope(true),3119 render: null,3120 proxy: null,3121 exposed: null,3122 exposeProxy: null,3123 withProxy: null,3124 provides: parent ? parent.provides : Object.create(appContext.provides),3125 accessCache: null,3126 renderCache: [],3127 components: null,3128 directives: null,3129 propsOptions: normalizePropsOptions(type, appContext),3130 emitsOptions: normalizeEmitsOptions(type, appContext),3131 emit: null,3132 emitted: null,3133 propsDefaults: EMPTY_OBJ,3134 inheritAttrs: type.inheritAttrs,3135 ctx: EMPTY_OBJ,3136 data: EMPTY_OBJ,3137 props: EMPTY_OBJ,3138 attrs: EMPTY_OBJ,3139 slots: EMPTY_OBJ,3140 refs: EMPTY_OBJ,3141 setupState: EMPTY_OBJ,3142 setupContext: null,3143 suspense,3144 suspenseId: suspense ? suspense.pendingId : 0,3145 asyncDep: null,3146 asyncResolved: false,3147 isMounted: false,3148 isUnmounted: false,3149 isDeactivated: false,3150 bc: null,3151 c: null,3152 bm: null,3153 m: null,3154 bu: null,3155 u: null,3156 um: null,3157 bum: null,3158 da: null,3159 a: null,3160 rtg: null,3161 rtc: null,3162 ec: null,3163 sp: null3164 };3165 {3166 instance.ctx = createDevRenderContext(instance);3167 }3168 instance.root = parent ? parent.root : instance;3169 instance.emit = emit$1.bind(null, instance);3170 if (vnode.ce) {3171 vnode.ce(instance);3172 }3173 return instance;3174}3175let currentInstance = null;3176const getCurrentInstance = () => currentInstance || currentRenderingInstance;3177const setCurrentInstance = (instance) => {3178 currentInstance = instance;3179 instance.scope.on();3180};3181const unsetCurrentInstance = () => {3182 currentInstance && currentInstance.scope.off();3183 currentInstance = null;3184};3185const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");3186function validateComponentName(name, config) {3187 const appIsNativeTag = config.isNativeTag || NO;3188 if (isBuiltInTag(name) || appIsNativeTag(name)) {3189 warn$1("Do not use built-in or reserved HTML elements as component id: " + name);3190 }3191}3192function isStatefulComponent(instance) {3193 return instance.vnode.shapeFlag & 4;3194}3195let isInSSRComponentSetup = false;3196function setupComponent(instance, isSSR = false) {3197 isInSSRComponentSetup = isSSR;3198 const { props } = instance.vnode;3199 const isStateful = isStatefulComponent(instance);3200 initProps$1(instance, props, isStateful, isSSR);3201 const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;3202 isInSSRComponentSetup = false;3203 return setupResult;3204}3205function setupStatefulComponent(instance, isSSR) {3206 const Component2 = instance.type;3207 {3208 if (Component2.name) {3209 validateComponentName(Component2.name, instance.appContext.config);3210 }3211 if (Component2.components) {3212 const names = Object.keys(Component2.components);3213 for (let i = 0; i < names.length; i++) {3214 validateComponentName(names[i], instance.appContext.config);3215 }3216 }3217 if (Component2.directives) {3218 const names = Object.keys(Component2.directives);3219 for (let i = 0; i < names.length; i++) {3220 validateDirectiveName(names[i]);3221 }3222 }3223 if (Component2.compilerOptions && isRuntimeOnly()) {3224 warn$1(`"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`);3225 }3226 }3227 instance.accessCache = Object.create(null);3228 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));3229 {3230 exposePropsOnRenderContext(instance);3231 }3232 const { setup } = Component2;3233 if (setup) {3234 const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;3235 setCurrentInstance(instance);3236 pauseTracking();3237 const setupResult = callWithErrorHandling(setup, instance, 0, [shallowReadonly(instance.props), setupContext]);3238 resetTracking();3239 unsetCurrentInstance();3240 if (isPromise(setupResult)) {3241 setupResult.then(unsetCurrentInstance, unsetCurrentInstance);3242 {3243 warn$1(`setup() returned a Promise, but the version of Vue you are using does not support it yet.`);3244 }3245 } else {3246 handleSetupResult(instance, setupResult, isSSR);3247 }3248 } else {3249 finishComponentSetup(instance, isSSR);3250 }3251}3252function handleSetupResult(instance, setupResult, isSSR) {3253 if (isFunction(setupResult)) {3254 {3255 instance.render = setupResult;3256 }3257 } else if (isObject(setupResult)) {3258 if (isVNode(setupResult)) {3259 warn$1(`setup() should not return VNodes directly - return a render function instead.`);3260 }3261 {3262 instance.devtoolsRawSetupState = setupResult;3263 }3264 instance.setupState = proxyRefs(setupResult);3265 {3266 exposeSetupStateOnRenderContext(instance);3267 }3268 } else if (setupResult !== void 0) {3269 warn$1(`setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`);3270 }3271 finishComponentSetup(instance, isSSR);3272}3273let compile;3274const isRuntimeOnly = () => !compile;3275function finishComponentSetup(instance, isSSR, skipOptions) {3276 const Component2 = instance.type;3277 if (!instance.render) {3278 instance.render = Component2.render || NOOP;3279 }3280 {...

Full Screen

Full Screen

vue.runtime.esm.js

Source:vue.runtime.esm.js Github

copy

Full Screen

...2739 });2740 }2741}2742// dev only2743function exposeSetupStateOnRenderContext(instance) {2744 const { ctx, setupState } = instance;2745 Object.keys(toRaw(setupState)).forEach(key => {2746 if (key[0] === '$' || key[0] === '_') {2747 warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +2748 `which are reserved prefixes for Vue internals.`);2749 return;2750 }2751 Object.defineProperty(ctx, key, {2752 enumerable: true,2753 configurable: true,2754 get: () => setupState[key],2755 set: NOOP2756 });2757 });2758}2759const emptyAppContext = createAppContext();2760let uid$2 = 0;2761function createComponentInstance(vnode, parent, suspense) {2762 const type = vnode.type;2763 // inherit parent app context - or - if root, adopt from root vnode2764 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;2765 const instance = {2766 uid: uid$2++,2767 vnode,2768 type,2769 parent,2770 appContext,2771 root: null,2772 next: null,2773 subTree: null,2774 update: null,2775 render: null,2776 proxy: null,2777 withProxy: null,2778 effects: null,2779 provides: parent ? parent.provides : Object.create(appContext.provides),2780 accessCache: null,2781 renderCache: [],2782 // local resovled assets2783 components: null,2784 directives: null,2785 // resolved props and emits options2786 propsOptions: normalizePropsOptions(type, appContext),2787 emitsOptions: normalizeEmitsOptions(type, appContext),2788 // emit2789 emit: null,2790 emitted: null,2791 // state2792 ctx: EMPTY_OBJ,2793 data: EMPTY_OBJ,2794 props: EMPTY_OBJ,2795 attrs: EMPTY_OBJ,2796 slots: EMPTY_OBJ,2797 refs: EMPTY_OBJ,2798 setupState: EMPTY_OBJ,2799 setupContext: null,2800 // suspense related2801 suspense,2802 suspenseId: suspense ? suspense.pendingId : 0,2803 asyncDep: null,2804 asyncResolved: false,2805 // lifecycle hooks2806 // not using enums here because it results in computed properties2807 isMounted: false,2808 isUnmounted: false,2809 isDeactivated: false,2810 bc: null,2811 c: null,2812 bm: null,2813 m: null,2814 bu: null,2815 u: null,2816 um: null,2817 bum: null,2818 da: null,2819 a: null,2820 rtg: null,2821 rtc: null,2822 ec: null2823 };2824 if ((process.env.NODE_ENV !== 'production')) {2825 instance.ctx = createRenderContext(instance);2826 }2827 else {2828 instance.ctx = { _: instance };2829 }2830 instance.root = parent ? parent.root : instance;2831 instance.emit = emit.bind(null, instance);2832 if ((process.env.NODE_ENV !== 'production') || false) ;2833 return instance;2834}2835let currentInstance = null;2836const setCurrentInstance = (instance) => {2837 currentInstance = instance;2838};2839const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');2840function validateComponentName(name, config) {2841 const appIsNativeTag = config.isNativeTag || NO;2842 if (isBuiltInTag(name) || appIsNativeTag(name)) {2843 warn('Do not use built-in or reserved HTML elements as component id: ' + name);2844 }2845}2846let isInSSRComponentSetup = false;2847function setupComponent(instance, isSSR = false) {2848 isInSSRComponentSetup = isSSR;2849 const { props, /* children, */ shapeFlag } = instance.vnode;2850 const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;2851 initProps(instance, props, isStateful, isSSR);2852 // initSlots(instance, children) // fixed by xxxxxx2853 const setupResult = isStateful2854 ? setupStatefulComponent(instance, isSSR)2855 : undefined;2856 isInSSRComponentSetup = false;2857 return setupResult;2858}2859function setupStatefulComponent(instance, isSSR) {2860 const Component = instance.type;2861 if ((process.env.NODE_ENV !== 'production')) {2862 if (Component.name) {2863 validateComponentName(Component.name, instance.appContext.config);2864 }2865 if (Component.components) {2866 const names = Object.keys(Component.components);2867 for (let i = 0; i < names.length; i++) {2868 validateComponentName(names[i], instance.appContext.config);2869 }2870 }2871 if (Component.directives) {2872 const names = Object.keys(Component.directives);2873 for (let i = 0; i < names.length; i++) {2874 validateDirectiveName(names[i]);2875 }2876 }2877 }2878 // 0. create render proxy property access cache2879 instance.accessCache = {};2880 // 1. create public instance / render proxy2881 // also mark it raw so it's never observed2882 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);2883 if ((process.env.NODE_ENV !== 'production')) {2884 exposePropsOnRenderContext(instance);2885 }2886 // 2. call setup()2887 const { setup } = Component;2888 if (setup) {2889 const setupContext = (instance.setupContext =2890 setup.length > 1 ? createSetupContext(instance) : null);2891 currentInstance = instance;2892 pauseTracking();2893 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [(process.env.NODE_ENV !== 'production') ? shallowReadonly(instance.props) : instance.props, setupContext]);2894 resetTracking();2895 currentInstance = null;2896 if (isPromise(setupResult)) {2897 if (isSSR) {2898 // return the promise so server-renderer can wait on it2899 return setupResult.then((resolvedResult) => {2900 handleSetupResult(instance, resolvedResult);2901 });2902 }2903 else if ((process.env.NODE_ENV !== 'production')) {2904 warn(`setup() returned a Promise, but the version of Vue you are using ` +2905 `does not support it yet.`);2906 }2907 }2908 else {2909 handleSetupResult(instance, setupResult);2910 }2911 }2912 else {2913 finishComponentSetup(instance);2914 }2915}2916function handleSetupResult(instance, setupResult, isSSR) {2917 if (isFunction(setupResult)) {2918 // setup returned an inline render function2919 instance.render = setupResult;2920 }2921 else if (isObject(setupResult)) {2922 // if ((process.env.NODE_ENV !== 'production') && isVNode(setupResult)) {2923 // warn(2924 // `setup() should not return VNodes directly - ` +2925 // `return a render function instead.`2926 // )2927 // }2928 // setup returned bindings.2929 // assuming a render function compiled from template is present.2930 if ((process.env.NODE_ENV !== 'production') || false) {2931 instance.devtoolsRawSetupState = setupResult;2932 }2933 instance.setupState = proxyRefs(setupResult);2934 if ((process.env.NODE_ENV !== 'production')) {2935 exposeSetupStateOnRenderContext(instance);2936 }2937 }2938 else if ((process.env.NODE_ENV !== 'production') && setupResult !== undefined) {2939 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);2940 }2941 finishComponentSetup(instance);2942}2943function finishComponentSetup(instance, isSSR) {2944 const Component = instance.type;2945 // template / render function normalization2946 if (!instance.render) {2947 instance.render = (Component.render || NOOP);2948 // for runtime-compiled render functions using `with` blocks, the render2949 // proxy used needs a different `has` handler which is more performant and ...

Full Screen

Full Screen

render.js

Source:render.js Github

copy

Full Screen

...907 instance.devtoolsRawSetupState = setupResult;908 }909 instance.setupState = proxyRefs(setupResult);910 {911 exposeSetupStateOnRenderContext(instance);912 }913 }914 else if ( setupResult !== undefined) {915 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);916 }917 finishComponentSetup(instance);918 }919 function finishComponentSetup(instance, isSSR) {920 const Component = instance.type;921 // template / render function normalization922 if (!instance.render) {923 // could be set from setup()924 if (compile && Component.template && !Component.render) {925 {926 startMeasure(instance, `compile`);927 }928 Component.render = compile(Component.template, {929 isCustomElement: instance.appContext.config.isCustomElement,930 delimiters: Component.delimiters931 });932 {933 endMeasure(instance, `compile`);934 }935 }936 instance.render = (Component.render || NOOP);937 // for runtime-compiled render functions using `with` blocks, the render938 // proxy used needs a different `has` handler which is more performant and939 // also only allows a whitelist of globals to fallthrough.940 if (instance.render._rc) {941 instance.withProxy = new Proxy(instance.ctx, RuntimeCompiledPublicInstanceProxyHandlers);942 }943 }944 // support for 2.x options945 {946 currentInstance = instance;947 applyOptions(instance, Component);948 currentInstance = null;949 }950 // warn missing template/render951 if ( !Component.render && instance.render === NOOP) {952 /* istanbul ignore if */953 if (!compile && Component.template) {954 warn(`Component provided template option but ` +955 `runtime compilation is not supported in this build of Vue.` +956 ( ` Use "vue.esm-browser.js" instead.`957 ) /* should not happen */);958 }959 else {960 warn(`Component is missing template or render function.`);961 }962 }963 }964 // Return a reactive-copy of the original object, where only the root level965 // properties are readonly, and does NOT unwrap refs nor recursively convert966 // returned properties.967 // This is used for creating the props proxy object for stateful components.968 function shallowReadonly(target) {969 return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);970 }971 const shallowReadonlyHandlers = extend({}, readonlyHandlers, {972 get: shallowReadonlyGet973 });974 const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);975 const readonlyHandlers = {976 get: readonlyGet,977 set(target, key) {978 {979 console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);980 }981 return true;982 },983 deleteProperty(target, key) {984 {985 console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);986 }987 return true;988 }989 };990 function createGetter(isReadonly = false, shallow = false) {991 return function get(target, key, receiver) {992 if (key === "__v_isReactive" /* IS_REACTIVE */) {993 return !isReadonly;994 }995 else if (key === "__v_isReadonly" /* IS_READONLY */) {996 return isReadonly;997 }998 else if (key === "__v_raw" /* RAW */ &&999 receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {1000 return target;1001 }1002 const targetIsArray = isArray(target);1003 if (targetIsArray && hasOwn(arrayInstrumentations, key)) {1004 return Reflect.get(arrayInstrumentations, key, receiver);1005 }1006 const res = Reflect.get(target, key, receiver);1007 const keyIsSymbol = isSymbol(key);1008 if (keyIsSymbol1009 ? builtInSymbols.has(key)1010 : key === `__proto__` || key === `__v_isRef`) {1011 return res;1012 }1013 if (!isReadonly) {1014 track(target, "get" /* GET */, key);1015 }1016 if (shallow) {1017 return res;1018 }1019 if (isRef(res)) {1020 // ref unwrapping - does not apply for Array + integer key.1021 const shouldUnwrap = !targetIsArray || !isIntegerKey(key);1022 return shouldUnwrap ? res.value : res;1023 }1024 if (isObject(res)) {1025 // Convert returned value into a proxy as well. we do the isObject check1026 // here to avoid invalid value warning. Also need to lazy access readonly1027 // and reactive here to avoid circular dependency.1028 return isReadonly ? readonly(res) : reactive(res);1029 }1030 return res;1031 };1032 }1033 function readonly(target) {1034 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);1035 }1036 function reactive(target) {1037 // if trying to observe a readonly proxy, return the readonly version.1038 if (target && target["__v_isReadonly" /* IS_READONLY */]) {1039 return target;1040 }1041 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);1042 }1043 const isObject = (val) => val !== null && typeof val === 'object';1044 function isRef(r) {1045 return Boolean(r && r.__v_isRef === true);1046 }1047 function pauseTracking() {1048 trackStack.push(shouldTrack);1049 shouldTrack = false;1050 }1051 function enableTracking() {1052 trackStack.push(shouldTrack);1053 shouldTrack = true;1054 }1055 function resetTracking() {1056 const last = trackStack.pop();1057 shouldTrack = last === undefined ? true : last;1058 }1059 function track(target, type, key) {1060 if (!shouldTrack || activeEffect === undefined) {1061 return;1062 }1063 let depsMap = targetMap.get(target);1064 if (!depsMap) {1065 targetMap.set(target, (depsMap = new Map()));1066 }1067 let dep = depsMap.get(key);1068 if (!dep) {1069 depsMap.set(key, (dep = new Set()));1070 }1071 if (!dep.has(activeEffect)) {1072 dep.add(activeEffect);1073 activeEffect.deps.push(dep);1074 if ( activeEffect.options.onTrack) {1075 activeEffect.options.onTrack({1076 effect: activeEffect,1077 target,1078 type,1079 key1080 });1081 }1082 }1083 }1084 function effect(fn, options = EMPTY_OBJ) {1085 if (isEffect(fn)) {1086 fn = fn.raw;1087 }1088 const effect = createReactiveEffect(fn, options);1089 if (!options.lazy) {1090 effect();1091 }1092 return effect;1093 }1094 function createReactiveEffect(fn, options) {1095 const effect = function reactiveEffect() {1096 if (!effect.active) {1097 return options.scheduler ? undefined : fn();1098 }1099 if (!effectStack.includes(effect)) {1100 cleanup(effect);1101 try {1102 enableTracking();1103 effectStack.push(effect);1104 activeEffect = effect;1105 return fn();1106 }1107 finally {1108 effectStack.pop();1109 resetTracking();1110 activeEffect = effectStack[effectStack.length - 1];1111 }1112 }1113 };1114 effect.id = uid++;1115 effect._isEffect = true;1116 effect.active = true;1117 effect.raw = fn;1118 effect.deps = [];1119 effect.options = options;1120 return effect;1121 }1122 const readonlyCollectionHandlers = {1123 get: createInstrumentationGetter(true, false)1124 };1125 function createInstrumentationGetter(isReadonly, shallow) {1126 const instrumentations = shallow1127 ? shallowInstrumentations1128 : isReadonly1129 ? readonlyInstrumentations1130 : mutableInstrumentations;1131 return (target, key, receiver) => {1132 if (key === "__v_isReactive" /* IS_REACTIVE */) {1133 return !isReadonly;1134 }1135 else if (key === "__v_isReadonly" /* IS_READONLY */) {1136 return isReadonly;1137 }1138 else if (key === "__v_raw" /* RAW */) {1139 return target;1140 }1141 return Reflect.get(hasOwn(instrumentations, key) && key in target1142 ? instrumentations1143 : target, key, receiver);1144 };1145 }1146 const shallowInstrumentations = {1147 get(key) {1148 return get$1(this, key, false, true);1149 },1150 get size() {1151 return size(this);1152 },1153 has: has$1,1154 add,1155 set: set$1,1156 delete: deleteEntry,1157 clear,1158 forEach: createForEach(false, true)1159 };1160 const readonlyInstrumentations = {1161 get(key) {1162 return get$1(this, key, true);1163 },1164 get size() {1165 return size(this, true);1166 },1167 has(key) {1168 return has$1.call(this, key, true);1169 },1170 add: createReadonlyMethod("add" /* ADD */),1171 set: createReadonlyMethod("set" /* SET */),1172 delete: createReadonlyMethod("delete" /* DELETE */),1173 clear: createReadonlyMethod("clear" /* CLEAR */),1174 forEach: createForEach(true, false)1175 };1176 const mutableInstrumentations = {1177 get(key) {1178 return get$1(this, key);1179 },1180 get size() {1181 return size(this);1182 },1183 has: has$1,1184 add,1185 set: set$1,1186 delete: deleteEntry,1187 clear,1188 forEach: createForEach(false, false)1189 };1190 function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {1191 if (!isObject(target)) {1192 {1193 console.warn(`value cannot be made reactive: ${String(target)}`);1194 }1195 return target;1196 }1197 // target is already a Proxy, return it.1198 // exception: calling readonly() on a reactive object1199 if (target["__v_raw" /* RAW */] &&1200 !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {1201 return target;1202 }1203 // target already has corresponding Proxy1204 const proxyMap = isReadonly ? readonlyMap : reactiveMap;1205 const existingProxy = proxyMap.get(target);1206 if (existingProxy) {1207 return existingProxy;1208 }1209 // only a whitelist of value types can be observed.1210 const targetType = getTargetType(target);1211 if (targetType === 0 /* INVALID */) {1212 return target;1213 }1214 const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);1215 proxyMap.set(target, proxy);1216 return proxy;1217 }1218 function getTargetType(value) {1219 return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)1220 ? 0 /* INVALID */1221 : targetTypeMap(toRawType(value));1222 }1223 function targetTypeMap(rawType) {1224 switch (rawType) {1225 case 'Object':1226 case 'Array':1227 return 1 /* COMMON */;1228 case 'Map':1229 case 'Set':1230 case 'WeakMap':1231 case 'WeakSet':1232 return 2 /* COLLECTION */;1233 default:1234 return 0 /* INVALID */;1235 }1236 }1237 const toTypeString = (value) => objectToString.call(value);1238 const toRawType = (value) => {1239 return toTypeString(value).slice(8, -1);1240 };1241 const readonlyHandlers = {1242 get: readonlyGet,1243 set(target, key) {1244 {1245 console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);1246 }1247 return true;1248 },1249 deleteProperty(target, key) {1250 {1251 console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);1252 }1253 return true;1254 }1255 };1256 const publicPropertiesMap = extend(Object.create(null), {1257 $: i => i,1258 $el: i => i.vnode.el,1259 $data: i => i.data,1260 $props: i => ( shallowReadonly(i.props) ),1261 $attrs: i => ( shallowReadonly(i.attrs) ),1262 $slots: i => ( shallowReadonly(i.slots) ),1263 $refs: i => ( shallowReadonly(i.refs) ),1264 $parent: i => i.parent && i.parent.proxy,1265 $root: i => i.root && i.root.proxy,1266 $emit: i => i.emit,1267 $options: i => ( resolveMergedOptions(i) ),1268 $forceUpdate: i => () => queueJob(i.update),1269 $nextTick: () => nextTick,1270 $watch: i => ( instanceWatch.bind(i) )1271 });1272 const PublicInstanceProxyHandlers = {1273 get({ _: instance }, key) {1274 const { ctx, setupState, data, props, accessCache, type, appContext } = instance;1275 // let @vue/reactivity know it should never observe Vue public instances.1276 if (key === "__v_skip" /* SKIP */) {1277 return true;1278 }1279 // data / props / ctx1280 // This getter gets called for every property access on the render context1281 // during render and is a major hotspot. The most expensive part of this1282 // is the multiple hasOwn() calls. It's much faster to do a simple property1283 // access on a plain object, so we use an accessCache object (with null1284 // prototype) to memoize what access type a key corresponds to.1285 let normalizedProps;1286 if (key[0] !== '$') {1287 const n = accessCache[key];1288 if (n !== undefined) {1289 switch (n) {1290 case 0 /* SETUP */:1291 return setupState[key];1292 case 1 /* DATA */:1293 return data[key];1294 case 3 /* CONTEXT */:1295 return ctx[key];1296 case 2 /* PROPS */:1297 return props[key];1298 // default: just fallthrough1299 }1300 }1301 else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {1302 accessCache[key] = 0 /* SETUP */;1303 return setupState[key];1304 }1305 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {1306 accessCache[key] = 1 /* DATA */;1307 return data[key];1308 }1309 else if (1310 // only cache other properties when instance has declared (thus stable)1311 // props1312 (normalizedProps = instance.propsOptions[0]) &&1313 hasOwn(normalizedProps, key)) {1314 accessCache[key] = 2 /* PROPS */;1315 return props[key];1316 }1317 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {1318 accessCache[key] = 3 /* CONTEXT */;1319 return ctx[key];1320 }1321 else if ( !isInBeforeCreate) {1322 accessCache[key] = 4 /* OTHER */;1323 }1324 }1325 const publicGetter = publicPropertiesMap[key];1326 let cssModule, globalProperties;1327 // public $xxx properties1328 if (publicGetter) {1329 if (key === '$attrs') {1330 track(instance, "get" /* GET */, key);1331 markAttrsAccessed();1332 }1333 return publicGetter(instance);1334 }1335 else if (1336 // css module (injected by vue-loader)1337 (cssModule = type.__cssModules) &&1338 (cssModule = cssModule[key])) {1339 return cssModule;1340 }1341 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {1342 // user may set custom properties to `this` that start with `$`1343 accessCache[key] = 3 /* CONTEXT */;1344 return ctx[key];1345 }1346 else if (1347 // global properties1348 ((globalProperties = appContext.config.globalProperties),1349 hasOwn(globalProperties, key))) {1350 return globalProperties[key];1351 }1352 else if (1353 currentRenderingInstance &&1354 (!isString(key) ||1355 // #1091 avoid internal isRef/isVNode checks on component instance leading1356 // to infinite warning loop1357 key.indexOf('__v') !== 0)) {1358 if (data !== EMPTY_OBJ &&1359 (key[0] === '$' || key[0] === '_') &&1360 hasOwn(data, key)) {1361 warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +1362 `character ("$" or "_") and is not proxied on the render context.`);1363 }1364 else {1365 warn(`Property ${JSON.stringify(key)} was accessed during render ` +1366 `but is not defined on instance.`);1367 }1368 }1369 },1370 set({ _: instance }, key, value) {1371 const { data, setupState, ctx } = instance;1372 if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {1373 setupState[key] = value;1374 }1375 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {1376 data[key] = value;1377 }1378 else if (key in instance.props) {1379 1380 warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance);1381 return false;1382 }1383 if (key[0] === '$' && key.slice(1) in instance) {1384 1385 warn(`Attempting to mutate public property "${key}". ` +1386 `Properties starting with $ are reserved and readonly.`, instance);1387 return false;1388 }1389 else {1390 if ( key in instance.appContext.config.globalProperties) {1391 Object.defineProperty(ctx, key, {1392 enumerable: true,1393 configurable: true,1394 value1395 });1396 }1397 else {1398 ctx[key] = value;1399 }1400 }1401 return true;1402 },1403 has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {1404 let normalizedProps;1405 return (accessCache[key] !== undefined ||1406 (data !== EMPTY_OBJ && hasOwn(data, key)) ||1407 (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||1408 ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||1409 hasOwn(ctx, key) ||1410 hasOwn(publicPropertiesMap, key) ||1411 hasOwn(appContext.config.globalProperties, key));1412 }1413 };1414 PublicInstanceProxyHandlers.ownKeys = (target) => {1415 warn(`Avoid app logic that relies on enumerating keys on a component instance. ` +1416 `The keys will be empty in production mode to avoid performance overhead.`);1417 return Reflect.ownKeys(target);1418 };1419 const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, {1420 get(target, key) {1421 // fast path for unscopables when using `with` block1422 if (key === Symbol.unscopables) {1423 return;1424 }1425 return PublicInstanceProxyHandlers.get(target, key, target);1426 },1427 has(_, key) {1428 const has = key[0] !== '_' && !isGloballyWhitelisted(key);1429 if ( !has && PublicInstanceProxyHandlers.has(_, key)) {1430 warn(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);1431 }1432 return has;1433 }1434 });1435 function proxyRefs(objectWithRefs) {1436 return isReactive(objectWithRefs)1437 ? objectWithRefs1438 : new Proxy(objectWithRefs, shallowUnwrapHandlers);1439 }1440 function unref(ref) {1441 return isRef(ref) ? ref.value : ref;1442 }1443 const shallowUnwrapHandlers = {1444 get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),1445 set: (target, key, value, receiver) => {1446 const oldValue = target[key];1447 if (isRef(oldValue) && !isRef(value)) {1448 oldValue.value = value;1449 return true;1450 }1451 else {1452 return Reflect.set(target, key, value, receiver);1453 }1454 }1455 };1456 function toRaw(observed) {1457 return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);1458 }1459 // dev only1460 function exposeSetupStateOnRenderContext(instance) {1461 const { ctx, setupState } = instance;1462 Object.keys(toRaw(setupState)).forEach(key => {1463 if (key[0] === '$' || key[0] === '_') {1464 warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +1465 `which are reserved prefixes for Vue internals.`);1466 return;1467 }1468 Object.defineProperty(ctx, key, {1469 enumerable: true,1470 configurable: true,1471 get: () => setupState[key],1472 set: NOOP1473 });1474 });...

Full Screen

Full Screen

note.js

Source:note.js Github

copy

Full Screen

...2226 instance.devtoolsRawSetupState = setupResult;2227 }2228 instance.setupState = proxyRefs(setupResult);2229 {2230 exposeSetupStateOnRenderContext(instance);2231 }2232 }2233 else if ( setupResult !== undefined) {2234 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);2235 }2236 finishComponentSetup(instance);2237}2238function proxyRefs(objectWithRefs) {2239 return isReactive(objectWithRefs)2240 ? objectWithRefs2241 : new Proxy(objectWithRefs, shallowUnwrapHandlers);2242}2243function exposePropsOnRenderContext(instance) {2244 const { ctx, propsOptions: [propsOptions] } = instance;...

Full Screen

Full Screen

setup.js

Source:setup.js Github

copy

Full Screen

...243 instance.devtoolsRawSetupState = setupResult;244 }245 instance.setupState = proxyRefs(setupResult);246 {247 exposeSetupStateOnRenderContext(instance);248 }249 }250 else if ( setupResult !== undefined) {251 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);252 }253 finishComponentSetup(instance);254}255 function proxyRefs(objectWithRefs) {256 return isReactive(objectWithRefs)257 ? objectWithRefs258 : new Proxy(objectWithRefs, shallowUnwrapHandlers);259 }260 const shallowUnwrapHandlers = {261 get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),262 set: (target, key, value, receiver) => {263 const oldValue = target[key];264 if (isRef(oldValue) && !isRef(value)) {265 oldValue.value = value;266 return true;267 }268 else {269 return Reflect.set(target, key, value, receiver);270 }271 }272 };273 // dev only274 function exposeSetupStateOnRenderContext(instance) {275 const { ctx, setupState } = instance;276 Object.keys(toRaw(setupState)).forEach(key => {277 if (key[0] === '$' || key[0] === '_') {278 warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +279 `which are reserved prefixes for Vue internals.`);280 return;281 }282 Object.defineProperty(ctx, key, {283 enumerable: true,284 configurable: true,285 get: () => setupState[key],286 set: NOOP287 });288 });...

Full Screen

Full Screen

Vue2.0.js

Source:Vue2.0.js Github

copy

Full Screen

...12/**13 * @param setupState14 * @param {object} context15 */16function exposeSetupStateOnRenderContext(setupState,17 context) {18 for (let key of Reflect.ownKeys(setupState)) {19 Reflect.defineProperty(context,20 key,21 {22 enumerable: false, configurable: false,23 get : () => setupState[key], set: NOOP,24 });25 }26}27/**28 * @param {any[]} AST29 */30function exposeOnRenderNode(AST) {31 return () => AST.map((/** @type {{ type: any; value: any; }} */32 child) => new Function(`with(this){return ${h(child)}}`).call({33 _v_,34 _t_,35 _c_,36 }),);37}38const initState = Object.assign;39function mount(properties,40 children) {41 properties.append(...children);42 return properties;43}44class Vue {45 static reactive = reactive;46 static ref = toRef;47 static watch = watcher;48 isVue = true;49 V_ID = VUE_UID++;50 #component = {};51 isMound = false;52 /**53 * @param {{}} config54 */55 constructor(config) {56 this.#component = config;57 }58 static createApp(config) {59 return new Vue(config)60 }61 $emit([message, payload]) {62 switch (message) {63 case "ref": {64 Reflect.set(this,65 `$${payload.key}`,66 payload.elm,67 this);68 }69 break;70 }71 }72 /**73 * @param {any} containerOrSelector74 */75 mount(containerOrSelector) {76 const container = normalizeContainer(containerOrSelector);77 if (!container) return;78 const {79 template = container.innerHTML, setup = emptyFunction, data = emptyFunction,80 methods = emptyObject, created = emptyFunction, mounted = emptyFunction,81 } = this.#component;82 container.innerHTML = ``;83 const vm = {};84 initState(vm,85 methods);86 initState(vm,87 setup(this));88 initState(vm,89 data?.() ?? data)90 exposeSetupStateOnRenderContext(vm,91 this,);92 created.call(vm);93 const parser = new Parser();94 parser.init(template);95 const AST = parser.ChildrenLiteral();96 const h = exposeOnRenderNode(AST);97 let environment = h();98 compileChild(environment,99 [this]);100 /**101 *102 * @type {Node[]}103 */104 const c = environment.map(render);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.exposeSetupStateOnRenderContext();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 exposeSetupStateOnRenderContext(context);7 const page = await context.newPage();8 await page.screenshot({ path: `example.png` });9 await browser.close();10})();11const { test, expect } = require('@playwright/test');12test('should expose setup state on render context', async ({ page }) => {13 await page.screenshot({ path: `example.png` });14 expect(page.context().setupState).toBeTruthy();15});16module.exports = {17};18 6 | test('should expose setup state on render context', async ({ page }) => {19 > 8 | await page.screenshot({ path: `example.png` });20 9 | expect(page.context().setupState).toBeTruthy();21 10 | });22 at Object.<anonymous> (test.spec.js:8:12)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');2const { chromium } = require('playwright');3const context = await chromium.launch().newContext();4exposeSetupStateOnRenderContext(context);5context.setupState = {6};7const { chromium } = require('playwright');8const { test, expect } = require('@playwright/test');9test('setup state', async ({ page }) => {10 const name = await page.evaluate(() => {11 return window.context.setupState.name;12 });13 expect(name).toBe('John Doe');14});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');2const { chromium } = require('playwright');3const path = require('path');4const fs = require('fs');5(async () => {6 const browser = await chromium.launch();7 const context = await browser.newContext();8 const page = await context.newPage();9 exposeSetupStateOnRenderContext(context);10 await page.screenshot({ path: 'example.png' });11 await browser.close();12})();13const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');14const { chromium } = require('playwright');15const path = require('path');16const fs = require('fs');17module.exports = {18 use: {19 viewport: { width: 1280, height: 720 },20 },21 {22 use: {23 launchOptions: {24 },25 },26 },27};28const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');29const { chromium } = require('playwright');30const path = require('path');31const fs = require('fs');32describe('Playwright Test', () => {33 it('should work', async ({ page }) => {34 await page.screenshot({ path: 'example.png' });35 });36});37Q: What are the steps to reproduce the issue? (If possible, please attach a simple script that reproduces the issue)

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright/lib/server/playwright');2playwright.exposeSetupStateOnRenderContext();3const playwright = require('playwright/lib/server/playwright');4playwright.exposeSetupStateOnRenderContext();5const playwright = require('playwright/lib/server/playwright');6playwright.exposeSetupStateOnRenderContext();7const playwright = require('playwright/lib/server/playwright');8playwright.exposeSetupStateOnRenderContext();9const playwright = require('playwright/lib/server/playwright');10playwright.exposeSetupStateOnRenderContext();11const playwright = require('playwright/lib/server/playwright');12playwright.exposeSetupStateOnRenderContext();13const playwright = require('playwright/lib/server/playwright');14playwright.exposeSetupStateOnRenderContext();15const playwright = require('playwright/lib/server/playwright');16playwright.exposeSetupStateOnRenderContext();17const playwright = require('playwright/lib/server/playwright');18playwright.exposeSetupStateOnRenderContext();19const playwright = require('playwright/lib/server/playwright');20playwright.exposeSetupStateOnRenderContext();21const playwright = require('playwright/lib/server/playwright');22playwright.exposeSetupStateOnRenderContext();23const playwright = require('playwright/lib

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');2const { test, expect } = require('@playwright/test');3test('test', async ({ page }) => {4 await page.waitForTimeout(5000);5 await exposeSetupStateOnRenderContext(page, { hello: 'world' });6 const result = await page.evaluate(() => window.hello);7 expect(result).toBe('world');8});9const { exposeSetupStateOnRenderContext } = require('playwright/lib/server/browserContext');10const { test, expect } = require('@playwright/test');11test('test', async ({ page }) => {12 await page.waitForTimeout(5000);13 await exposeSetupStateOnRenderContext(page, { hello: 'world' });14 const result = await page.evaluate(() => window.hello);15 expect(result).toBe('world');16});17const { test, expect } = require('@playwright/test');18test('test', async ({ page }) => {19 await page.waitForTimeout(5000);20 await exposeSetupStateOnRenderContext(page, { hello: 'world' });21 const result = await page.evaluate(() => window.hello);22 expect(result).toBe('world');23});24const { test, expect } = require('@playwright/test');25test('test', async ({ page }) => {26 await page.waitForTimeout(5000);27 await exposeSetupStateOnRenderContext(page, { hello: 'world' });28 const result = await page.evaluate(() => window.hello);29 expect(result).toBe('world');30});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { exposeSetupStateOnRenderContext } from 'playwright/lib/internal';2const { test } = require('@playwright/test');3test.beforeEach(async ({ page }) => {4});5test('exposeSetupStateOnRenderContext', async ({ page }) => {6 const context = await page.context();7 exposeSetupStateOnRenderContext(context);8 await page.evaluate(() => {9 console.log('page: ', page);10 });11});12test('exposeSetupStateOnRenderContext', async ({ page }) => {13 await page.evaluate(() => {14 console.log('page: ', page);15 });16});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exposeSetupStateOnRenderContext } = require('@playwright/test/lib/server/kit');2const { setupState } = require('./setupState');3exposeSetupStateOnRenderContext(setupState);4const { exposeSetupStateOnRenderContext } = require('@playwright/test/lib/server/kit');5const { setupState } = require('./setupState');6exposeSetupStateOnRenderContext(setupState);7const { test, expect } = require('@playwright/test');8test('test', async ({ page }) => {9 const { setupState } = page.context();10 expect(setupState).toBe('setupState');11});12import { Test } from '@playwright/test';13declare global {14 const test: Test;15}16import { expect } from '@playwright/test';17test.beforeEach(({ page }) => {18 const { setupState } = page.context();19 test['setupState'] = setupState;20});21test('test', async ({ page }) => {22 const { setupState } = test;23 expect(setupState).toBe('setupState');24});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('expose setup state on render context', async ({page}) => {3 await page.exposeSetupStateOnRenderContext({4 });5 const text = await page.evaluate(() => window.mySetupState);6 expect(text).toBe('Hello');7});8const { PlaywrightTestConfig } = require('@playwright/test');9const config = {10 use: {11 },12};13module.exports = config;14const { test, expect } = require('@playwright/test');15test.use({16});17test('expose setup state on render context', async ({page}) => {18 await page.exposeSetupStateOnRenderContext({19 });20 const text = await page.evaluate(() => window.mySetupState);21 expect(text).toBe('Hello');22});23const { test, expect } = require('@playwright/test');24test('expose setup state on render context', async ({page}) => {25 await page.exposeSetupStateOnRenderContext({26 });27 const text = await page.evaluate(() => window.mySetupState);28 expect(text).toBe('Hello');29});30const { test, expect } = require('@playwright/test');31test('expose setup state on render context

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 await page.exposeSetupStateOnRenderContext('setupState');4 const title = await page.evaluate(() => setupState.title);5 expect(title).toBe('Playwright');6});

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful