@torpor/view 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,42 @@
1
1
  import type Context from "../types/Context";
2
+ import type Region from "../types/Region";
2
3
 
3
- const context: Context = {
4
- activeTarget: null,
5
- previousEffect: null,
6
- extent: 0,
7
- batch: 0,
8
- batchOperation: 0,
9
- registerComputed: null,
4
+ // TODO: Possibly create this in mount/hydrate so we aren't always checking
5
+ // whether it exists with `??=`
10
6
 
11
- firstEffectToRun: null,
12
- firstSignalToUpdate: null,
7
+ const CONTEXT_SYMBOL: unique symbol = Symbol.for("t_context");
13
8
 
14
- // These will definitely be set, in mount or render
9
+ const context: Context =
15
10
  // @ts-ignore
16
- activeRegion: null,
17
- // @ts-ignore
18
- previousRegion: null,
19
- // @ts-ignore
20
- rootRegion: null,
21
-
22
- mountEffects: [],
23
- stashedEvents: [],
24
- stashedAnimations: [],
25
-
26
- hydrationNode: null,
27
- //hn: null,
28
- //get hydrationNode() {
29
- // return this.hn;
30
- //},
31
- //set hydrationNode(value) {
32
- // console.log(`set hydration ${printNode(value)}`);
33
- // this.hn = value;
34
- //},
35
- };
11
+ (globalThis[CONTEXT_SYMBOL] ??= {
12
+ activeTarget: null,
13
+ previousEffect: null,
14
+ extent: 0,
15
+ batch: 0,
16
+ batchOperation: 0,
17
+ registerComputed: null,
18
+
19
+ firstEffectToRun: null,
20
+ firstSignalToUpdate: null,
21
+
22
+ // These will definitely be set, in mount or render
23
+ activeRegion: null as unknown as Region,
24
+ previousRegion: null as unknown as Region,
25
+ rootRegion: null as unknown as Region,
26
+
27
+ mountEffects: [],
28
+ stashedEvents: [],
29
+ stashedAnimations: [],
30
+
31
+ hydrationNode: null,
32
+ //hn: null,
33
+ //get hydrationNode() {
34
+ // return this.hn;
35
+ //},
36
+ //set hydrationNode(value) {
37
+ // console.log(`set hydration ${printNode(value)}`);
38
+ // this.hn = value;
39
+ //},
40
+ } satisfies Context);
36
41
 
37
42
  export default context;
@@ -1 +0,0 @@
1
- {"version":3,"file":"devContext-CM-9Rx7k.js","names":["devContext: DevContext"],"sources":["../src/dev/devContext.ts"],"sourcesContent":["import type DevContext from \"./types/DevContext\";\n\nconst noop = () => {};\n\nconst devContext: DevContext = {\n\tenabled: false,\n\tdepth: 0,\n\tindex: -1,\n\tboundaries: [],\n\n\tformat: () => \"\",\n\tgetDetails: () => \"\",\n\tunmark: noop,\n\tmark: noop,\n\n\t// Hooks\n\tonWatch: noop,\n\tonRun: noop,\n\tonRegionPushed: noop,\n\tonRegionPopped: noop,\n\tonRegionCleared: noop,\n\n\tsignalSet: noop,\n\teffectRun: noop,\n};\n\n// Add to globalThis for getting from the extension\n// @ts-ignore\nglobalThis.T_DEV_CTX = devContext;\n\nexport default devContext;\n"],"mappings":";AAEA,MAAM,aAAa;AAEnB,MAAMA,aAAyB;CAC9B,SAAS;CACT,OAAO;CACP,OAAO;CACP,YAAY,EAAE;CAEd,cAAc;CACd,kBAAkB;CAClB,QAAQ;CACR,MAAM;CAGN,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CAEjB,WAAW;CACX,WAAW;CACX;AAID,WAAW,YAAY;AAEvB,yBAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"devContext-nomc0xCl.cjs","names":["devContext: DevContext"],"sources":["../src/dev/devContext.ts"],"sourcesContent":["import type DevContext from \"./types/DevContext\";\n\nconst noop = () => {};\n\nconst devContext: DevContext = {\n\tenabled: false,\n\tdepth: 0,\n\tindex: -1,\n\tboundaries: [],\n\n\tformat: () => \"\",\n\tgetDetails: () => \"\",\n\tunmark: noop,\n\tmark: noop,\n\n\t// Hooks\n\tonWatch: noop,\n\tonRun: noop,\n\tonRegionPushed: noop,\n\tonRegionPopped: noop,\n\tonRegionCleared: noop,\n\n\tsignalSet: noop,\n\teffectRun: noop,\n};\n\n// Add to globalThis for getting from the extension\n// @ts-ignore\nglobalThis.T_DEV_CTX = devContext;\n\nexport default devContext;\n"],"mappings":";;AAEA,MAAM,aAAa;AAEnB,MAAMA,aAAyB;CAC9B,SAAS;CACT,OAAO;CACP,OAAO;CACP,YAAY,EAAE;CAEd,cAAc;CACd,kBAAkB;CAClB,QAAQ;CACR,MAAM;CAGN,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CAEjB,WAAW;CACX,WAAW;CACX;AAID,WAAW,YAAY;AAEvB,yBAAe"}