tungsten 0.2.9 → 0.2.11

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.
Files changed (33) hide show
  1. package/dist/Components.d.ts +0 -3
  2. package/dist/Components.d.ts.map +1 -1
  3. package/dist/Components.js +0 -18
  4. package/dist/Instance/Instance.d.ts +1 -0
  5. package/dist/Instance/Instance.d.ts.map +1 -1
  6. package/dist/Instance/Instance.js +19 -1
  7. package/dist/Instance/runTrackedWork.sxyt.d.ts +2 -0
  8. package/dist/Instance/runTrackedWork.sxyt.d.ts.map +1 -0
  9. package/dist/Instance/runTrackedWork.sxyt.js +35 -0
  10. package/dist/componentProxyHandlers.d.ts.map +1 -1
  11. package/dist/componentProxyHandlers.js +5 -8
  12. package/dist/components/bindable/BindableSelect.d.ts +11 -11
  13. package/dist/components/bindable/BindableSelect.d.ts.map +1 -1
  14. package/dist/components/bindable/BindableSelect.js +8 -4
  15. package/dist/components/bindable/BindableSelect.sxyt.d.ts +2 -0
  16. package/dist/components/bindable/BindableSelect.sxyt.d.ts.map +1 -0
  17. package/dist/components/bindable/BindableSelect.sxyt.js +186 -0
  18. package/dist/hydrate/hydrate.js +0 -1
  19. package/dist/testing/createTestApp.sxyt.d.ts +2 -0
  20. package/dist/testing/createTestApp.sxyt.d.ts.map +1 -0
  21. package/dist/testing/createTestApp.sxyt.js +470 -0
  22. package/dist/testing/ensureTestEnvLoaded.d.ts +4 -0
  23. package/dist/testing/ensureTestEnvLoaded.d.ts.map +1 -0
  24. package/dist/testing/ensureTestEnvLoaded.js +32 -0
  25. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts +2 -0
  26. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts.map +1 -0
  27. package/dist/testing/ensureTestEnvLoaded.sxyt.js +20 -0
  28. package/dist/testing/index.d.ts +36 -0
  29. package/dist/testing/index.d.ts.map +1 -0
  30. package/dist/testing/index.js +157 -0
  31. package/dist/update/integrateUpdateVdom.js +0 -1
  32. package/package.json +1 -1
  33. package/readme.md +2 -2
@@ -0,0 +1,157 @@
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
7
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
8
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
9
+ import { Instance } from "../Instance/Instance.js";
10
+ import { initStores } from "../Servers/initStores.js";
11
+ import { ensureTestEnvLoaded } from "./ensureTestEnvLoaded.js";
12
+ export { ensureTestEnvLoaded, testEnvVariableName } from "./ensureTestEnvLoaded.js";
13
+ import { createTungstenRootComponent, deleteTungstenRoot } from "../update/integrateUpdateVdom.js";
14
+ import { UpdateScheduler } from "../update/UpdateScheduler.js";
15
+ export function testStore(registration, initialize) {
16
+ return {
17
+ registration,
18
+ initialize
19
+ };
20
+ }
21
+ var _instance = /*#__PURE__*/new WeakMap();
22
+ var _scheduler = /*#__PURE__*/new WeakMap();
23
+ var _root = /*#__PURE__*/new WeakMap();
24
+ var _ownsContainer = /*#__PURE__*/new WeakMap();
25
+ var _unmounted = /*#__PURE__*/new WeakMap();
26
+ class TestAppImplementation {
27
+ constructor(document, container, component, instance, scheduler, root, ownsContainer) {
28
+ _defineProperty(this, "document", void 0);
29
+ _defineProperty(this, "container", void 0);
30
+ _defineProperty(this, "component", void 0);
31
+ _classPrivateFieldInitSpec(this, _instance, void 0);
32
+ _classPrivateFieldInitSpec(this, _scheduler, void 0);
33
+ _classPrivateFieldInitSpec(this, _root, void 0);
34
+ _classPrivateFieldInitSpec(this, _ownsContainer, void 0);
35
+ _classPrivateFieldInitSpec(this, _unmounted, false);
36
+ _defineProperty(this, "resolved", async () => {
37
+ await _classPrivateFieldGet(_scheduler, this).resolved();
38
+ });
39
+ _defineProperty(this, "setProps", async props => {
40
+ if (_classPrivateFieldGet(_unmounted, this)) throw new Error('Cannot set props on an unmounted Tungsten TestApp.');
41
+ this.component.props = props;
42
+ _classPrivateFieldGet(_instance, this).queueUpdate(this.component);
43
+ await this.resolved();
44
+ });
45
+ _defineProperty(this, "unmount", async () => {
46
+ if (_classPrivateFieldGet(_unmounted, this)) return;
47
+ _classPrivateFieldSet(_unmounted, this, true);
48
+ _classPrivateFieldGet(_scheduler, this).cancelPending();
49
+ let cleanupError;
50
+ try {
51
+ deleteTungstenRoot(_classPrivateFieldGet(_root, this));
52
+ _classPrivateFieldGet(_instance, this).disposeRegisteredComponents();
53
+ await _classPrivateFieldGet(_scheduler, this).resolved();
54
+ } catch (error) {
55
+ cleanupError = error;
56
+ try {
57
+ _classPrivateFieldGet(_instance, this).disposeRegisteredComponents();
58
+ } catch {
59
+ // Preserve the first cleanup failure.
60
+ }
61
+ } finally {
62
+ _classPrivateFieldGet(_scheduler, this).dispose();
63
+ if (_classPrivateFieldGet(_ownsContainer, this)) this.container.remove();else while (this.container.firstChild !== null) this.container.removeChild(this.container.firstChild);
64
+ }
65
+ if (cleanupError !== undefined) throw cleanupError;
66
+ });
67
+ this.document = document;
68
+ this.container = container;
69
+ this.component = component;
70
+ _classPrivateFieldSet(_instance, this, instance);
71
+ _classPrivateFieldSet(_scheduler, this, scheduler);
72
+ _classPrivateFieldSet(_root, this, root);
73
+ _classPrivateFieldSet(_ownsContainer, this, ownsContainer);
74
+ }
75
+ }
76
+ export async function createTestApp(RootComponent, ...args) {
77
+ await ensureTestEnvLoaded();
78
+ const options = args[0];
79
+ const suppliedDocument = options?.document ?? globalThis.document;
80
+ if (suppliedDocument === undefined) {
81
+ // eslint-disable-line @typescript-eslint/no-unnecessary-condition
82
+ throw new Error('createTestApp() requires options.document when no global document is available.');
83
+ }
84
+ const document = suppliedDocument;
85
+ const ownsContainer = options?.container === undefined;
86
+ const container = options?.container ?? document.createElement('div');
87
+ if (container.ownerDocument !== document) {
88
+ throw new Error('The TestApp container must belong to options.document.');
89
+ }
90
+ if (container.childNodes.length > 0) {
91
+ throw new Error('The TestApp container must be empty before mounting.');
92
+ }
93
+ if (ownsContainer) {
94
+ if (document.body === null) {
95
+ // eslint-disable-line @typescript-eslint/no-unnecessary-condition
96
+ throw new Error('The supplied document must have a body element.');
97
+ }
98
+ document.body.appendChild(container);
99
+ }
100
+ const location = options?.location ?? '/';
101
+ const globalData = options?.globalData ?? {};
102
+ const matchedRouteInfo = {
103
+ key: null,
104
+ params: options?.routeParams ?? {},
105
+ content: null,
106
+ ...(options !== undefined && 'routeData' in options ? {
107
+ data: options.routeData
108
+ } : {})
109
+ };
110
+ const scheduler = new UpdateScheduler();
111
+ const runtimeContext = {
112
+ document,
113
+ window: document.defaultView,
114
+ scheduler,
115
+ navigation: false
116
+ };
117
+ const {
118
+ internalStore,
119
+ stores,
120
+ storeSubscriptions
121
+ } = initStores(location, null, globalData, matchedRouteInfo);
122
+ const instanceConfig = {
123
+ prod: false,
124
+ useRootComponent: true,
125
+ clientSideNav: false,
126
+ siteBasePath: '/',
127
+ staticSite: false
128
+ };
129
+ const emptyRoutes = {};
130
+ const instance = new Instance(location, instanceConfig, null, emptyRoutes, emptyRoutes, internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, runtimeContext);
131
+ try {
132
+ for (const override of options?.stores ?? []) {
133
+ const store = override.registration.getStore(instance.stores);
134
+ await override.initialize(store);
135
+ }
136
+ const props = options?.props ?? {};
137
+ const root = await createTungstenRootComponent(RootComponent, props, options?.routeParams, options?.routeData, instance, container);
138
+ const testApp = new TestAppImplementation(document, container, root.component, instance, scheduler, root, ownsContainer);
139
+ try {
140
+ await testApp.resolved();
141
+ return testApp;
142
+ } catch (error) {
143
+ await testApp.unmount();
144
+ throw error;
145
+ }
146
+ } catch (error) {
147
+ try {
148
+ instance.disposeRegisteredComponents();
149
+ } catch {
150
+ // Preserve the mount failure.
151
+ }
152
+ scheduler.dispose();
153
+ while (container.firstChild !== null) container.removeChild(container.firstChild);
154
+ if (ownsContainer) container.remove();
155
+ throw error;
156
+ }
157
+ }
@@ -1188,7 +1188,6 @@ async function updateClassComponent({
1188
1188
  //throwError('','')
1189
1189
  const updateResult = await element.__update();
1190
1190
  domPointer.increment(updateResult.nodesLength); // bump the dom pointer index forward by the number of nodes within that element's content
1191
- element.__didUpdate();
1192
1191
  return {
1193
1192
  ...newNode,
1194
1193
  element,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tungsten",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
package/readme.md CHANGED
@@ -1,5 +1,5 @@
1
- # Tungsten Frontend Framework
2
-
1
+ # Tungsten Frontend Framework
2
+
3
3
  [Docs](https://robertsandiford.co.uk/tungsten)
4
4
 
5
5
  ## Component testing