Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .testem.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lib/jquery-ui/jquery-ui.js",
"lib/json3/lib/json3.min.js",
"lib/jquery-maskedinput/dist/jquery.maskedinput.min.js",
"build/alpaca/bootstrap/alpaca.js",
"dist/alpaca/alpaca.umd.js",
"tests/qunit/qunit.js",
"tests/js/fields/**/*.js"
],
Expand Down
4 changes: 2 additions & 2 deletions features/support/cucumber.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Alpaca Cucumber Tests</title>
<link rel="stylesheet" href="../../build/alpaca/bootstrap/alpaca.min.css">
<link rel="stylesheet" href="../../dist/alpaca/alpaca.css">
<link rel="stylesheet" href="../../lib/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="../../lib/handsontable/dist/jquery.handsontable.full.css">
<link rel="stylesheet" href="cucumber.css">
Expand All @@ -23,7 +23,7 @@
<script src="../../lib/validate.js"></script>
<script src="../../lib/jquery-maskedinput/dist/jquery.maskedinput.min.js"></script>
<script src="../../lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../../build/alpaca/bootstrap/alpaca.js"></script>
<script src="../../dist/alpaca/alpaca.umd.js"></script>

</head>
<body>
Expand Down
10 changes: 9 additions & 1 deletion features/support/world.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
var path = require('path');
var webdriver = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');

var _ = require('lodash');

var options = new chrome.Options();
options.addArguments('--headless');
options.addArguments('--no-sandbox');
options.addArguments('--disable-dev-shm-usage');
options.addArguments('--remote-debugging-port=9222');

var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
forBrowser('chrome').
setChromeOptions(options).
build();

var World = function(cb) {
Expand Down
31 changes: 31 additions & 0 deletions fix-errors-todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Fix Errors Todo

## Data Loading Errors
- [x] Fix `DATA_LOADING_ERROR` in tests trying to load `../examples/...`.
- These tests fail because they try to load local files via XHR which isn't supported or the path is wrong.
- Solution: Mock `$.ajax` in `vitest.setup.js` to read files from `site/demos/` when `../examples/` is requested.

## Assertion Errors
- [x] Fix `tests/js/hideInitValidationError.js`.
- Error: `Initial validation should have discovered the form is invalid.: expected true to deeply equal false`.
- Solution: Modified `src/js/Alpaca.js` to ensure validation state is refreshed even if initial validation errors are hidden.
- [x] Fix assertions in `EditForm.js`, `CreateForm.js` etc.
- Status: `View normalization` fixed.
- Solution: Added `.alpaca-controlfield` class in `src/js/ControlField.js` and updated test selectors. Corrected expectations for number of fields.

## Runtime Errors
- [x] Fix `ReferenceError: observable is not defined` in `tests/js/fields/AddressField.js`.
- Location: `src/js/ObservableUtils.js:184:24`.
- [x] Fix `View normalization failed` in `tests/js/forms/EditForm.js`.
- Solution: Added legacy view aliases in `vitest.setup.js`.
- [x] Fix `TypeError` in `CreateForm.js` due to missing fixture.
- Solution: Added setup/teardown with fixture creation.

## Other Errors
- [x] Investigate and fix timeouts in `tests/js/fields/ArrayField.js`.
- Solution:
- Fixed selector issues (using `[type="text"]` instead of `:text` pseudo-selector for `happy-dom` compatibility).
- Fixed race conditions by using `setTimeout` in click handlers (simulating async nature).
- Fixed `simulateClick` reference error by attaching it to `window`.
- Disabled animation in tests to avoid timing issues with `animatedSwap`.
- Fixed DOM cleaning in `vitest.setup.js` to prevent test pollution.
File renamed without changes.
26 changes: 22 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "alpaca",
"scripts": {
"build": "./node_modules/.bin/gulp default",
"build": "npx vite build",
"build:gulp": "./node_modules/.bin/gulp default",
"site": "./node_modules/.bin/gulp site",
"server": "./node_modules/.bin/gulp server",
"clean": "./node_modules/.bin/gulp clean",
Expand All @@ -13,7 +14,14 @@
},
"license": "Apache-2.0",
"version": "1.5.27",
"main": "dist/alpaca/bootstrap/alpaca.js",
"main": "dist/alpaca/alpaca.cjs.js",
"module": "dist/alpaca/alpaca.es.js",
"exports": {
".": {
"import": "./dist/alpaca/alpaca.es.js",
"require": "./dist/alpaca/alpaca.cjs.js"
}
},
"devDependencies": {
"bower": "^1.8.8",
"cucumber": "~0.3.3",
Expand Down Expand Up @@ -43,8 +51,11 @@
"gulp-watch": "^5.0.1",
"gulp-wrap": "^0.14.0",
"gulp-wrap-umd": "^0.2.1",
"handlebars": "^4.7.6",
"jquery": "^3.5.1",
"handlebars": "^4.7.8",
"happy-dom": "^20.3.7",
"jquery": "^3.7.1",
"jquery-ui-dist": "^1.13.3",
"jquery.maskedinput": "^1.4.1",
"jsdom": "^9.12.0",
"jshint": "^2.9.7",
"jshint-stylish": "^2.2.1",
Expand All @@ -53,10 +64,17 @@
"node-static": "^0.7.11",
"phantom": "^6.0.3",
"q": "^1.5.1",
"rollup": "^4.55.2",
"run-sequence": "^2.2.1",
"selenium-webdriver": "^4.40.0",
"stream-browserify": "^2.0.1",
"through2": "^3.0.0",
"vite": "^7.3.1",
"vitest": "^4.0.18",
"wd": "^1.12.1",
"wrench": "^1.5.9"
},
"dependencies": {
"jquery-price-format": "^0.0.1"
}
}
29 changes: 29 additions & 0 deletions refactor-esm-todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Refactor ESM - Remaining Tasks

The core codebase has been migrated to ESM, and a Vite build system has been established. However, several follow-up tasks are recommended to fully complete the transition and ensure the ecosystem around AlpacaJS is consistent.

## 1. Update `package.json`
- Update the `"main"` field to point to the new CommonJS or UMD bundle (e.g., `dist/alpaca/alpaca.umd.js` or `dist/alpaca/alpaca.cjs.js`).
- Add a `"module"` field pointing to the ESM bundle (`dist/alpaca/alpaca.es.js`).
- Add an `"exports"` field to correctly expose the entry points for modern node environments and bundlers.
- Update `"scripts"`: Replace or augment `build` to use `vite build`.

## 2. Test Suite Migration
- **Unit Tests (`tests/`)**: Review unit tests. If they rely on global `Alpaca` variables or old path structures, update them to import the built artifacts or source modules.
- **Cucumber Tests (`features/`)**: Verify that cucumber tests run correctly against the new build.
- **Test Runner**: Consider moving from `grunt`/`gulp` based test runners to a modern runner like Vitest or Jest, which handles ESM natively.

## 3. Site and Documentation (`site/`)
- The `site` folder and `gulp site` task likely depend on the old build artifacts (`dist/alpaca/bootstrap/...`).
- Update the site generation process to consume the new `dist/alpaca/` bundles.
- Update documentation examples to show how to use Alpaca with ESM (`import Alpaca from 'alpaca'`) and Script Tags (using the UMD build).

## 4. Dependencies and Cleanup
- **Gulp/Grunt**: Determine if `gulp` and `grunt` are still needed. If their only purpose was building the library, they can be removed in favor of Vite. If they build the site/docs, plan a migration for those tasks as well.
- **Thirdparty**: Review `thirdparty/` directory. `Base.js` is currently imported. Consider if it should be refactored into the main source tree or kept as is.

## 5. Continuous Integration (CI)
- Update any `.travis.yml` or GitHub Actions workflows to use the new build commands (`npm run build` / `npx vite build`) and check generated artifacts.

## 6. Verification
- Perform a "Smoke Test" by creating a small separate project that installs this package (via `npm link` or local path) and attempts to use it in both a Webpack/Vite project (ESM) and a legacy script-tag project (UMD).
10 changes: 6 additions & 4 deletions src/js/AbstractTemplateEngine.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(function($)
{
Alpaca.AbstractTemplateEngine = Base.extend(
import jQuery from "jquery";
import Alpaca from "./Alpaca.js";
import Base from "../../thirdparty/base/Base.js";
var $ = jQuery;

Alpaca.AbstractTemplateEngine = Base.extend(
{
constructor: function(id)
{
Expand Down Expand Up @@ -232,4 +235,3 @@

});

})(jQuery);
115 changes: 8 additions & 107 deletions src/js/Alpaca-async.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////
import jQuery from "jquery";
import Alpaca from "./Alpaca.js";
var $ = jQuery;/////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -14,7 +17,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////

(function() {

//'use strict';

Expand Down Expand Up @@ -4598,108 +4600,7 @@
doDuring: doWhilst$1
};

var exports = async;

exports.default = index;
exports.apply = apply;
exports.applyEach = applyEach$1;
exports.applyEachSeries = applyEachSeries;
exports.asyncify = asyncify;
exports.auto = auto;
exports.autoInject = autoInject;
exports.cargo = cargo;
exports.cargoQueue = cargo$1;
exports.compose = compose;
exports.concat = concat$1;
exports.concatLimit = concatLimit$1;
exports.concatSeries = concatSeries$1;
exports.constant = constant;
exports.detect = detect$1;
exports.detectLimit = detectLimit$1;
exports.detectSeries = detectSeries$1;
exports.dir = dir;
exports.doUntil = doUntil;
exports.doWhilst = doWhilst$1;
exports.each = each;
exports.eachLimit = eachLimit$2;
exports.eachOf = eachOf$1;
exports.eachOfLimit = eachOfLimit$2;
exports.eachOfSeries = eachOfSeries$1;
exports.eachSeries = eachSeries$1;
exports.ensureAsync = ensureAsync;
exports.every = every$1;
exports.everyLimit = everyLimit$1;
exports.everySeries = everySeries$1;
exports.filter = filter$1;
exports.filterLimit = filterLimit$1;
exports.filterSeries = filterSeries$1;
exports.forever = forever$1;
exports.groupBy = groupBy;
exports.groupByLimit = groupByLimit$1;
exports.groupBySeries = groupBySeries;
exports.log = log;
exports.map = map$1;
exports.mapLimit = mapLimit$1;
exports.mapSeries = mapSeries$1;
exports.mapValues = mapValues;
exports.mapValuesLimit = mapValuesLimit$1;
exports.mapValuesSeries = mapValuesSeries;
exports.memoize = memoize;
exports.nextTick = nextTick;
exports.parallel = parallel;
exports.parallelLimit = parallelLimit;
exports.priorityQueue = priorityQueue;
exports.queue = queue$1;
exports.race = race$1;
exports.reduce = reduce$1;
exports.reduceRight = reduceRight;
exports.reflect = reflect;
exports.reflectAll = reflectAll;
exports.reject = reject$2;
exports.rejectLimit = rejectLimit$1;
exports.rejectSeries = rejectSeries$1;
exports.retry = retry;
exports.retryable = retryable;
exports.seq = seq;
exports.series = series;
exports.setImmediate = setImmediate$1;
exports.some = some$1;
exports.someLimit = someLimit$1;
exports.someSeries = someSeries$1;
exports.sortBy = sortBy$1;
exports.timeout = timeout;
exports.times = times;
exports.timesLimit = timesLimit;
exports.timesSeries = timesSeries;
exports.transform = transform;
exports.tryEach = tryEach$1;
exports.unmemoize = unmemoize;
exports.until = until;
exports.waterfall = waterfall$1;
exports.whilst = whilst$1;
exports.all = every$1;
exports.allLimit = everyLimit$1;
exports.allSeries = everySeries$1;
exports.any = some$1;
exports.anyLimit = someLimit$1;
exports.anySeries = someSeries$1;
exports.find = detect$1;
exports.findLimit = detectLimit$1;
exports.findSeries = detectSeries$1;
exports.forEach = each;
exports.forEachSeries = eachSeries$1;
exports.forEachLimit = eachLimit$2;
exports.forEachOf = eachOf$1;
exports.forEachOfSeries = eachOfSeries$1;
exports.forEachOfLimit = eachOfLimit$2;
exports.inject = reduce$1;
exports.foldl = reduce$1;
exports.foldr = reduceRight;
exports.select = filter$1;
exports.selectLimit = filterLimit$1;
exports.selectSeries = filterSeries$1;
exports.wrapSync = asyncify;
exports.during = whilst$1;
exports.doDuring = doWhilst$1;

})();
Object.assign(async, index);

export default async;

Loading