porffor 0.61.6 → 0.61.7

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.
@@ -5,6 +5,7 @@ import { BuiltinFuncs, BuiltinVars, importedFuncs, NULL, UNDEFINED } from './bui
5
5
  import { TYPES, TYPE_FLAGS, TYPE_NAMES } from './types.js';
6
6
  import semantic from './semantic.js';
7
7
  import parse from './parse.js';
8
+ import temporalPolyfillSource from './temporal.js';
8
9
  import { log } from './log.js';
9
10
  import './prefs.js';
10
11
 
@@ -7556,6 +7557,14 @@ export default program => {
7556
7557
  program = objectHack(program);
7557
7558
  if (Prefs.closures) program = semantic(program);
7558
7559
 
7560
+ if (!globalThis.precompile && program._usesTemporal) {
7561
+ const temporalPolyfillAst = parse(temporalPolyfillSource);
7562
+ const temporalPolyfillBody = temporalPolyfillAst?.body ?? [];
7563
+ if (temporalPolyfillBody.length > 0) {
7564
+ program.body = temporalPolyfillBody.concat(program.body);
7565
+ }
7566
+ }
7567
+
7559
7568
  generateFunc({}, {
7560
7569
  type: 'Program',
7561
7570
  id: { name: '#main' },
@@ -135,7 +135,9 @@ const annotate = node => {
135
135
 
136
136
  switch (node.type) {
137
137
  case 'Identifier':
138
+ if (node.name === 'Temporal') scopes[0]._usesTemporal = true;
138
139
  if (objectHackers.includes(node.name)) break;
140
+
139
141
  for (let i = scopes.length - 1; i >= 0; i--) {
140
142
  if (scopes[i]._variables?.[node.name]) {
141
143
  const variable = scopes[i]._variables[node.name];
@@ -145,7 +147,17 @@ const annotate = node => {
145
147
  }
146
148
  break;
147
149
 
150
+ case 'Literal':
151
+ if (typeof node.value === 'string' && node.value === 'Temporal') scopes[0]._usesTemporal = true;
152
+ break;
153
+
148
154
  case 'MemberExpression':
155
+ if (node.object?.type === 'Identifier' && ['globalThis', 'window', 'self'].includes(node.object.name)) {
156
+ if (!node.computed && node.property?.type === 'Identifier' && node.property.name === 'Temporal') {
157
+ scopes[0]._usesTemporal = true;
158
+ }
159
+ }
160
+
149
161
  if (node.computed) annotate(node.property);
150
162
  annotate(node.object);
151
163
  return;