@hypen-space/core 0.4.14 → 0.4.16

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 (46) hide show
  1. package/dist/app.js +9 -83
  2. package/dist/app.js.map +3 -3
  3. package/dist/components/builtin.js +9 -83
  4. package/dist/components/builtin.js.map +3 -3
  5. package/dist/context.js +9 -4
  6. package/dist/context.js.map +3 -3
  7. package/dist/discovery.js +250 -250
  8. package/dist/discovery.js.map +5 -5
  9. package/dist/disposable.js +9 -4
  10. package/dist/disposable.js.map +3 -3
  11. package/dist/engine.browser.js +167 -131
  12. package/dist/engine.browser.js.map +3 -3
  13. package/dist/engine.js +2 -2
  14. package/dist/engine.js.map +2 -2
  15. package/dist/events.js +9 -4
  16. package/dist/events.js.map +3 -3
  17. package/dist/index.browser.js +278 -154
  18. package/dist/index.browser.js.map +7 -6
  19. package/dist/index.js +427 -434
  20. package/dist/index.js.map +10 -10
  21. package/dist/loader.js +2 -2
  22. package/dist/loader.js.map +2 -2
  23. package/dist/logger.js +9 -4
  24. package/dist/logger.js.map +3 -3
  25. package/dist/plugin.js +351 -6
  26. package/dist/plugin.js.map +5 -4
  27. package/dist/remote/client.js +9 -94
  28. package/dist/remote/client.js.map +3 -3
  29. package/dist/remote/index.js +481 -342
  30. package/dist/remote/index.js.map +7 -6
  31. package/dist/remote/server.js +481 -331
  32. package/dist/remote/server.js.map +7 -6
  33. package/dist/renderer.js +9 -4
  34. package/dist/renderer.js.map +3 -3
  35. package/dist/resolver.js +350 -5
  36. package/dist/resolver.js.map +4 -3
  37. package/dist/router.js +9 -4
  38. package/dist/router.js.map +3 -3
  39. package/dist/state.js +8 -3
  40. package/dist/state.js.map +2 -2
  41. package/package.json +1 -1
  42. package/src/logger.ts +1 -1
  43. package/wasm-browser/hypen_engine_bg.wasm +0 -0
  44. package/wasm-browser/package.json +1 -1
  45. package/wasm-node/hypen_engine_bg.wasm +0 -0
  46. package/wasm-node/package.json +1 -1
package/dist/discovery.js CHANGED
@@ -27,254 +27,6 @@ var __export = (target, all) => {
27
27
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
28
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
29
29
 
30
- // src/state.ts
31
- function deepClone(obj) {
32
- if (obj === null || typeof obj !== "object") {
33
- return obj;
34
- }
35
- if (typeof obj === "function") {
36
- return obj;
37
- }
38
- if (typeof obj.__getSnapshot === "function") {
39
- return obj.__getSnapshot();
40
- }
41
- if (obj instanceof WeakMap || obj instanceof WeakSet) {
42
- return obj;
43
- }
44
- const visited = new WeakMap;
45
- function cloneInternal(value) {
46
- if (value === null || typeof value !== "object") {
47
- return value;
48
- }
49
- if (typeof value === "function") {
50
- return value;
51
- }
52
- if (visited.has(value)) {
53
- return visited.get(value);
54
- }
55
- if (value instanceof WeakMap || value instanceof WeakSet) {
56
- return value;
57
- }
58
- if (value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
59
- try {
60
- return structuredClone(value);
61
- } catch {}
62
- }
63
- if (Array.isArray(value)) {
64
- const arrClone = [];
65
- visited.set(value, arrClone);
66
- for (let i = 0;i < value.length; i++) {
67
- arrClone[i] = cloneInternal(value[i]);
68
- }
69
- return arrClone;
70
- }
71
- const objClone = {};
72
- visited.set(value, objClone);
73
- for (const key in value) {
74
- if (Object.prototype.hasOwnProperty.call(value, key)) {
75
- objClone[key] = cloneInternal(value[key]);
76
- }
77
- }
78
- const symbolKeys = Object.getOwnPropertySymbols(value);
79
- for (const sym of symbolKeys) {
80
- objClone[sym] = cloneInternal(value[sym]);
81
- }
82
- return objClone;
83
- }
84
- return cloneInternal(obj);
85
- }
86
- function diffState(oldState, newState, basePath = "") {
87
- const paths = [];
88
- const newValues = {};
89
- function diff(oldVal, newVal, path) {
90
- if (oldVal === newVal)
91
- return;
92
- if (typeof oldVal !== "object" || typeof newVal !== "object" || oldVal === null || newVal === null) {
93
- if (oldVal !== newVal) {
94
- paths.push(path);
95
- newValues[path] = newVal;
96
- }
97
- return;
98
- }
99
- if (Array.isArray(oldVal) || Array.isArray(newVal)) {
100
- if (!Array.isArray(oldVal) || !Array.isArray(newVal) || oldVal.length !== newVal.length) {
101
- paths.push(path);
102
- newValues[path] = newVal;
103
- return;
104
- }
105
- for (let i = 0;i < newVal.length; i++) {
106
- const itemPath = path ? `${path}.${i}` : `${i}`;
107
- diff(oldVal[i], newVal[i], itemPath);
108
- }
109
- return;
110
- }
111
- const oldKeys = new Set(Object.keys(oldVal));
112
- const newKeys = new Set(Object.keys(newVal));
113
- for (const key of newKeys) {
114
- const propPath = path ? `${path}.${key}` : key;
115
- if (!oldKeys.has(key)) {
116
- paths.push(propPath);
117
- newValues[propPath] = newVal[key];
118
- } else {
119
- diff(oldVal[key], newVal[key], propPath);
120
- }
121
- }
122
- for (const key of oldKeys) {
123
- if (!newKeys.has(key)) {
124
- const propPath = path ? `${path}.${key}` : key;
125
- paths.push(propPath);
126
- newValues[propPath] = undefined;
127
- }
128
- }
129
- }
130
- diff(oldState, newState, basePath);
131
- return { paths, newValues };
132
- }
133
- function createObservableState(initialState, options) {
134
- const opts = options || { onChange: () => {} };
135
- if (initialState === null || initialState === undefined) {
136
- initialState = {};
137
- }
138
- if (initialState instanceof Number || initialState instanceof String || initialState instanceof Boolean) {
139
- throw new TypeError("Cannot create observable state from primitive wrapper objects (Number, String, Boolean). " + "Use plain primitives or regular objects instead.");
140
- }
141
- initialState = deepClone(initialState);
142
- let lastSnapshot = deepClone(initialState);
143
- const pathPrefix = opts.pathPrefix || "";
144
- let batchDepth = 0;
145
- let pendingChange = null;
146
- function notifyChange() {
147
- if (batchDepth > 0)
148
- return;
149
- const change = diffState(lastSnapshot, state, pathPrefix);
150
- if (change.paths.length > 0) {
151
- lastSnapshot = deepClone(state);
152
- if (pendingChange) {
153
- change.paths.push(...pendingChange.paths);
154
- Object.assign(change.newValues, pendingChange.newValues);
155
- pendingChange = null;
156
- }
157
- opts.onChange(change);
158
- }
159
- }
160
- let notificationPending = false;
161
- function scheduleBatch() {
162
- if (batchDepth === 0) {
163
- if (!notificationPending) {
164
- notificationPending = true;
165
- queueMicrotask(() => {
166
- notificationPending = false;
167
- if (batchDepth === 0) {
168
- notifyChange();
169
- }
170
- });
171
- }
172
- }
173
- }
174
- const proxyCache = new WeakMap;
175
- function createProxy(target, basePath) {
176
- const cached = proxyCache.get(target);
177
- if (cached)
178
- return cached;
179
- const proxy = new Proxy(target, {
180
- get(obj, prop) {
181
- if (prop === IS_PROXY)
182
- return true;
183
- if (prop === RAW_TARGET)
184
- return obj;
185
- if (prop === "__beginBatch") {
186
- return () => {
187
- batchDepth++;
188
- };
189
- }
190
- if (prop === "__endBatch") {
191
- return () => {
192
- batchDepth--;
193
- if (batchDepth === 0) {
194
- notifyChange();
195
- }
196
- };
197
- }
198
- if (prop === "__getSnapshot") {
199
- return () => deepClone(obj);
200
- }
201
- const value = obj[prop];
202
- if (value && typeof value === "object") {
203
- if (value[IS_PROXY]) {
204
- return value;
205
- }
206
- if (value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) {
207
- return value;
208
- }
209
- const cachedNested = proxyCache.get(value);
210
- if (cachedNested) {
211
- return cachedNested;
212
- }
213
- const nestedProxy = createProxy(value, basePath ? `${basePath}.${String(prop)}` : String(prop));
214
- return nestedProxy;
215
- }
216
- return value;
217
- },
218
- set(obj, prop, value) {
219
- const oldValue = obj[prop];
220
- if (value && typeof value === "object" && value[IS_PROXY]) {
221
- value = value[RAW_TARGET];
222
- }
223
- obj[prop] = value;
224
- if (oldValue !== value) {
225
- scheduleBatch();
226
- }
227
- return true;
228
- },
229
- deleteProperty(obj, prop) {
230
- if (prop in obj) {
231
- delete obj[prop];
232
- scheduleBatch();
233
- }
234
- return true;
235
- }
236
- });
237
- proxyCache.set(target, proxy);
238
- return proxy;
239
- }
240
- const state = createProxy(initialState, pathPrefix);
241
- return state;
242
- }
243
- function batchStateUpdates(state, fn) {
244
- const s = state;
245
- if (s.__beginBatch && s.__endBatch) {
246
- s.__beginBatch();
247
- try {
248
- fn();
249
- } finally {
250
- s.__endBatch();
251
- }
252
- } else {
253
- fn();
254
- }
255
- }
256
- function getStateSnapshot(state) {
257
- const s = state;
258
- if (s.__getSnapshot) {
259
- return s.__getSnapshot();
260
- }
261
- return deepClone(state);
262
- }
263
- function isStateProxy(value) {
264
- return value !== null && typeof value === "object" && value[IS_PROXY] === true;
265
- }
266
- function unwrapProxy(value) {
267
- if (value !== null && typeof value === "object" && value[IS_PROXY]) {
268
- return value[RAW_TARGET];
269
- }
270
- return value;
271
- }
272
- var IS_PROXY, RAW_TARGET;
273
- var init_state = __esm(() => {
274
- IS_PROXY = Symbol.for("hypen.isProxy");
275
- RAW_TARGET = Symbol.for("hypen.rawTarget");
276
- });
277
-
278
30
  // src/logger.ts
279
31
  function isProduction() {
280
32
  if (typeof process !== "undefined" && process.env) {
@@ -428,7 +180,7 @@ var init_logger = __esm(() => {
428
180
  error: "\x1B[31m"
429
181
  };
430
182
  config = {
431
- level: isProduction() ? "error" : "debug",
183
+ level: isProduction() ? "error" : "info",
432
184
  colors: true,
433
185
  timestamps: false
434
186
  };
@@ -644,6 +396,254 @@ var init_result = __esm(() => {
644
396
  };
645
397
  });
646
398
 
399
+ // src/state.ts
400
+ function deepClone(obj) {
401
+ if (obj === null || typeof obj !== "object") {
402
+ return obj;
403
+ }
404
+ if (typeof obj === "function") {
405
+ return obj;
406
+ }
407
+ if (typeof obj.__getSnapshot === "function") {
408
+ return obj.__getSnapshot();
409
+ }
410
+ if (obj instanceof WeakMap || obj instanceof WeakSet) {
411
+ return obj;
412
+ }
413
+ const visited = new WeakMap;
414
+ function cloneInternal(value) {
415
+ if (value === null || typeof value !== "object") {
416
+ return value;
417
+ }
418
+ if (typeof value === "function") {
419
+ return value;
420
+ }
421
+ if (visited.has(value)) {
422
+ return visited.get(value);
423
+ }
424
+ if (value instanceof WeakMap || value instanceof WeakSet) {
425
+ return value;
426
+ }
427
+ if (value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
428
+ try {
429
+ return structuredClone(value);
430
+ } catch {}
431
+ }
432
+ if (Array.isArray(value)) {
433
+ const arrClone = [];
434
+ visited.set(value, arrClone);
435
+ for (let i = 0;i < value.length; i++) {
436
+ arrClone[i] = cloneInternal(value[i]);
437
+ }
438
+ return arrClone;
439
+ }
440
+ const objClone = {};
441
+ visited.set(value, objClone);
442
+ for (const key in value) {
443
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
444
+ objClone[key] = cloneInternal(value[key]);
445
+ }
446
+ }
447
+ const symbolKeys = Object.getOwnPropertySymbols(value);
448
+ for (const sym of symbolKeys) {
449
+ objClone[sym] = cloneInternal(value[sym]);
450
+ }
451
+ return objClone;
452
+ }
453
+ return cloneInternal(obj);
454
+ }
455
+ function diffState(oldState, newState, basePath = "") {
456
+ const paths = [];
457
+ const newValues = {};
458
+ function diff(oldVal, newVal, path) {
459
+ if (oldVal === newVal)
460
+ return;
461
+ if (typeof oldVal !== "object" || typeof newVal !== "object" || oldVal === null || newVal === null) {
462
+ if (oldVal !== newVal) {
463
+ paths.push(path);
464
+ newValues[path] = newVal;
465
+ }
466
+ return;
467
+ }
468
+ if (Array.isArray(oldVal) || Array.isArray(newVal)) {
469
+ if (!Array.isArray(oldVal) || !Array.isArray(newVal) || oldVal.length !== newVal.length) {
470
+ paths.push(path);
471
+ newValues[path] = newVal;
472
+ return;
473
+ }
474
+ for (let i = 0;i < newVal.length; i++) {
475
+ const itemPath = path ? `${path}.${i}` : `${i}`;
476
+ diff(oldVal[i], newVal[i], itemPath);
477
+ }
478
+ return;
479
+ }
480
+ const oldKeys = new Set(Object.keys(oldVal));
481
+ const newKeys = new Set(Object.keys(newVal));
482
+ for (const key of newKeys) {
483
+ const propPath = path ? `${path}.${key}` : key;
484
+ if (!oldKeys.has(key)) {
485
+ paths.push(propPath);
486
+ newValues[propPath] = newVal[key];
487
+ } else {
488
+ diff(oldVal[key], newVal[key], propPath);
489
+ }
490
+ }
491
+ for (const key of oldKeys) {
492
+ if (!newKeys.has(key)) {
493
+ const propPath = path ? `${path}.${key}` : key;
494
+ paths.push(propPath);
495
+ newValues[propPath] = undefined;
496
+ }
497
+ }
498
+ }
499
+ diff(oldState, newState, basePath);
500
+ return { paths, newValues };
501
+ }
502
+ function createObservableState(initialState, options) {
503
+ const opts = options || { onChange: () => {} };
504
+ if (initialState === null || initialState === undefined) {
505
+ initialState = {};
506
+ }
507
+ if (initialState instanceof Number || initialState instanceof String || initialState instanceof Boolean) {
508
+ throw new TypeError("Cannot create observable state from primitive wrapper objects (Number, String, Boolean). " + "Use plain primitives or regular objects instead.");
509
+ }
510
+ initialState = deepClone(initialState);
511
+ let lastSnapshot = deepClone(initialState);
512
+ const pathPrefix = opts.pathPrefix || "";
513
+ let batchDepth = 0;
514
+ let pendingChange = null;
515
+ function notifyChange() {
516
+ if (batchDepth > 0)
517
+ return;
518
+ const change = diffState(lastSnapshot, state, pathPrefix);
519
+ if (change.paths.length > 0) {
520
+ lastSnapshot = deepClone(state);
521
+ if (pendingChange) {
522
+ change.paths.push(...pendingChange.paths);
523
+ Object.assign(change.newValues, pendingChange.newValues);
524
+ pendingChange = null;
525
+ }
526
+ opts.onChange(change);
527
+ }
528
+ }
529
+ let notificationPending = false;
530
+ function scheduleBatch() {
531
+ if (batchDepth === 0) {
532
+ if (!notificationPending) {
533
+ notificationPending = true;
534
+ queueMicrotask(() => {
535
+ notificationPending = false;
536
+ if (batchDepth === 0) {
537
+ notifyChange();
538
+ }
539
+ });
540
+ }
541
+ }
542
+ }
543
+ const proxyCache = new WeakMap;
544
+ function createProxy(target, basePath) {
545
+ const cached = proxyCache.get(target);
546
+ if (cached)
547
+ return cached;
548
+ const proxy = new Proxy(target, {
549
+ get(obj, prop) {
550
+ if (prop === IS_PROXY)
551
+ return true;
552
+ if (prop === RAW_TARGET)
553
+ return obj;
554
+ if (prop === "__beginBatch") {
555
+ return () => {
556
+ batchDepth++;
557
+ };
558
+ }
559
+ if (prop === "__endBatch") {
560
+ return () => {
561
+ batchDepth--;
562
+ if (batchDepth === 0) {
563
+ notifyChange();
564
+ }
565
+ };
566
+ }
567
+ if (prop === "__getSnapshot") {
568
+ return () => deepClone(obj);
569
+ }
570
+ const value = obj[prop];
571
+ if (value && typeof value === "object") {
572
+ if (value[IS_PROXY]) {
573
+ return value;
574
+ }
575
+ if (value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) {
576
+ return value;
577
+ }
578
+ const cachedNested = proxyCache.get(value);
579
+ if (cachedNested) {
580
+ return cachedNested;
581
+ }
582
+ const nestedProxy = createProxy(value, basePath ? `${basePath}.${String(prop)}` : String(prop));
583
+ return nestedProxy;
584
+ }
585
+ return value;
586
+ },
587
+ set(obj, prop, value) {
588
+ const oldValue = obj[prop];
589
+ if (value && typeof value === "object" && value[IS_PROXY]) {
590
+ value = value[RAW_TARGET];
591
+ }
592
+ obj[prop] = value;
593
+ if (oldValue !== value) {
594
+ scheduleBatch();
595
+ }
596
+ return true;
597
+ },
598
+ deleteProperty(obj, prop) {
599
+ if (prop in obj) {
600
+ delete obj[prop];
601
+ scheduleBatch();
602
+ }
603
+ return true;
604
+ }
605
+ });
606
+ proxyCache.set(target, proxy);
607
+ return proxy;
608
+ }
609
+ const state = createProxy(initialState, pathPrefix);
610
+ return state;
611
+ }
612
+ function batchStateUpdates(state, fn) {
613
+ const s = state;
614
+ if (s.__beginBatch && s.__endBatch) {
615
+ s.__beginBatch();
616
+ try {
617
+ fn();
618
+ } finally {
619
+ s.__endBatch();
620
+ }
621
+ } else {
622
+ fn();
623
+ }
624
+ }
625
+ function getStateSnapshot(state) {
626
+ const s = state;
627
+ if (s.__getSnapshot) {
628
+ return s.__getSnapshot();
629
+ }
630
+ return deepClone(state);
631
+ }
632
+ function isStateProxy(value) {
633
+ return value !== null && typeof value === "object" && value[IS_PROXY] === true;
634
+ }
635
+ function unwrapProxy(value) {
636
+ if (value !== null && typeof value === "object" && value[IS_PROXY]) {
637
+ return value[RAW_TARGET];
638
+ }
639
+ return value;
640
+ }
641
+ var IS_PROXY, RAW_TARGET;
642
+ var init_state = __esm(() => {
643
+ IS_PROXY = Symbol.for("hypen.isProxy");
644
+ RAW_TARGET = Symbol.for("hypen.rawTarget");
645
+ });
646
+
647
647
  // src/app.ts
648
648
  var exports_app = {};
649
649
  __export(exports_app, {
@@ -1241,4 +1241,4 @@ export {
1241
1241
  discoverComponents
1242
1242
  };
1243
1243
 
1244
- //# debugId=75A232D98C70314364756E2164756E21
1244
+ //# debugId=CF7A70112177A49264756E2164756E21