Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible 2.8 #2

Open
wants to merge 35 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dfad546
first batch of changes to make compatible with node
znewsham Sep 25, 2022
8f3cd59
allow wait for main
znewsham Sep 27, 2022
0e04239
hoist import
znewsham Sep 27, 2022
de938ec
(temp) remove fiber bindenv requirement
znewsham Sep 27, 2022
20db4f5
use globalThis
znewsham Sep 27, 2022
d579bd3
remove package global from mainModule package
znewsham Sep 27, 2022
712e11a
hoist import
znewsham Sep 27, 2022
b7b2867
make true commonjs
znewsham Sep 27, 2022
197c863
remove await from fiber dependent code
znewsham Sep 27, 2022
1ffaeb3
latest
znewsham Sep 29, 2022
ea9e553
latest
znewsham Oct 12, 2022
813e5b0
getting tests running
znewsham Oct 13, 2022
6e91948
more changes to get promises to work nicely
znewsham Oct 31, 2022
6862bc1
remove npmrc
znewsham Oct 31, 2022
b3c961b
more work to make compatible
znewsham Nov 15, 2022
bb82f2a
Merge tag 'release/[email protected]' into make-compatible-2.8
znewsham Nov 18, 2022
32b0fab
cleaner _setNewContextAndGetCurrent
znewsham Nov 18, 2022
31930e7
add assets
znewsham Nov 29, 2022
3940bd6
fix tests
znewsham Dec 5, 2022
a89079e
allow access to _meteor_dynamics from the current fiber
znewsham Dec 21, 2022
eca9730
make Meteor a global so esbuild will replace Meteor.is*
znewsham Dec 21, 2022
8507ec3
add getBinary to assets package
znewsham Apr 21, 2023
955373c
fix bug in email package
znewsham Apr 21, 2023
63820a1
handle getpath in assets
znewsham May 3, 2023
ba7e2e0
better/safer EV set/withValue - must be used with >=5.0.2-5 of fibers
znewsham Jun 30, 2023
f41621b
clean up bindEnvironment
znewsham Jul 5, 2023
741e022
remove debugger
znewsham Jul 5, 2023
3bf96c1
bump meteor package version
znewsham Jul 5, 2023
11d8a45
fix shell server
znewsham Jul 5, 2023
6cf1eab
remove unnecessary error
znewsham Sep 20, 2023
6982b2b
allow for fewer fiber yields
znewsham Oct 5, 2023
9899d94
Add options to the log-in attempt
harwood-qualia Feb 15, 2024
ae7f9d2
Merge pull request #4 from qualialabs/add_options_to_attempt
znewsham Feb 16, 2024
dc24d39
Update @meteor/accounts-base version to fix semver
harwood-qualia Mar 6, 2024
6058681
Merge pull request #5 from qualialabs/update_accounts_base_version
znewsham Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions npm-packages/meteor-promise/fiber_pool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var assert = require("assert");
const { AsyncResource } = require("async_hooks");

function FiberPool(targetFiberCount) {
assert.ok(this instanceof FiberPool);
Expand Down Expand Up @@ -26,7 +27,6 @@ function FiberPool(targetFiberCount) {
// continue waiting for the next entry object.
continue;
}

// Ensure this Fiber is no longer in the pool once it begins to
// execute an entry.
assert.strictEqual(fiberStack.indexOf(fiber), -1);
Expand All @@ -40,10 +40,10 @@ function FiberPool(targetFiberCount) {
}

try {
entry.resolve(entry.callback.apply(
entry.resolve(entry._ar.runInAsyncScope(() => entry.callback.apply(
entry.context || null,
entry.args || []
));
)));
} catch (error) {
entry.reject(error);
}
Expand Down Expand Up @@ -79,7 +79,7 @@ function FiberPool(targetFiberCount) {
this.run = function (entry, Promise) {
assert.strictEqual(typeof entry, "object");
assert.strictEqual(typeof entry.callback, "function");

entry._ar = new AsyncResource("FiberPoolJob");
if (typeof Promise.Fiber !== "function") {
return new Promise(function (resolve) {
resolve(entry.callback.apply(
Expand All @@ -95,7 +95,6 @@ function FiberPool(targetFiberCount) {
entry.resolve = resolve;
entry.reject = reject;
});

fiber.run(entry);

return promise;
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/meteor-promise/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm-packages/meteor-promise/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "meteor-promise",
"author": "Ben Newman <[email protected]>",
"version": "0.9.1",
"version": "0.9.1-2",
"description": "ES6 Promise polyfill with Fiber support",
"keywords": [
"meteor",
Expand Down
5 changes: 4 additions & 1 deletion npm-packages/meteor-promise/promise_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var fiberPool = require("./fiber_pool.js").makePool();

exports.makeCompatible = function (Promise, Fiber) {
var es6PromiseThen = Promise.prototype.then;
Promise.prototype.es6PromiseThen = es6PromiseThen;

if (typeof Fiber === "function") {
Promise.Fiber = Fiber;
Expand All @@ -16,6 +17,9 @@ exports.makeCompatible = function (Promise, Fiber) {
var Promise = this.constructor;
var Fiber = Promise.Fiber;

if (Promise.noYieldOnFiberlessThen && Fiber && !Fiber.current) {
return es6PromiseThen.call(this, onResolved, onRejected);
}
if (typeof Fiber === "function" &&
! this._meteorPromiseAlreadyWrapped) {
onResolved = wrapCallback(onResolved, Promise);
Expand Down Expand Up @@ -84,7 +88,6 @@ exports.makeCompatible = function (Promise, Fiber) {
run = process.domain.bind(run);
throwInto = process.domain.bind(throwInto);
}

// The overridden es6PromiseThen function is adequate here because these
// two callbacks do not need to run in a Fiber.
es6PromiseThen.call(promise, function (result) {
Expand Down
36 changes: 20 additions & 16 deletions packages/accounts-base/accounts_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ export class AccountsServer extends AccountsCommon {
if (user) {
attempt.user = user;
}
if (result.options) {
attempt.options = result.options;
}

// _validateLogin may mutate `attempt` by adding an error and changing allowed
// to false, but that's the only change it can make (and the user's callbacks
Expand Down Expand Up @@ -1804,21 +1807,23 @@ const setupUsersCollection = users => {
});

/// DEFAULT INDEXES ON USERS
users.createIndex('username', { unique: true, sparse: true });
users.createIndex('emails.address', { unique: true, sparse: true });
users.createIndex('services.resume.loginTokens.hashedToken',
{ unique: true, sparse: true });
users.createIndex('services.resume.loginTokens.token',
{ unique: true, sparse: true });
// For taking care of logoutOtherClients calls that crashed before the
// tokens were deleted.
users.createIndex('services.resume.haveLoginTokensToDelete',
{ sparse: true });
// For expiring login tokens
users.createIndex("services.resume.loginTokens.when", { sparse: true });
// For expiring password tokens
users.createIndex('services.password.reset.when', { sparse: true });
users.createIndex('services.password.enroll.when', { sparse: true });
Meteor.startup(() => {
users.createIndex('username', { unique: true, sparse: true });
users.createIndex('emails.address', { unique: true, sparse: true });
users.createIndex('services.resume.loginTokens.hashedToken',
{ unique: true, sparse: true });
users.createIndex('services.resume.loginTokens.token',
{ unique: true, sparse: true });
// For taking care of logoutOtherClients calls that crashed before the
// tokens were deleted.
users.createIndex('services.resume.haveLoginTokensToDelete',
{ sparse: true });
// For expiring login tokens
users.createIndex("services.resume.loginTokens.when", { sparse: true });
// For expiring password tokens
users.createIndex('services.password.reset.when', { sparse: true });
users.createIndex('services.password.enroll.when', { sparse: true });
});
};


Expand All @@ -1840,4 +1845,3 @@ const generateCasePermutationsForString = string => {
}
return permutations;
}

2 changes: 1 addition & 1 deletion packages/accounts-base/accounts_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ Tinytest.add(
'accounts - verify setAdditionalFindUserOnExternalLogin hook can provide user',
test => {
// create test user, without a google service
const testEmail = "[email protected]"
const testEmail = "[email protected]" + Random.id();
const uid0 = Accounts.createUser({email: testEmail})

// Verify that user is found from email and service merged
Expand Down
8 changes: 2 additions & 6 deletions packages/accounts-base/client_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
* @namespace Accounts
* @summary The namespace for all client-side accounts-related methods.
*/
Accounts = new AccountsClient();
const Accounts = new AccountsClient();

/**
* @summary A [Mongo.Collection](#collections) containing user documents.
Expand All @@ -20,9 +20,5 @@ Meteor.users = Accounts.users;
export {
Accounts,
AccountsClient,
AccountsTest,
// For backwards compatibility. Note that exporting an object as the
// default export is *not* the same as exporting its properties as named
// exports, as was previously assumed.
exports as default,
AccountsTest
};
2 changes: 1 addition & 1 deletion packages/accounts-base/package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
summary: 'A user account system',
version: '2.2.5',
version: '2.2.6-2',
});

Package.onUse(api => {
Expand Down
5 changes: 3 additions & 2 deletions packages/accounts-base/server_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AccountsServer } from "./accounts_server.js";
* @namespace Accounts
* @summary The namespace for all server-side accounts-related methods.
*/
Accounts = new AccountsServer(Meteor.server);
const Accounts = new AccountsServer(Meteor.server);

// Users table. Don't use the normal autopublish, since we want to hide
// some fields. Code to autopublish this is in accounts_server.js.
Expand All @@ -23,5 +23,6 @@ export {
// accounts-base package, properties of non-entry-point modules need to
// be re-exported in order to be accessible to modules that import the
// accounts-base package.
AccountsServer
AccountsServer,
Accounts
};
15 changes: 9 additions & 6 deletions packages/accounts-password/password_server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bcrypt from 'bcrypt'
import {Accounts} from "meteor/accounts-base";
import Fiber from "fibers";

const bcryptHash = Meteor.wrapAsync(bcrypt.hash);
const bcryptCompare = Meteor.wrapAsync(bcrypt.compare);
Expand Down Expand Up @@ -997,9 +998,11 @@ Accounts.createUser = (options, callback) => {
///
/// PASSWORD-SPECIFIC INDEXES ON USERS
///
Meteor.users.createIndex('services.email.verificationTokens.token',
{ unique: true, sparse: true });
Meteor.users.createIndex('services.password.reset.token',
{ unique: true, sparse: true });
Meteor.users.createIndex('services.password.enroll.token',
{ unique: true, sparse: true });
new Fiber(() => {
Meteor.users.createIndex('services.email.verificationTokens.token',
{ unique: true, sparse: true });
Meteor.users.createIndex('services.password.reset.token',
{ unique: true, sparse: true });
Meteor.users.createIndex('services.password.enroll.token',
{ unique: true, sparse: true });
}).run()
2 changes: 1 addition & 1 deletion packages/accounts-password/password_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ if (Meteor.isClient) (() => {
// Create user error without callback should throw error
function (test, expect) {
this.newUsername = `adalovelace${this.randomSuffix}`;
test.throws(function(){
test.throws(() => {
Accounts.createUser({ username: this.newUsername, password: '' });
}, /Password may not be empty/);
},
Expand Down
3 changes: 3 additions & 0 deletions packages/assets/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function createAssets() {
return {};
}
10 changes: 10 additions & 0 deletions packages/assets/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package.describe({
name: 'assets',
version: '0.0.3',
description: 'a simple assets package',
});

Package.onUse(function (api) {
api.mainModule('server.js', 'server');
api.mainModule('client.js', 'client');
});
24 changes: 24 additions & 0 deletions packages/assets/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import fs from 'fs';
import fsPromises from 'fs/promises';
import Fiber from 'fibers';
import path from 'path';

export function createAssets(moduleId) {
const basePath = path.dirname(moduleId).replace('file:', '');
return {
getText(file) {
return Fiber.current
? Promise.await(fsPromises.readFile(path.join(basePath, file))).toString()
: fs.readFileSync(path.join(basePath, file)).toString();
},
getBinary(file) {
return Fiber.current
? Promise.await(fsPromises.readFile(path.join(basePath, file))).toString()
: fs.readFileSync(path.join(basePath, file)).toString();
},
absoluteFilePath(file) {
return path.join(basePath, file);
}
}
};
1 change: 1 addition & 0 deletions packages/autoupdate/autoupdate_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Autoupdate.appId = __meteor_runtime_config__.appId = process.env.APP_ID;
var syncQueue = new Meteor._SynchronousQueue();

function updateVersions(shouldReloadClientProgram) {
Promise.await(WebApp.waitForReady());
// Step 1: load the current client program on the server
if (shouldReloadClientProgram) {
WebAppInternals.reloadClientPrograms();
Expand Down
1 change: 1 addition & 0 deletions packages/babel-compiler/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Package.describe({

Npm.depends({
'@meteorjs/babel': '7.16.0-beta.1',
'semver': '7.3.8',
'json5': '2.1.1'
});

Expand Down
5 changes: 3 additions & 2 deletions packages/babel-runtime/babel-runtime.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try {
var babelRuntimeVersion = require("@babel/runtime/package.json").version;
//var babelRuntimeVersion = (await import("@babel/runtime/package.json")).version;
} catch (e) {
throw new Error([
"",
Expand All @@ -10,7 +10,7 @@ try {
""
].join("\n"));
}

/*
if (parseInt(babelRuntimeVersion, 10) < 7 ||
(babelRuntimeVersion.indexOf("7.0.0-beta.") === 0 &&
parseInt(babelRuntimeVersion.split(".").pop(), 10) < 56)) {
Expand All @@ -24,3 +24,4 @@ if (parseInt(babelRuntimeVersion, 10) < 7 ||
""
].join("\n"));
}
*/
8 changes: 4 additions & 4 deletions packages/boilerplate-generator/generator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { readFile } from 'fs';
import { create as createStream } from "combined-stream2";

import WebBrowserTemplate from './template-web.browser';
import WebCordovaTemplate from './template-web.cordova';
import * as WebBrowserTemplate from './template-web.browser';
import * as WebCordovaTemplate from './template-web.cordova';

// Copied from webapp_server
const readUtf8FileSync = filename => Meteor.wrapAsync(readFile)(filename, 'utf8');
Expand Down Expand Up @@ -118,7 +118,7 @@ export class Boilerplate {

manifest.forEach(item => {
const urlPath = urlMapper(item.url);
const itemObj = { url: urlPath };
const itemObj = { url: urlPath, type: item.type };

if (inline) {
itemObj.scriptContent = readUtf8FileSync(
Expand All @@ -132,7 +132,7 @@ export class Boilerplate {
boilerplateBaseData.css.push(itemObj);
}

if (item.type === 'js' && item.where === 'client' &&
if ((item.type === 'js' || item.type === 'module js') && item.where === 'client' &&
// Dynamic JS modules should not be loaded eagerly in the
// initial HTML of the app.
!item.path.startsWith('dynamic/')) {
Expand Down
3 changes: 2 additions & 1 deletion packages/boilerplate-generator/template-web.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export const closeTemplate = ({
'',

...(js || []).map(file =>
template(' <script type="text/javascript" src="<%- src %>"<%= sri %>></script>')({
template(' <script type="<%- type %>" src="<%- src %>"<%= sri %>></script>')({
src: bundledJsCssUrlRewriteHook(file.url),
sri: sri(file.sri, sriMode),
type: file.type === 'module js' ? 'module' : 'text/javascript'
})
),

Expand Down
4 changes: 3 additions & 1 deletion packages/browser-policy-content/browser-policy-content.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Fiber from 'fibers';
// By adding this package, you get the following default policy:
// No eval or other string-to-code, and content can only be loaded from the
// same origin as the app (except for XHRs and websocket connections, which can
Expand Down Expand Up @@ -300,6 +301,7 @@ _.each(resources,
 function (resource) {
};
});

setDefaultPolicy();
// setDefaultPolicy eventually calls WebAppInternals.generateBoilerplate which must be in a fiber
new Fiber(() => { setDefaultPolicy(); }).run();

exports.BrowserPolicy = BrowserPolicy;
4 changes: 2 additions & 2 deletions packages/context/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const {
asyncFromGen,
} = require("@wry/context");

Object.assign(exports, {
export {
Slot,
bind,
noContext,
setTimeout,
asyncFromGen,
});
}
2 changes: 1 addition & 1 deletion packages/ddp-client/common/livedata_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Hook } from 'meteor/callback-hook';
import { MongoID } from 'meteor/mongo-id';
import { DDP } from './namespace.js';
import MethodInvoker from './MethodInvoker.js';
import { ClientStream } from "meteor/socket-stream-client";
import {
hasOwn,
slice,
Expand Down Expand Up @@ -84,7 +85,6 @@ export class Connection {
if (typeof url === 'object') {
self._stream = url;
} else {
const { ClientStream } = require("meteor/socket-stream-client");
self._stream = new ClientStream(url, {
retry: options.retry,
ConnectionError: DDP.ConnectionError,
Expand Down
Loading
Loading