ripple 0.2.45 → 0.2.46

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is a TypeScript UI framework for the web",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.45",
6
+ "version": "0.2.46",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -61,7 +61,9 @@ function RipplePlugin(config) {
61
61
  currentType === tt.colon || // After :
62
62
  currentType === tt.question || // After ?
63
63
  currentType === tt.logicalOR || // After ||
64
- currentType === tt.logicalAND; // After &&
64
+ currentType === tt.logicalAND || // After &&
65
+ currentType === tt.dot || // After . (for member expressions like obj.@prop)
66
+ currentType === tt.questionDot; // After ?. (for optional chaining like obj?.@prop)
65
67
 
66
68
  if (inExpression) {
67
69
  return this.readAtIdentifier();
@@ -235,6 +237,11 @@ function RipplePlugin(config) {
235
237
  return this.finishNode(node, 'SpreadAttribute');
236
238
  } else {
237
239
  const id = this.parseIdentNode();
240
+ node.tracked = false;
241
+ if (id.name.startsWith('@')) {
242
+ node.tracked = true;
243
+ id.name = id.name.slice(1);
244
+ }
238
245
  this.finishNode(id, 'Identifier');
239
246
  node.name = id;
240
247
  node.value = id;
@@ -79,6 +79,10 @@ function visit_function(node, context) {
79
79
  function_depth: context.state.function_depth + 1,
80
80
  expression: null,
81
81
  });
82
+
83
+ if (node.metadata.tracked) {
84
+ mark_as_tracked(context.path);
85
+ }
82
86
  }
83
87
 
84
88
  function mark_as_tracked(path) {
@@ -117,11 +121,13 @@ const visitors = {
117
121
 
118
122
  if (
119
123
  is_reference(node, /** @type {Node} */ (parent)) &&
120
- context.state.metadata?.tracking === false &&
121
- is_tracked_name(node) &&
124
+ (is_tracked_name(node) || node.tracked) &&
122
125
  binding?.node !== node
123
126
  ) {
124
- context.state.metadata.tracking = true;
127
+ mark_as_tracked(context.path);
128
+ if (context.state.metadata?.tracking === false) {
129
+ context.state.metadata.tracking = true;
130
+ }
125
131
  }
126
132
 
127
133
  if (
@@ -269,7 +275,7 @@ const visitors = {
269
275
  if (!computed) {
270
276
  return node;
271
277
  }
272
- return b.call('$.set_property', node, computed, value, b.id('__block'));
278
+ return b.call('$.old_set_property', node, computed, value, b.id('__block'));
273
279
  },
274
280
  };
275
281
  break;
@@ -286,6 +292,15 @@ const visitors = {
286
292
  const has_tracked = paths.some(
287
293
  (path) => path.node.type === 'Identifier' && is_tracked_name(path.node.name),
288
294
  );
295
+ for (const path of paths) {
296
+ if (path.node.tracked) {
297
+ error(
298
+ 'Variables cannot be reactively referenced using @',
299
+ state.analysis.module.filename,
300
+ path.node,
301
+ );
302
+ }
303
+ }
289
304
 
290
305
  if (has_tracked) {
291
306
  const tmp = state.scope.generate('tmp');
@@ -312,7 +327,7 @@ const visitors = {
312
327
  } else if (metadata.tracking && !metadata.await) {
313
328
  if (is_tracked_name(path.node.name) && value.type === 'MemberExpression') {
314
329
  return b.call(
315
- '$.get_property',
330
+ '$.old_get_property',
316
331
  b.call('$.get_computed', value.object),
317
332
  value.property.type === 'Identifier'
318
333
  ? b.literal(value.property.name)
@@ -334,7 +349,7 @@ const visitors = {
334
349
 
335
350
  if (is_tracked_name(path.node.name) && value.type === 'MemberExpression') {
336
351
  return b.call(
337
- '$.get_property',
352
+ '$.old_get_property',
338
353
  value.object,
339
354
  value.property.type === 'Identifier'
340
355
  ? b.literal(value.property.name)
@@ -397,10 +412,10 @@ const visitors = {
397
412
  };
398
413
  } else {
399
414
  binding.transform = {
400
- read: (_) => b.call('$.get_property', b.id('__props'), b.literal(name)),
415
+ read: (_) => b.call('$.old_get_property', b.id('__props'), b.literal(name)),
401
416
  assign: (node, value) => {
402
417
  return b.call(
403
- '$.set_property',
418
+ '$.old_set_property',
404
419
  b.id('__props'),
405
420
  b.literal(name),
406
421
  value,
@@ -409,7 +424,7 @@ const visitors = {
409
424
  },
410
425
  update: (_) =>
411
426
  b.call(
412
- node.prefix ? '$.update_property_pre' : '$.update_property',
427
+ node.prefix ? '$.old_update_property_pre' : '$.old_update_property',
413
428
  b.id('__props'),
414
429
  b.literal(name),
415
430
  b.id('__block'),
@@ -530,6 +545,8 @@ const visitors = {
530
545
 
531
546
  attr.metadata.delegated = delegated_event;
532
547
  }
548
+ } else {
549
+ visit(attr.value, state);
533
550
  }
534
551
  }
535
552
  } else if (attr.type === 'AccessorAttribute') {
@@ -17,16 +17,25 @@ import {
17
17
  is_boolean_attribute,
18
18
  is_dom_property,
19
19
  is_ripple_import,
20
- is_declared_within_component,
20
+ is_declared_function_within_component,
21
21
  is_inside_call_expression,
22
22
  is_tracked_computed_property,
23
23
  is_value_static,
24
24
  is_void_element,
25
+ is_component_level_function,
25
26
  } from '../../utils.js';
26
27
  import is_reference from 'is-reference';
27
28
  import { extract_paths, object } from '../../../utils/ast.js';
28
29
  import { render_stylesheets } from './stylesheet.js';
29
30
 
31
+ function add_ripple_internal_import(context) {
32
+ if (!context.state.to_ts) {
33
+ if (!context.state.imports.has(`import * as $ from 'ripple/internal/client'`)) {
34
+ context.state.imports.add(`import * as $ from 'ripple/internal/client'`);
35
+ }
36
+ }
37
+ }
38
+
30
39
  function visit_function(node, context) {
31
40
  if (context.state.to_ts) {
32
41
  context.next(context.state);
@@ -54,13 +63,18 @@ function visit_function(node, context) {
54
63
  let body = context.visit(node.body, state);
55
64
 
56
65
  if (metadata?.tracked === true) {
66
+ const new_body = [];
67
+
68
+ if (!is_inside_component(context, true) && is_component_level_function(context)) {
69
+ add_ripple_internal_import(context);
70
+ new_body.push(b.var('__block', b.call('$.scope')));
71
+ }
72
+ new_body.push(...body.body);
73
+
57
74
  return /** @type {FunctionExpression} */ ({
58
75
  ...node,
59
76
  params: node.params.map((param) => context.visit(param, state)),
60
- body:
61
- body.type === 'BlockStatement'
62
- ? { ...body, body: [b.var('__block', b.call('$.scope')), ...body.body] }
63
- : body,
77
+ body: body.type === 'BlockStatement' ? { ...body, body: new_body } : body,
64
78
  });
65
79
  }
66
80
 
@@ -79,6 +93,8 @@ function build_getter(node, context) {
79
93
  const read_fn = transform?.read || (node.tracked && transform?.read_tracked);
80
94
 
81
95
  if (read_fn) {
96
+ add_ripple_internal_import(context);
97
+
82
98
  return read_fn(node, context.state?.metadata?.spread, context.visit);
83
99
  }
84
100
  }
@@ -161,7 +177,7 @@ const visitors = {
161
177
  (is_ripple_import(callee, context) &&
162
178
  (callee.type !== 'Identifier' ||
163
179
  (callee.name !== 'array' && callee.name !== 'deferred'))) ||
164
- is_declared_within_component(callee, context)
180
+ is_declared_function_within_component(callee, context)
165
181
  ) {
166
182
  return context.next();
167
183
  }
@@ -284,6 +300,18 @@ const visitors = {
284
300
  MemberExpression(node, context) {
285
301
  const parent = context.path.at(-1);
286
302
 
303
+ if (node.property.type === 'Identifier' && node.property.tracked) {
304
+ add_ripple_internal_import(context);
305
+
306
+ context.state.metadata.tracking = true;
307
+ return b.call(
308
+ '$.get_property',
309
+ context.visit(node.object),
310
+ node.computed ? context.visit(node.property) : b.literal(node.property.name),
311
+ node.optional ? b.true : undefined,
312
+ );
313
+ }
314
+
287
315
  if (parent.type !== 'AssignmentExpression') {
288
316
  const object = node.object;
289
317
  const property = node.property;
@@ -303,14 +331,14 @@ const visitors = {
303
331
 
304
332
  if (tracked_name) {
305
333
  return b.call(
306
- '$.get_property',
334
+ '$.old_get_property',
307
335
  context.visit(object),
308
336
  property.type === 'Identifier' ? b.literal(property.name) : property,
309
337
  node.optional ? b.true : undefined,
310
338
  );
311
339
  } else {
312
340
  return b.call(
313
- '$.get_property',
341
+ '$.old_get_property',
314
342
  context.visit(object),
315
343
  context.visit(property),
316
344
  node.optional ? b.true : undefined,
@@ -560,9 +588,10 @@ const visitors = {
560
588
 
561
589
  if (name === 'value' || name === '$value') {
562
590
  const id = state.flush_node();
563
- const expression = visit(attr.value, state);
591
+ const metadata = { tracking: false, await: false };
592
+ const expression = visit(attr.value, { ...state, metadata });
564
593
 
565
- if (name === '$value') {
594
+ if (name === '$value' || metadata.tracking) {
566
595
  local_updates.push(b.stmt(b.call('$.set_value', id, expression)));
567
596
  } else {
568
597
  state.init.push(b.stmt(b.call('$.set_value', id, expression)));
@@ -573,9 +602,10 @@ const visitors = {
573
602
 
574
603
  if (name === 'checked' || name === '$checked') {
575
604
  const id = state.flush_node();
576
- const expression = visit(attr.value, state);
605
+ const metadata = { tracking: false, await: false };
606
+ const expression = visit(attr.value, { ...state, metadata });
577
607
 
578
- if (name === '$checked') {
608
+ if (name === '$checked' || metadata.tracking) {
579
609
  local_updates.push(b.stmt(b.call('$.set_checked', id, expression)));
580
610
  } else {
581
611
  state.init.push(b.stmt(b.call('$.set_checked', id, expression)));
@@ -585,9 +615,10 @@ const visitors = {
585
615
 
586
616
  if (name === 'selected' || name === '$selected') {
587
617
  const id = state.flush_node();
588
- const expression = visit(attr.value, state);
618
+ const metadata = { tracking: false, await: false };
619
+ const expression = visit(attr.value, { ...state, metadata });
589
620
 
590
- if (name === '$selected') {
621
+ if (name === '$selected' || metadata.tracking) {
591
622
  local_updates.push(b.stmt(b.call('$.set_selected', id, expression)));
592
623
  } else {
593
624
  state.init.push(b.stmt(b.call('$.set_selected', id, expression)));
@@ -625,7 +656,7 @@ const visitors = {
625
656
  delegated_assignment = b.array(args);
626
657
  } else if (
627
658
  handler.type === 'Identifier' &&
628
- is_declared_within_component(handler, context)
659
+ is_declared_function_within_component(handler, context)
629
660
  ) {
630
661
  delegated_assignment = handler;
631
662
  } else {
@@ -657,11 +688,12 @@ const visitors = {
657
688
  continue;
658
689
  }
659
690
 
691
+ const metadata = { tracking: false, await: false };
692
+ const expression = visit(attr.value, { ...state, metadata });
660
693
  // All other attributes
661
- if (is_tracked_name(name)) {
662
- const attribute = name.slice(1);
694
+ if (is_tracked_name(name) || metadata.tracking) {
695
+ const attribute = is_tracked_name(name) ? name.slice(1) : name;
663
696
  const id = state.flush_node();
664
- const expression = visit(attr.value, state);
665
697
 
666
698
  if (is_dom_property(attribute)) {
667
699
  local_updates.push(b.stmt(b.assignment('=', b.member(id, attribute), expression)));
@@ -672,7 +704,6 @@ const visitors = {
672
704
  }
673
705
  } else {
674
706
  const id = state.flush_node();
675
- const expression = visit(attr.value, state);
676
707
 
677
708
  if (is_dom_property(name)) {
678
709
  state.init.push(b.stmt(b.assignment('=', b.member(id, name), expression)));
@@ -700,13 +731,14 @@ const visitors = {
700
731
  handle_static_attr(class_attribute.name.name, value);
701
732
  } else {
702
733
  const id = state.flush_node();
703
- let expression = visit(class_attribute.value, state);
734
+ const metadata = { tracking: false, await: false };
735
+ let expression = visit(class_attribute.value, { ...state, metadata });
704
736
 
705
737
  if (node.metadata.scoped && state.component.css) {
706
738
  expression = b.binary('+', b.literal(state.component.css.hash + ' '), expression);
707
739
  }
708
740
 
709
- if (class_attribute.name.name === '$class') {
741
+ if (class_attribute.name.name === '$class' || metadata.tracking) {
710
742
  local_updates.push(b.stmt(b.call('$.set_class', id, expression)));
711
743
  } else {
712
744
  state.init.push(b.stmt(b.call('$.set_class', id, expression)));
@@ -898,9 +930,7 @@ const visitors = {
898
930
 
899
931
  Fragment(node, context) {
900
932
  if (!context.state.to_ts) {
901
- if (!context.state.imports.has(`import * as $ from 'ripple/internal/client'`)) {
902
- context.state.imports.add(`import * as $ from 'ripple/internal/client'`);
903
- }
933
+ add_ripple_internal_import(context);
904
934
  }
905
935
 
906
936
  const metadata = { await: false };
@@ -924,11 +954,7 @@ const visitors = {
924
954
  Component(node, context) {
925
955
  let prop_statements;
926
956
 
927
- if (!context.state.to_ts) {
928
- if (!context.state.imports.has(`import * as $ from 'ripple/internal/client'`)) {
929
- context.state.imports.add(`import * as $ from 'ripple/internal/client'`);
930
- }
931
- }
957
+ add_ripple_internal_import(context);
932
958
 
933
959
  const metadata = { await: false };
934
960
 
@@ -1018,6 +1044,34 @@ const visitors = {
1018
1044
 
1019
1045
  const left = node.left;
1020
1046
 
1047
+ if (
1048
+ left.type === 'MemberExpression' &&
1049
+ left.property.type === 'Identifier' &&
1050
+ left.property.tracked
1051
+ ) {
1052
+ add_ripple_internal_import(context);
1053
+ const operator = node.operator;
1054
+ const right = node.right;
1055
+
1056
+ if (operator !== '=') {
1057
+ context.state.metadata.tracking = true;
1058
+ }
1059
+
1060
+ return b.call(
1061
+ '$.set_property',
1062
+ context.visit(left.object),
1063
+ left.computed ? context.visit(left.property) : b.literal(left.property.name),
1064
+ operator === '='
1065
+ ? context.visit(right)
1066
+ : b.binary(
1067
+ operator === '+=' ? '+' : operator === '-=' ? '-' : operator === '*=' ? '*' : '/',
1068
+ /** @type {Pattern} */ (context.visit(left)),
1069
+ /** @type {Expression} */ (context.visit(right)),
1070
+ ),
1071
+ b.id('__block'),
1072
+ );
1073
+ }
1074
+
1021
1075
  if (left.type === 'MemberExpression') {
1022
1076
  // need to capture setting length of array to throw a runtime error
1023
1077
  if (
@@ -1026,7 +1080,7 @@ const visitors = {
1026
1080
  ) {
1027
1081
  if (left.property.name !== '$length') {
1028
1082
  return b.call(
1029
- '$.set_property',
1083
+ '$.old_set_property',
1030
1084
  context.visit(left.object),
1031
1085
  left.computed ? context.visit(left.property) : b.literal(left.property.name),
1032
1086
  visit_assignment_expression(node, context, build_assignment) ?? context.next(),
@@ -1059,6 +1113,23 @@ const visitors = {
1059
1113
  }
1060
1114
  const argument = node.argument;
1061
1115
 
1116
+ if (
1117
+ argument.type === 'MemberExpression' &&
1118
+ argument.property.type === 'Identifier' &&
1119
+ argument.property.tracked
1120
+ ) {
1121
+ add_ripple_internal_import(context);
1122
+ context.state.metadata.tracking = true;
1123
+
1124
+ return b.call(
1125
+ node.prefix ? '$.update_pre_property' : '$.update_property',
1126
+ context.visit(argument.object),
1127
+ argument.computed ? context.visit(argument.property) : b.literal(argument.property.name),
1128
+ b.id('__block'),
1129
+ node.operator === '--' ? b.literal(-1) : undefined,
1130
+ );
1131
+ }
1132
+
1062
1133
  if (
1063
1134
  argument.type === 'MemberExpression' &&
1064
1135
  ((argument.property.type === 'Identifier' && is_tracked_name(argument.property.name)) ||
@@ -1066,7 +1137,7 @@ const visitors = {
1066
1137
  is_tracked_computed_property(argument.object, argument.property, context)))
1067
1138
  ) {
1068
1139
  return b.call(
1069
- node.prefix ? '$.update_pre_property' : '$.update_property',
1140
+ node.prefix ? '$.old_update_pre_property' : '$.old_update_property',
1070
1141
  context.visit(argument.object),
1071
1142
  argument.computed ? context.visit(argument.property) : b.literal(argument.property.name),
1072
1143
  b.id('__block'),
@@ -374,6 +374,30 @@ export function is_inside_component(context, includes_functions = false) {
374
374
  return false;
375
375
  }
376
376
 
377
+ export function is_component_level_function(context) {
378
+ for (let i = context.path.length - 1; i >= 0; i -= 1) {
379
+ const context_node = context.path[i];
380
+ const type = context_node.type;
381
+
382
+ if (type === 'BlockStatement') {
383
+ if (context_node.body.find((n) => n.type === 'Component')) {
384
+ return true;
385
+ }
386
+ debugger
387
+
388
+ }
389
+
390
+ if (
391
+ type === 'FunctionExpression' ||
392
+ type === 'ArrowFunctionExpression' ||
393
+ type === 'FunctionDeclaration'
394
+ ) {
395
+ return false;
396
+ }
397
+ }
398
+ return true;
399
+ }
400
+
377
401
  export function is_inside_call_expression(context) {
378
402
  for (let i = context.path.length - 1; i >= 0; i -= 1) {
379
403
  const context_node = context.path[i];
@@ -452,7 +476,7 @@ export function is_ripple_import(callee, context) {
452
476
  return false;
453
477
  }
454
478
 
455
- export function is_declared_within_component(node, context) {
479
+ export function is_declared_function_within_component(node, context) {
456
480
  const component = context.path.find((n) => n.type === 'Component');
457
481
 
458
482
  if (node.type === 'Identifier' && component) {
@@ -460,6 +484,14 @@ export function is_declared_within_component(node, context) {
460
484
  const component_scope = context.state.scopes.get(component);
461
485
 
462
486
  if (binding !== null && component_scope !== null) {
487
+ if (
488
+ binding.declaration_kind !== 'function' &&
489
+ binding.initial?.type !== 'FunctionDeclaration' &&
490
+ binding.initial?.type !== 'ArrowFunctionExpression' &&
491
+ binding.initial?.type !== 'FunctionExpression'
492
+ ) {
493
+ return false;
494
+ }
463
495
  let scope = binding.scope;
464
496
 
465
497
  while (scope !== null) {
@@ -1,5 +1,5 @@
1
1
  import { TRACKED_OBJECT } from './constants';
2
- import { get_property } from './runtime';
2
+ import { old_get_property } from './runtime';
3
3
 
4
4
  const array_proto = Array.prototype;
5
5
 
@@ -21,7 +21,7 @@ export function array_reduce(array, callback, initial_value) {
21
21
  let accumulator = initial_value;
22
22
 
23
23
  for (let i = 0; i < array.length; i++) {
24
- accumulator = callback(accumulator, get_property(array, i), i, array);
24
+ accumulator = callback(accumulator, old_get_property(array, i), i, array);
25
25
  }
26
26
 
27
27
  return accumulator;
@@ -45,7 +45,7 @@ export function array_join(array, separator) {
45
45
  if (i > 0 && separator !== undefined) {
46
46
  result += separator;
47
47
  }
48
- result += String(get_property(array, i));
48
+ result += String(old_get_property(array, i));
49
49
  }
50
50
 
51
51
  return result;
@@ -68,7 +68,7 @@ export function array_map(array, callback) {
68
68
  const result = [];
69
69
  for (let i = 0; i < array.length; i++) {
70
70
  if (i in array) {
71
- result[i] = callback(get_property(array, i), i, array);
71
+ result[i] = callback(old_get_property(array, i), i, array);
72
72
  }
73
73
  }
74
74
 
@@ -91,7 +91,7 @@ export function array_filter(array, callback) {
91
91
  const result = [];
92
92
  for (let i = 0; i < array.length; i++) {
93
93
  if (i in array) {
94
- const value = get_property(array, i);
94
+ const value = old_get_property(array, i);
95
95
  if (callback(value, i, array)) {
96
96
  result.push(value);
97
97
  }
@@ -116,7 +116,7 @@ export function array_forEach(array, callback) {
116
116
 
117
117
  for (let i = 0; i < array.length; i++) {
118
118
  if (i in array) {
119
- callback(get_property(array, i), i, array);
119
+ callback(old_get_property(array, i), i, array);
120
120
  }
121
121
  }
122
122
  }
@@ -135,7 +135,7 @@ export function array_includes(array, value) {
135
135
  }
136
136
 
137
137
  for (let i = 0; i < array.length; i++) {
138
- if (i in array && get_property(array, i) === value) {
138
+ if (i in array && old_get_property(array, i) === value) {
139
139
  return true;
140
140
  }
141
141
  }
@@ -157,7 +157,7 @@ export function array_indexOf(array, value) {
157
157
  }
158
158
 
159
159
  for (let i = 0; i < array.length; i++) {
160
- if (i in array && get_property(array, i) === value) {
160
+ if (i in array && old_get_property(array, i) === value) {
161
161
  return i;
162
162
  }
163
163
  }
@@ -179,7 +179,7 @@ export function array_lastIndexOf(array, value) {
179
179
  }
180
180
 
181
181
  for (let i = array.length - 1; i >= 0; i--) {
182
- if (i in array && get_property(array, i) === value) {
182
+ if (i in array && old_get_property(array, i) === value) {
183
183
  return i;
184
184
  }
185
185
  }
@@ -201,7 +201,7 @@ export function array_every(array, callback) {
201
201
  }
202
202
 
203
203
  for (let i = 0; i < array.length; i++) {
204
- if (i in array && !callback(get_property(array, i), i, array)) {
204
+ if (i in array && !callback(old_get_property(array, i), i, array)) {
205
205
  return false;
206
206
  }
207
207
  }
@@ -223,7 +223,7 @@ export function array_some(array, callback) {
223
223
  }
224
224
 
225
225
  for (let i = 0; i < array.length; i++) {
226
- if (i in array && callback(get_property(array, i), i, array)) {
226
+ if (i in array && callback(old_get_property(array, i), i, array)) {
227
227
  return true;
228
228
  }
229
229
  }
@@ -249,7 +249,7 @@ export function array_toString(array) {
249
249
  result += ',';
250
250
  }
251
251
  if (i in array) {
252
- result += String(get_property(array, i));
252
+ result += String(old_get_property(array, i));
253
253
  }
254
254
  }
255
255
 
@@ -272,7 +272,7 @@ export function array_toSorted(array, compare_fn) {
272
272
  const result = [];
273
273
  for (let i = 0; i < array.length; i++) {
274
274
  if (i in array) {
275
- result.push(get_property(array, i));
275
+ result.push(old_get_property(array, i));
276
276
  }
277
277
  }
278
278
 
@@ -297,7 +297,7 @@ export function array_toSpliced(array, start, delete_count, ...items) {
297
297
  const result = [];
298
298
  for (let i = 0; i < array.length; i++) {
299
299
  if (i in array) {
300
- result.push(get_property(array, i));
300
+ result.push(old_get_property(array, i));
301
301
  }
302
302
  }
303
303
 
@@ -321,7 +321,7 @@ export function array_values(array) {
321
321
  const result = [];
322
322
  for (let i = 0; i < array.length; i++) {
323
323
  if (i in array) {
324
- result.push(get_property(array, i));
324
+ result.push(old_get_property(array, i));
325
325
  }
326
326
  }
327
327
 
@@ -344,7 +344,7 @@ export function array_entries(array) {
344
344
  const result = [];
345
345
  for (let i = 0; i < array.length; i++) {
346
346
  if (i in array) {
347
- result.push([i, get_property(array, i)]);
347
+ result.push([i, old_get_property(array, i)]);
348
348
  }
349
349
  }
350
350
 
@@ -22,7 +22,6 @@ import {
22
22
  run_block,
23
23
  run_teardown,
24
24
  schedule_update,
25
- set_property,
26
25
  } from './runtime';
27
26
  import { suspend } from './try';
28
27
 
@@ -29,10 +29,14 @@ export {
29
29
  computed_property,
30
30
  call_property,
31
31
  get_property,
32
+ old_get_property,
33
+ old_set_property,
32
34
  set_property,
33
35
  update,
34
36
  update_pre,
37
+ old_update_property,
35
38
  update_property,
39
+ old_update_pre_property,
36
40
  update_pre_property,
37
41
  object_values,
38
42
  object_entries,
@@ -2,7 +2,7 @@ import { branch, destroy_block, render } from './blocks';
2
2
  import { UNINITIALIZED } from './constants';
3
3
  import { handle_root_events } from './events';
4
4
  import { create_text } from './operations';
5
- import { get_property } from './runtime';
5
+ import { old_get_property } from './runtime';
6
6
 
7
7
  export function Portal(_, props) {
8
8
  let $target = UNINITIALIZED;
@@ -11,8 +11,8 @@ export function Portal(_, props) {
11
11
  var anchor = null;
12
12
 
13
13
  render(() => {
14
- if ($target === ($target = get_property(props, '$target'))) return;
15
- if (children === (children = get_property(props, 'children'))) return;
14
+ if ($target === ($target = old_get_property(props, '$target'))) return;
15
+ if (children === (children = old_get_property(props, 'children'))) return;
16
16
 
17
17
  if (b !== null) {
18
18
  destroy_block(b);
@@ -431,7 +431,7 @@ export function deferred(fn) {
431
431
  var value = fn();
432
432
 
433
433
  res[0] = value;
434
- set_property(res, 0, value, block);
434
+ old_set_property(res, 0, value, block);
435
435
 
436
436
  if (prev_value !== UNINITIALIZED) {
437
437
  if ((t.f & DEFERRED) === 0) {
@@ -870,7 +870,7 @@ export function computed_property(fn) {
870
870
  export function call_property(obj, property, chain_obj, chain_prop, ...args) {
871
871
  // don't swallow errors if either the object or property is nullish,
872
872
  // respect optional chaining as provided
873
- if(!chain_obj && !chain_prop) {
873
+ if (!chain_obj && !chain_prop) {
874
874
  return obj[property].call(obj, ...args);
875
875
  } else if (chain_obj && chain_prop) {
876
876
  return obj?.[property]?.call(obj, ...args);
@@ -888,6 +888,20 @@ export function call_property(obj, property, chain_obj, chain_prop, ...args) {
888
888
  * @returns {any}
889
889
  */
890
890
  export function get_property(obj, property, chain = false) {
891
+ if (chain && obj == null) {
892
+ return undefined;
893
+ }
894
+ var tracked = obj[property];
895
+ return get(tracked);
896
+ }
897
+
898
+ /**
899
+ * @param {any} obj
900
+ * @param {string | number | symbol} property
901
+ * @param {boolean} [chain=false]
902
+ * @returns {any}
903
+ */
904
+ export function old_get_property(obj, property, chain = false) {
891
905
  if (chain && obj == null) {
892
906
  return undefined;
893
907
  }
@@ -903,7 +917,7 @@ export function get_property(obj, property, chain = false) {
903
917
  } else if (SPREAD_OBJECT in obj) {
904
918
  var spread_fn = obj[SPREAD_OBJECT];
905
919
  var properties = spread_fn();
906
- return get_property(properties, property, chain);
920
+ return old_get_property(properties, property, chain);
907
921
  } else if (is_ripple_array(obj)) {
908
922
  obj.$length;
909
923
  }
@@ -911,6 +925,11 @@ export function get_property(obj, property, chain = false) {
911
925
  return value;
912
926
  }
913
927
 
928
+ export function set_property(obj, property, value, block) {
929
+ var tracked = obj[property];
930
+ set(tracked, value, block);
931
+ }
932
+
914
933
  /**
915
934
  * @param {any} obj
916
935
  * @param {string | number | symbol} property
@@ -918,7 +937,7 @@ export function get_property(obj, property, chain = false) {
918
937
  * @param {Block} block
919
938
  * @returns {any}
920
939
  */
921
- export function set_property(obj, property, value, block) {
940
+ export function old_set_property(obj, property, value, block) {
922
941
  var tracked_properties = obj[TRACKED_OBJECT];
923
942
  var rip_arr = is_ripple_array(obj);
924
943
  var tracked = !(rip_arr && property === 'length') ? tracked_properties?.[property] : undefined;
@@ -955,9 +974,7 @@ export function set_property(obj, property, value, block) {
955
974
  export function update(tracked, block, d = 1) {
956
975
  var value = get(tracked);
957
976
  var result = d === 1 ? value++ : value--;
958
-
959
977
  set(tracked, value, block);
960
-
961
978
  return result;
962
979
  }
963
980
 
@@ -988,9 +1005,15 @@ export function decrement(tracked, block) {
988
1005
  export function update_pre(tracked, block, d = 1) {
989
1006
  var value = get(tracked);
990
1007
  var new_value = d === 1 ? ++value : --value;
991
-
992
1008
  set(tracked, new_value, block);
1009
+ return new_value;
1010
+ }
993
1011
 
1012
+ export function update_property(obj, property, block, d = 1) {
1013
+ var tracked = obj[property];
1014
+ var value = get(tracked);
1015
+ var new_value = d === 1 ? value++ : value++;
1016
+ set(tracked, value, block);
994
1017
  return new_value;
995
1018
  }
996
1019
 
@@ -1001,7 +1024,7 @@ export function update_pre(tracked, block, d = 1) {
1001
1024
  * @param {number} [d]
1002
1025
  * @returns {number}
1003
1026
  */
1004
- export function update_property(obj, property, block, d = 1) {
1027
+ export function old_update_property(obj, property, block, d = 1) {
1005
1028
  var tracked_properties = obj[TRACKED_OBJECT];
1006
1029
  var tracked = tracked_properties?.[property];
1007
1030
  var tracked_exists = tracked !== undefined;
@@ -1019,11 +1042,19 @@ export function update_property(obj, property, block, d = 1) {
1019
1042
  }
1020
1043
  }
1021
1044
 
1022
- obj[property] = value
1045
+ obj[property] = value;
1023
1046
 
1024
1047
  return value;
1025
1048
  }
1026
1049
 
1050
+ export function update_pre_property(obj, property, block, d = 1) {
1051
+ var tracked = obj[property];
1052
+ var value = get(tracked);
1053
+ var new_value = d === 1 ? ++value : --value;
1054
+ set(tracked, new_value, block);
1055
+ return new_value;
1056
+ }
1057
+
1027
1058
  /**
1028
1059
  * @param {any} obj
1029
1060
  * @param {string | number | symbol} property
@@ -1031,19 +1062,19 @@ export function update_property(obj, property, block, d = 1) {
1031
1062
  * @param {number} [d]
1032
1063
  * @returns {number}
1033
1064
  */
1034
- export function update_pre_property(obj, property, block, d = 1) {
1065
+ export function old_update_pre_property(obj, property, block, d = 1) {
1035
1066
  var tracked_properties = obj[TRACKED_OBJECT];
1036
1067
  var tracked = tracked_properties?.[property];
1037
1068
  var tracked_exists = tracked !== undefined;
1038
1069
  var value = tracked_exists ? get(tracked) : obj[property];
1039
1070
 
1040
1071
  if (d === 1) {
1041
- ++value
1072
+ ++value;
1042
1073
  if (tracked_exists) {
1043
1074
  increment(tracked, block);
1044
1075
  }
1045
1076
  } else {
1046
- --value
1077
+ --value;
1047
1078
  if (tracked_exists) {
1048
1079
  decrement(tracked, block);
1049
1080
  }
@@ -1092,7 +1123,7 @@ export function object_values(obj) {
1092
1123
  var values = [];
1093
1124
 
1094
1125
  for (var i = 0; i < keys.length; i++) {
1095
- values.push(get_property(obj, keys[i]));
1126
+ values.push(old_get_property(obj, keys[i]));
1096
1127
  }
1097
1128
 
1098
1129
  return values;
@@ -1112,7 +1143,7 @@ export function object_entries(obj) {
1112
1143
 
1113
1144
  for (var i = 0; i < keys.length; i++) {
1114
1145
  var key = keys[i];
1115
- entries.push([key, get_property(obj, key)]);
1146
+ entries.push([key, old_get_property(obj, key)]);
1116
1147
  }
1117
1148
 
1118
1149
  return entries;
@@ -1129,7 +1160,7 @@ export function spread_object(obj) {
1129
1160
 
1130
1161
  for (var i = 0; i < keys.length; i++) {
1131
1162
  var key = keys[i];
1132
- values[key] = get_property(obj, key);
1163
+ values[key] = old_get_property(obj, key);
1133
1164
  }
1134
1165
 
1135
1166
  return values;