🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@glimmer/reference

Package Overview
Dependencies
Maintainers
13
Versions
297
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/reference - npm Package Compare versions

Comparing version

to
0.86.0

2

dist/dev/index.d.ts

@@ -8,3 +8,3 @@ import { Nullable, Reference, ReferenceSymbol } from "@glimmer/interfaces";

}
declare function createPrimitiveRef<T>(value: T): Reference<T>;
declare function createPrimitiveRef<T extends string | symbol | number | boolean | null | undefined>(value: T): Reference<T>;
declare const UNDEFINED_REFERENCE: Reference<any>;

@@ -11,0 +11,0 @@ declare const NULL_REFERENCE: Reference<any>;

import { DEBUG } from '@glimmer/env';
import { getProp, setProp, toIterator, getPath } from '@glimmer/global-context';
import { setProp, getProp, toIterator, getPath } from '@glimmer/global-context';
import { expect, isDict, EMPTY_ARRAY, isObject } from '@glimmer/util';

@@ -58,5 +58,3 @@ import { CONSTANT_TAG, validateTag, track, valueForTag, consumeTag, INITIAL, createTag, dirtyTag } from '@glimmer/validator';

}
function createComputeRef(compute) {
let update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
let debugLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unknown';
function createComputeRef(compute, update = null, debugLabel = 'unknown') {
const ref = new ReferenceImpl(COMPUTE);

@@ -63,0 +61,0 @@ ref.compute = compute;

@@ -8,3 +8,3 @@ import { Nullable, Reference, ReferenceSymbol } from "@glimmer/interfaces";

}
declare function createPrimitiveRef<T>(value: T): Reference<T>;
declare function createPrimitiveRef<T extends string | symbol | number | boolean | null | undefined>(value: T): Reference<T>;
declare const UNDEFINED_REFERENCE: Reference<any>;

@@ -11,0 +11,0 @@ declare const NULL_REFERENCE: Reference<any>;

@@ -1,2 +0,2 @@

import{getProp as t,setProp as e,toIterator as n,getPath as r}from"@glimmer/global-context";import{expect as i,isDict as u,EMPTY_ARRAY as l,isObject as s}from"@glimmer/util";import{CONSTANT_TAG as a,validateTag as o,track as c,valueForTag as p,consumeTag as d,INITIAL as h,createTag as f,dirtyTag as g}from"@glimmer/validator";const m=Symbol("REFERENCE"),b=1,v=2;class k{[m];tag=null;lastRevision=h;lastValue;children=null;compute=null;update=null;debugLabel;constructor(t){this[m]=t}}function w(t){const e=new k(v);return e.tag=a,e.lastValue=t,e.debugLabel=String(t),e}const y=w(void 0),M=w(null),L=w(!0),E=w(!1);function _(t,e){const n=new k(0);return n.lastValue=t,n.tag=a,n.debugLabel=e,n}function x(t,e){const n=new k(v);return n.lastValue=t,n.tag=a,n.debugLabel=e,n}function V(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unknown";const r=new k(b);return r.compute=t,r.update=e,r.debugLabel=`(result of a \`${n}\` helper)`,r}function $(t){return A(t)?V((()=>C(t)),null,t.debugLabel):t}function F(t){return 3===t[m]}function R(t){const e=V((()=>C(t)),(e=>N(t,e)));return e.debugLabel=t.debugLabel,e[m]=3,e}function S(t){return t.tag===a}function A(t){return null!==t.update}function C(t){const e=t;let{tag:n}=e;if(n===a)return e.lastValue;const{lastRevision:r}=e;let i;if(null!==n&&o(n,r))i=e.lastValue;else{const{compute:t}=e,r=c((()=>{i=e.lastValue=t()}),e.debugLabel);n=e.tag=r,e.lastRevision=p(r)}return d(n),i}function N(t,e){i(t.update,"called update on a non-updatable reference")(e)}function W(n,r){const i=n,l=i[m];let s,a=i.children;if(null===a)a=i.children=new Map;else if(s=a.get(r),void 0!==s)return s;if(l===v){const t=C(i);s=u(t)?x(t[r],`${i.debugLabel}.${r}`):y}else s=V((()=>{const e=C(i);if(u(e))return t(e,r)}),(t=>{const n=C(i);if(u(n))return e(n,r,t)})),s.debugLabel=`${i.debugLabel}.${r}`;return a.set(r,s),s}function j(t,e){let n=t;for(const t of e)n=W(n,t);return n}let q;q=(t,e)=>{const n=V((()=>C(e)),A(e)?t=>N(e,t):null);return n[m]=e[m],n.debugLabel=t,n};const z={},B=(t,e)=>e,D=(t,e)=>String(e),G=t=>null===t?z:t;function H(t){switch(t){case"@key":return K(B);case"@index":return K(D);case"@identity":return K(G);default:return function(t){if("@"===t[0])throw new Error(`invalid keypath: '${t}', valid keys: @index, @identity, or a path`);return K((e=>r(e,t)))}(t)}}class I{_weakMap;_primitiveMap;get weakMap(){return void 0===this._weakMap&&(this._weakMap=new WeakMap),this._weakMap}get primitiveMap(){return void 0===this._primitiveMap&&(this._primitiveMap=new Map),this._primitiveMap}set(t,e){s(t)?this.weakMap.set(t,e):this.primitiveMap.set(t,e)}get(t){return s(t)?this.weakMap.get(t):this.primitiveMap.get(t)}}const J=new I;function K(t){let e=new I;return(n,r)=>{let i=t(n,r),u=e.get(i)||0;return e.set(i,u+1),0===u?i:function(t,e){let n=J.get(t);void 0===n&&(n=[],J.set(t,n));let r=n[e];return void 0===r&&(r={value:t,count:e},n[e]=r),r}(i,u)}}function O(t,e){return V((()=>{let r=C(t),i=H(e);if(Array.isArray(r))return new T(r,i);let u=n(r);return null===u?new T(l,(()=>null)):new Q(u,i)}))}function P(t){let e=t,n=f();return V((()=>(d(n),e)),(t=>{e!==t&&(e=t,g(n))}))}class Q{constructor(t,e){this.inner=t,this.keyFor=e}isEmpty(){return this.inner.isEmpty()}next(){let t=this.inner.next();return null!==t&&(t.key=this.keyFor(t.value,t.memo)),t}}class T{current;pos=0;constructor(t,e){this.iterator=t,this.keyFor=e,0===t.length?this.current={kind:"empty"}:this.current={kind:"first",value:t[this.pos]}}isEmpty(){return"empty"===this.current.kind}next(){let t,e=this.current;if("first"===e.kind)this.current={kind:"progress"},t=e.value;else{if(this.pos>=this.iterator.length-1)return null;t=this.iterator[++this.pos]}let{keyFor:n}=this;return{key:n(t,this.pos),value:t,memo:this.pos}}}export{E as FALSE_REFERENCE,M as NULL_REFERENCE,m as REFERENCE,L as TRUE_REFERENCE,y as UNDEFINED_REFERENCE,W as childRefFor,j as childRefFromParts,V as createComputeRef,_ as createConstRef,q as createDebugAliasRef,R as createInvokableRef,P as createIteratorItemRef,O as createIteratorRef,w as createPrimitiveRef,$ as createReadOnlyRef,x as createUnboundRef,S as isConstRef,F as isInvokableRef,A as isUpdatableRef,N as updateRef,C as valueForRef};
import{setProp as t,getProp as e,toIterator as n,getPath as r}from"@glimmer/global-context";import{expect as i,isDict as u,EMPTY_ARRAY as l,isObject as s}from"@glimmer/util";import{CONSTANT_TAG as a,validateTag as o,track as c,valueForTag as p,consumeTag as d,INITIAL as h,createTag as f,dirtyTag as g}from"@glimmer/validator";const m=Symbol("REFERENCE"),b=1,v=2;class k{[m];tag=null;lastRevision=h;lastValue;children=null;compute=null;update=null;debugLabel;constructor(t){this[m]=t}}function w(t){const e=new k(v);return e.tag=a,e.lastValue=t,e.debugLabel=String(t),e}const y=w(void 0),M=w(null),L=w(!0),E=w(!1);function _(t,e){const n=new k(0);return n.lastValue=t,n.tag=a,n.debugLabel=e,n}function x(t,e){const n=new k(v);return n.lastValue=t,n.tag=a,n.debugLabel=e,n}function V(t,e=null,n="unknown"){const r=new k(b);return r.compute=t,r.update=e,r.debugLabel=`(result of a \`${n}\` helper)`,r}function $(t){return A(t)?V((()=>C(t)),null,t.debugLabel):t}function F(t){return 3===t[m]}function R(t){const e=V((()=>C(t)),(e=>N(t,e)));return e.debugLabel=t.debugLabel,e[m]=3,e}function S(t){return t.tag===a}function A(t){return null!==t.update}function C(t){const e=t;let{tag:n}=e;if(n===a)return e.lastValue;const{lastRevision:r}=e;let i;if(null!==n&&o(n,r))i=e.lastValue;else{const{compute:t}=e,r=c((()=>{i=e.lastValue=t()}),e.debugLabel);n=e.tag=r,e.lastRevision=p(r)}return d(n),i}function N(t,e){i(t.update,"called update on a non-updatable reference")(e)}function W(n,r){const i=n,l=i[m];let s,a=i.children;if(null===a)a=i.children=new Map;else if(s=a.get(r),void 0!==s)return s;if(l===v){const t=C(i);s=u(t)?x(t[r],`${i.debugLabel}.${r}`):y}else s=V((()=>{const t=C(i);if(u(t))return e(t,r)}),(e=>{const n=C(i);if(u(n))return t(n,r,e)})),s.debugLabel=`${i.debugLabel}.${r}`;return a.set(r,s),s}function j(t,e){let n=t;for(const t of e)n=W(n,t);return n}let q;q=(t,e)=>{const n=V((()=>C(e)),A(e)?t=>N(e,t):null);return n[m]=e[m],n.debugLabel=t,n};const z={},B=(t,e)=>e,D=(t,e)=>String(e),G=t=>null===t?z:t;function H(t){switch(t){case"@key":return K(B);case"@index":return K(D);case"@identity":return K(G);default:return function(t){if("@"===t[0])throw new Error(`invalid keypath: '${t}', valid keys: @index, @identity, or a path`);return K((e=>r(e,t)))}(t)}}class I{_weakMap;_primitiveMap;get weakMap(){return void 0===this._weakMap&&(this._weakMap=new WeakMap),this._weakMap}get primitiveMap(){return void 0===this._primitiveMap&&(this._primitiveMap=new Map),this._primitiveMap}set(t,e){s(t)?this.weakMap.set(t,e):this.primitiveMap.set(t,e)}get(t){return s(t)?this.weakMap.get(t):this.primitiveMap.get(t)}}const J=new I;function K(t){let e=new I;return(n,r)=>{let i=t(n,r),u=e.get(i)||0;return e.set(i,u+1),0===u?i:function(t,e){let n=J.get(t);void 0===n&&(n=[],J.set(t,n));let r=n[e];return void 0===r&&(r={value:t,count:e},n[e]=r),r}(i,u)}}function O(t,e){return V((()=>{let r=C(t),i=H(e);if(Array.isArray(r))return new T(r,i);let u=n(r);return null===u?new T(l,(()=>null)):new Q(u,i)}))}function P(t){let e=t,n=f();return V((()=>(d(n),e)),(t=>{e!==t&&(e=t,g(n))}))}class Q{constructor(t,e){this.inner=t,this.keyFor=e}isEmpty(){return this.inner.isEmpty()}next(){let t=this.inner.next();return null!==t&&(t.key=this.keyFor(t.value,t.memo)),t}}class T{current;pos=0;constructor(t,e){this.iterator=t,this.keyFor=e,0===t.length?this.current={kind:"empty"}:this.current={kind:"first",value:t[this.pos]}}isEmpty(){return"empty"===this.current.kind}next(){let t,e=this.current;if("first"===e.kind)this.current={kind:"progress"},t=e.value;else{if(this.pos>=this.iterator.length-1)return null;t=this.iterator[++this.pos]}let{keyFor:n}=this;return{key:n(t,this.pos),value:t,memo:this.pos}}}export{E as FALSE_REFERENCE,M as NULL_REFERENCE,m as REFERENCE,L as TRUE_REFERENCE,y as UNDEFINED_REFERENCE,W as childRefFor,j as childRefFromParts,V as createComputeRef,_ as createConstRef,q as createDebugAliasRef,R as createInvokableRef,P as createIteratorItemRef,O as createIteratorRef,w as createPrimitiveRef,$ as createReadOnlyRef,x as createUnboundRef,S as isConstRef,F as isInvokableRef,A as isUpdatableRef,N as updateRef,C as valueForRef};
//# sourceMappingURL=index.js.map
{
"name": "@glimmer/reference",
"type": "module",
"version": "0.85.13",
"version": "0.86.0",
"license": "MIT",
"description": "Objects used to track values and their dirtiness in Glimmer",
"license": "MIT",
"repository": {

@@ -12,2 +11,8 @@ "type": "git",

},
"type": "module",
"main": null,
"types": "dist/dev/index.d.ts",
"publishConfig": {
"access": "public"
},
"files": [

@@ -18,6 +23,6 @@ "dist"

"@glimmer/env": "^0.1.7",
"@glimmer/global-context": "^0.85.13",
"@glimmer/interfaces": "^0.85.13",
"@glimmer/util": "^0.85.13",
"@glimmer/validator": "^0.85.13"
"@glimmer/global-context": "^0.86.0",
"@glimmer/interfaces": "^0.86.0",
"@glimmer/util": "^0.86.0",
"@glimmer/validator": "^0.86.0"
},

@@ -27,17 +32,12 @@ "devDependencies": {

"publint": "^0.2.5",
"rollup": "^3.21.6",
"rollup": "^4.5.1",
"typescript": "*",
"@glimmer-workspace/build-support": "^1.0.0",
"@glimmer/local-debug-flags": "^0.85.13"
"@glimmer/local-debug-flags": "^0.86.0"
},
"main": null,
"types": "dist/dev/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "rollup -c rollup.config.mjs",
"test:lint": "eslint .",
"test:types": "tsc --noEmit -p ../tsconfig.json",
"build": "rollup -c rollup.config.mjs",
"test:publint": "publint"
"test:publint": "publint",
"test:types": "tsc --noEmit -p ../tsconfig.json"
},

@@ -44,0 +44,0 @@ "exports": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet